description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | n, k, a, b = list(map(int, input().split()))
h = [0] + list(map(int, input().split()))
h.sort()
def binp(nu):
l = 0
r = len(h) - 1
while r - l > 1:
if h[(l + r) // 2] > nu:
r = (l + r) // 2
else:
l = (l + r) // 2
if h[r] <= nu:
return l + 1
else:
... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR VAR NUMBER VA... |
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
def bs(num):
low = 0
high = k - 1
while low < high:
mid = (low + high) // 2
if l[mid] > num:
high = mid - 1
else:
low = mid + 1
if l[low] > num:
return low
else:
ret... | IMPORT ASSIGN VAR VAR EXPR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR RETURN VAR RETURN BIN_OP VAR NUMBER FUNC_DEF IF VAR VAR IF VAR VAR RETURN ... |
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | n = 0
k = 0
a = 0
b = 0
num = []
def __upper_bound__(val):
global num
global k
l = 0
r = k - 1
while l < r:
mid = l + r >> 1
if num[mid] < val:
l = mid + 1
else:
r = mid
if l >= k:
return l
if num[l] < val:
l += 1
return l... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR VAR RETURN VAR IF VAR VAR VAR VAR NUMBER RETURN VAR FUNC... |
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | def I():
return list(map(int, input().split()))
def rec(l, r):
numavens = getnums(l, r)
if numavens == 0:
return a
if l == r:
return b * numavens
mid = (r - l) // 2 + l
return min((r - l + 1) * numavens * b, rec(l, mid) + rec(mid + 1, r))
def getnums(l, r):
if l == 0:
... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER RETURN VAR IF VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR RETURN FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR BIN_OP FUNC_CALL VAR VAR ... |
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | n, k, a, b = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort()
def se(st, en):
nonlocal l
c = 0
lo = 0
hi = len(l) - 1
while lo <= hi:
mid = (lo + hi) // 2
if l[mid] <= en:
lo = mid + 1
else:
hi = mid - 1
c += hi
lo... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VA... |
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | n, k, A, B = list(map(int, input().split()))
n = 2**n
a = list(sorted(list(map(int, input().split()))))
def recurs(start, end, array):
if len(array) == 0:
return A
if end - start == 1:
return B * len(array)
middle = (start + end) // 2
c, d = [], []
for x in array:
if x < mi... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR IF BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR FUNC_CALL VAR VAR ASSIGN V... |
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | n, k, A, B = map(int, input().split())
def solve(l, r, a):
if len(a) == 0:
return A
if l == r:
return B * len(a)
mid = (l + r) // 2
lx = []
rx = []
for i in a:
if i <= mid:
lx.append(i)
else:
rx.append(i)
return min(B * len(a) * (r - ... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR IF VAR VAR RETURN BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN FUNC_CALL VA... |
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | def helper(start, end, aveL, aveR):
if aveR - aveL == -1:
return A
if start == end:
return B * (aveR - aveL + 1)
temp = start + (end - start) // 2
l, r = aveL, aveR
while l <= r:
mid = l + (r - l) // 2
if avengers[mid] > temp:
r = mid - 1
else:
... | FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN VAR IF VAR VAR RETURN BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETUR... |
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | from sys import stdin
def input():
return stdin.readline()[:-1]
def recur(l, r, A, B, avengers):
if not avengers:
return A
if l == r:
return B * len(avengers)
else:
cost = B * len(avengers) * (r - l + 1)
mid = (l + r) // 2
x = []
y = []
for i i... | FUNC_DEF RETURN FUNC_CALL VAR NUMBER FUNC_DEF IF VAR RETURN VAR IF VAR VAR RETURN BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL ... |
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | n, k, a, b = map(int, input().split())
arr = sorted(map(int, input().split()))
el = None
c = 0
d = []
for e in arr:
if el is None:
el = e
c = 1
elif el == e:
c += 1
else:
d.append((el - 1, c, c * b))
el = e
c = 1
d.append((el - 1, c, c * b))
for g in range(0, ... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NONE ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR NONE ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR ASS... |
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | from sys import setrecursionlimit
setrecursionlimit(1000000000)
n, k, A, B = map(int, input().split())
av = [0] + list(map(int, input().split()))
av.sort()
def solve(ss, se):
st, en = -1, -1
l, h = 0, k
while l <= h:
m = (l + h) // 2
if av[m] < ss:
st = m
l = m + 1... | EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR... |
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | def solve(l, r, y):
if len(y) == 0:
return a
if l == r:
return b * len(y)
c = []
d = []
m = (l + r) // 2
for i in y:
if i <= m:
c += [i]
else:
d += [i]
return min(b * (r - l + 1) * len(y), solve(l, m, c) + solve(m + 1, r, d))
n, k, a,... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR IF VAR VAR RETURN BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR VAR IF VAR VAR VAR LIST VAR VAR LIST VAR RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP FUNC_CALL V... |
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | def ans(arr, l, r, a, b):
if len(arr) == 0:
return a
if l == r:
return len(arr) * b
arr_left = []
arr_right = []
mid = (l + r) // 2
for el in arr:
if l <= el <= mid:
arr_left += [el]
if mid + 1 <= el <= r:
arr_right += [el]
return min(
... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR IF VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR LIST VAR IF BIN_OP VAR NUMBER VAR VAR VAR LIST VAR RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP BIN_OP ... |
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | n, k, A, B = list(map(int, input().split()))
n = 2**n
a = sorted(list(map(int, input().split())))
def recurs(start, end, sum_all, array):
if sum_all == 0:
return A
else:
energy = B * (end - start) * sum_all
if end - start == 1:
return energy
c, d = [], []
for x in array:
... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER RETURN VAR ASSIGN VAR VA... |
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.
Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t... | def searchlow(arr, l, r, x):
if arr[-1] < x:
return -1
while l <= r:
m = (l + r) // 2
if arr[m] >= x:
r = m - 1
else:
l = m + 1
return r + 1
def searchhigh(arr, l, r, x):
if arr[0] > x:
return -1
while l <= r:
m = (l + r) // 2... | FUNC_DEF IF VAR NUMBER VAR RETURN NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER VAR RETURN NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP... |
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes i, j (i ≠ j);
* perform assignments tmp = a[i], a[i] = a[j], a[j] = tmp.
What maximum value of function m(a) can Serej... | read_line = lambda: [int(i) for i in input().split()]
n, k = read_line()
x = read_line()
print(
max(
sum(sorted(x[l:r] + sorted(x[:l] + x[r:])[-k:])[l - r :])
for l in range(n)
for r in range(l + 1, n + 1)
)
) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMB... |
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes i, j (i ≠ j);
* perform assignments tmp = a[i], a[i] = a[j], a[j] = tmp.
What maximum value of function m(a) can Serej... | n, k = map(int, input().split())
a = list(map(int, input().split()))
r_sum = a[0]
for l in range(n):
for r in range(l, n):
inside = sorted(a[l : r + 1])
outside = sorted(a[:l] + a[r + 1 :], reverse=True)
t_sum = sum(inside)
for i in range(min(k, len(inside), len(outside))):
... | 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 FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBE... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | input()
x = sorted(map(int, input().split()))
suml = 0
sumr = sum(x)
res = 0
resv = float("inf")
for i in range(len(x)):
dist = x[i] * i - suml + sumr - x[i] * (len(x) - i)
if dist < resv:
res = x[i]
resv = dist
suml += x[i]
sumr -= x[i]
print(res) | EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR BIN_OP FUNC_CALL VAR VA... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
dots = [int(x) for x in input().split()]
dots.sort()
dot = dots[0]
left = 0
right = sum([abs(x - dot) for x in dots])
results = [right]
for i in range(1, n):
ldot = dot
dot = dots[i]
left += (dot - ldot) * i
right -= (dot - ldot) * (n - i)
results.append(left + right)
print(dots[res... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP BIN_O... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | try:
while True:
n = int(input())
a = sorted(map(int, input().split()))
ls = 0
result = rs = sum(a) - a[0] * n
index = 0
for i in range(1, n):
d = a[i] - a[i - 1]
ls += d * i
rs -= d * (n - i)
if ls + rs < result:
... | WHILE 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 NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
a = list(map(int, input().split()))
a.sort()
if n % 2 == 0:
print(a[n // 2 - 1])
else:
print(a[n // 2]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
L = list(map(int, input().split()))
L.sort()
if n % 2 == 0:
ans = n // 2 - 1
else:
ans = n // 2
print(L[ans]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | def get_median(data, n):
data.sort()
return data[int((n + 1) / 2) - 1]
def main():
n = int(input())
nNumsLine = list(map(int, input().split()))
print(int(get_median(nNumsLine, n)))
main() | FUNC_DEF EXPR FUNC_CALL VAR RETURN VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | def opPoint(arr, point):
range = 0
for t in arr:
range += abs(point - t)
return range
def diff(len, ind, val):
return (2 * ind - len) * val
len = int(input())
a = list(map(int, input().split()))
a.sort()
av = sum(a) / len
min_ind = a[0]
min_range = opPoint(a, a[0])
last_r = min_range
for i i... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR VAR N... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
l = list(map(int, input().split()))
l.sort()
x = n // 2
if n % 2 == 0:
x -= 1
print(l[x]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
points = sorted(tuple(map(int, input().split())))
def calc(points, start, stop, step):
n = len(points)
ans = [None] * n
ans[start] = 0
cnt = 1
for i in range(start + step, stop, step):
ans[i] = ans[i - step] + abs(points[i] - points[i - step]) * cnt
cnt += 1
re... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR VAR BIN_... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | MOD = 1000000007
ii = lambda: int(input())
si = lambda: input()
dgl = lambda: list(map(int, input()))
f = lambda: map(int, input().split())
il = lambda: list(map(int, input().split()))
ls = lambda: list(input())
n = ii()
l = sorted(il())
print(l[(n - 1) // 2]) | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN 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 ASSIGN VAR FUNC_CALL V... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
s = input().split()
for i in range(n):
s[i] = int(s[i])
s.sort()
if n % 2 != 0:
print(s[n // 2])
else:
print(s[n // 2 - 1]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | N = int(input())
number_list = list(map(int, input().split(" ")))
number_list.sort()
mid = len(number_list) // 2
if len(number_list) % 2 == 0:
median = (number_list[mid - 1] + number_list[mid]) / 2.0
else:
median = number_list[mid]
min_value = min(abs(i - median) for i in number_list)
temp = []
for j in number_... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL V... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
x = list(map(int, input().split()))
x.sort()
s = sum(x)
it = x[0]
m = s - n * x[0]
result = x[0]
for i in range(1, n):
cur = s - it - (n - i) * x[i] + (i * x[i] - it)
it += x[i]
if cur < m:
result = x[i]
m = cur
print(result) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_O... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | import sys
input = sys.stdin.readline
def ceil(x, y):
return (x + y - 1) // y
def swaparr(arr, a, b):
temp = arr[a]
arr[a] = arr[b]
arr[b] = temp
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def nCr(n, k):
if k > n - k:
k = n - k
res = 1
for i in r... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_DEF IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR V... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | def d(a, x):
t = 0
for n in a:
t += abs(n - x)
return t
def solve():
n = int(input())
a = list(map(int, input().split()))
a.sort()
if n % 2 == 0:
if d(a, a[n // 2 - 1]) <= d(a, a[n // 2]):
print(a[n // 2 - 1])
else:
print(a[n // 2])
else:... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER IF FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR VAR ... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | def main():
n = int(input())
arr = map(int, str(input()).split())
arr = list(sorted(arr))
if n % 2 == 0:
n = int(n / 2)
else:
n = int(n / 2 + 1)
print(arr[n - 1])
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR ... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | numPoints = int(input())
points = list(map(int, input().split(" ")))
points.sort()
def calcVal(point, points):
tally = 0
for i in range(len(points)):
tally += abs(points[i] - point)
return tally
if len(points) % 2 == 0:
leftDex = len(points) // 2 - 1
rightDex = len(points) // 2
print... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_C... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
arr = sorted(list(map(int, input().split())))
if len(arr) % 2 == 0:
print(arr[len(arr) // 2 - 1])
else:
print(arr[len(arr) // 2]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
x = [int(p) for p in input().split()]
x.sort()
S = [0]
for i in range(0, n):
S.append(S[i] + x[i])
L = []
R = []
for i in range(0, n):
L.append(i * x[i] - S[i])
R.append(S[n] - S[i + 1] - (n - i - 1) * x[i])
mind = L[0] + R[0]
mini = 0
for i in range(1, n):
d = L[i] + R[i]
if d < mi... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR V... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | from sys import stdin, stdout
def right_range(x):
return cntr[-1] - cntr[x] - (coordinate[x] - coordinate[0]) * (n - x - 1)
def left_range(x):
return cntl[0] - cntl[x] - (coordinate[-1] - coordinate[x]) * x
n = int(stdin.readline())
coordinate = sorted(list(map(int, stdin.readline().split())))
cntr = [0]
... | FUNC_DEF RETURN BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASS... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | read = input().split(" ")
n = int(read[0])
tab = sorted(map(int, input().split(" ")))
wynik = tab[int((n - 1) / 2)]
print(wynik) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | N = int(input())
numbers = [int(n) for n in input().split()]
numbers.sort()
if N % 2 == 1:
Ans = numbers[N // 2]
print(Ans)
else:
Ans = numbers[N // 2 - 1]
print(Ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | def abs(x):
if x < 0:
return -x
else:
return x
inp = input()
n = int(inp)
x = input().split()
for i in range(0, n):
x[i] = int(x[i])
x.sort()
ans = 0
val = 0
for i in range(0, n):
val += x[i] - x[0]
ans = val
pnt = x[0]
diff = 0
for i in range(1, n):
diff = x[i] - x[i - 1]
val ... | FUNC_DEF IF VAR NUMBER RETURN VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR VAR VAR NUMBE... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | def main():
n = int(input())
arr = [int(a) for a in input().split()]
arr.sort()
print(arr[len(arr) // 2 - 1 + len(arr) % 2])
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | N = int(input())
X = list(map(int, input().split()))
X.sort()
if N % 2 != 0:
print(X[N // 2])
else:
left = sum([abs(x - X[N // 2 - 1]) for x in X])
right = sum([abs(x - X[N // 2]) for x in X])
if left <= right:
print(X[N // 2 - 1])
elif left > right:
print(X[N // 2]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CA... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
x = sorted(list(map(int, input().split())))
P, N = 0, 0
a = n * [0]
for i in range(1, n):
P = (x[i] - x[i - 1]) * i + P
N = (x[-i] - x[-i - 1]) * i + N
a[i] += P
a[-i - 1] += N
print(x[a.index(min(a))]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VA... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
a = input().split(" ")
for i in range(len(a)):
a[i] = int(a[i])
a.sort()
if len(a) % 2 == 0:
print(a[int(len(a) / 2) - 1])
else:
print(a[int(len(a) / 2)]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | import sys
INF = 10**9 + 3
fin = sys.stdin
fout = sys.stdout
n = int(fin.readline())
points = list(map(int, fin.readline().split()))
points.sort()
if n % 2 == 1:
fout.write(str(points[n // 2]))
else:
fout.write(str(points[n // 2 - 1])) | IMPORT ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR 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 EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL ... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
line = sorted(list(map(int, input().split())))
a = 0
for i in range(1, n):
a += line[i] - line[0]
ind = line[0]
rasst = a
for i in range(1, n):
r = abs(line[i] - line[i - 1])
a1 = a - (n - i - 1) * r + (i - 1) * r
if a1 < rasst:
rasst = a1
ind = line[i]
a = a1
print(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_O... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | import sys
input = sys.stdin.readline
n = int(input())
points = list(map(int, input().strip().split()))
points.sort()
if n % 2 == 1:
n = n // 2
else:
n = n // 2 - 1
print(points[n]) | 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 FUNC_CALL VAR EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
s = list(map(int, input().strip().split()))
s.sort()
print(s[int(n / 2) - 1] if n % 2 == 0 else s[int(n / 2)]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
array = list(map(int, input().split()))
array.sort()
summ = sum(array)
summ2 = 0
differences = [0] * n
for i in range(n):
differences[i] = summ - (summ2 + array[i]) - summ2
summ2 += array[i]
dist = [0] * n
for i in range(n):
dist[i] = array[i] * i + differences[i] - array[i] * (n - i - 1)
m... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP LI... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
l = list(map(int, input().strip().split(" ")))
l.sort()
a = {(0): "even", (1): "odd"}
s = sum(l)
if a[n % 2] is "even":
n -= 1
sum1 = 0
for k in l:
sum1 += abs(k - l[int(n / 2)])
sum2 = 0
for k in l:
sum2 += abs(k - l[int((n + 1) / 2)])
if sum1 > sum2:
pr... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR DICT NUMBER NUMBER STRING STRING ASSIGN VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
a = list(map(int, input().split(" ")))
a.sort()
l = [0] * 333333
r = [0] * 333333
for i in range(1, n):
l[i] = l[i - 1] + i * (a[i] - a[i - 1])
for i in range(n - 2, -1, -1):
r[i] = r[i + 1] + (n - i - 1) * (a[i + 1] - a[i])
mn = 2222222222222222
ind = 0
for i in range(n):
if mn > l[i] + r[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP ... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
a = list(map(int, input().split()))
a.sort()
k = 0
r = 0
for i in range(1, n):
k = k + abs(a[i] - a[0])
if n % 2 == 1:
print(a[n // 2])
else:
for j in range(n):
r = r + abs(a[n // 2 - 1] - a[j])
for i in range(n):
k = k + abs(a[n // 2] - a[i])
if r <= k:
prin... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NU... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
X = [int(x) for x in input().split()]
X.sort()
lrdiff = n
cur = X[0]
for x in X:
if lrdiff > 0:
cur = x
lrdiff -= 2
continue
break
print(cur) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
l = sorted(list(map(int, input().split())))
h = len(l)
if h % 2 == 0:
h = int(h / 2 - 1)
else:
h = int(h // 2)
print(l[h]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
dist = 0
dict = {}
change = -n + 2
lst = list(map(int, input().split()))
lst.sort()
n = 0
i1 = lst[0]
ret = lst[0]
for i in lst[1:]:
if change >= 0:
break
dist += change * (i - i1)
ret = i
n = dist
change += 2
i1 = i
print(ret) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN ... |
You are given n points on a line with their coordinates x_{i}. Find the point x so the sum of distances to the given points is minimal.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers x_{i} ( - 10^9 ≤ x_{i} ≤ 10^9) — the coor... | n = int(input())
l = list(map(int, input().split()))
l.sort()
ls = [(0) for i in range(1, n + 1)]
ls[0] = l[0]
for i in range(1, n):
ls[i] = l[i] + ls[i - 1]
dis = 10**15 * 4
ans = 10**15
for i in range(0, n):
x = l[i] * (i + 1) - l[i] * (n - (i + 1)) - ls[i] + ls[-1] - ls[i]
if x < dis:
dis = x
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BI... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | n = int(input())
lst = [int(input()) for i in range(n)]
for el in lst:
if el >= 13:
D = 36 + 8 * (el - 5)
trio_amount = int((-6 + D**0.5) / 4) + 1
elif el >= 5:
trio_amount = 1
else:
trio_amount = 0
print(trio_amount) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EX... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | def solve():
x = int(input())
t = int((2.0 * x - 1) ** 0.5)
if t & 1:
t += 1
ans = t // 2 - 1
print(ans)
t = int(input())
for _ in range(t):
solve() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | t = int(input())
while t:
n = int(input())
a = (2 * n + 1) ** 0.5
if a.is_integer():
a = a // 2 - 1
else:
a = int(a)
a = a // 2 if a % 2 else a // 2 - 1
print(int(a))
t -= 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER IF FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FU... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | t = int(input())
for _ in range(t):
n = int(input())
x = ((2 * n - 1) ** 0.5 - 3) // 2
print(0 if x < 0 else int(x) + 1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
a = 1
ans = 0
while True:
b = a * a // 2
c = a * a - b
if a <= b <= c <= n:
ans += 1
if c > n:
break
a += 2
print(ans) | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL V... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | k = int(input())
s = str()
for i in range(k):
n = int(input())
if n < 5:
s = s + "0" + "\n"
else:
a = int((2 * n - 1) ** (1 / 2))
if a % 2 == 0:
a = a - 1
a = int(a / 2)
elif a % 2 != 0:
a = int(a / 2)
s = s + str(a) + "\n"
print(s) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR STRING STRING ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | t = int(input())
for _ in range(t):
n = int(input())
res = 0
for a in range(2, 10**9):
a2 = pow(a, 2)
if a2 <= 2 * n + 1:
if (a2 - 1) % 2 == 0:
b = (a2 - 1) // 2
if a <= b <= n:
c = a2 - b
if b <= c <= n:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NU... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | def main():
tc = int(input())
for _ in range(tc):
r = int(input())
occurance = 0
m = 2
n = 1
c = m**2 + n**2
while c <= r:
a = m**2 - n**2
b = 2 * m * n
c = m**2 + n**2
noobsc = a**2 - b
if noobsc == c:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | t = int(input())
for _ in range(t):
n = int(input())
k = int((2 * n - 1) ** 0.5)
if k % 2 == 1:
print(k // 2)
else:
print(k // 2 - 1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | from sys import stdin
nii = lambda: map(int, stdin.readline().split())
lnii = lambda: list(map(int, stdin.readline().split()))
t = int(input())
for tt in range(t):
n = int(input())
ans = 0
num = 3
while num**2 <= 2 * n - 1:
ans += 1
num += 2
print(ans) | ASSIGN 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER VAR ... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | maxn = int(400000.0)
c = []
for a in range(3, maxn, 2):
c.append((a * a + 1) // 2)
for _ in range(int(input())):
n = int(input())
lo, hi, ans = 0, len(c), 0
while lo <= hi:
mid = lo + (hi - lo) // 2
if c[mid] <= n:
ans = mid
lo = mid + 1
else:
... | ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_O... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | (T,) = map(int, input().split())
Q = []
for i in range(T):
(N,) = map(int, input().split())
Q.append((i, N))
Q.sort(key=lambda x: x[1])
a = 1
cnt = 0
R = [0] * T
now = 0
while True:
a += 1
if a**2 % 2:
b = (a**2 - 1) // 2
c = b + 1
if c > 10**9:
break
if a**2 ... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER WHILE NUMBER VAR NUMBER IF ... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | t = int(input())
while t:
t -= 1
b = int(input())
if b < 4:
print(0)
continue
b -= 1
res = int((2 * b + 1) ** 0.5)
if res % 2 == 0:
res -= 1
res = (res - 3) // 2 + 1
print(res) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER EXP... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | N = int(input())
for t in range(N):
n = int(input())
if n < 5:
print(0)
else:
print((int((2 * n - 1) ** 0.5) - 1) // 2) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER NUMBER NUMBER |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | ansl = []
for _ in range(int(input())):
n = int(input())
max2b_1 = 2 * n - 1
max_root = int(max2b_1**0.5)
ans = (max_root - 1) // 2
ansl.append(ans)
for a in ansl:
print(a) | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | t = int(input())
def abc(d):
i = 1
j = 10**5
ans = 1
while i <= j:
mid = i + (j - i) // 2
if mid * mid <= d:
ans = mid
i = mid + 1
else:
j = mid - 1
return ans
for _ in range(t):
n = int(input())
x = 2 * n - 1
x = abc(x)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN ... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | ans = []
p = []
for i in range(3, 100000, 2):
p.append(i * i // 2 + 1)
for _ in range(int(input())):
n = int(input())
if p[0] > n:
ans.append(0)
continue
L = 0
R = len(p)
while R - L > 1:
M = (L + R) // 2
if p[M] > n:
R = M
else:
L ... | ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHI... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | t = int(input())
for _ in range(t):
n = int(input())
x = int((2 * n - 1) ** 0.5)
print(max(0, (x - 1) // 2)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | for t in range(int(input())):
n = int(input())
l = 3
r = int((2 * n - 1) ** 0.5)
ans = 2
if r % 2 == 0:
r += 1
for i in range(r, l - 1, -2):
if (i**2 + 1) // 2 <= n:
ans = i
break
ans = (ans - 3) // 2 + 1
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP BIN_OP BIN_OP VAR NUMBER... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | T = int(input())
ans_ls = [0] * T
def db(*arg):
print(*arg)
for t in range(T):
N = int(input())
ans = 0
for a in range(1, int((2 * N) ** 0.5) + 10, 2):
b = a**2 // 2
c = a**2 // 2 + 1
if a <= b and c <= N:
ans += 1
ans_ls[t] = ans
for ans in ans_ls:
print(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FUNC_DEF EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER ... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | def pytho(n):
i = 3
cnt = 0
while i**2 <= 2 * n - 1:
cnt += 1
i += 2
return cnt
for i in range(int(input())):
print(pytho(int(input()))) | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | for _ in range(int(input())):
n = int(input())
real_n = 2 * n - 1
i = 3
count = 0
while i * i <= real_n:
count += 1
i += 2
print(count) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | for t in range(int(input())):
n = int(input())
x = int((2 * n + 1) ** 0.5)
y = (x + 1) // 2 - 1
if (x * x - 1) // 2 == n:
y -= 1
print(max(0, y)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VA... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | import sys
mod = 1000000007
eps = 10**-9
def main():
import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
N = int(input())
ok = 1
ng = N
mid = (ok + ng) // 2
while ng - ok > 1:
if (mid * mid + 1) // 2 <= N:
ok = mi... | IMPORT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUM... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | try:
t = int(input())
while t != 0:
n = int(input())
maxi = int((2 * n - 1) ** 0.5)
print((maxi + 1) // 2 - 1)
t -= 1
except EOFError as e:
print("") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR STRING |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | import sys
input = sys.stdin.readline
def inp():
return int(input())
def st():
return input().rstrip("\n")
def lis():
return list(map(int, input().split()))
def ma():
return map(int, input().split())
t = inp()
while t:
t -= 1
n = inp()
x = 2 * n
x = int(pow(x, 0.5))
print(... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | for _ in range(int(input())):
n = int(input())
limit = pow(2 * n - 1, 1 / 2)
ans = (limit - 1) // 2
print(int(ans)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | t = int(input())
for q in range(t):
n = int(input())
z = int(2**0.5 * (n - 0.5) ** 0.5)
if z % 2 == 0:
print(int(z / 2 - 1))
else:
print(int((z - 1) / 2)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_O... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | t = int(input())
for _ in range(t, 0, -1):
n = int(input())
cnt = 0
for a in range(3, 50000, +2):
b = (a * a - 1) / 2
c = b + 1
if c < n + 1:
cnt = cnt + 1
else:
break
print(cnt) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | T = int(input())
r = 1
while r <= T:
n = int(input())
ans = int((2 * n - 1) ** 0.5)
ans = (ans - 1) // 2
print(ans)
r += 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | import sys
input = sys.stdin.readline
def solve(arr):
n = int(input())
if arr[0][2] > n:
return 0
lo, hi = 0, len(arr) - 1
while lo < hi:
mid = (lo + hi + 1) // 2
if arr[mid][2] <= n:
lo = mid
else:
hi = mid - 1
return lo + 1
arr = []
for ... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER NUMBER VAR RETURN NUMBER ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBE... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | read = lambda: map(int, input().split())
t = int(input())
for _ in range(t):
n = int(input())
print((int((2 * n - 1) ** 0.5) - 1) // 2) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER NUMBER NUMBER |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | from sys import stdin, stdout
nmbr = lambda: int(stdin.readline())
lst = lambda: list(map(int, stdin.readline().split()))
for _ in range(nmbr()):
n = nmbr()
p = 3
ans = 0
while 1:
sq = p * p
if (sq + 1) // 2 > n:
break
ans += 1
p += 2
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VA... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | def answer(n):
l = int((2 * n - 1) ** 0.5)
c = 0
for i in range(3, l + 1, 2):
c += 1
print(c)
t = int(input())
for i in range(t):
n = int(input())
answer(n) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | def arrIn():
return list(map(int, input().split()))
def mapIn():
return map(int, input().split())
for ii in range(int(input())):
n = int(input())
c = n
a = c + c - 1
a = int(a**0.5)
if a % 2 == 0:
a -= 1
c = (a - 3) // 2 + 1
print(c) | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF ... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | def main():
num_cases = int(input())
for case_num in range(1, num_cases + 1):
solve(case_num)
def solve(case_num):
n = int(input())
sol = 0
for a in range(3, n + 1):
if a**2 > 2 * n - 1:
break
if (a**2 - 1) % 2 == 0:
sol += 1
print(sol)
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR NUMBER N... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n = int(input())
i = 3
ans = 0
while i <= n and (i * i - 1) // 2 <= n:
if (
(i * i - 1) % 2 == 0
and (i * i - 1) // 2 >= i
and i * i - (i * i - 1) // 2 <= n
):
ans +... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR IF BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER V... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | t = int(input())
while t > 0:
n = int(input())
ans = 0
i = 3
while i**2 <= 2 * n - 1:
ans += 1
i += 2
print(ans)
t -= 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | t = int(input())
for i in range(t):
n = int(input())
m = int((2 * n - 1) ** (1 / 2))
k = int((m - 1) / 2)
print(k) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | t = int(input())
for _ in range(t):
n = int(input())
ans = 0
for i in range(3, int((2 * n - 1) ** 0.5) + 1, 2):
if (i**2 - 1) % 2 == 0:
ans += 1
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER NUMBER NUMBER IF BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VA... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | for _ in range(int(input())):
n = int(input())
ans = 0
temp = int(pow(2 * n - 1, 0.5))
if temp % 2 == 0:
ans = temp // 2 - 1
else:
ans = temp // 2
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | import sys
def run_case():
n = int(input())
print(int((2 * n - 1) ** 0.5 - 1) >> 1)
t = int(input())
for _ in range(t):
run_case() | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | rn = lambda: int(input())
rns = lambda: map(int, input().split())
rl = lambda: list(map(int, input().split()))
rs = lambda: input()
YN = lambda x: print("YES") if x else print("NO")
mod = lambda x: x % (10**9 + 7)
def d(a):
d = {}
for i in a:
if i not in d:
d[i] = 0
d[i] += 1
r... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR DI... |
A Pythagorean triple is a triple of integer numbers $(a, b, c)$ such that it is possible to form a right triangle with the lengths of the first cathetus, the second cathetus and the hypotenuse equal to $a$, $b$ and $c$, respectively. An example of the Pythagorean triple is $(3, 4, 5)$.
Vasya studies the properties of ... | for _ in range(int(input())):
n = int(input())
i = 3
ans = 0
while (i**2 - 1) // 2 < n:
ans += 1
i += 2
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.