description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for tc in range(int(input())):
ls = list(map(int, input().split()))
lk = list(map(int, input().split()))
lk.sort(reverse=True)
val = ls[2]
k = ls[1]
su = 0
for x in range(0, len(lk) - 1, 2):
if k > 0:
if lk[x] + lk[x + 1] > val:
su += val
k... | FOR VAR FUNC_CALL 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 ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VA... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for t in range(int(input())):
n, k, x = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort()
res = 0
while k > 0:
res += min(x, A.pop() + A.pop())
k -= 1
while len(A) > 0:
res += A.pop()
print(res) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL 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 NUMBER WHILE VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
while t:
N, K, X = list(map(int, input().split()))
arr = list(map(int, input().split()))
count = 0
arr.sort()
n = N
if N == 0:
print(0)
if N == 1:
print(arr[0])
while K > 0 and len(arr) > 1:
sz = len(arr)
if X < arr[sz - 1] + arr[sz - 2]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR 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 NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | def clearArr(arr, n, k, x):
sumi = sum(arr)
if k == 0:
return sumi
arr.sort(reverse=True)
prs = []
i = 0
while i + 1 < n and k:
if arr[i] + arr[i + 1] > x:
prs.append(arr[i])
prs.append(arr[i + 1])
k -= 1
i += 2
suma = sum(prs)
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR AS... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
for i in range(t):
n, k, x = map(int, input().split())
a = list(map(int, input().split()))
c = sum(a)
a.sort(reverse=True)
t1 = 0
r = 0
while t1 == 0:
if a[r] + a[r + 1] > x and k > 0:
c = c - (a[r] + a[r + 1]) + x
k = k - 1
r = r ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR VAR V... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
for test in range(t):
n, k, x = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
i = n - 2
j = n - 1
res = 0
while i >= 0:
if a[i] + a[j] >= x and k > 0:
res += x
i -= 2
j -= 2
k -= 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR 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 ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER I... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split(" "))
arr = [int(w) for w in input().split(" ")]
arr.sort(reverse=True)
ans = sum(arr)
i = 0
while i < n and i + 1 < n:
if k == 0:
break
if arr[i] + arr[i + 1] > x:
ans = ans - (arr[i] + arr[i ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER IF BIN_OP VAR V... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for t in range(int(input())):
N, K, X = map(int, input().split())
arr = list(map(int, input().split()))
cost = 0
i = N - 1
arr.sort()
while K:
if arr[i] + arr[i - 1] > X:
cost += X
K -= 1
i -= 2
else:
break
cost += sum(arr[: i +... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR 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 NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR WHILE VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER VAR... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for __ in range(int(input())):
N, K, X = map(int, input().split())
A = list(map(int, input().split()))
cost = sum(A)
A.sort(reverse=True)
for i in range(0, 2 * K, 2):
if X <= A[i] + A[i + 1]:
cost += X - (A[i] + A[i + 1])
print(cost) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR 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 EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR NUMBER IF VAR BIN_OP VAR VAR VAR BIN_OP ... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | for _ in range(int(input())):
n, k, x = map(int, input().split())
s = 0
l = list(map(int, input().split()))
l.sort()
while k > 0 and len(l) > 1:
if l[-1] + l[-2] > x:
s += x
k -= 1
l.pop()
l.pop()
else:
break
s = sum(l) ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR WHILE VAR NUMBER FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER VAR VAR VAR VAR NUMBER EXPR FUN... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | def costClrArr(n, k, x, arr):
totalCost = 0
if n == 1:
return arr[0]
if n == 2:
return min(x, arr[0] + arr[1])
arr = arr[::-1]
i = 0
while k > 0:
c = arr[i] + arr[i + 1]
if x <= c:
totalCost = totalCost + x
k -= 1
i += 2
... | FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER RETURN VAR NUMBER IF VAR NUMBER RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUN... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
for _ in range(t):
n, k, x = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
i = n - 1
ans = 0
while i >= 1 and k > 0:
temp = arr[i] + arr[i - 1]
if temp <= x:
ans = ans + temp
else:
ans = ans + x
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR 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 ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
You are given an array A of N elements. You can do the following operations on that array:
Remove the leftmost element of the array, with index l, for the cost A_{l}. This can be done any number of times if the array is non-empty (has a... | t = int(input())
for i in range(t):
n, k, x = map(int, input().split())
numbers = [int(x) for x in input().split()]
numbers.sort(reverse=True)
minCost = 0
for j in range(k):
if len(numbers) >= 2:
first = numbers[0]
second = numbers[1]
s = first + second
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NU... |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | n, a, b = [int(c) for c in input().split()]
days = [int(c) for c in input().split()]
res = []
for i in range(len(days)):
p = days[i] * a % b
f1 = int(p // a)
res.append(f1)
print(" ".join(map(str, res))) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FU... |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | def binary_search(n, a, b):
l = 0
r = n
maxx = n * a // b
while l < r:
mid = (l + r) // 2
if mid * a // b < maxx:
l = mid + 1
else:
r = mid
return l
n, a, b = map(int, input().split())
l1 = list(map(int, input().split()))
a1 = []
for i in l1:
ans... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR... |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | n, a, b = map(int, input().split())
w = list(map(int, input().split()))
w = [(x * a % b // a) for x in w]
print(" ".join(map(str, w))) | ASSIGN VAR VAR 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 BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | arr = []
arr2 = []
scann = input()
arr = scann.split()
n = int(arr[0])
a = int(arr[1])
b = int(arr[2])
scann = input()
arr2 = scann.split()
aux = []
j = 0
k = 0
l = 0
for i in range(n):
j = int(arr2[i]) * a
k = j % b
l = k / a
aux.append(int(l))
print(*aux) | ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FU... |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | n, a, b = map(int, input().strip().split(" "))
L = list(map(int, input().split(" ")))
for i in range(n):
s = L[i]
res = s * a // b
j = int(s - b * res / a)
print(j) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | def solve(w, a, b):
q = list()
for i in w:
k = i * a % b
q.append(k // a)
return q
n, a, b = map(int, input().split())
w = map(int, input().split())
res = map(str, solve(w, a, b))
print(" ".join(res)) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC... |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | import sys
def ints_input():
return [int(i) for i in sys.stdin.readline().strip("\n").split(" ")]
def print_list(arr):
sys.stdout.writelines(str(x) + " " for x in arr)
sys.stdout.write("\n")
def fast_input(type=str):
return type(sys.stdin.readline().strip("\n"))
n, a, b = ints_input()
arr = ints... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING VAR VAR EXPR FUNC_CALL VAR STRING FUNC_DEF VAR RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VA... |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | n, a, b = map(int, input().split())
coins = list(map(int, input().split()))
for i in range(n):
coins[i] = coins[i] * a % b // a
print(*coins) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | n, a, b = map(int, input().split())
lis = list(map(int, input().split()))
for i in lis:
x = i * a % b
print(int(x / a)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | n, a, b = map(int, input().split())
l = list(map(int, input().split()))
out = []
for i in range(n):
out.append(str(l[i] * a % b // a))
print(" ".join(out)) | ASSIGN VAR VAR 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 LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | def main():
n, a, b = map(int, input().split())
ar = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
ans[i] = ar[i] * a % b // a
print(*ans)
main() | FUNC_DEF ASSIGN VAR VAR 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 BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | class InputHandlerObject(object):
inputs = []
def getInput(self, n=0):
res = ""
inputs = self.inputs
if not inputs:
inputs.extend(input().split(" "))
if n == 0:
res = inputs[:]
inputs[:] = []
while n > len(inputs):
inputs.e... | CLASS_DEF VAR ASSIGN VAR LIST FUNC_DEF NUMBER ASSIGN VAR STRING ASSIGN VAR VAR IF VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR LIST RETURN V... |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | n, a, b = map(int, input().split())
arr = [int(z) for z in input().split()]
res = []
for i in arr:
res.append(i * a % b // a)
print(*res) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | n, a, b = map(int, input().split())
x = [int(i) for i in input().split()]
def find_index(n):
l = 0
r = n
while l < r:
mid = (l + r) // 2
if mid * a // b == r * a // b:
r = mid
else:
l = mid + 1
return r
for i in range(n):
print(x[i] - find_index(x[... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN ... |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | def Mashmokh(arr, a, b):
arr1 = []
for i in arr:
if i % (a * b) == 0:
arr1.append(0)
else:
resultado = i - b / a * (i * a // b)
arr1.append(int(resultado))
arr_aux = " ".join(map(str, arr1))
return arr_aux
a1, a2, a3 = input().split()
n = int(a1)
a =... | FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR... |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | n, a, b = map(int, input().split())
for i in input().split():
i = int(i)
r = b / a
x = i // r
print(int(i - r * x), end=" ") | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR STRING |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | t = input().split()
n = int(t[0])
a = int(t[1])
b = int(t[2])
for x in input().split():
w = int(x) * a % b
w //= a
print(w, end=" ") | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | def main():
n, a, b = map(int, input().split())
l = list(map(int, input().split()))
for i, x in enumerate(l):
l[i] = x * a % b // a
print(" ".join(map(str, l)))
main() | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | def main():
n, a, b = list(map(int, input().split()))
x_list = list(map(int, input().split()))
res = list()
for x in x_list:
res.append(str(x * a % b // a))
print(" ".join(res))
main() | FUNC_DEF ASSIGN VAR VAR 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 FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | n, a, b = map(int, input().split())
arr = list(map(int, input().split()))
for i in range(n):
arr[i] = arr[i] * a % b // a
print(arr[0], end="")
for i in range(1, len(arr)):
print("", arr[i], end="")
print("") | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING ... |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | __author__ = "Lipen"
def main():
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
answer = list(map(lambda i: int(x[i] - int(x[i] * a / b) / a * b), range(n)))
print(" ".join(map(str, answer)))
main() | ASSIGN VAR STRING FUNC_DEF ASSIGN VAR VAR 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 FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CAL... |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | n, a, b = map(int, input().split())
t = [(w - 1 - (w * a // b * b - 1) // a) for w in map(int, input().split())]
print(" ".join(map(str, t))) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | import sys
[n, a, b] = map(int, sys.stdin.readline().split())
buttons = map(int, sys.stdin.readline().split())
res = []
for x in buttons:
money = int(1.0 * x * a / b)
rest = x - 1.0 * money * b / a
res.append(int(rest))
print(" ".join(map(str, res))) | IMPORT ASSIGN LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EX... |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | n, a, b = map(int, input().split())
x = list(map(int, input().split()))
[print(el * a % b // a, end=" ") for el in x]
print("\n") | ASSIGN VAR VAR 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 BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR STRING VAR VAR EXPR FUNC_CALL VAR STRING |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | import sys
n, a, b = map(int, sys.stdin.readline().split())
w_arr = map(int, sys.stdin.readline().split())
print(" ".join(map(str, [(w * a % b // a) for w in w_arr]))) | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | [n, a, b] = [int(x) for x in input().split()]
amount = [int(x) for x in input().split()]
res = [0] * n
curr = 0
for i, day in enumerate(amount):
s = int(day * a / b)
tmp = int(s * b / a) if s * b % a == 0 else int(s * b / a) + 1
res[i] = day + curr - tmp
print(" ".join(map(str, res))) | ASSIGN LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR NUMBER FUNC_CALL VAR BI... |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | n, a, b = input().split(" ")
n, a, b = int(n), int(a), int(b)
INPUT = [int(x) for x in input().split(" ")]
for w in INPUT:
res = w * a % b
res //= a
print(res, end=" ") | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING |
Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of ... | import sys
f = sys.stdin.readline
n, a, b = map(int, f().strip().split())
x = [int(v) for v in f().strip().split()]
out = []
for v in x:
out.append(v * a % b // a)
print(" ".join(map(str, out))) | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | I = lambda: list(map(int, input().split()))
(n,) = I()
l = I()
ans = []
for i in range(n):
for j in range(i + 1, n):
if l[i] > l[j]:
ans.append([l[i], i + 1, j + 1])
ans.sort()
ans.sort(reverse=True, key=lambda x: x[2])
print(len(ans))
for i in ans:
print(i[1], i[2]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_C... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | from sys import stdin, stdout
def inversion_swapsort(n, a):
I = []
for i in range(n):
for j in range(i + 1, n):
if a[i] > a[j]:
I.append([a[i], i + 1, j + 1])
I.sort()
I.sort(key=lambda x: x[2], reverse=True)
print(len(I))
if len(I) > 0:
for i in I:
... | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FOR VAR VAR ASSIG... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | n = int(input())
arr = list(map(int, input().split()))
x = []
for i in range(n):
x.append([arr[i], i])
x.sort(reverse=True)
res = []
for v, pos in x:
for i in range(pos):
if arr[i] > v:
res.append(str(i + 1) + " " + str(pos + 1))
print(len(res))
print("\n".join(res)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | inf = int(1000000.0)
n = int(input())
lis = list(map(int, input().split()))
store = []
index = list(range(0, n))
for k in range(1, n):
for _ in range(k):
for i in range(1, k + 1):
if lis[i] < lis[i - 1]:
lis[i], lis[i - 1] = lis[i - 1], lis[i]
index[i], index[i - ... | ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | n = int(input())
s = list(map(int, input().split()))
out = []
for i in range(n - 1):
temp = s[i]
l = []
for j in range(i + 1, n):
if s[j] < temp:
l.append([s[j], j])
l.sort()
l.reverse()
for ii in l:
out.append([i, ii[1]])
print(len(out))
for i in out:
print(i[0] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | n = int(input())
li = list(map(int, input().split()))
lp = li.copy()
j = 1
lf = []
c = max(lp)
while j <= n:
a = min(lp)
i = lp.index(a)
li[i] = j
lp[i] = c + j
j += 1
while n > 1:
a = li.pop()
while a < n:
i = li.index(a + 1)
li[i] = a
lf += [f"{i + 1} {n}"]
... | 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 ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR N... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | import sys
def rs():
return sys.stdin.readline().rstrip()
def ri():
return int(sys.stdin.readline())
def ria():
return list(map(int, sys.stdin.readline().split()))
def ws(s):
sys.stdout.write(s + "\n")
def wi(n):
sys.stdout.write(str(n) + "\n")
def wia(a):
sys.stdout.write(" ".join([... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR BIN_OP VAR STRING FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL STRING... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | import sys
inpy = [int(x) for x in sys.stdin.read().split()]
n = inpy[0]
arr = inpy[1:]
res = []
for i in range(n - 1, -1, -1):
x = []
for j in range(i):
if arr[j] > arr[i]:
x.append((arr[j], j))
x.sort()
for a, j in x:
res.append((j + 1, i + 1))
print(len(res))
for i, j in ... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR VAR VAR EXPR FUNC_CALL ... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | n = int(input())
arr = list(map(int, input().split()))
ans = []
for i in range(n):
for j in range(n - 1, i, -1):
if arr[i] > arr[j]:
ans.append((arr[i], i + 1, j + 1))
ans = sorted(ans, key=lambda x: x[0])
ans = sorted(ans, reverse=True, key=lambda x: x[2])
print(len(ans))
for _, u, v in ans:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | n = int(input())
a = [int(i) for i in input().split()]
ans = 0
dc = [[] for i in range(n)]
for i in range(n):
for j in range(i):
if a[i] < a[j]:
dc[i].append((a[j], j))
ans += 1
print(ans)
for i in range(n - 1, -1, -1):
dc[i].sort()
for j in dc[i]:
print(j[1] + 1, i +... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | it = lambda: list(map(int, input().strip().split()))
def solve():
N = int(input())
A = it()
inversions = []
for i in range(N):
inversion = []
for j in range(i):
if A[j] > A[i]:
inversion.append(j)
inversions.append(inversion)
R = []
B = [[a, ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIG... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | def swapsort(k, a):
array_zip = list(zip(a, range(k)))
array_zip.sort()
pos = [(0) for i in range(k)]
for i in range(k):
a[array_zip[i][1]] = i
pos[i] = array_zip[i][1]
res = []
end = False
while not end:
end = True
for i in range(k - 1):
if pos[i]... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF ... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | input()
a = list(map(int, input().split()))
b = sorted((i, -a[j], -j) for j in range(len(a)) for i in range(j) if a[i] > a[j])
print(len(b))
for i, j, k in b:
print(i + 1, -k + 1) | EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | from sys import stdin, stdout
def main():
n = int(stdin.readline())
ary = list(map(int, stdin.readline().split()))
invs = [[(False) for i in range(n)] for j in range(n)]
pair = []
for i in range(n):
pair.append((ary[i], i))
pair.sort()
perm = [-1] * n
fxa = [-1] * n
posof =... | 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 NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | n = int(input())
a = list(map(int, input().split()))
cc = []
for i, u in enumerate(a):
tl = []
for j in range(n - 1, i, -1):
if a[j] < u:
tl.append((i, j))
cc.append((u, tl))
res = []
for _, tl in sorted(cc):
for u, v in tl:
res.append((u, v))
print(len(res))
for u, v in res:... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR FUNC... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | n = int(input())
a = list(map(int, input().split()))
b = sorted([(a[i], i) for i in range(n)])
res = []
for _ in range(n):
for i in range(n - 1):
if b[i][1] > b[i + 1][1]:
res.append((b[i + 1][1], b[i][1]))
b[i], b[i + 1] = b[i + 1], b[i]
print(len(res))
for i, j in res:
print(i ... | 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 VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | import sys
def input():
return sys.stdin.readline().rstrip()
def split_input():
return [int(i) for i in input().split()]
def allpos(a):
n = len(a)
m = len(a[0])
def onBoard(i, j):
return i >= 0 and j >= 0 and i < n and j < m
dirs = [(1, 0), (0, 1), (-1, 0), (0, -1)]
for i in ... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN VAR NUMBER VAR NUMBER VAR VAR VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUN... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | n = int(input())
a = list(map(int, input().split()))
idx = sorted(range(n), key=lambda i: a[i])
ans = [[] for _ in range(n)]
cnt = 0
for i in range(n):
for j in range(n - 1, i, -1):
if a[i] > a[j]:
ans[i].append(str(i + 1) + " " + str(j + 1))
cnt += 1
print(cnt)
for i in idx:
if ... | 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 VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_C... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | import sys
input = sys.stdin.readline
I = lambda: list(map(int, input().split()))
(n,) = I()
l = I()
iv = 0
an = []
pr = [0] * n
ix = [0] * n
for i in range(n):
c = 0
for j in range(n):
if j < i and l[j] == l[i]:
c += 1
if l[j] < l[i]:
c += 1
pr[i] = c
for i in range... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VA... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | n = int(input())
a = list(map(int, input().split()))
ans = []
def f(l):
return -l[1], l[2], l[0]
for i in range(n):
for j in range(i + 1, n):
if a[i] > a[j]:
ans.append((i + 1, j + 1, a[i]))
ans.sort(key=f)
print(len(ans))
for i in ans:
print(*i[:2]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF RETURN VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR V... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | n = int(input())
lst = [int(j) for j in input().split()]
inversions = list()
for i in range(1, n):
for j in range(i):
if lst[i] < lst[j]:
inversions.append((i, -lst[j], -j))
inversions.sort(reverse=True)
res = list(range(len(inversions)))
if res:
print(len(res))
for elem in res:
... | 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 FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF ... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | n = int(input())
a = list(map(int, input().split()))
aWithIndex = []
for i in range(n):
aWithIndex.append((a[i], i))
aWithIndex.sort(key=lambda x: x[0])
aOrder = [-1] * n
for i in range(n):
aOrder[aWithIndex[i][1]] = i
aOrderInverse = [-1] * n
for i in range(n):
aOrderInverse[aOrder[i]] = i
result = []
for ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER VAR ASSIGN VAR BIN_OP LIS... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int, minp().split())
def issorted(a):
for i in range(1, len(a)):
if a[i - 1] > a[i]:
return False
return True
def stupid(a, inv, was, order):
if len(ord... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_C... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | n = int(input())
s = [int(x) for x in input().split()]
kk = []
for i in range(n):
h = []
kk.append(h)
for i in range(0, len(s)):
for j in range(i + 1, len(s)):
if s[i] > s[j]:
kk[j].append((s[i], i))
for i in range(0, n):
kk[i].sort()
fnl = []
for i in range(n - 1, -1, -1):
for j... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR ... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | n = int(input())
arr = list(map(int, input().split()))
ans = []
for i in range(n):
ans.append((arr[i], i))
ans.sort()
ans = ans[-1::-1]
p = []
for i in ans:
for j in range(i[1]):
if i[0] < arr[j]:
p.append((j + 1, i[1] + 1))
print(len(p))
for i in p:
print(i[0], i[1]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR VAR EXPR FUNC_... |
Madeline has an array $a$ of $n$ integers. A pair $(u, v)$ of integers forms an inversion in $a$ if:
$1 \le u < v \le n$. $a_u > a_v$.
Madeline recently found a magical paper, which allows her to write two indices $u$ and $v$ and swap the values $a_u$ and $a_v$. Being bored, she decided to write a list of pairs $... | import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int, minp().split())
def issorted(a):
for i in range(1, len(a)):
if a[i - 1] > a[i]:
return False
return True
n = mint()
a = list(mints())
inv = []
for i in... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | from sys import stdin, stdout
def fn(days):
sm1 = 0
for i in range(n):
if a[i] - i // days <= 0:
break
sm1 += a[i] - i // days
return sm1
for _ in range(1):
n, k = list(map(int, stdin.readline().split()))
a = list(map(int, stdin.readline().split()))
a.sort(reverse... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR 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 ... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | n, m = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort(reverse=True)
left = 1
right = n
def check(k, m):
if m > 0:
lef = 0
z = 0
for i in range(n):
m -= max(0, l[i] - lef)
z += 1
if z == k:
z = 0
... | ASSIGN VAR 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 ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_DEF IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VA... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | def calc(ans, k, n):
for i in range(1, len(ans)):
if ans[i] >= n + k * ((i - k) // k * ((i - k) // k + 1)) // 2 + (i - k) % k * (
(i - k) // k + 1
):
return True
return False
def bins(ans, n, low, high):
if low == high and calc(ans, low, n):
return low
e... | FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR VAR FUNC_CALL VAR VA... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | class Solution:
def __init__(self):
firstline = input().split()
n = int(firstline[0])
m = int(firstline[1])
a = input().split()
for i in range(n):
a[i] = int(a[i])
a.sort(key=int, reverse=True)
l = 1
r = m + 1
while l < r:
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIG... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | n, m = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
summ = sum(l)
result = 0
def find(x):
s = 0
pos_count = 0
day_count = 0
for i in l:
s += max(0, i - pos_count)
day_count += 1
if day_count == x:
day_count = 0
pos_count += 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | def stack(days, count):
x = count // days
y = count % days
return days * x * (x - 1) // 2 + y * x
def func(arr, days):
total = 0
for x in range(len(arr)):
if arr[x] <= x // days:
break
else:
total += arr[x] - x // days
return total
def main():
arr ... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CAL... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | def check(num):
arr = [[] for i in range(num)]
j, count = 0, 0
for i in range(n):
arr[j].append(max(0, c[i] - len(arr[j])))
count += arr[j][-1]
j = (j + 1) % num
if count >= m:
return True
return False
n, m = map(int, input().split())
c = list(map(int, input().split... | FUNC_DEF ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_C... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | def check(k):
s = 0
for i in range(n):
s += max(0, a[i] - i // k)
return s >= m
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
low = 1
high = n + 1
while low <= high:
mid = (low + high) // 2
if check(mid):
high = mid - 1
else:
... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR VAR ASSIGN VAR 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 ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | def check(arr, d, mm):
ss = 0
k = -1
for i in range(n):
if i % d == 0:
k += 1
ss += max(0, arr[i] - k)
if ss >= mm:
return True
else:
return False
n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
s = 1
e = n
a... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR 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 F... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | def func(mid):
s = 0
c = 0
v = 0
for i in range(n):
c += 1
s += max(a[i] - v, 0)
if c == mid:
v += 1
c = 0
return s >= m
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
an = 0
if sum(a) < m:
an = -1
up ... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FU... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | def check(sz):
aa = 0
for i in range(n):
aa += max(0, a[i] - i // sz)
if aa >= M:
return True
return False
n, M = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) < M:
print(-1)
exit()
a.sort(reverse=True)
l = 1
r = n
while l < r:
m = l + r
... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBE... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | from sys import exit, setrecursionlimit
setrecursionlimit(10**6)
inn = lambda: input().strip()
mapp = lambda: map(int, inn().split(" "))
N, work = mapp()
coffee = list(mapp())
coffee.sort(reverse=True)
if sum(coffee) < work:
print(-1)
exit()
def getMaxPower(day):
if day == 0:
return False
max... | EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_DEF IF VAR NUMBE... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | import sys
input = sys.stdin.readline
def fun(x):
su = 0
global ar, n
for i in range(n):
su += max(0, ar[i] - i // x)
return bool(su >= m)
n, m = map(int, input().split())
ar = list(map(int, input().split()))
ar.sort(reverse=True)
if sum(ar) < m:
print(-1)
else:
l = 1
r = n
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR 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 IF FUNC_CAL... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | [n, m] = list(map(int, input().split()))
arr = list(map(int, input().split()))
arr.sort(reverse=True)
def check(i):
mins = 0
cnt = 0
sums = 0
for x in arr:
sums += max(x - mins, 0)
if sums >= m:
return True
cnt += 1
if cnt >= i:
cnt = 0
... | ASSIGN LIST VAR 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 FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF VAR VAR RETURN NUMBER VAR NUMBER ... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | import sys
n, m = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
left = 1
right = n + 1
ans = 10**18 + 1
while left != right:
mid = (left + right) // 2
din = 0
kaam = 0
c = 0
for i in l:
if i - din <= 0:
break
kaam += i - din
c... | IMPORT ASSIGN VAR 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 ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBE... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | n, m = list(map(int, input().split()))
a = list(sorted(map(int, input().split()), reverse=True))
def proc(n, m, a):
possible_minimum = -1
l, r = 1, n
sub_c = [0] * n
while l <= r:
i = (l + r) // 2
current_m = m
for j in range(i):
sub_c[j] = 0
for j in range(... | ASSIGN VAR 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 FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FOR V... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | def sum1(day, n, lst):
std = n // day
sumi = 0
sub = -1
for i in range(n):
if i % day == 0:
sub += 1
sumi += max(0, lst[i] - sub)
return sumi
def binary(n, m, arr):
l = 1
r = n
ans = -1
while l <= r:
mid = (l + r) // 2
pages = sum1(mid, n... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CA... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | n, m = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
A.reverse()
def func(i):
ans = 0
for j in range(0, n):
ans += max(A[j] - j // i, 0)
return ans >= m
l = 1
r = n
while r - l > 1:
s = l + r >> 1
if func(s) == 1:
r = s
else:
l = s
if func(l) ... | ASSIGN VAR 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 FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | n_cups, target = [int(i) for i in input().split()]
cups = [int(i) for i in input().split()]
cups = sorted(cups, reverse=True)
found = False
if sum(cups) < target:
print(-1)
found = True
def find_value(c, days):
val = 0
for i in range(len(c)):
val += max(c[i] - i // days, 0)
return val
lo... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CAL... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | def check(mid):
tp = su = s = 0
for i in range(n):
su += max(0, lis[i] - s)
tp += 1
if tp == mid:
s += 1
tp = 0
return su >= m
n, m = map(int, input().split())
lis = sorted(map(int, input().split()), reverse=True)
if sum(lis) < m:
print("-1")
elif sum(li... | FUNC_DEF ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER RETURN VAR VAR ASSIGN VAR 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 IF FUNC_CALL VAR V... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | def solveFor(m):
sm = 0
for i in range(m):
ct = 0
for j in range(i, n, m):
if arr[j] > ct:
sm += arr[j] - ct
else:
break
ct += 1
return sm
n, k = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
a... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR 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 ASSIGN VAR V... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | n, m = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = []
def bin(s):
tmp = [[] for k in range(s)]
cur = s
tr = 0
for i in range(n):
if cur == s:
cur = 0
tmp[cur].append(l[i])
cur += 1
for i in range(s):
for... | ASSIGN VAR 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 ASSIGN VAR LIST FUNC_DEF ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR NUMBER EXPR ... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | _ = input()
n, m = _.split()
n, m = int(n), int(m)
_ = input()
_a = _.split()
b = []
num_list = []
_counter = {}
_sum = 0
for i in _a:
value = int(i)
_sum = _sum + value
b.append(value)
if value in _counter:
_counter[value] = _counter[value] + 1
else:
_counter[value] = 1
num_... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VA... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
def solve(days):
pages = 0
for i in range(n):
pages += max(0, a[i] - i // days)
return pages >= m
res = -1
lo = 1
hi = n + 1
while lo < hi:
mid = lo + (hi - lo) // 2
if solve(mid):
hi = mid... | ASSIGN VAR 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 FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_O... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | def check(d, a):
ans = 0
for q in range(len(a)):
ans += max(a[q] - q // d, 0)
return ans
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
if sum(a) < m:
print(-1)
else:
l, r = 0, n
while r - l > 1:
m1 = (l + r) // 2
if check(m1,... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER RETURN VAR ASSIGN VAR 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 IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VA... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort(reverse=True)
def check(d):
s = 0
for i in range(len(a)):
s += max(0, a[i] - i // d)
return s >= m
if sum(a) < m:
print(-1)
else:
l, r = 1, n
mid = l + r >> 1
while l < r:
if check(mid):... | ASSIGN VAR 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 NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort(reverse=True)
if sum(a) < m:
print(-1)
else:
l = 1
r = n
while l < r:
mid = l + r >> 1
s = 0
for j in range(n):
s += max(0, a[j] - j // mid)
if s >= m:
r = mid
... | ASSIGN VAR 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 NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VA... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | def isvalid(d, li, m):
if d == 0:
return 0
n = len(li)
sumi = 0
for i in range(n):
sumi += max(0, li[i] - i // d)
if sumi >= m:
return 1
return 0
def binary_search(li, left, right, m):
if right < left:
return 0
mid = (left + right) // 2
if isvalid(mi... | FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR IF FUNC_CALL ... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | import sys
n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
if sum(A) < m:
print(-1)
return
A.sort(reverse=True)
MIN = 1
MAX = n
while MIN != MAX:
d = (MIN + MAX) // 2
ANS = 0
j = 0
count = 0
for a in A:
if a <= j:
continue
ANS += a - j
... | IMPORT ASSIGN VAR 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 IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSI... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | def search_binary(cups, pages, doses):
if sum(doses) < pages:
return -1
elif sum(doses) == pages:
return len(doses)
else:
doses = sorted(doses, reverse=True)
new_doses = []
new_doses = doses[0:pages]
max_days = len(new_doses)
min_days = 0
while max_days - min_days... | FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN NUMBER IF FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | def check_possibility(days, m, coffee):
sum_coffee = 0
for i, cup in enumerate(coffee):
tax = i // days
if sum_coffee >= m or tax >= cup:
break
sum_coffee += cup - tax
return sum_coffee >= m
n, m = list(map(int, input().split()))
coffee = sorted(map(int, input().split()... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR BIN_OP VAR VAR RETURN VAR VAR ASSIGN VAR 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 ASSIGN VAR FUNC_CALL ... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | import sys
input = sys.stdin.readline
def ceil_div(x, y):
return -(-x // y)
def can(a, k, m):
if len(a) <= k:
return sum(a) >= m
else:
sum_ = 0
minus = 0
for i in range(len(a)):
if i % k == 0 and i != 0:
minus += 1
sum_ += max(0, a... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR VA... |
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of $m$ pages.
Polycarp also has $n$ cups of coffee. The coffee in the $i$-th cup Polycarp has $a_i$ caffeine in it. Polycarp can drink some cups of coffee (each one no more than once). He... | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 1
su = sum(a)
a.sort(reverse=True)
s = [0] * n
s[0] = a[0]
for i in range(1, n):
s[i] = s[i - 1] + a[i]
def pos(d):
i = d
while i <= n:
k = i // d
neg = k * i - k * (k + 1) // 2 * d
if s[i - 1] - neg >... | ASSIGN VAR 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 NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.