description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$.
You ha... | for _ in range(int(input())):
m, n = map(int, input().split())
s = []
for i in range(m):
s.append(list(map(int, input().split())))
h = set()
flag = False
for i in range(m):
row = sorted(s[i])
for j in range(n):
if row[j] != s[i][j]:
h.add(j + 1... | 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 LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VA... |
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$.
You ha... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
a = []
for i in range(n):
l = list(map(int, input().strip().split()))
a.append(l)
idx = []
for i in range(n):
b = a[i]
d = sorted(b)
for j in range(m):
if b[j] != d[j]:
... | 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 LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR... |
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$.
You ha... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
a = []
for _ in range(n):
a.append(list(map(int, input().split())))
sorteda = []
for i in a:
sorteda.append(sorted(i))
unsortindex = set()
ls = []
for i in range(n):
l = 0
for j in range(... | 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 LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_... |
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$.
You ha... | for _ in range(int(input())):
n, m = map(int, input().split())
matrix = []
for _ in range(n):
matrix.append(list(map(int, input().split())))
sorted_matrix = []
for row in matrix:
sorted_matrix.append(sorted(row))
total_incorrect = 0
wrongs = []
for i in range(n):
... | 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 LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LI... |
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$.
You ha... | for _ in range(int(input())):
n, m = map(int, input().split())
mat = [[int(x) for x in input().split()] for i in range(n)]
res = set()
for i in range(n):
b = sorted(mat[i])
t = []
for j in range(m):
if b[j] != mat[i][j]:
t.append(j + 1)
if t:
... | 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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR V... |
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$.
You ha... | def is_sorted(l):
return all(l[i] <= l[i + 1] for i in range(len(l) - 1))
t = int(input())
for c in range(t):
n, m = input().split()
n, m = int(n), int(m)
mat = []
for i in range(n):
mat.append([int(x) for x in input().split()])
first, last = 0, 0
for k in range(n):
for i i... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CAL... |
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$.
You ha... | n = int(input())
def swap(arr, i, j):
tmp = arr[i]
arr[i] = arr[j]
arr[j] = tmp
for i in range(n):
r, c = map(int, input().split())
matrix = []
result = 0
for j in range(r):
row = list(map(int, input().split()))
matrix.append(row)
swap_i = -1
swap_j = -1
for k... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR E... |
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$.
You ha... | t = int(input())
while t:
n, m = map(int, input().split())
l = []
flag = 1
key = -1
for i in range(n):
ll = list(map(int, input().split()))
l.append(ll)
for i in range(n):
lo = sorted(l[i])
if lo != l[i]:
key = i
break
c = 0
lt = so... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL... |
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$.
You ha... | for _ in range(int(input())):
n, m = map(int, input().split())
l = []
for i in range(n):
l.append([int(i) for i in input().split()])
ans = []
f = 0
for i in l:
if i != sorted(i):
ans.append(i)
if len(ans) == 2:
break
ind = []
for i ... | 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 LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL... |
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$.
You ha... | for _ in range(int(input())):
n, m = map(int, input().split())
mat = []
arr = []
for i in range(n):
temp = [int(x) for x in input().split()]
mat.append(temp)
arr.append(sorted(temp))
diff = []
same = True
for i in range(n):
count = 0
cols = []
... | 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 LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR ... |
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$.
You ha... | def check(list):
ans = True
for i in range(len(list) - 1):
if list[i] > list[i + 1]:
ans = False
break
return ans
def index(list):
temp = sorted(list)
val = []
for i in range(len(list)):
if list[i] != temp[i]:
val.append(i)
return val
t... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_... |
You are given a grid with $n$ rows and $m$ columns, where each cell has a positive integer written on it. Let's call a grid good, if in each row the sequence of numbers is sorted in a non-decreasing order. It means, that for each $1 \le i \le n$ and $2 \le j \le m$ the following holds: $a_{i,j} \ge a_{i, j-1}$.
You ha... | for _ in range(int(input())):
n, m = map(int, input().split())
L, R = 0, 0
b = 0
ll = []
for i in range(n):
l = list(map(int, input().split()))
ll.append(l.copy())
if b:
continue
sl = sorted(l)
l[L], l[R] = l[R], l[L]
for j in range(m):
... | 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 VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR IF VAR ASSIGN VAR FUNC_C... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | def ff(a, b):
mx = max(a, b)
mi = min(a, b)
ans = 0
if mi < mx // 2:
ans = mx // 2 + mx % 2
else:
a = (2 * mx - mi) // 3
ans = a
mx -= 2 * a
mi -= a
if mi > 0:
ans += mi // 2 + mi % 2
mx -= mi // 2 + mi % 2
if mx > 0:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP NUMBER VAR VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER BIN_OP... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | n = int(input())
li = [int(i) for i in input().split()]
ans = 10000000000
for i in range(n - 1):
cur = 0
x = li[i]
y = li[i + 1]
if x < y:
x = li[i + 1]
y = li[i]
cnt = min(x - y, (x + 1) // 2)
cur += cnt
x -= 2 * cnt
y -= cnt
if x > 0 and y > 0:
cur += (x + y... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP V... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | n = int(input())
A = list(map(int, input().split()))
S = sorted(A)
ANS = (S[0] + 1) // 2 + (S[1] + 1) // 2
for i in range(n - 2):
a = A[i]
b = A[i + 2]
if a % 2 == 1 and b % 2 == 1:
ANS = min(ANS, a // 2 + b // 2 + 1)
for i in range(n - 1):
a = A[i]
b = A[i + 1]
if a > b:
a, b = ... | 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 ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMB... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | n = int(input())
a = list(map(int, input().split()))
b = a[:]
b.sort()
ans = (b[0] + 1) // 2 + (b[1] + 1) // 2
for i in range(n - 1):
q = max(a[i], a[i + 1])
w = min(a[i], a[i + 1])
if q > 2 * w:
ans = min(ans, (q + 1) // 2)
else:
ans = min(ans, (q + w + 2) // 3)
a = [99999999] + a + [99... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP ... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | import sys
input = sys.stdin.readline
def solve():
N = int(input())
INF = 10**20
a = [INF] + list(map(int, input().split()))
a.append(INF)
best = INF
N = len(a)
for i in range(1, N - 1):
best = min(best, max(a[i - 1], a[i + 1]))
best = min(best, max(min(a[i - 1], a[i + 1])... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL ... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | import sys
def solve():
inp = sys.stdin.readline
n = int(inp())
a = list(map(int, inp().split()))
ans = int(20000000.0)
for i in range(2, n):
b = a[i - 2]
c = a[i]
b, c = min(b, c), max(b, c)
ans = min(ans, b + (c - b + 1) // 2)
for i in range(1, n):
b =... | IMPORT FUNC_DEF 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 ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN ... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | import sys
input = sys.stdin.readline
n = int(input())
data = list(map(int, input().split()))
temp = sorted(data)
a, b = temp[0], temp[1]
answer = (a + 1) // 2 + (b + 1) // 2
for i in range(1, n):
t1 = int(1000000000.0)
if i + 1 < n:
t1 = data[i - 1] // 2 + data[i + 1] // 2
t1 += data[i - 1] % ... | 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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR ... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | INT_MAX = 9999999999
n = int(input())
arr = list(map(int, input().split()))
val1 = INT_MAX
val2 = INT_MAX
for i in range(1, n):
if i < n - 1:
x = arr[i - 1] + arr[i + 1]
if x % 2:
x += 1
val2 = min(val2, x // 2)
x = max(arr[i], arr[i - 1])
y = min(arr[i], arr[i - 1])
... | ASSIGN 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 VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUN... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | n = int(input())
l = [int(i) for i in input().split(" ")]
a, b = 1000000.0 + 1, 1000000.0 + 1
for i in l:
if i < a:
a, b = i, a
elif i < b:
a, b = a, i
best = -1
for i in range(n):
x = l[i]
tmp = []
if i > 0:
tmp.append(l[i - 1])
if i < len(l) - 1:
tmp.append(l[i ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST I... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | n = int(input())
arr = list(map(int, input().split()))
mini = max(arr)
for i in range(n):
if i != n - 1:
if (
arr[i] >= arr[i + 1]
and arr[i] <= 2 * arr[i + 1]
or arr[i] <= arr[i + 1]
and 2 * arr[i] >= arr[i + 1]
):
ans = (arr[i] + arr[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 FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR VAR VAR B... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | def resi():
n = int(input())
a = list(map(int, input().split()))
min1, min2 = 10000001, 10000001
for i in range(n):
if a[i] <= min1:
min2 = min1
min1 = a[i]
elif a[i] <= min2:
min2 = a[i]
res1 = (min1 + 1) // 2 + (min2 + 1) // 2
res2 = 10000001... | 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 VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | n = int(input())
a = list(map(int, input().split()))
ind = 0
for i in range(1, n):
if a[i] < a[ind]:
ind = i
ind2 = -1
for i in range(n):
if i == ind:
continue
if ind2 == -1:
ind2 = i
elif a[i] < a[ind2]:
ind2 = i
def f(x):
return (x + 1) // 2
ans = f(a[ind]) + f(... | 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 FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR NUMBER ASSIGN VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR FUNC_DEF RE... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | def main():
n = int(input())
a = list(map(int, input().split()))
ans = [0] * (n - 1)
ans_ = [0] * (n - 2)
for i in range(n - 1):
x1, x2 = a[i], a[i + 1]
s = x1 + x2
min_ = (s + 2) // 3
x1, x2 = max(x1, x2), min(x1, x2)
if x2 * 2 >= x1:
ans[i] = min... | 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VA... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | N, A = int(input()), list(map(int, input().split()))
c = 1000000
for i in range(N - 2):
prev = c
c = min(c, max(A[i], A[i + 2]))
if A[i] % 2 == A[i + 2] % 2 == 1:
c = min(c, A[i] // 2 + A[i + 2] // 2 + 1)
for i in range(N - 1):
x = min(A[i], A[i + 1])
y = A[i] + A[i + 1] - x
if min(A[i],... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN ... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | n = int(input())
a = list(map(int, input().split()))
ans1 = 10000000
for i in range(n - 1):
if max(a[i], a[i + 1]) >= 2 * min(a[i], a[i + 1]):
curr = max(a[i] + 1, a[i + 1] + 1) // 2
else:
curr = (a[i] + a[i + 1] + 2) // 3
if curr < ans1:
ans1 = curr
ans2 = 10000000
for i in range(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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMB... |
Monocarp plays "Rage of Empires II: Definitive Edition" — a strategic computer game. Right now he's planning to attack his opponent in the game, but Monocarp's forces cannot enter the opponent's territory since the opponent has built a wall.
The wall consists of $n$ sections, aligned in a row. The $i$-th section initi... | def solve():
n = int(input())
l = list(map(int, input().split()))
mn_ans = l[0] + l[1]
for i in range(1, n - 1):
x, y = l[i - 1], l[i + 1]
if x < y:
t = x
x = y
y = t
mn_ans = min(mn_ans, y + (x - y + 1) // 2)
for i in range(0, n - 1):
... | 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 BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASS... |
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is playing a noob version of the game Flappy Bird with the following rules:
The bird starts at a height $H$ at $x = 0$.
There are $N$ obstacles (numbered $1$ through $N$). For each valid $i$, the $i$-th obstacle is at a position $... | for _ in range(int(input())):
n, H = map(int, input().rstrip().split())
x = list(map(int, input().rstrip().split()))
h = list(map(int, input().rstrip().split()))
p = list()
for i in range(n):
p.append((x[i], h[i] - H))
flag = True
clicks = 0
for x, h in p:
if x <= h:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VA... |
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is playing a noob version of the game Flappy Bird with the following rules:
The bird starts at a height $H$ at $x = 0$.
There are $N$ obstacles (numbered $1$ through $N$). For each valid $i$, the $i$-th obstacle is at a position $... | def check(k, x, h, H):
for i in range(len(x)):
if x[i] <= k and H + x[i] <= h[i]:
return False
if x[i] > k and H + k - (x[i] - k) <= h[i]:
return False
return True
for _ in range(int(input())):
N, H = map(int, input().split())
x = list(map(int, input().split()))... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR RETURN NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR VAR RETURN NUMBER RETURN 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 FUNC_... |
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is playing a noob version of the game Flappy Bird with the following rules:
The bird starts at a height $H$ at $x = 0$.
There are $N$ obstacles (numbered $1$ through $N$). For each valid $i$, the $i$-th obstacle is at a position $... | n_testcase = int(input())
for testcase in range(n_testcase):
n, initial_height = (int(x) for x in input().split())
obstacle_positions = [int(x) for x in input().split()]
obstacle_heights = [int(x) for x in input().split()]
obstacles = list(zip(obstacle_positions, obstacle_heights))
impossible = any(... | 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 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 FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP V... |
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is playing a noob version of the game Flappy Bird with the following rules:
The bird starts at a height $H$ at $x = 0$.
There are $N$ obstacles (numbered $1$ through $N$). For each valid $i$, the $i$-th obstacle is at a position $... | t = int(input())
for i in range(t):
n, h = map(int, input().split())
x = list(map(int, input().split()))
h1 = list(map(int, input().split()))
for j in range(n):
h1[j] = h1[j] - h
c = 0
for k in range(n):
if x[k] <= h1[k]:
print(-1)
c = 1
break
... | 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 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR ASSI... |
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is playing a noob version of the game Flappy Bird with the following rules:
The bird starts at a height $H$ at $x = 0$.
There are $N$ obstacles (numbered $1$ through $N$). For each valid $i$, the $i$-th obstacle is at a position $... | for _ in range(int(input())):
N, H = map(int, input().split())
l = []
for i in input().split():
x = int(i)
l.append(x)
h = []
for i in input().split():
x = int(i)
h.append(x - H)
flag = True
ans = 0
for a, b in zip(l, h):
if a <= b:
fla... | 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 LIST FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR AS... |
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is playing a noob version of the game Flappy Bird with the following rules:
The bird starts at a height $H$ at $x = 0$.
There are $N$ obstacles (numbered $1$ through $N$). For each valid $i$, the $i$-th obstacle is at a position $... | for _ in range(int(input())):
n, h = map(int, input().split())
X = list(map(int, input().split()))
H = list(map(int, input().split()))
Y = []
for i in range(n):
x = X[i]
reqh = H[i]
if reqh >= h + x:
print(-1)
break
else:
Y.append(h... | 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 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 LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR... |
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is playing a noob version of the game Flappy Bird with the following rules:
The bird starts at a height $H$ at $x = 0$.
There are $N$ obstacles (numbered $1$ through $N$). For each valid $i$, the $i$-th obstacle is at a position $... | def check(obs_pos, obs_h, h, clicks):
for i in range(len(obs_pos)):
if i == 0:
if clicks <= obs_pos[0]:
h += clicks
h -= obs_pos[0] - clicks
clicks = 0
else:
h += obs_pos[0]
clicks -= obs_pos[0]
e... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER IF VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR VAR VAR BIN_OP VA... |
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is playing a noob version of the game Flappy Bird with the following rules:
The bird starts at a height $H$ at $x = 0$.
There are $N$ obstacles (numbered $1$ through $N$). For each valid $i$, the $i$-th obstacle is at a position $... | def check(x):
for i in range(n):
if X[i] <= x:
if H[i] >= X[i]:
return False
elif H[i] >= x - (X[i] - x):
return False
return True
for _ in range(int(input())):
n, h = map(int, input().split())
X = list(map(int, input().split()))
H = list(map... | FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF VAR VAR VAR VAR RETURN NUMBER IF VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR RETURN NUMBER RETURN 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CAL... |
Read problem statements in [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is playing a noob version of the game Flappy Bird with the following rules:
The bird starts at a height $H$ at $x = 0$.
There are $N$ obstacles (numbered $1$ through $N$). For each valid $i$, the $i$-th obstacle is at a position $... | t = int(input())
for _ in range(t):
n, H = map(int, input().split())
x = list(map(int, input().split()))
h = list(map(int, input().split()))
res = []
for i in range(len(h)):
s = h[i] - H
res.append(s)
result = 0
flag = 0
for i in range(len(res)):
if x[i] > res[i]:... | 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 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 LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN V... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | numOfTowers, numOfOperations = map(int, input().split())
heights = list(map(int, input().split()))
l = []
for i in range(numOfOperations):
max_index = heights.index(max(heights))
min_index = heights.index(min(heights))
if min_index != max_index:
heights[max_index] -= 1
heights[min_index] += ... | 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR LIST BIN... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
a = list(map(int, input().split()))
d = [[a[i], i] for i in range(n)]
d.sort()
cnt = 0
ops = []
while d[n - 1][0] - d[0][0] > 1 and cnt < k:
ops.append([d[n - 1][1] + 1, d[0][1] + 1])
d[n - 1][0] -= 1
d[0][0] += 1
cnt += 1
d.sort()
print(d[n - 1][0] - d[0][0], cnt)
f... | 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 ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | a, b = map(int, input().split())
l = list(map(int, input().split()))
count = 0
arr = []
for i in range(b):
minimum = min(l)
maximum = max(l)
if maximum - minimum <= 1:
break
minindex = l.index(minimum)
maxindex = l.index(maximum)
l[minindex] += 1
l[maxindex] -= 1
arr.append((maxi... | 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 ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
a = list(map(int, input().split()))
actions = []
for i in range(k):
max_index = min_index = 0
max_value = min_value = a[0]
for j, value in enumerate(a):
if value > max_value:
max_index = j
max_value = value
elif value < min_value:
... | 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
l = list(map(int, input().split()))
gap, res = 10000, []
while 1:
i, j = (f(range(n), key=l.__getitem__) for f in (min, max))
if gap > l[j] - l[i]:
gap = l[j] - l[i]
top = len(res)
if gap < 2:
break
if len(res) == k:
break
l[i]... | 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 ASSIGN VAR VAR NUMBER LIST WHILE NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | import sys
input = sys.stdin.readline
def multi_input():
return map(int, input().split())
def array_print(arr):
print(" ".join(map(str, arr)))
n, k = multi_input()
a = list(multi_input())
m = 0
ans = []
diff = sys.maxsize
while k > 0 and max(a) != min(a):
max1 = a.index(max(a))
min1 = a.index(min... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR NUMBER FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASS... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
a = list(map(int, input().split()))
ans, rest = [], []
while k > 0:
maxa = max(a)
mina = min(a)
res = maxa - mina
if res <= 1:
break
maxi = a.index(maxa)
mini = a.index(mina)
a[maxi] -= 1
a[mini] += 1
ans.append(maxi + 1)
rest.append(mini ... | 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 ASSIGN VAR VAR LIST LIST WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = list()
cnt = 0
while cnt < k:
i = a.index(max(a))
j = a.index(min(a))
if i == j:
break
ans.append((i + 1, j + 1))
a[i] -= 1
a[j] += 1
cnt += 1
stability = max(a) - min(a)
print(stability, cnt)
for i, j in ans:... | 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_O... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
l = list(map(int, input().split()))
if n == 1:
print(0, 0)
exit()
l1 = [[l[i], i + 1] for i in range(n)]
k1 = k
opa = []
while k1 > 0:
l1 = sorted(l1, key=lambda x: x[0])
if abs(l1[0][0] - l1[-1][0]) <= 1:
break
opa.append(str(l1[-1][1]) + " " + str(l1[0][1])... | 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 VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR FUNC_CA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | def inp(s):
j = 0
a = []
for i in range(len(s)):
if s[i] == " ":
a.append(int(s[j:i]))
j = i + 1
if i == len(s) - 1:
a.append(int(s[j:]))
return a
def ins(a):
return max(a) - min(a)
n, k = input().split()
k = int(k)
s = input()
a = inp(s)
i = 0... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
l = list(map(int, input().split()))
diff = max(l) - min(l)
if diff == 0:
print(0, 0)
elif diff == 1:
print(1, 0)
else:
s = 0
ans = []
while s < k:
x = l.index(min(l))
y = l.index(max(l))
if max(l) - min(l) <= 1:
break
else:... | 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 ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR ... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | def main():
n, k = map(int, input().split())
arr = list(map(int, input().split()))
arr1 = []
for i in range(n):
arr1.append([arr[i], i])
arr = arr1[:]
ans = []
arr.sort()
min_val = arr[0][0]
max_val = arr[-1][0]
while max_val > min_val and k > 0:
arr[0][0] += 1
... | FUNC_DEF 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER W... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | infinity = 10**30
def find_extreme_towers(towers):
min_tower, max_tower = 0, 0
for tower in range(len(towers)):
if towers[tower] < towers[min_tower]:
min_tower = tower
if towers[tower] > towers[max_tower]:
max_tower = tower
return min_tower, max_tower
def compute_... | ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR RETURN BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, m = map(int, input().split())
l = list(map(int, input().split()))[:n]
g = []
f = []
cnt = 0
while max(l) - min(l) > 1:
cnt += 1
if cnt > m:
cnt -= 1
break
b = max(l)
c = min(l)
g.append(l.index(b) + 1)
f.append(l.index(c) + 1)
l[l.index(b)] -= 1
l[l.index(c)] += 1
prin... | 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 VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | from sys import stdin, stdout
def get():
return stdin.readline().strip()
def getf():
return [int(i) for i in get().split()]
def put(a, end="\n"):
stdout.write(str(a) + end)
def putf(a, sep=" ", end="\n"):
stdout.write(sep.join(map(str, a)) + end)
def minMaxIx(a, n):
mn = 0
mx = 0
f... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_DEF STRING STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | v = list(input().split())
n = int(v[0])
k = int(v[1])
v = list(int(x) for x in input().split())
dol = list()
dolc = 0
s = 0
for i in range(k):
minv = min(v)
maxv = max(v)
minvi = v.index(minv)
maxvi = v.index(maxv)
if maxv - minv == 0:
break
if maxv - minv == 1:
if s == 1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR F... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | def test(lst):
for i in range(len(lst) - 1):
if lst[i] != lst[i + 1]:
return True
return False
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
p = []
m = 0
tst = test(a)
s = max(a) - min(a)
while k > 0 and tst and s > 1:
i = a.index(max(a))
j = a.index(mi... | FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER RETURN NUMBER RETURN 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 ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = input().split()
list_ = input()
mass = []
result = []
s = 0
n = int(n)
k = int(k)
k_1 = k
summ = ""
i = 0
while i < len(list_):
if list_[i] == " ":
mass.append(int(summ))
summ = ""
else:
summ = summ + list_[i]
if i == len(list_) - 1:
mass.append(int(summ))
... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR STR... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
towers = list(map(int, input().split()))
operations = []
instability = 10000
operation = 0
for _ in range(k):
minn, maxx = min(towers), max(towers)
min_index = towers.index(minn)
max_index = towers.index(maxx)
towers[min_index] += 1
towers[max_index] -= 1
minn, m... | 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 ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR N... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | tower, move = map(int, input().split())
height = list(map(int, input().split()))
m = max(height)
n = min(height)
difference = m - n
indexMax = -1
indexMin = -1
for i in range(tower):
if m == height[i]:
indexMax = i
if n == height[i]:
indexMin = i
chances = []
counter = 0
while move != 0 and diff... | 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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR ASSIG... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
arr = list(map(int, input().split()))
lst = []
j = count = 0
check = -1
while j < k:
mini = 10**4 + 3
maxi = 0
for i in range(n):
if maxi < arr[i]:
max_index = i
maxi = arr[i]
if mini > arr[i]:
min_index = i
min... | 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 ASSIGN VAR LIST ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR ASSIGN... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
output = []
instability, moves = max(a) - min(a), 0
while moves < k:
high, low = max(a), min(a)
h, l = a.index(max(a)), a.index(min(a))
if h == l:
break
a[h], a[l] = a[h] - 1, a[l] + 1
moves += 1
output.append... | 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 LIST ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | f = list(map(int, input().split()))
heights = list(map(int, input().split()))
num = f[0]
kops = f[1]
minpossible = 0 if sum(heights) % num == 0 else 1
curinstability = max(heights) - min(heights)
opscounter = 0
rem = list()
while curinstability > minpossible and opscounter < kops:
lowi = heights.index(min(heights))... | 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 VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
kb = k
a = [[i + 1, e] for i, e in enumerate(map(int, input().split()))]
ans = []
a = sorted(a, key=lambda x: x[1], reverse=True)
while k > 0:
if a[0][1] - a[-1][1] > 1:
ans.append([a[0][0], a[-1][0]])
a[0][1] -= 1
a[-1][1] += 1
a = sorted(a, key=lamb... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER EXPR FUNC_CAL... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
a, risp = [], []
a = list(map(int, input().split()))
s = max(a) - min(a)
m = 0
if s < 2:
print(s, 0)
else:
for x in range(k):
maxi = max(a)
IndMaxi = a.index(maxi)
mini = min(a)
IndMini = a.index(mini)
a[IndMaxi] -= 1
a[IndMini] +=... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | towers, operationsNum = map(int, input().split())
towersHeights = list(map(int, input().split()))
changes = []
for i in range(operationsNum):
minH, maxH = min(towersHeights), max(towersHeights)
instability = max(towersHeights) - min(towersHeights)
minindex, maxindex = towersHeights.index(minH), towersHeight... | 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = [int(x) for x in input().split()]
m = [int(x) for x in input().split()]
a = 1
b = max(m)
c = min(m)
w = []
while a <= k and b > c:
p = m.index(b)
q = m.index(c)
w.append([p + 1, q + 1])
m[p] -= 1
m[q] += 1
b = max(m)
c = min(m)
a += 1
print(b - c, end=" ")
print(a - 1)
for c in w:... | 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 NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST WHILE VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST BIN_OP... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, x = map(int, input().split())
l = list(map(int, input().split()))
ls = []
c = 0
for i in range(x):
ma = max(l)
mi = min(l)
if ma - mi > 1:
mai = l.index(ma)
mii = l.index(mi)
l[mai] = l[mai] - 1
l[mii] = l[mii] + 1
ls.append([mai + 1, mii + 1])
c = c + 1
... | 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 ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | inpt = input().split(" ")
n = int(inpt[0])
k = int(inpt[1])
i_lst = []
j_lst = []
m = 0
inpt = input().split(" ")
for i in range(len(inpt)):
inpt[i] = int(inpt[i])
for i in range(k):
mn = min(inpt)
mx = max(inpt)
if mn != mx:
i_mn = inpt.index(mn)
i_mx = inpt.index(mx)
inpt[i_mn]... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR ... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
a = list(map(int, input().split()))
s = max(a) - min(a)
answer = []
m = 0
max_s = max(a) - min(a)
if max_s != 0:
while k != 0:
if max_s >= max(a) - min(a):
max_s = max(a) - min(a)
else:
break
max_a = a.index(max(a))
min_a = a.i... | 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 ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER WHILE VAR NUMBER IF VAR BIN_OP FUNC_CALL... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
l = []
r = []
f = True
for h in range(k):
mi = a[0]
ma = a[0]
ai = 0
aj = 0
for i in range(len(a)):
if a[i] < mi:
mi = a[i]
ai = i
if a[i] > ma:
ma = a[i]
aj =... | 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 ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR ... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | f = input()
s = input()
a = f.split(" ")
n = int(a[0])
k = int(a[1])
a = s.split(" ")
i = 0
while i < n:
a[i] = int(a[i])
i = i + 1
ans = -1
v1 = list()
v2 = list()
while k > 0:
posmn = -1
posmx = -1
mn = 2**16
mx = -1
i = 0
while i < n:
if mn > a[i]:
mn = a[i]
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | import sys
input = sys.stdin.readline
def update_front(n, arr):
for i in range(n - 1):
if arr[i][0] > arr[i + 1][0]:
arr[i], arr[i + 1] = arr[i + 1], arr[i]
else:
break
def update_back(n, arr):
for i in reversed(range(n - 1)):
if arr[i][0] > arr[i + 1][0]:
... | IMPORT ASSIGN VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = []
while k > 0:
mn = min(a)
mx = max(a)
if mn + 1 >= mx:
break
for i in range(n):
if a[i] == mn:
a[i] += 1
ans.append(i)
break
for i in range(n):
if a[i] == mx:
... | 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 ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR F... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | a, b = map(int, input().split(" "))
towers = list(map(int, input().split(" ")))
tow2 = [[towers[i], i + 1] for i in range(len(towers))]
tot = sum(towers)
should = tot // a
num1 = (should + 1) * a - tot
num2 = a - num1
ideal = num1 * [should] + num2 * [should + 1]
ct = 1
x = []
while ct <= b:
tow2.sort(key=lambda x:... | ASSIGN VAR 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 VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
p = k
a = list(map(int, input().split()))
c = list()
while k > 0 and max(a) - min(a) > 1:
c.append(a.index(max(a)) + 1)
c.append(a.index(min(a)) + 1)
a[a.index(max(a))] -= 1
a[a.index(min(a))] += 1
k -= 1
print(max(a) - min(a), p - k)
i = 0
while len(c) > i:
prin... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_O... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | def main():
n, k = map(int, input().split())
towers = list(map(int, input().split()))
min_index = towers.index(min(towers))
max_index = towers.index(max(towers))
dif = towers[max_index] - towers[min_index]
cant = 0
operations = []
while k > 0 and dif > 0:
if min_index == max_inde... | FUNC_DEF 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER VAR NUMBER IF VA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
l = list(map(int, input().split()))
ans = []
for i in range(n):
ans.append([l[i], i + 1])
ans.sort(key=lambda x: (x[0], x[1]))
s = 0
fns = []
while s != k:
diff = ans[-1][0] - ans[0][0]
if diff == 0:
break
s += 1
ans[-1][0] -= 1
ans[0][0] += 1
fns.app... | 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR BIN_... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
x = list(map(int, input().split()))
oldins = 0
ins = max(x) - min(x)
diff = 0
order = []
while max(x) != min(x) and max(x) != min(x) + 1 and diff < k:
a = x.index(min(x))
b = x.index(max(x))
order.append([b + 1, a + 1])
x[x.index(min(x))] += 1
x[x.index(max(x))] -= 1... | 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 ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBE... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | a, b = map(int, input().split())
k1 = []
k2 = []
c = list(map(int, input().split()))
lol = max(c) - min(c)
if a == 1:
print(0, 0)
else:
for i in range(b):
mix = -1
man = 10000000000000
for j in range(a):
if c[j] >= mix:
mix = c[j]
p1 = j
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER F... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
a = list(zip(list(map(int, input().split())), [i for i in range(1, n + 1)]))
a.sort()
add = [0] * n
ans = []
m = 0
while k > 0 and a[0][0] + 1 + add[0] < a[-1][0] + add[-1]:
l = 0
while a[l + 1][0] + add[l + 1] == a[l][0] + add[l]:
l += 1
r = n - 1
while a[r][0] ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER BIN_OP BIN_OP VAR... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
l = list(map(int, input().split()))
num_position = [[el, index] for index, el in enumerate(l)]
current_unstability = abs(max(num_position)[0] - min(num_position)[0])
min_unstability = 10 * 5
res = []
nb_step = 0
while k > 0:
index_max, index_min = max(num_position)[1], min(num_posit... | 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 ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBE... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | line = input("")
line = line.split()
amount = int(line[0])
movess = int(line[1])
towers = input("")
towers = towers.split()
towers = list(map(int, towers))
count = 0
insta = max(towers) - min(towers)
moves = []
instaCount = 1
for i in range(movess):
if insta == 1 or insta == 0:
break
else:
moves... | ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
towers = list(map(int, input().split()))
stow = sorted([[towers[i], i] for i in range(0, n)], key=lambda k: k[0])
operations = []
for i in range(0, k):
stow = sorted(stow, key=lambda k: k[0])
if stow[n - 1][0] <= stow[0][0] + 1:
break
stow[n - 1][0] -= 1
stow[0][... | 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 ASSIGN VAR FUNC_CALL VAR LIST VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER ... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
li = list(map(int, input().split()))
nextli = []
alist = sorted(li)
s = 0
r = max(alist) - min(alist)
while True:
m = li.index(max(alist))
p = li.index(min(alist))
li[m] -= 1
li[p] += 1
blist = sorted(li)
l = max(alist) - min(alist)
if blist == alist or s >= ... | 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 ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR WHILE NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = []
for i in range(k):
mi = 10**10
for j in range(n):
if a[j] < mi:
mi = a[j]
pos_mi = j
ma = -(10**10)
for j in range(n):
if a[j] > ma:
ma = a[j]
pos_ma = j
if m... | 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
heights = []
total = 0
i = 1
for item in map(int, input().split()):
heights.append([item, i])
total += item
i += 1
heights.sort()
middle = total // n
if total % n != 0:
middle += 1
most_h = heights[n - 1][0]
min_h = heights[0][0]
up_ind = n - 1
down_ind = 0
level_down = ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUM... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = list(map(int, input().split(" ")))
t = list(map(int, input().split(" ")))
inst = max(t) - min(t)
i = 0
steps = []
while inst > 0 and i < k:
imax = t.index(max(t))
imin = t.index(min(t))
steps.append(imax + 1)
steps.append(imin + 1)
t[imax] -= 1
t[imin] += 1
inst = max(t) - min(t)
... | 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 BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR F... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | s, m = map(int, input().split())
ls = [int(u) for u in input().split()]
ls_copy = ls.copy()
k = 0
operations = []
for _ in range(0, m):
if max(ls) == min(ls):
break
else:
k += 1
operations.append([ls.index(max(ls)) + 1, ls.index(min(ls)) + 1])
ls[ls.index(max(ls))] -= 1
l... | ASSIGN 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 FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR N... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
s, i, j = "", 0, 10000
t = [[] for x in range(j + 1)]
for y, x in enumerate(map(int, input().split()), 1):
t[x].append(str(y))
while not t[i]:
i += 1
while not t[j]:
j -= 1
while k and i < j:
a, b = t[j].pop(), t[i].pop()
s += "\n" + a + " " + b
t[j - 1].append(a... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR STRING NUMBER NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR NUMBER WHILE VAR VAR VAR NUMBER WHILE... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
h = list(map(int, input().split()))
val = max(h) - min(h)
step = 0
move = []
for t in range(k):
i = h.index(max(h))
j = h.index(min(h))
h[i] -= 1
h[j] += 1
move.append((i + 1, j + 1))
newval = max(h) - min(h)
if val > newval:
step = t + 1
val ... | 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 ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = input().split()
n = int(n)
k = int(k)
a = [int(i) for i in input().split()]
thres = round(sum(a) / n)
pos = []
early = False
for i in range(k):
low = a[0]
l_pos = 0
high = a[0]
h_pos = 0
for j in range(1, n):
if a[j] > high:
high = a[j]
h_pos = j
elif a... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR V... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = []
for i in range(n):
a[i] = [a[i], i]
a.sort()
i = -1
if a[-1][0] - a[0][0] == 1 or a[-1][0] - a[0][0] == 0:
k = 0
for i in range(k):
a[-1][0] -= 1
a[0][0] += 1
ans += [[a[-1][1] + 1, a[0][1] + 1]]
if a[0][0] > a[1][0] o... | 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER BIN_OP VAR NUMBER NUMBER VAR NUM... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | l = input().split()
n = int(l[0])
k = int(l[1])
a = input().split()
ans = []
for i in range(len(a)):
a[i] = int(a[i])
b = []
for i in range(len(a)):
b.append(a[i])
ms = max(a) - min(a)
op = 0
dum = 1
while k > 0 and dum == 1:
k -= 1
ma = a.index(max(a))
a[ma] -= 1
mi = a.index(min(a))
a[mi] ... | 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR AS... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
heights = list(map(int, input().split()))
stabilities = [max(heights) - min(heights)]
pos = [(0, 0)]
for i in range(k):
higher = heights.index(max(heights))
lower = heights.index(min(heights))
heights[higher] -= 1
heights[lower] += 1
stabilities.append(max(heights) -... | 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 ASSIGN VAR LIST BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | from sys import stdin, stdout
outputs = []
n, m = (int(num) for num in stdin.readline().strip().split())
arr = [int(num) for num in stdin.readline().strip().split()]
for i in range(n):
arr[i] = [arr[i], i + 1]
arr = sorted(arr, key=lambda t: t[0])
res = []
diff = arr[-1][0] - arr[0][0]
while True and m > 0:
if... | ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER NUMBER VA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = [int(x) for x in input().split()]
towers = list(map(int, input().split()))
prom = int(sum(towers) / n)
actions = []
while k > 0:
alto = towers.index(max(towers)) + 1
bajo = towers.index(min(towers)) + 1
if alto == bajo:
break
towers[alto - 1] -= 1
towers[bajo - 1] += 1
actions.app... | ASSIGN VAR VAR FUNC_CALL VAR 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 BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | import sys
class Item:
def __init__(self, i, v):
self.i = i
self.v = v
def __repr__(self):
return "%s %s" % (self.i, self.v)
n, k = sys.stdin.readline().split()
n = int(n)
k = int(k)
tower = sys.stdin.readline().split()
for i in range(len(tower)):
tower[i] = Item(i + 1, int(tow... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP STRING VAR VAR 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 FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CA... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
a = list(map(int, input().split()))
s = ""
c = 0
best = [max(a) - min(a), c, ""]
if n > 1:
for pog in range(k):
m = 0
i = 0
mp = 100000000000000000
ip = 0
m = max(a)
i = a.index(m)
mp = min(a)
ip = a.index(mp)
i... | 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 ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR STRING IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUM... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | import sys
tow = [int(x) for x in sys.stdin.readline().split()]
initalSteps = tow[1]
towData = [int(x) for x in sys.stdin.readline().split()]
tower = [None] * len(towData)
for idx in range(0, len(towData)):
tower[idx] = [idx + 1, towData[idx]]
tower = sorted(tower, key=lambda x: x[1])
result = ""
while tow[1] > 0:... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR LIST BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBE... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | def minmax(a, n):
mn, mx, idx = 0, 0, 0
for idx in range(1, n):
if a[idx] > a[mx]:
mx = idx
if a[idx] < a[mn]:
mn = idx
return [mx + 1, mn + 1]
[n, k] = list(map(int, input().split()))
a = list(map(int, input().split()))
moves = []
oper = 0
while oper < k:
loc =... | FUNC_DEF ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR RETURN LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER 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 FUN... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | n, k = map(int, input().split())
t = list(map(int, input().split()))
moves = []
best = 10000
bestl = 0
for l in range(k + 1):
imin = min(range(len(t)), key=lambda i: t[i])
imax = max(range(len(t)), key=lambda i: t[i])
if best > t[imax] - t[imin]:
best = t[imax] - t[imin]
bestl = l
if t[i... | 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 ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ... |
As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same size. Tower with number i consists of a_{i} cubes stacked one on top of the other. Petya defines the instability of a set of towers as a value equal to the difference between the heights of the highes... | def mi(a):
m = a[0]
mi = 0
for i in range(len(a)):
if a[i] < m:
m = a[i]
mi = i
return mi
def ma(a):
m = a[0]
mi = 0
for i in range(len(a)):
if a[i] > m:
m = a[i]
mi = i
return mi
n, k = map(int, input().split())
towers ... | FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.