description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
char = set()
n = len(s)
i = 0
j = n - 1
fin = ""
lis = []
while j >= i + 3:
if s[i] == s[j]:
lis.append(i)
i += 1
j -= 1
elif s[i] == s[j - 1]:
lis.append(i)
i += 1
j -= 2
elif s[i + 1] == s[j]:
lis.append(i + 1)
i += 2
j -=... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR STRING ASSIGN VAR LIST WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER V... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = list(input().rstrip())
n = len(s)
i = 0
j = n - 1
d = []
while j - i > 1:
if s[i] == s[j]:
d.append(s[i])
i += 1
j -= 1
elif s[i] == s[j - 1]:
d.append(s[i])
j -= 2
i += 1
else:
i += 1
if i <= j:
d.append(s[i])
d += d[: len(d) - 1][::-1]
el... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST WHILE BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER V... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | import sys
def rl(proc=None):
if proc is not None:
return proc(sys.stdin.readline())
else:
return sys.stdin.readline().rstrip()
def srl(proc=None):
if proc is not None:
return list(map(proc, rl().split()))
else:
return rl().split()
def main():
s = rl()
i = 0... | IMPORT FUNC_DEF NONE IF VAR NONE RETURN FUNC_CALL VAR FUNC_CALL VAR RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF NONE IF VAR NONE RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | l1 = []
l2 = []
s = input()
n = len(s)
if n == 2 or n == 3:
print(s[0])
exit(0)
p = 0
q = n - 1
i = 0
while p + 1 < q - 1:
a = s[p]
b = s[p + 1]
c = s[q]
d = s[q - 1]
if a == c:
l1.append(a)
l2.append(c)
p += 1
q -= 1
elif a == d:
l1.append(a)
... | ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR N... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
remainingLength = len(s)
i = 0
j = remainingLength - 1
palindrome = ""
middleChar = ""
while remainingLength > 0:
if remainingLength >= 4:
firstPart = {s[i], s[i + 1]}
lastPart = {s[j], s[j - 1]}
palindromeCharacter = firstPart.intersection(lastPart).pop()
palindrome = pa... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIG... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
l = 0
n = len(s) - 1
r = n
ans = ""
cent = ""
while r > l:
if s[l] == s[r]:
ans += s[l]
l += 1
r -= 1
elif s[l + 1] == s[r - 1] and r - l > 2:
ans += s[l + 1]
l += 2
r -= 2
elif r - l > 1:
if l < n - r:
if s[l + 1] == s[r]:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING WHILE VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
n = len(s)
def sol(s, n):
center = ""
if n % 2 == 0:
if n == 2:
return s[0]
elif n % 4 == 0:
second, third = n // 2 - 1, n // 2
else:
center = s[n // 2]
second, third = n // 2 - 2, n // 2 + 1
elif n == 1 or n == 3:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR STRING IF BIN_OP VAR NUMBER NUMBER IF VAR NUMBER RETURN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
t = ""
n = len(s)
for i in range(0, n, 2):
if n - i - 2 <= i + 1:
break
s1 = s[i : i + 2]
s2 = s[n - i - 1] + s[n - i - 2]
if "a" in s1 and "a" in s2:
t += "a"
elif "b" in s1 and "b" in s2:
t += "b"
else:
t += "c"
if n % 4:
fin = t + s[n // 2] + t[... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER IF STRING VAR STRING VAR VAR STRING I... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
i, j = 0, len(s) - 1
half = []
while j - i + 1 > 3:
if s[i] == s[j]:
half.append(s[i])
i += 1
j -= 1
elif s[i + 1] == s[j]:
half.append(s[i + 1])
i += 2
j -= 1
elif s[i] == s[j - 1]:
half.append(s[i])
i += 1
j -= 2
else:... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST WHILE BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
n = len(s)
ans = ""
for i in range(0, n // 2, 2):
if n - i - 2 <= i + 1:
break
else:
l = set(s[i : i + 2])
r = set(s[n - i - 2 : n - i])
temp = l.intersection(r)
ans += [i for i in temp][0]
print(ans + s[n // 2] + ans[::-1] if n % 4 != 0 else ans + ans[::-1]) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | import sys
input = sys.stdin.readline
s = list(input())
if s[-1] != "a" and s[-1] != "b" and s[-1] != "c":
s = s[:-1]
ans = []
i = 0
while i + 1 < len(s) - i - 2:
st = s[i] + s[i + 1] + s[len(s) - i - 1] + s[len(s) - i - 2]
if st.count("a") >= 2:
ans.append("a")
elif st.count("b") >= 2:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER STRING VAR NUMBER STRING VAR NUMBER STRING ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | def Input():
tem = input().split()
ans = []
for it in tem:
ans.append(int(it))
return ans
s = input()
n = len(s)
if n < 4:
print(s[0])
else:
m = n // 2
l, r = 0, n - 1
ans = [[] for i in range(2)]
while l + 1 < r - 1:
if s[l + 1] == s[r]:
ans[0].append(s... | FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | word = input()
n = len(word)
ln = n // 2
letters = [[], [], []]
dic = {"a": 0, "b": 1, "c": 2}
for i in range(n):
letters[dic[word[i]]].append(i)
ln2 = ln // 2
ans = ""
lb = -1
rb = n
for i in range(ln2):
for a, b in [
(lb + 1, rb - 1),
(lb + 2, rb - 1),
(lb + 1, rb - 2),
(lb + 2... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST LIST LIST LIST ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = str(input())
lst = []
l = 0
h = len(s) - 1
while h >= l:
if s[l] == s[h]:
lst.append(s[l])
l = l + 1
h = h - 1
elif s[l] == s[h - 1]:
h = h - 1
elif s[l + 1] == s[h]:
l = l + 1
else:
l = l + 1
h = h - 1
lst1 = lst[::-1]
for i in range(len(lst))... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | import sys
input = lambda: sys.stdin.readline().strip()
s = list(input())
i = 0
j = len(s) - 1
res = [""]
while i < j - 2:
if s[i] == s[j] or s[i] == s[j - 1]:
res.append(s[i])
else:
res.append(s[i + 1])
i += 2
j -= 2
print("".join(res + ([s[i]] if len(s) % 4 else [""]) + list(reversed(... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST STRING WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
n = len(s)
i, j = 0, n - 1
ans = []
t = n // 4
for i in range(t):
x = i * 2
y = n - 2 - i * 2
if s[x] == s[y] or s[x] == s[y + 1]:
ans.append(s[x])
else:
ans.append(s[x + 1])
if n % 4 >= 2:
ans = ans + [s[n // 2]] + ans[::-1]
else:
ans = ans + ans[::-1]
print("".join(... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
p = ""
for i in range(len(s) // 4):
if s[i * 2] == s[-i * 2 - 1]:
p += s[i * 2]
elif s[i * 2 + 1] == s[-i * 2 - 1]:
p += s[i * 2 + 1]
elif s[i * 2] == s[-i * 2 - 2]:
p += s[i * 2]
else:
p += s[i * 2 + 1]
l = len(p)
if len(s) % 4 != 0:
p += s[len(s) // 2]
f... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUM... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
left = 0
right = len(s) - 1
out = ""
needed = len(s) // 2
if len(s) <= 3:
print(s[0])
else:
while right - left >= 3 and len(out) < needed:
if s[left] == s[right]:
out += s[left]
left += 1
right -= 1
elif s[left] == s[right - 1]:
out += ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR V... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | import sys
for line in sys.stdin:
line = line[:-1]
ans = ["a"] * (len(line) // 4)
for i in range(len(line) // 4):
if line[2 * i] in {line[-2 * i - 1], line[-2 * i - 2]}:
ans[i] = line[2 * i]
else:
ans[i] = line[2 * i + 1]
if len(line) % 2 == 1 or len(line) % 4 ==... | IMPORT FOR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST STRING BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR VAR BIN_OP BIN... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | import sys
input = sys.stdin.readline
s = input().rstrip()
n = len(s)
ans = []
l = 0
r = n - 1
while l <= r:
if s[l] == s[r]:
ans.append(s[l])
l += 1
r -= 1
elif s[l + 1] == s[r]:
l += 1
elif s[l] == s[r - 1]:
r -= 1
else:
l += 1
r -= 1
res = ans ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER V... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | from sys import stdin, stdout
s = input()
N = len(s)
required = N // 2
front = []
tail = []
left = 0
right = N - 1
while left <= right and required > 0:
A = left
B = left + 1
C = right - 1
D = right
if required == 1:
front.append(s[A])
required -= 1
break
if s[A] == s[D]... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR ... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
i = 0
j = len(s) - 1
t = []
middle = None
while i <= j:
if j - i + 1 <= 3:
middle = s[i]
elif s[i] == s[j] or s[i] == s[j - 1]:
t.append(s[i])
else:
t.append(s[i + 1])
i += 2
j -= 2
a = "".join(t)
b = "".join(t[::-1])
if middle:
print(f"{a}{middle}{b}")
else:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NONE WHILE VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER VA... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
if len(s) == 3:
print(s[0])
else:
ans = ["a"] * (len(s) // 4)
for i in range(len(s) // 4):
if s[2 * i + 1] == s[-2 * i - 1]:
ans[i] = s[2 * i + 1]
elif s[2 * i + 1] == s[-2 * i - 2]:
ans[i] = s[2 * i + 1]
elif s[2 * i] == s[-2 * i - 1]:
... | ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST STRING BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP NUMBER VAR NU... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
n = len(s)
f, b = [], []
i, j = 0, n - 1
while i < j:
if s[i] != s[j]:
if s[i] == s[j - 1]:
j -= 1
elif s[i + 1] == s[j]:
i += 1
else:
i += 1
j -= 1
if s[i] == s[j]:
f.append(s[i])
if i < j:
b.append(s[j])
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR VAR E... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | S = input()
N = len(S)
l, r = 0, N - 1
res = ""
mid = ""
while l <= r:
if l == r:
mid = S[l]
break
elif S[l] == S[r]:
res += S[l]
l += 1
r -= 1
elif S[l + 1] == S[r]:
l += 1
elif S[r - 1] == S[l]:
r -= 1
elif l > N - r:
r -= 1
else:... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING WHILE VAR VAR IF VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER IF VA... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | import sys
input = lambda: sys.stdin.readline().strip()
s = list(input())
i = 0
j = len(s) - 1
res = [""]
while i < j - 2:
if s[i] == s[j] or s[i] == s[j - 1]:
res += s[i]
else:
res.append(s[i + 1])
i += 2
j -= 2
n = len(res)
if len(s) % 4:
res.append(s[i])
for i in range(n - 1, -1,... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST STRING WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASS... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
n = len(s)
i = 0
j = n - 1
ans = [-1] * n
while i < j:
if s[i] != s[j]:
if s[i + 1] == s[j - 1]:
ans[i + 1] = ans[j - 1] = s[i + 1]
i += 2
j -= 2
elif s[i] == s[j - 1]:
ans[i] = ans[j - 1] = s[i]
i += 1
j -= 2
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR WHILE VAR VAR IF VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | line = input()
n = len(line)
def f(left, right):
d = [(0) for _ in range(n + 1)]
cnt = 0
if left + 2 == right:
d[left + 1] = 1
cnt += 1
while left >= 0 and right < n:
if line[left] == line[right]:
d[left] = 1
d[right] = 1
left -= 1
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER WHILE VAR NUMBER VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
i = 0
j = len(s) - 1
m = len(s) // 2
if s.count("a") >= m:
print("a" * m)
elif s.count("b") >= m:
print("b" * m)
elif s.count("c") >= m:
print("c" * m)
else:
i = 0
j = len(s) - 1
r = []
while j - i > 2:
if s[i] == s[j]:
r.append(s[i])
i += 1
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING VAR IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR BIN_OP STRING ... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | def find(s):
if len(s) == 1:
return s
if len(s) == 2:
return s[0]
if len(s) == 3:
return s[0]
left = 0
right = len(s) - 1
construct = []
left_get = left
right_get = right
while left < right:
if s[left] == s[right]:
construct += [s[left]]
... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR IF FUNC_CALL VAR VAR NUMBER RETURN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VAR IF VAR VAR VAR VAR VAR LIST VAR VAR ASSIGN VAR VAR ASSIGN V... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
n = len(s)
l = 0
h = n - 1
ans = []
while h >= l:
if s[l] == s[h]:
ans.append(s[l])
l += 1
h -= 1
elif s[l + 1] == s[h]:
l += 1
elif s[l] == s[h - 1]:
h -= 1
else:
h -= 1
l += 1
n = len(ans)
for i in range(n):
print(ans[i], end="")
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR ... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | s = input()
n = len(s)
b = []
for j in s:
b.append(j)
x = []
y = []
j = 0
i = n - 1
while j < i:
if b[j] == b[i]:
if i != j:
x.append(b[j])
y.append(b[i])
else:
x.append(b[j])
i += -1
j += 1
elif b[j] == b[i - 1]:
if i - 1 != j:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ... |
Alice bought a Congo Prime Video subscription and was watching a documentary on the archaeological findings from Factor's Island on Loch Katrine in Scotland. The archaeologists found a book whose age and origin are unknown. Perhaps Alice can make some sense of it?
The book contains a single string of characters "a", "... | t = 1
for _ in range(t):
s = input()
n = len(s)
if n <= 3:
print(s[0])
exit(0)
finl_Str = ""
for i in range(0, n, 2):
if n - i - 2 <= i + 1:
break
if "a" in s[i : i + 2] and "a" in s[n - i - 2 : n - i]:
finl_Str += "a"
elif "b" in s[i :... | ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER IF STRING VAR VAR BIN_OP VAR NUMBER STRING V... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
x = r - l + 1
t = [i for i in range(1, x + 1)]
b = True
if sum(t) > s:
b = False
print(-1)
else:
s -= sum(t)
to_add = s // x
for i in range(x):
t[i] += to_add
to_add =... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VA... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | t = int(input())
while t > 0:
t -= 1
n, l, r, s = map(int, input().split())
k = r - l + 1
smin = k * (k + 1) // 2
smax = smin + k * (n - k)
if smin <= s <= smax:
dif = s - smin
q1 = dif // k
q2 = dif % k
a = [(i + 1) for i in range(k)]
for i in range(k - 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIG... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def get(sum, dist, n):
if not (dist + 1) * dist / 2 <= sum <= (2 * n - dist + 1) * dist / 2:
return None
ans = []
for cur in range(n, 0, -1):
if dist * (dist - 1) / 2 + cur <= sum:
ans.append(cur)
sum -= cur
dist -= 1
return ans
t = int(input())
for ... | FUNC_DEF IF BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER RETURN NONE ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def fun(length, s, n):
sum1 = 0
lis = []
for i in range(1, length + 1):
lis.append(i)
sum1 += i
limit = n
j = len(lis) - 1
left = s - sum1
while j >= 0:
if left == 0:
se.remove(lis[j])
j -= 1
continue
if limit - lis[j] >= le... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR VAR VAR EXPR FUN... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | tc = int(input())
for _ in range(tc):
n, l, r, s = list(map(int, input().split()))
needed = r - l + 1
minsum = 0
sum_left = s
max_left = n
lis = []
taken = [(False) for _ in range(n + 3)]
for i in range(needed):
minsum += i + 1
works = True
while needed > 0:
if mi... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | import sys
input = sys.stdin.readline
def solve():
n, l, r, s = map(int, input().split())
k = r - l + 1
z = list(range(1, k + 1))
t = sum(z)
j = 0
for i in range(k - 1, -1, -1):
w = min(n - j - z[i], s - t)
if w > 0:
t += w
z[i] += w
j += 1
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CAL... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | (T,) = map(int, input().split())
for _ in range(T):
n, l, r, s = map(int, input().split())
x = list(range(1, r - l + 2))
mx = sum(range(n - (r - l), n + 1))
mn = sum(x)
if s > mx or s < mn:
print(-1)
continue
c = -1
for _ in range(s - mn):
if c == -1:
if x... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CA... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
c = r - l + 1
sp = []
f = range(n - c + 1, n + 1)
h = range(1, c + 1)
max_s = sum(f)
min_s = sum(h)
if s > max_s or s < min_s:
print(-1)
elif s == min_s:
c = list(range(1, n + 1))
for el in h... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VA... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for i in range(int(input())):
n, l, r, s = [int(n) for n in input().split()]
length = r - l + 1
max_sum = length * (2 * n + 1 - length) // 2
min_sum = length * (length + 1) // 2
if s > max_sum or s < min_sum:
print("-1")
else:
left_part, right_part = [], []
for j in range... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR VAR EXPR FUNC... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | t = int(input())
for _ in range(t):
n, l, r, s = map(int, input().split())
d = r - l + 1
k = n - d
mini = d * (d + 1) // 2
maxi = d * n - d * (d - 1) // 2
if s not in range(mini, maxi + 1):
print(-1)
continue
if k == 0:
print(" ".join(map(str, range(1, n + 1))))
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER N... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def solve(n: int, l: int, r: int, s: int) -> str:
max_sum = 0
for i in range(n, n - (r - l + 1), -1):
max_sum += i
if s > max_sum:
return "-1"
arr = [i for i in range(1, r - l + 2)]
total = sum(arr)
if s < total:
return "-1"
nums = [i for i in range(1, n + 1)]
max... | FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR IF VAR VAR RETURN STRING ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN STRING ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP V... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def high(i, k):
return k * (2 * i + 1 - k) // 2
def low(k):
return k * (k + 1) // 2
for z in range(int(input())):
n, le, r, s = map(int, input().split())
s2 = s
k = r - le + 1
l = []
for i in range(n, 0, -1):
if k > 0 and high(i, k) >= s and s - i >= low(k - 1):
s -= ... | FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | t = int(input())
for _ in range(t):
def solve():
n, l, r, s = map(int, input().split())
sz = r - l + 1
lb = n - sz + 1
def cal(x, y):
return (x + y) * (y - x + 1) // 2
if cal(1, sz) <= s and s <= cal(lb, n):
ans, vis = [0] * n, [False] * (n + 1)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF FUNC_CALL VAR NUM... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def main():
T = int(input())
while T:
n, l, r, s = map(int, input().split())
if s < (r - l + 1) * (r - l + 2) // 2 or s > (r - l + 1) * (r - l + 2) // 2 + (
r - l + 1
) * (n - (r - l + 1)):
print(-1)
else:
LR = [i for i in range(1, r - l + 2)]
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split(" "))
t = r - l + 1
l = l - 1
r = r - 1
lo = t * (t + 1) // 2
hi = t * (2 * n - t + 1) // 2
if s > hi or s < lo:
print(-1)
else:
res = [i for i in range(1, t + 1)]
res.reverse()
curr = lo
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = list(map(int, input().split()))
l -= 1
r -= 1
k = r - l + 1
a = [(0) for _ in range(n)]
j = 1
for i in range(l, r + 1):
a[i] = j
j += 1
s1 = k * (k + 1) // 2
s2 = k * (2 * n - k + 1) // 2
if s < s1 or s > s2:
prin... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR NUMB... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def answer():
m = r - l + 1
v1 = n * (n + 1) // 2 - (n - m) * (n - m + 1) // 2
v2 = m * (m + 1) // 2
if v1 < s or v2 > s:
return [-1]
req = []
taken = [False] * (n + 1)
for i in range(1, r - l + 2):
taken[i] = True
req.append(i)
need = s - sum(req)
for i in ra... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR VAR RETURN LIST NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER BIN_OP ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
n, l, r, s = map(int, input().split())
k = r - l + 1
vals = [i for i in range(1, k + 1)][::-1]
sigma = sum(vals)
if sigma > s:
print(-1)
continue
ptr = -1
last = n
while sigma < s:
... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSI... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def solve(n, l, r, s):
sol = list(range(1, r - l + 2))
sol.reverse()
somme = sum(sol)
i = 0
while somme < s:
if i >= len(sol):
print(-1)
return
if sol[i] < n and (i == 0 or sol[i] < sol[i - 1] - 1):
sol[i] += 1
somme += 1
else:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN IF VAR VAR VAR VAR NUMBER VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER VA... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | t = int(input())
for _ in range(t):
n, l, r, s = list(map(int, input().split()))
els = []
sels = 0
nb = r - l + 1
els = [(i + 1) for i in range(nb)]
sels = (nb + 1) * nb // 2
if sels > s:
print(-1)
continue
i = len(els) - 1
while sels < s and i >= 0:
if sels +... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMB... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def Low(k):
return k * (k + 1) // 2
def High(n, k):
return k * (2 * n - k + 1) // 2
for _ in range(int(input())):
n, l, r, s = map(int, input().split())
k = r - l + 1
r, l = r - 1, l - 1
if not High(n, k) >= s >= Low(k):
print(-1)
continue
L = [0] * n
lp, rp = l, l - ... | FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
l -= 1
k = r - l
if sum(range(1, 1 + k)) <= s <= sum(range(n + 1 - k, n + 1)):
togo = s - sum(range(1, 1 + k))
A = list(range(1 + togo // k, 1 + togo // k + k))
togo %= k
for i in range(k - togo, k):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL V... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | import sys
N = int(200000.0 + 5)
sys.setrecursionlimit(N)
def charming():
n, l, r, s = map(int, input().split())
len = r - l + 1
def cal(l, r) -> int:
return (r - l + 1) * (r + l) // 2
if cal(n - len + 1, n) < s or cal(1, len) > s:
print(-1)
return
cur = n
used = set... | IMPORT ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR IF FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
k = [0] * n
p = r - l + 1
t = n * (n + 1) // 2
q = (n - p) * (n - p + 1) // 2
if p * (p + 1) // 2 > s or t - q < s:
print(-1)
continue
a = 1
p = 0
t = set()
for i in range(l - 1, r):
k[i]... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER I... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
c = 1
f = []
for i in range(l, r + 1):
f.append(c)
c += 1
ll = r - l + 1
k = 0
i = ll - 1
while True:
if sum(f) == s:
break
if f[i] > n:
k = 1
break
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
w = r - l + 1
m = sum(range(n, n - w, -1))
if s > m or s < sum(range(1, w + 1)):
print(-1)
continue
j = n - w + 1
arr = set()
for i in range(1, n + 1):
if m - j + i >= s:
arr.add(i)
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER IF VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, total = map(int, input().split())
mini, maxi, a, b = 0, 0, 1, n
s = total
for i in range(l - 1, r):
mini += a
maxi += b
b -= 1
a += 1
if total > maxi or total < mini:
print(-1)
continue
a = [i for i in range(1... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
c = r - l + 1
if s >= c * (c + 1) // 2 and s <= c * (2 * n - c + 1) // 2:
sett = set()
ss = 0
cnt = c - 1
for i in range(1, n + 1):
if ss + i <= s and ss + i + cnt * (2 * n - cnt + 1) // 2 >= s:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in " " * int(input()):
n, l, r, s = map(int, input().split())
if n * (n + 1) // 2 - (n - r + l - 1) * (n - r + l) // 2 < s:
print(-1)
continue
if (r - l + 1) * (r - l + 2) // 2 > s:
print(-1)
continue
x = n
add = [(i + 1) for i in range(r - l + 1)]
sa = sum(... | FOR VAR BIN_OP STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP BIN_OP BIN_OP VAR ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | t = int(input())
for _ in range(t):
n, l, r, s = map(int, input().split())
l -= 1
r -= 1
c = r - l + 1
if c * (c + 1) // 2 > s or c * (2 * n + 1 - c) // 2 < s:
print(-1)
continue
sec = [i for i in range(1, c + 1)]
sec.reverse()
s -= c * (c + 1) // 2
cnt = 0
while ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER VAR EXPR F... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = list(map(int, input().split()))
l -= 1
r -= 1
k = r - l + 1
s1 = k * (k + 1) // 2
s2 = k * (2 * n - k + 1) // 2
if s < s1 or s > s2:
print(-1)
else:
a = [(i + 1) for i in range(n)]
last = n
mid = []
while ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUM... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | t = int(input())
for i in range(t):
n, l, r, s = map(int, input().split())
ans = 0
s1 = 0
k = 1
a = []
for j in range(r - l + 1):
s1 = s1 + k
a.append(k)
k = k + 1
s2 = 0
k = n
for j in range(r - l + 1):
s2 = s2 + k
k = k - 1
if s <= s2 and... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VA... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | t = int(input())
for _ in range(t):
n, l, r, s = [int(num) for num in input().strip().split(" ")]
seq = [i for i in range(1, n + 1)]
k = r - l + 1
low = sum(seq[:k])
high = sum(seq[n - k :])
if s < low or s > high:
print(-1)
continue
used = set()
for i in reversed(seq):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VA... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | from sys import stdin
input = stdin.buffer.readline
t = int(input())
for i in range(t):
n, l, r, s = map(int, input().split())
k = r - l + 1
if s < k * (k + 1) // 2 or s > k * (2 * n + 1 - k) // 2:
print(-1)
continue
arr = [0] * (n + 1)
for i in range(1, k + 1):
arr[i] = 1
... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CAL... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for test in range(int(input())):
n, l, r, s = map(int, input().split())
lst = [i for i in range(n, 0, -1)]
x = r - l + 1
store = set()
for i in range(n):
if x * (x - 1) // 2 <= s - lst[i]:
store.add(lst[i])
x -= 1
s -= lst[i]
if len(store) == r - l + 1... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR VA... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
l -= 1
r -= 1
x = r - l + 1
a = [(n - i) for i in range(x)]
temps = sum(a)
if temps < s:
print(-1)
continue
elif temps == s:
b = [0] * n
j = 1
for i in range(n):
if i ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for w in range(int(input())):
n, left, right, s = tuple(map(int, input().split()))
length = right - left + 1
l = [(i + 1) for i in range(n)]
temp = 0
keys = []
ans = [-1] * n
for i in range(length):
temp += l[i]
keys.append(i)
pointer = length - 1
k = keys[pointer]
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR VA... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in " " * int(input()):
n, l, r, s = map(int, input().split())
p, a, f = [], [0] * n, [0] * 5000
for i in range(1, n + 1):
p.append(i)
w = list(p[: r - l + 1])
b = sum(w)
if not b <= s <= sum(p[-(r - l + 1) :]):
print(-1)
else:
c = s - b
m = c % (r - l + ... | FOR VAR BIN_OP STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR LIST BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSI... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | I = lambda: [*map(int, input().split())]
def out(x):
print(str(x))
def solve():
n, l, r, s = I()
c = [i for i in range(1, r - l + 2)]
sm = sum(c)
if sm > s:
out(-1)
return
ci = len(c) - 1
free = set(i for i in range(r - l + 2, n + 1))
used = set(c)
while ci >= 0 a... | ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR BIN_OP FUNC_CALL ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for i in range(int(input())):
n, l, r, s = map(int, input().split())
d = r - l + 1
mi = d * (d + 1) // 2
ma = n * (n + 1) // 2 - (n - d) * (n - d + 1) // 2
if s < mi or s > ma:
print(-1)
else:
li = []
for jj in range(d):
li.append(jj + 1)
s -= jj +... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | T = int(input())
for _ in range(T):
n, l, r, k = map(int, input().split())
_len = r - l + 1
lb = (_len + 1) * _len // 2
ub = (n + n - _len + 1) * _len // 2
ans = [0] * n
used = []
if lb <= k <= ub:
dis = k - lb
step = dis // _len
rem = dis % _len
for i in rang... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LI... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def solve(n, lft, r, s):
l = r - lft + 1
arr = [i for i in range(1, l + 1)]
sm = l * (l + 1) // 2
if s < sm:
return -1
if s > sm:
x = (s - sm) // l
xm = s - (x * l + sm)
if x + arr[-1] > n:
return -1
if x + arr[-1] == n:
if xm != 0:
... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR RETURN NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER VAR RETURN NU... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
x = r - l + 1
if x * (x + 1) // 2 > s:
print(-1)
elif n * (n + 1) / 2 - (n - x) * (n - x + 1) / 2 < s:
print(-1)
else:
ans = [(0) for i in range(n)]
i = n
j = l - 1
while j < r:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def out(ans, n):
num = [i for i in range(1, n + 1) if i not in ans]
for i in range(n):
if ans[i] == 0:
ans[i] = num.pop()
print(" ".join(map(str, ans)))
t = int(input())
for _ in range(t):
n, l, r, s = [int(x) for x in input().split(" ")]
ans = [0] * n
ex = r - l + 1
lo... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | import sys
def main():
t = int(input())
allans = []
for _ in range(t):
n, l, r, s = readIntArr()
l -= 1
r -= 1
requiredCnt = r - l + 1
minPossible = sum(range(1, requiredCnt + 1))
maxPossible = sum(range(n, n - requiredCnt, -1))
if s < minPossible or... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR VAR NU... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def solve(N, L, R, S):
n = N
max_val, min_val = 0, (1 + R - L + 1) * (R - L + 1) // 2
for _ in range(R - L + 1):
max_val += n
n -= 1
if not min_val <= S <= max_val:
return -1
diff = max_val - S
can = []
for i in range(R - L + 1):
can += [N - i]
can.reverse... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def low(k):
return k * (k + 1) / 2
def high(n, k):
return k * (2 * n + 1 - k) / 2
for _ in range(int(input())):
n, l, r, s = map(int, input().split())
k = r - l + 1
minSumm = k * (k + 1) / 2
maxSumm = k * (2 * n - k + 1) / 2
segment = []
used = [-1] * n
for i in range(n, -1, -1):... | FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | t = int(input())
low = lambda k: k * (k + 1) // 2
high = lambda n, k: k * (2 * n - k + 1) // 2
for ti in range(t):
n, l, r, s = map(int, input().split())
k = r - l + 1
if s < low(k) or s > high(n, k):
print(-1)
continue
ans = []
for i in range(n, 0, -1):
if k > 0 and high(i, ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR FUNC_CALL ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | from sys import stdin
t = int(stdin.readline().strip())
for i in range(t):
lst = [int(x) for x in stdin.readline().strip().split()]
n = lst[0]
l = lst[1]
r = lst[2]
s = lst[3]
d = r - l + 1
e = n - d
if d * (d + 1) // 2 > s:
print(-1)
continue
if n * (n + 1) // 2 - e... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP BIN_OP VAR BIN... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | t = int(input())
for _ in range(t):
n, l, r, s = (int(i) for i in input().split())
nums = r - l + 1
mins = (nums + 1) * nums // 2
maxs = (n + n - nums + 1) * nums // 2
if s < mins or s > maxs:
print(-1)
continue
lst = list(range(1, nums + 1))
d = s - mins
i = 1
maxnum... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR V... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = [int(x) for x in input().split()]
diff = r - l + 1
lal = diff - 1
lala = lal * (lal + 1) // 2
if s < diff * (diff + 1) // 2 or s > diff * n - lala:
print(-1)
continue
main = [i for i in range(1, diff + 1)]
sum = diff * (diff + 1) // ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR VAR VA... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
subarr = [i for i in range(1, r - l + 2)]
if (
s > len(subarr) * (2 * n - len(subarr) + 1) // 2
or s < len(subarr) * (len(subarr) + 1) // 2
):
print(-1)
continue
minsum = (r - l + 1) * (r - l + 2) //... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR BIN_OP BIN_OP FUNC_CALL VAR V... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def ari(n, start):
end = start + n - 1
return (start + end) * n // 2
for _ in range(int(input())):
n, l, r, s = map(int, input().split())
k = r - l + 1
if ari(k, 1) > s:
print(-1)
continue
if ari(k, n - k + 1) < s:
print(-1)
continue
segment = []
for i i... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER IF FUNC_CAL... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
summ1, summ2 = 0, 0
for i in range(1, r - l + 2):
summ1 += i
for i in range(n - r + l, n + 1):
summ2 += i
if summ1 <= s <= summ2:
a = []
for i in range(
(s - summ1) // (r - l + 1) + 1, (s... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR IF VAR VAR VAR ASSIGN VAR LIST FOR V... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | import sys
def solve(n, l, r, s):
l -= 1
r -= 1
ll = r - l + 1
if s > (n + n - ll + 1) * ll // 2 or s < (1 + ll) * ll // 2:
print(-1)
else:
ans = [None] * n
arr = list(range(1, n + 1))
p_sum = sum(arr[:ll])
found = False
for i in range(ll, n):
... | IMPORT FUNC_DEF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER A... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
x = r - l + 1
y = sum(range(n - x + 1, n + 1))
z = sum(range(1, x + 1))
if s > y or s < z:
print(-1)
else:
test = n - x + 1
s1 = []
for i in range(1, n + 1):
if y - test + i >= s:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR ... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | t = int(input())
while t:
t -= 1
n, l, r, s = map(int, input().split())
interval = r - l + 1
if s < interval * (interval + 1) // 2 or s > (2 * n - interval + 1) * (
interval // 2
) + interval % 2 * ((2 * n - interval + 1) // 2):
print(-1)
continue
s -= interval * (interva... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER B... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
z = r - l + 1
m = 0
t = 0
temp = n - z + 1
while t < z:
m += n - t
t += 1
mi = z * (z + 1) // 2
if s >= mi and s <= m:
a = []
v = []
for i in range(n):
v.append(0)
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBE... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | import sys
input = sys.stdin.readline
t = int(input())
for you in range(t):
l = input().split()
n = int(l[0])
r = int(l[2])
s = int(l[3])
l = int(l[1])
ok = 0
for i in range(n, n - (r - l + 1), -1):
ok += i
if s > ok:
print(-1)
continue
if s < r - l + 1:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR 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 FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
x = r - l + 1
f = 0
ai = []
for i in range(x):
ai.append(i + 1)
if sum(ai) > s:
print(-1)
else:
k = (s - sum(ai)) // x
y = (s - sum(ai)) % x
for i in range(x):
ai[i] = ai[... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def solve():
n, l, r, s = [int(i) for i in input().split()]
k = r - l + 1
l1 = [0] * n
l2 = [i for i in range(1, n + 1)]
l3 = []
low = k * (k + 1) // 2
high = k * (2 * n + 1 - k) // 2
if s < low or high < s:
print(-1)
return
c = l - 1
for i in range(n, 0, -1):
... | FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def question5():
Length, Left, Right, sum_from_l_r = map(int, input().split())
sub_length = Right - Left + 1
remain = Length - sub_length
if (
sub_length * (sub_length + 1) // 2
<= sum_from_l_r
<= Length * (Length + 1) // 2 - remain * (remain + 1) // 2
):
initial = [i... | FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMB... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
ct = r - l + 1
a = list(range(1, ct + 1))
high = n
sm = sum(a)
if sm > s:
print(-1)
continue
for j in range(ct - 1, -1, -1):
if sm == s:
break
s1 = sm - a[j]
cand = min(hi... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VA... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def solve(n, l, r, s):
a = r - l + 1
u = (n - a + 1 + n) * a // 2
w = (a + 1) * a // 2
if not w <= s <= u:
print(-1)
return
m = list(reversed(range(1, a + 1)))
s -= w
for i in range(a):
y = n - i
if s > y - m[i]:
s -= y - m[i]
m[i] = y
... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR FOR VAR... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | def gauss(a, b):
return (a + b) * (b - a + 1) // 2
for t in range(int(input())):
n, l, r, s = map(int, input().split())
s2 = s
cnt = r - l + 1
taken = set()
for i in range(1, cnt + 1):
for j in range(n - i + 1, 0, -1):
if gauss(1, cnt - i) + j <= s:
taken.ad... | FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMB... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | for _ in range(int(input())):
n, l, r, s = map(int, input().split())
z = r - l + 1
p = 0
q = 0
i = 0
b = list([(i + 1) for i in range(n)])
a = list(b[:z])
while i < z:
p = p + i + 1
q = q + n - i
i += 1
c = s - p
if s <= q and s >= p:
i = -1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR WHILE VAR VAR... |
A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.
Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{... | t = int(input())
def high(i, k):
return k * (2 * i + 1 - k) / 2
def low(k):
return k * (k + 1) / 2
def fun(n, width, s):
rset = []
if width == 1:
rset.append(s)
return rset
if s == width * (width + 1) // 2:
return list(range(1, width + 1))
if high(n, width) >= s and... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR IF VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN FUNC_CAL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.