description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | from itertools import accumulate, chain, islice
n, v = (int(i) for i in input().split(" "))
little = []
big = []
for index in range(n):
t, m = input().split(" ")
t, m = int(t), int(m)
(little if t == 1 else big).append((m, index))
little.sort(key=lambda item: -item[0])
little = little[:v]
little_acc = list... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | import sys
__author__ = "Eddie"
def get_filehandler(is_file):
if is_file:
return open(file="data")
else:
import sys
return sys.stdin
fh = get_filehandler(is_file=False)
n, v = [int(value) for value in fh.readline().split()]
d = {"1": [], "2": []}
for _i in range(1, n + 1):
t, c... | IMPORT ASSIGN VAR STRING FUNC_DEF IF VAR RETURN FUNC_CALL VAR STRING IMPORT RETURN VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT STRING STRING LIST LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | N, cap = [int(_) for _ in input().split()]
one = []
two = []
for _ in range(N):
n, c = [int(_) for _ in input().split()]
if n == 1:
one.append([c, _])
else:
two.append([c, _])
one.sort(reverse=True)
two.sort(reverse=True)
for i in range(1, len(one)):
one[i][0] += one[i - 1][0]
for i in r... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FU... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | from sys import stdin
n, v = [int(x) for x in stdin.readline().split()]
k = []
c = []
for x in range(n):
a, b = [int(x) for x in stdin.readline().split()]
if a == 1:
k.append((b, x + 1))
else:
c.append((b, x + 1))
k.sort()
c.sort()
cap = 0
boats = []
if v % 2 == 1 and k:
x = k.pop()
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | n, v = tuple(map(int, input().split()))
vehicles = []
vehicles1 = []
res1 = []
res2 = []
res = []
for i in range(n):
lst = input().split()
vehicles.append((int(lst[1]), int(lst[0]), i))
if lst[0] == "1":
vehicles1.append((int(lst[1]), int(lst[0]), i))
vehicles.sort(reverse=True)
vehicles1.sort(rever... | 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 LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR IF VAR NUMBER STRING EXPR FUNC_CALL... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | n, v = map(int, input().split())
l1 = []
l2 = []
for i in range(0, n):
t, p = map(int, input().split())
if t == 1:
l1.append((p, i + 1))
else:
l2.append((p, i + 1))
l1 = sorted(l1, key=lambda tup: tup[0], reverse=True)
l2 = sorted(l2, key=lambda tup: tup[0], reverse=True)
sum1 = [0]
sum2 = [... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBE... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | import sys
line = list(map(int, sys.stdin.readline().split()))
n = line[0]
v = line[1]
kayaks = []
catamarans = []
for i in range(0, n):
nums = list(map(int, sys.stdin.readline().split()))
if nums[0] == 1:
kayaks.append((nums[1], i + 1))
else:
catamarans.append((nums[1], i + 1))
kayaks.sort... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER E... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | n, v = map(int, input().split())
list1 = []
list2 = []
for i in range(n):
t, p = map(int, input().split())
if t == 1:
list1.append([p, i + 1])
else:
list2.append([p, i + 1])
list1.sort(reverse=True)
list2.sort(reverse=True)
temp1 = [0]
temp2 = [0]
for i in range(0, min(v, len(list1))):
t... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL V... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | def main():
n, v = map(int, input().split())
kayak = list()
k_add = kayak.append
catamaran = list()
c_add = catamaran.append
for i in range(1, n + 1):
t, p = map(int, input().split())
pn = p, i
if t == 1:
k_add(pn)
else:
c_add(pn)
catam... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | import sys
n, v = sys.stdin.readline().strip().split()
n = int(n)
v = int(v)
lines = []
for i in range(0, n):
lines.append(sys.stdin.readline().strip())
vehicles = []
for index, vehicle in enumerate(lines):
typ, capacity = vehicle.split()
typ = int(typ)
capacity = int(capacity)
eff = capacity / typ... | IMPORT ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | n, v = tuple(map(int, input().split()))
boats = []
for i in range(n):
t, c = tuple(map(int, input().split()))
d = c / t
if t == 1:
d += 1e-07
boats.append((d, t, c, i + 1))
boats.sort(key=lambda tpl: tpl[0], reverse=True)
sumt = 0
sumc = 0
boatorder = []
last1 = None
last1_idx = None
for i in ra... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER NUMBER... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | import sys
__author__ = "Darren"
def solve():
import sys
stdin = sys.stdin if True else open("data")
n, v = map(int, next(stdin).split())
kayaks, catamarans = [], []
for i in range(n):
t, p = map(int, next(stdin).split())
if t == 1:
kayaks.append((str(i + 1), p))
... | IMPORT ASSIGN VAR STRING FUNC_DEF IMPORT ASSIGN VAR NUMBER VAR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBE... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | n, v = (int(x) for x in input().split())
a1, a2 = [], []
for i in range(n):
t, p = (int(x) for x in input().split())
(a1 if t == 1 else a2).append((p, i + 1))
a1.sort()
a2.sort()
c = 0
z = []
def pop(t):
global c, v
a = a1 if t == 1 else a2
c += a[-1][0]
z.append(a[-1][1])
a.pop()
v -=... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_DEF ASSIGN VAR... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | n, v = map(int, input().split())
ba = []
ka = []
for i in range(n):
t, p = map(int, input().split())
if t == 1:
ba.append([i + 1, p])
else:
ka.append([i + 1, p])
ba.sort(key=lambda x: x[1], reverse=True)
ka.sort(key=lambda x: x[1], reverse=True)
ba_pos = -1
ka_pos = -1
w = 0
while w < v:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER EXPR ... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | n, v = map(int, input().split())
a = []
b = []
for i in range(n):
typ, carry = map(int, input().split())
if typ == 1:
a.append([carry, i + 1])
else:
b.append([carry, i + 1])
a.sort(reverse=True)
b.sort(reverse=True)
for i in range(1, len(a)):
a[i][0] += a[i - 1][0]
for i in range(1, min(... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL V... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | def merge_sort_recursive(arr):
if len(arr) <= 1:
return arr
middle = len(arr) // 2
left = merge_sort_recursive(arr[:middle])
right = merge_sort_recursive(arr[middle:])
i = j = 0
for k in range(len(arr)):
if j == len(right) or i < len(left) and left[i] < right[j]:
arr[... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER ASSI... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | n, v = map(int, input().split())
baydarki, katamaran = [], []
for i in range(n):
t, p = map(int, input().split())
if t == 1:
baydarki.append([p, i + 1])
else:
katamaran.append([p, i + 1])
baydarki.sort(reverse=True)
katamaran.sort(reverse=True)
load1, load2 = [0], [0]
capacity = 0
for i in r... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMB... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | def print_v(v):
print(v, eval(v))
n, v = map(int, input().split())
vehicle1 = []
vehicle2 = []
for i in range(n):
t, p = map(int, input().split())
if t == 1:
vehicle1.append((p, i + 1))
else:
vehicle2.append((p, i + 1))
vehicle1.sort(key=lambda x: x[0], reverse=True)
vehicle2.sort(key=... | FUNC_DEF EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EX... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | n, v = map(int, input().split())
boat_list = []
for _ in range(n):
t, p = map(int, input().split())
boat_list.append([t, p])
boat1 = []
boat2 = []
for i in range(n):
if boat_list[i][0] == 1:
boat1.append([boat_list[i][1], i + 1])
else:
boat2.append([boat_list[i][1], i + 1])
boat1 = list(... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST VAR VAR NUMBER BIN_OP VAR... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | n, v = map(int, input().split())
V = [[], []]
for i in range(n):
t, s = map(int, input().split())
V[t - 1].append((s, i + 1))
V[0].append((-1000000, 0))
V[0].append((-1000000, 0))
V[1].append((-1000000, 0))
V[0].sort()
V[1].sort()
V[0] = V[0][::-1]
V[1] = V[1][::-1]
cnt0 = 0
cnt1 = 0
while v >= 2:
s1 = V[0]... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL ... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | n, v = map(int, input().split())
boat = []
for i in range(n):
boat.append(list(map(int, input().split())))
boat[i].append(i + 1)
boat1 = [b for b in boat if b[0] == 1]
boat2 = [b for b in boat if b[0] == 2]
boat1.sort(key=lambda x: x[1], reverse=True)
boat2.sort(key=lambda x: x[1], reverse=True)
ans, res = 0, "... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ... |
A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the point of departure. It's known that all kayaks are of the same size (and each of them occupies the space of 1 cubic metre), and all catamarans are of the same size, but two times b... | kk = lambda: map(int, input().split())
ll = lambda: list(kk())
def pop(ls):
if not ls:
return 0, -1
return ls.pop(-1)
def pop1():
v, i = pop(l1)
v2, i2 = pop(l1)
return v + v2, i, i2
def pop2():
return pop(l2)
n, v = kk()
l1, l2 = [], []
for i in range(n):
t, k = kk()
if ... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR RETURN NUMBER NUMBER RETURN FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR RETURN BIN_OP VAR VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | from sys import stdin
input = stdin.readline
for i in range(int(input())):
input()
c = 2
for i, j in zip(
sorted(map(int, input().split())),
sorted(map(int, input().split()), reverse=True),
):
c = i + j if i + j > c else c
print(c) | ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | for _ in range(int(input())):
n = int(input())
boy_heights = sorted(list(map(int, input().split())))
girl_heights = sorted(list(map(int, input().split())), reverse=True)
m = -1
for i in range(n):
if boy_heights[i] + girl_heights[i] > m:
m = boy_heights[i] + girl_heights[i]
pr... | 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR ... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | class likeness:
def __init__(self):
self.n = int(input())
self.l1 = list(map(int, input().split()))
self.l2 = list(map(int, input().split()))
def find(self):
self.l1.sort()
self.l2.sort(reverse=True)
self.max = self.l1[0] + self.l2[0]
for i in range(1, s... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR A... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | for i in range(int(input())):
n = int(input())
l = sorted(list(map(int, input().split())))
m = list(map(int, input().split()))
m.sort(reverse=True)
for j in range(n):
m[j] = m[j] + l[j]
print(max(m)) | 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR V... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | def couples(g, b, length):
g.sort()
b.sort(reverse=True)
k = max([(g[i] + b[i]) for i in range(length)])
return k
for i in range(int(input())):
length = int(input())
b = [int(i) for i in input().split()]
g = [int(i) for i in input().split()]
print(couples(g, b, length)) | FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR 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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_C... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | testCases = int(input())
for case in range(testCases):
n = int(input())
boys = []
girls = []
for i in input().split(" "):
boys.append(int(i))
for i in input().split(" "):
girls.append(int(i))
boys.sort()
girls.sort()
likeness = []
for i in range(n):
likeness.a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CAL... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | t = int(input())
for i in range(t):
n = int(input())
boys = list(map(int, input().split()))
girls = list(map(int, input().split()))
boys.sort()
girls.sort()
likeness = []
temp = n - 1
for i in range(n):
value = boys[i] + girls[temp]
likeness.append(value)
temp -= ... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | for i in range(int(input())):
n = int(input())
boys = list(map(int, input().split()))
girls = list(map(int, input().split()))
boys.sort()
girls.sort()
girls.reverse()
ans = []
for num in range(n):
ans.append(boys[num] + girls[num])
print(max(ans)) | 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VA... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | t = int(input())
for i in range(t):
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a1.sort(reverse=False)
a2.sort(reverse=True)
maximum = -1
for i in range(n):
maximum = max(maximum, a1[i] + a2[i])
print(maximum) | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | t = int(input())
while t:
s = []
n = int(input())
B = [int(i) for i in input().split()]
G = [int(i) for i in input().split()]
B.sort()
G = sorted(G, reverse=True)
for i in range(n):
s.append(B[i] + G[i])
print(max(s))
t -= 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BI... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | t = int(input())
for _ in range(t):
n = int(input())
list1 = sorted(list(map(int, input().split())))
list2 = sorted(list(map(int, input().split())), reverse=True)
a = [(list1[i] + list2[i]) for i in range(n)]
print(max(a)) | 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | t = int(input())
for i in range(t):
n = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
A.sort()
B.sort()
C = []
for j in range(n):
C.append(A[j] + B[n - j - 1])
print(max(C)) | 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | for t in range(int(input())):
student = int(input())
boys = list(map(int, input().split()))
girl = list(map(int, input().split()))
boys.sort()
girl.sort()
couple = []
for i in range(student):
h = boys[i] + girl[student - i - 1]
couple = [h] + couple
couple.sort()
prin... | 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | t = int(input())
while t:
n = int(input())
boys = list(map(int, input().split(" ")))
girls = list(map(int, input().split(" ")))
boys.sort()
girls.sort(reverse=True)
maxnum = []
for i in range(n):
maxnum.append(boys[i] + girls[i])
print(max(maxnum))
t = t - 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR V... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | def solve():
for _ in range(int(input())):
_ = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()), reverse=True)
max_likeness = 0
for a, b in zip(A, B):
max_likeness = max(max_likeness, a + b)
print(max_likeness)
solv... | FUNC_DEF 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | x = int(input())
ander = []
for tte in range(0, x):
e = int(input())
lp = str(input())
rr = lp.split(" ")
mut = str(input())
eewq = mut.split(" ")
ssa = []
for bbc in rr:
ssa.append(int(bbc))
gge = []
for iiew in eewq:
gge.append(int(iiew))
aswq = [ssa, gge]
a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | T = int(input())
for I in range(T):
n = int(input())
max = 0
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a.sort()
b.sort(reverse=True)
for i in range(0, n):
if max < a[i] + b[i]:
max = a[i] + b[i]
print(max) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | for i in range(int(input())):
n = int(input())
hb = list(map(int, input().split()))
hg = list(map(int, input().split()))
hb = sorted(hb, reverse=True)
hg = sorted(hg)
likness = []
for i in range(n):
lik = hb[i] + hg[i]
likness.append(lik)
print(max(likness)) | 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CAL... |
There are two groups, one of $N$ boys and the other of $N$ girls numbered from $1$ to $N$.
You are given two arrays $A$ and $B$ containing $N$ numbers each, denoting the height of boys and girls in the group.
You have to form $N$ couples, where each couple will consist of $1$ boy and $1$ girl.
Each couple has a LIKE... | for i in range(int(input())):
int(input())
m = sorted(list(map(int, input().split())))
n = sorted(list(map(int, input().split())), reverse=True)
print(max([sum([i, j]) for i, j in zip(m, n)])) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR LIST VAR VAR VAR VAR ... |
The only difference between easy and hard versions is constraints.
Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions β and he won't start playing until he gets all of them.
E... | import sys
DEBUG = False
if DEBUG:
inf = open("input.txt")
else:
inf = sys.stdin
N, M = list(map(int, inf.readline().split(" ")))
n_items = list(map(int, inf.readline().split(" ")))
sales = []
for _ in range(M):
sale = list(map(int, inf.readline().split(" ")))
sales.append(sale)
sales = sorted(sales, k... | IMPORT ASSIGN VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC... |
The only difference between easy and hard versions is constraints.
Ivan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions β and he won't start playing until he gets all of them.
E... | n, m = input().split()
n = int(n)
m = int(m)
nList = input().split()
bList = [0] * len(nList)
for i in range(len(nList)):
nList[i] = int(nList[i])
shopD = {}
shopT = {}
oHis = []
mHis = []
maxD = 0
for i in range(m):
d, t = input().split()
if nList[int(t) - 1] != 0:
maxD = max(maxD, int(d))
... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR LIST... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
def input():
return sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
per = n * (n + 1) // 2
count0 = n - m
nG = m + 1
k = count0 // nG
rem = count0 // nG
val = per - rem * (rem + 1) // 2 * nG - (k + 1) * (count0 % nG)
p... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN 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 VAR VAR ASSIGN VAR BIN_O... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
z = int(readline())
for _ in range(z):
n, m = map(int, readline().split())
G = m + 1
Z = n - m
k, rest = divmod(Z, G)
print(n * (n + 1) // 2 - (G * (k * (k + 1) // 2) + (k + 1) * rest... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
t = int(input())
C = [list(map(int, input().split())) for i in range(t)]
def c(x, y):
if x % 2 == 0:
return x // 2 * y
else:
return y // 2 * x
for i in range(t):
n = C[i][0]
o = C[i][1]
z = n - o
al = c(n, n - 1) + n
if z - 1 <= o:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VA... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
for l in range(int(input())):
n, m = map(int, input().split(" "))
zerosPer = (n - m) // (m + 1)
numUpper = (n - m) % (m + 1)
x = (m + 1 - numUpper) * zerosPer * (zerosPer + 1) // 2
x = x + numUpper * (zerosPer + 1) * (zerosPer + 2) // 2
print(n * (n + 1) //... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
for _ in range(int(sys.stdin.readline())):
n, m = map(int, sys.stdin.readline().split())
r = n - m
if m == 0:
print(0)
else:
v = r % (m + 1)
k = r // (m + 1)
c = v * ((k + 1) * k // 2 + k + 1) + (m + 1 - v) * (k * (k - 1) // 2 + k)
print(n * (n - 1) //... | IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
t = int(sys.stdin.readline())
def go(n, m):
if n // 2 <= m:
ans = n * (n + 1) // 2
ans -= n - m
return ans
elif m == 0:
return 0
else:
k = (n - m) // (m + 1)
r = (n - m) % (m + 1)
r2 = m + 1 - r
a0 = n - (k + 1) + 1
ans2 =... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR RETURN VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP V... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | from sys import stdin, stdout
T = int(input())
def summ(n):
return n * (n + 1) // 2
for case in range(T):
n, m = map(int, stdin.readline().split())
if m >= n / 2:
A = summ(n) - (n - m)
else:
c = m + 1
f = (n - m) // c
f_u = f + 1
n_f_u = (n - m) % c
n... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR V... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
t = int(sys.stdin.readline())
for _ in range(t):
n, m = map(int, sys.stdin.readline().split())
g = m + 1
z = n - m
k = z // g
ans = 0
a = z % g
total = n * (n + 1) // 2
ans += a * (k + 1) * (k + 2) // 2
ans += k * (k + 1) // 2 * (m + 1 - a)
print(total - ans) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP B... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | T = int(input())
arr = []
for i in range(T):
n, m = map(int, input().split())
k = n - m
m += 1
t = k // m
kol = k - t * m
ans = n * (n + 1) // 2 - (kol * (t + 1) ** 2 + (m - kol) * t**2 + k) // 2
arr.append(ans)
print("\n".join(map(str, arr))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP ... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | from sys import stdin, stdout
t = int(stdin.readline())
while t:
t -= 1
n, m = map(int, stdin.readline().split())
mul, rem = divmod(n - m, m + 1)
ans = (
n * (n + 1) // 2
- (m + 1 - rem) * mul * (mul + 1) // 2
- rem * (mul + 1) * (mul + 2) // 2
)
stdout.write(str(ans) + ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER N... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
for _ in range(int(sys.stdin.readline())):
n, m = map(int, sys.stdin.readline().split())
ans = n * (n + 1) // 2
x = (n - m) // (m + 1)
y = (n - m) % (m + 1)
ans -= y * (x + 2) * (x + 1) // 2 + (m + 1 - y) * (x + 1) * x // 2
print(ans) | IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUM... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
n, m = map(int, input().split())
zeros = n - m
if zeros == 0:
print(n * (n + 1) // 2)
else:
div = zeros // (m + 1)
rem = zeros % (m + 1)
print(
n * (n + 1) // 2
- rem * (div... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR N... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | from sys import stdin, stdout
def total(k):
return k * (k + 1) // 2
ans = []
t = int(stdin.readline())
for line in stdin:
n, m = tuple(map(int, line.split()))
if m == 0:
ans.append(str(0))
else:
al = total(n)
zeros = n - m
k, extra = zeros // (m + 1), zeros % (m + 1)
... | FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VA... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
t = int(sys.stdin.readline())
for i in range(t):
n, m = [int(i) for i in sys.stdin.readline().split()]
st = 1
if n == 1:
if m == int(1):
print("1")
else:
print("0")
st = -1
ans = n * (n - 1) // 2 + n
nl = n - m
if (n - m) % (m + 1) == 0... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUM... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, m = map(int, input().split())
grps = m + 1
zeach = (n - m) // grps
extras = (n - m) % grps
print(n * (n + 1) // 2 - zeach * (zeach + 1) // 2 * grps - extras * (zeach + 1)) | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_O... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
get = lambda x: x * (x + 1) // 2
t = int(sys.stdin.readline())
for _ in range(t):
n, m = map(int, sys.stdin.readline().split(" "))
all = get(n)
zeros = n - m
len_complete_intervals = zeros // (m + 1)
len_remained_intervals = zeros % (m + 1)
print(
all
- get(len_comple... | IMPORT ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NU... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
N, M = map(int, input().split())
if M < N // 2:
l, k = divmod(N - M, M + 1)
print(
N * (N + 1) // 2
- (l * (l + 1) // 2 * (M + 1 - k) + (l + 1) * (l + 2) // 2 * k)
)
else:
print... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
def main():
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
N, M = list(map(int, input().split()))
S = (N + 1) * N // 2
zero = N - M
num = zero // (M + 1)
major = zero % (M + 1)
minor = M + 1 - major
S -= maj... | IMPORT FUNC_DEF IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
(T,) = map(int, input().split())
ans = []
for t in range(T):
N, M = map(int, input().split())
numSubstrings = N * (N + 1) // 2
numZeroes = N - M
numGroups = M + 1
d, r = divmod(numZeroes, numGroups)
assert (numGroups - r) * d + r * (d + 1) == numZeroes
ans.append(
numSubs... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN 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 VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP B... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | from sys import stdin
input = stdin.readline
t = int(input())
for i in range(t):
n, m = list(map(int, input().split()))
nd = n // 2
mi = m + 1
diff = n - m
if m == 0:
print(0)
continue
if m >= nd:
k = n * (n + 1) // 2 + m - n
print(int(k))
else:
a, b ... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BI... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | from sys import stdin
input = stdin.readline
q = int(input())
for _ in range(q):
n, j = map(int, input().split())
z = n - j
przedjed = z // (j + 1)
cyk = z - (j + 1) * przedjed
chuj = (
cyk * (przedjed + 2) * (przedjed + 1) // 2
+ (j + 1 - cyk) * przedjed * (przedjed + 1) // 2
)... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_O... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
def getCnts(l):
return (l + 1) * l // 2
def getAns(n, m):
smaller = (n - m) // (m + 1)
smallerCnts = smaller * m + smaller + 2 * m + 1 - n
larger = smaller + 1
largerCnts = m + 1 - smallerCnts
ans = getCnts(n) - smallerCnts * getCnts(smaller) - largerCnts * getCnts(larger)
ret... | IMPORT FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP NUMBER VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | from sys import stdin, stdout
input = stdin.readline
pr = stdout.write
for _ in range(int(input())):
n, m = map(int, input().split())
k = n - m
a = k // (m + 1)
b = k % (m + 1)
pr(
str(
n * (n + 1) // 2
- (m + 1 - b) * (a * (a + 1) // 2)
- b * ((a + 1) * ... | ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_O... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
t = int(sys.stdin.readline())
for _ in range(t):
n, m = map(int, sys.stdin.readline().split(" "))
p = (n - m) // (m + 1)
q = (n - m) % (m + 1)
x = q * (p + 1) * (p + 2) // 2
y = (m + 1 - q) * p * (p + 1) // 2
res = n * (n + 1) // 2 - (x + y)
print(res) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASS... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
lines = list(sys.stdin.readlines())
t = int(lines[0])
def count(x):
return x * (x + 1) // 2
for i in range(t):
n, ones = map(int, lines[i + 1].split())
zeros = n - ones
if zeros == 0:
print(count(n))
continue
used_ones = min(ones, zeros - 1)
groups = used_ones + 1... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR ... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
def solve(n, m):
z = n - m
g = m + 1
k = int(z / g)
ans = n * (n + 1) // 2 - k * (k + 1) // 2 * g - (k + 1) * (z % g)
return int(ans)
t = int(input())
out = []
for i in range(t):
n, m = map(int, input().split())
out.append(solve(n, m))
print("\n".jo... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN ... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
n, m = map(int, input().split())
z = n - m
k = z // (m + 1)
totalk = k * (k + 1) / 2
g = m + 1
output = n * (n + 1) // 2 - k * (k + 1) // 2 * g - (k + 1) * (z % g)
print(int(output)) | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BI... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
sys.setrecursionlimit(10**7)
T = int(input())
CASE = []
for _ in range(T):
n, m = map(int, input().split())
CASE.append([n, m])
res = []
for n, m in CASE:
zero_cnt = n - m
p, q = divmod(zero_cnt, m + 1)
total = n * (n + 1) // 2
if p == 0:
total -= zero_cnt
else:
t... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR N... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
def calc(x):
return x * (x + 1) // 2
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
zeros = n - m
x = zeros // (m + 1)
r = zeros % (m + 1)
print(calc(n) - calc(x) * (m + 1 - r) - calc(x + 1) * r) | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_C... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | for _ in range(int(input())):
[a, b] = list(map(int, input().split(" ")))
k = (a - b) // (b + 1)
extra = (a - b) % (b + 1)
print((a * (a + 1) - (a - b + extra) * (k + 1)) // 2) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP VA... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | from sys import stdin, stdout
for I in range(int(stdin.readline())):
stdout.write(
(
lambda n, m: str(
n * (n + 1) // 2
- (m + 1 - (n - m) % (m + 1))
* ((n - m) // (m + 1) * ((n - m) // (m + 1) + 1) // 2)
- (n - m)
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL BIN_OP FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP V... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
n = int(input())
for _ in range(n):
n, m = map(int, sys.stdin.readline().split())
grp = (n - m) // (m + 1)
ans = (
n * (n + 1) // 2
- grp * (grp + 1) // 2 * (m + 1)
- (grp + 1) * ((n - m) % (m + 1))
)
print(ans) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER BIN_... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
t = int(input())
for case in range(t):
n, m = map(int, input().split())
z = n - m
g = m + 1
if m == 0:
print(0)
continue
if m == n:
print(n * (n + 1) // 2)
continue
if m >= n // 2:
print(n * (n + 1) // 2 - (n - m))
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR B... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
t = int(input())
for T in range(t):
n, m = [int(x) for x in sys.stdin.readline().split()]
ans = n * (n + 1) // 2
val = (n - m) // (m + 1)
ans -= val * (val + 1) * (m + 1) // 2
rem = (n - m) % (m + 1)
ans -= (val + 1) * rem
print(ans) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, m = list(map(int, input().split()))
all_ptn = n * (n - 1) // 2 + n
small = (n - m) // (m + 1)
large_cnt = (n - m) % (m + 1)
small_cnt = m + 1 - large_cnt
large = small + 1
cnt = (small * (small - 1) // 2 + small) *... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NU... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | t = int(input())
raw = []
for _ in range(t):
raw.append(list(map(int, input().split())))
for i in range(t):
n, m = raw[i]
p = (n - m) // (m + 1)
q = (n - m) % (m + 1)
ans = n * (n + 1) // 2
ans -= (p + 1) * (p + 2) * q // 2
ans -= p * (p + 1) * (m + 1 - q) // 2
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BI... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
for _ in range(int(sys.stdin.readline())):
n, m = map(int, sys.stdin.readline().split())
s = (n - m) // (m + 1)
none = (m + 1 - (n - m) % (m + 1)) * s * (s + 1) // 2 + (n - m) % (m + 1) * (
s + 1
) * (s + 2) // 2
print((n + 1) * n // 2 - none) | IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP B... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
t = int(input())
for ii in range(t):
n, m = map(int, input().split())
ans = n * (n - 1) // 2 + n
if m >= n // 2:
print(ans - (n - m))
else:
z = n - m
if z % (m + 1) == 0:
p = z // (m + 1)
k = m + 1
print(a... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR B... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
def nSubarr(n):
return n * (n + 1) >> 1
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
n += 1
m += 1
x, rem = divmod(n, m)
ctr_zero = (m - rem) * nSubarr(x - 1) + rem * nSubarr(x)
ans... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP ... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
out = sys.stdout
for _ in range(int(input())):
n, m = map(int, input().split())
a = (n - m) // (m + 1)
b = (n - m) % (m + 1)
a1 = (m + 1 - b) * (a * (a + 1)) // 2
b1 = b * ((a + 1) * (a + 2)) // 2
ans = n * (n + 1) // 2 - a1 - b1
out.write(str(ans) + "\... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VA... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
N, M = map(int, input().split())
if M == 0:
print(0)
elif N == M:
print(N * (N + 1) // 2)
else:
Partitions = M + 1
Extra = 0
if (N - M) % (M + 1) == 0:
SizeOfPartitions = (N - M) // (... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP BIN_OP VAR VAR BIN_OP... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.buffer.readline
def s(n):
return n * (n + 1) // 2
t = int(input())
res = []
for _ in range(t):
n, m = map(int, input().split())
x = s(n)
z = n - m
x -= z % (m + 1) * s(z // (m + 1) + 1)
x -= (m + 1 - z % (m + 1)) * s(z // (m + 1))
res.append(x)
print("\n".jo... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER FUNC_C... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
read = lambda: list(map(int, sys.stdin.readline().strip().split()))
def cal():
n, m = read()
z = n - m
g = m + 1
k = z // g
n = n * (n + 1) // 2
t = k * (k + 1) // 2
ans = n
ans -= t * g
ans -= (k + 1) * (z % g)
return ans
for _ in range(int(input())):
print(c... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP 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 BIN_OP VAR NUMBER NUMBER ASSIGN VA... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
def fun(x):
return x * (x + 1) // 2
for _ in range(int(input())):
n, m = map(int, sys.stdin.readline().split())
emp = n - m
if emp >= m + 1:
xx = emp // (m + 1)
if emp % (m + 1) == 0:
times = m + 1
print(fun(n) - fun(xx) * times)
else:
... | IMPORT 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
def main():
t = int(input())
for _ in range(t):
N, M = [int(x) for x in input().split()]
if M == 0:
print(0)
continue
total = N * (N + 1) // 2
if N - M <= M + 1:
print(total - (N - M))
else:
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
for nt in range(int(input())):
n, m = map(int, input().split())
z = n - m
s = n * (n + 1) // 2
k1 = z // (m + 1)
k2 = z % (m + 1)
sub = k1 * (k1 + 1) // 2 * (m + 1 - k2)
sub += (k1 + 1) * (k1 + 2) // 2 * k2
print(s - sub) | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
read = lambda: list(map(int, sys.stdin.readline().strip().split()))
sigma = lambda x: x * (x + 1) // 2
for _ in range(int(input())):
n, m = read()
k = n - m
total = sigma(n)
if k > m:
e, f = divmod(k, m + 1)
total -= (m + 1 - f) * sigma(e) + f * sigma(e + 1)
else:
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = lambda: sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
N, M = map(int, input().split())
Z = N - M
A = Z // (M + 1)
B = Z % (M + 1)
print(
N * (N + 1) // 2 - A * (A + 1) // 2 * (M + 1 - B) - (A + 1) * (A + 2) // 2 * B
) | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
t = int(input())
for i in range(t):
line = list(map(int, sys.stdin.readline().split()))
n = line[0]
m = line[1]
rem = (n - m) % (m + 1)
q = (n - m) // (m + 1)
ans = (
n * (n - 1) // 2
+ m
- rem * ((q + 1) * q) // 2
- (m + 1 - rem) * (q * (q - 1) // 2)
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | t = int(input())
ans = []
for kek in range(t):
n, m = map(int, input().split())
ans2 = 0
if m == 0:
ans2 = 0
else:
k = int((n + 1) / (m + 1))
ans2 += m * (k + 1) * k // 2
ans2 += (n - k) * (1 + n - k) // 2
ans.append(ans2)
print(*ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER VAR BI... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | def solve():
n, m = map(int, input().split())
n -= m
k = n // (m + 1)
ans = n % (m + 1) * (k + 1)
ans += (m + 1) * k * (k + 1) // 2
n += m
print(n * (n + 1) // 2 - ans)
for i in range(int(input())):
solve() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | t = int(input())
zxc = []
for i in range(t):
n, m = [int(k) for k in input().split()]
res = (1 + n) * n // 2
eta = (n - m) // (m + 1)
zeta = (n - m) % (m + 1)
def f(x):
return (1 + x) * x // 2
res -= zeta * f(eta + 1)
res -= (m + 1 - zeta) * f(eta)
zxc.append(res)
print("\n".jo... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER FUNC_DEF RETURN BIN_OP... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
for _ in range(int(input())):
n, m = map(int, sys.stdin.readline().split())
emp = n - m
if emp >= m + 1:
xx = emp // (m + 1)
rem = emp % (m + 1)
print(
n * (n + 1) // 2
- rem * (xx + 1) * (xx + 2) // 2
- (m + 1 - rem) * xx * (xx + 1) //... | IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = sys.stdin.readline
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]
for N, M in Query:
Z = N - M
s = M + 1
m1 = Z // s
m2 = m1 + 1
ans = (
N * (N + 1) // 2
- m1 * (m1 + 1) // 2 * (s - Z % s)
- m2 * (m2 + 1) // 2 * (Z % s)
)
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR B... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | n = int(input())
l1 = []
l2 = []
for x in range(n):
s = str(input())
l = s.split(" ")
l1.append(int(l[0]))
l2.append(int(l[1]))
l3 = []
i = 0
while i < n:
k = l2[i] + 1
z = l1[i] - l2[i]
q = z // k
r = z % k
tz = r * ((q + 2) * (q + 1) // 2) + (k - r) * ((q + 1) * q // 2)
l3.appe... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_O... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
def input():
return sys.stdin.readline().strip()
t = int(input())
for _ in range(t):
n, m = list(map(int, input().split()))
ans = n * (n + 1) // 2
if m == 0:
print(0)
elif n - m <= (n + 1) // 2:
print(ans - (n - m))
else:
zeros = n - m
blockcnt = m ... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER ... |
Ayoub thinks that he is a very smart person, so he created a function $f(s)$, where $s$ is a binary string (a string which contains only symbols "0" and "1"). The function $f(s)$ is equal to the number of substrings in the string $s$ that contains at least one symbol, that is equal to "1".
More formally, $f(s)$ is equ... | import sys
input = lambda: sys.stdin.readline().rstrip()
for _ in range(int(input())):
n, m = map(int, input().split())
z = n - m
div = z // (m + 1)
rem = z % (m + 1)
ans = n * (n + 1) // 2 - div * (div + 1) * (m + 1) // 2 - (div + 1) * rem
print(ans) | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMB... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.