description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates (x, y), such that x_1 ≤ x ≤ x_2 and y_1 ≤ y ≤ y_2, where (x_1, y_1) and (x...
n = int(input()) arr = list(map(int, input().split())) arr.sort() x1 = arr[0] y1 = arr[n] x2 = arr[n - 1] y2 = arr[2 * n - 1] if n == 1: print(0) else: ans = (arr[n - 1] - arr[0]) * (arr[-1] - arr[n]) for i in range(1, n): ans = min((arr[n + i - 1] - arr[i]) * (arr[-1] - arr[0]), ans) print(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 ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_O...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates (x, y), such that x_1 ≤ x ≤ x_2 and y_1 ≤ y ≤ y_2, where (x_1, y_1) and (x...
n = int(input()) a = sorted(map(int, input().split())) x1, y2 = a[0], a[-1] x2, y1 = a[n - 1], a[n] m = (x1 - x2) * (y1 - y2) x1, x2 = a[0], a[-1] for i in range(1, n): y1, y2 = a[i], a[i + n - 1] m = min(m, (x1 - x2) * (y1 - y2)) print(m)
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 VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates (x, y), such that x_1 ≤ x ≤ x_2 and y_1 ≤ y ≤ y_2, where (x_1, y_1) and (x...
n = int(input()) a = sorted(list(map(int, input().split()))) res = (a[n - 1] - a[0]) * (a[-1] - a[n]) for i in range(1, n + 1): curr = (a[i + n - 1] - a[i]) * (a[-1] - a[0]) res = min(res, curr) print(res)
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 BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR BIN...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates (x, y), such that x_1 ≤ x ≤ x_2 and y_1 ≤ y ≤ y_2, where (x_1, y_1) and (x...
n = int(input()) lin = sorted(list(map(int, input().split()))) ( print( min( (lin[-1] - lin[0]) * min(lin[i + n - 1] - lin[i] for i in range(1, n)), (lin[-1] - lin[n]) * (lin[n - 1] - lin[0]), ) ) if n > 1 else print(0) )
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 EXPR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR ...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) l = input().split() l = [int(i) for i in l] l.sort() m = (l[2 * n - 1] - l[n]) * (l[n - 1] - l[0]) for i in range(1, n): if m > (l[2 * n - 1] - l[0]) * (l[i + n - 1] - l[i]): m = (l[2 * n - 1] - l[0]) * (l[i + n - 1] - l[i]) print(m)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP NUMBER VA...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) v = sorted([int(x) for x in input().split()]) ans = (v[n - 1] - v[0]) * (v[n * 2 - 1] - v[n]) for i in range(1, n + 1): ans = min(ans, (v[i + n - 1] - v[i]) * (v[2 * n - 1] - v[0])) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP ...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
import sys input = lambda: sys.stdin.readline().strip("\r\n") n = int(input()) a = sorted(list(map(int, input().split()))) print( min( (a[n - 1] - a[0]) * (a[-1] - a[n]), (a[-1] - a[0]) * min(a[n - 1 + i] - a[i] for i in range(n)), ) )
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING 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 EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
numPoints = int(input()) coord = list(map(int, input().split(" "))) coord.sort() solution = (coord[numPoints - 1] - coord[0]) * ( coord[2 * numPoints - 1] - coord[numPoints] ) for i in range(1, numPoints): new = (coord[i + numPoints - 1] - coord[i]) * (coord[2 * numPoints - 1] - coord[0]) if new < solution:...
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 BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) a = list(map(int, input().split())) a.sort() x = float("Inf") for i in range(1, n): x = min(x, a[i + n - 1] - a[i]) print(min((a[n - 1] - a[0]) * (a[-1] - a[n]), x * (a[-1] - a[0])))
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 STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BI...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
num_points = int(input()) coords = [int(x) for x in input().split()] coords.sort() width = coords[num_points - 1] - coords[0] height = coords[-1] - coords[num_points] area1 = width * height width2 = min(coords[i + num_points - 1] - coords[i] for i in range(num_points + 1)) height2 = coords[-1] - coords[0] area2 = width...
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 BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR FUNC_CALL VAR ...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) a = list(map(int, input().split())) a.sort() x1 = a[n - 1] - a[0] x2 = a[2 * n - 1] - a[n] ans = x1 * x2 for i in range(1, n): ans = min(ans, (a[2 * n - 1] - a[0]) * (a[i + n - 1] - a[i])) print(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 ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VA...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) a = sorted(map(int, input().split())) if n == 1: print(0) exit() d = (a[n - 1] - a[0]) * (a[-1] - a[n]) e = (a[-1] - a[0]) * min(a[s + n - 1] - a[s] for s in range(1, n)) print(min(d, e))
ASSIGN VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
import sys ioRead = sys.stdin.readline ioWrite = lambda x: sys.stdout.write(f"{x}\n") n = int(ioRead()) points = sorted(map(int, ioRead().split(" "))) answer = points[-1] ** 2 for c in range(n): axis_1 = [points[c], points[c + n - 1]] axis_2 = [points[n if c == 0 else 0], points[-1]] c_answer = (axis_1[1] ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST VAR VAR NUMBER...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) a = sorted(map(int, input().split())) print( min( [(a[n - 1] - a[0]) * (a[-1] - a[n])] + [((a[-1] - a[0]) * (y - x)) for x, y in zip(a, a[n - 1 :])] ) )
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 BIN_OP LIST BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMB...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) a = list(map(int, input().split())) a = sorted(a) s = (a[len(a) // 2 - 1] - a[0]) * (a[-1] - a[len(a) // 2]) s1 = s delta_x = a[-1] - a[0] for i in range(1, n): s1 = min(s1, delta_x * (a[i + len(a) // 2 - 1] - a[i])) print(s1)
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 VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER V...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) a = list(map(int, input().split())) a.sort() minn = 10000000000000 for i in range(n): minn = min(minn, a[i + n - 1] - a[i]) if n == 1: print(0) else: print(min((a[2 * n - 1] - a[0]) * minn, (a[n - 1] - a[0]) * (a[2 * n - 1] - a[n])))
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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR B...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
def solve(a, n): if n == 1: return 0 a.sort() minn = 1000000000.0 + 239 for i in range(1, n): minn = min(minn, a[i + n - 1] - a[i]) ans = min((a[2 * n - 1] - a[0]) * minn, (a[n - 1] - a[0]) * (a[2 * n - 1] - a[n])) return ans n = int(input()) a = list(map(int, input().split()))...
FUNC_DEF IF VAR NUMBER RETURN NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUM...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) s = list(map(int, input().split())) s.sort() mix = s[0] maxx = s[n - 1] miy = s[n] may = s[-1] dp = [] dp.append([maxx, mix, may, miy]) for i in range(1, n): dp.append([s[-1], s[0], s[i + n - 1], s[i]]) ans = (dp[0][0] - dp[0][1]) * (dp[0][2] - dp[0][3]) for i in dp: ans = min(ans, (i[0] - i[1]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) a = [int(i) for i in input().split()] a.sort() count = {} run = False for x in a: if x not in count: count[x] = 0 count[x] += 1 if count[x] == n: run = True best = (a[n - 1] - a[0]) * (a[2 * n - 1] - a[n]) for i in range(1, n): j = i + n - 1 val = (a[j] - a[i]) * (a[...
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 DICT ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR BIN_OP BI...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
N = int(input()) a = list(map(int, input().split())) a = sorted(a) r = 10**10 for i in range(N): if r > a[i + N - 1] - a[i]: r = a[i + N - 1] - a[i] s1 = (a[len(a) - 1] - a[0]) * r s2 = (a[N - 1] - a[0]) * (a[len(a) - 1] - a[N]) res = min(s1, s2) print(res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR BI...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
N = int(input()) Ns = list(map(int, input().strip().split())) Ns.sort() diff1 = Ns[N - 1] - Ns[0] diff2 = Ns[-1] - Ns[N] best = diff1 * diff2 diff_ends = Ns[-1] - Ns[0] for x in range(N): diff = (Ns[x + N - 1] - Ns[x]) * diff_ends if diff < best: best = diff print(best)
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 ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIG...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n1 = int(input()) a = sorted(list(map(int, input().split()))) i = 0 j = n1 - 1 mn = (a[j] - a[0]) * (a[-1] - a[j + 1]) j += 1 i += 1 ki = 0 kj = n1 - 1 while j < 2 * n1: if j == 2 * n1 - 1: n = (a[j] - a[i]) * (a[i - 1] - a[0]) elif i == 0: n = (a[j] - a[i]) * (a[-1] - a[j + 1]) else: ...
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 ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
def smallestarea(arr): arr = sorted(arr) i, j = 0, len(arr) // 2 n = len(arr) // 2 xdiff = arr[-1] - arr[0] ydiff = 100000000000.0 for i in range(1, n): ydiff = min(ydiff, arr[i + n - 1] - arr[i]) return int(min(ydiff * xdiff, (arr[n - 1] - arr[0]) * (arr[-1] - arr[n]))) input() ar...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR RETURN FUNC_CALL ...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
maxn = 200000.0 + 10 n = int(input()) a = list(map(int, input().split())) a.sort() ans = 0 ans = (a[n - 1] - a[0]) * (a[2 * n - 1] - a[n]) tmp = 0 for i in range(1, n): tmp = a[i + n - 1] - a[i] ans = min(ans, tmp * (a[2 * n - 1] - a[0])) print(ans)
ASSIGN VAR BIN_OP NUMBER NUMBER 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 BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL ...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) ls = list(map(int, input().split())) ls.sort() x = ls[len(ls) - 1] - ls[0] y = 34359738367 for i in range(1, n): tep = ls[i + n - 1] - ls[i] if tep < y: y = tep ans = x * y x = ls[n - 1] - ls[0] y = ls[len(ls) - 1] - ls[n] ans = min(ans, x * y) print(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 ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF VAR VAR ASSIGN VA...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) m = list(map(int, input().split())) m.sort() n *= 2 mi = (m[n // 2 - 1] - m[0]) * (m[n - 1] - m[n // 2]) for i in range(1, n // 2): mi = min(mi, (m[n // 2 - 1 + i] - m[i]) * (m[n - 1] - m[0])) print(mi)
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 VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUN...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) a = list(map(int, input().split())) a.sort() res = (a[n - 1] - a[0]) * (a[2 * n - 1] - a[n]) x = max(a) y = min(a) for i in range(1, n + 1): res = min(res, (x - y) * (a[i + n - 1] - a[i])) print(res)
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 BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) m = 2 * n arr = list(map(int, input().split())) arr = sorted(arr) set1_ans = (arr[n - 1] - arr[0]) * (arr[2 * n - 1] - arr[n]) set2_ans = 1e20 for i in range(1, n): a = (arr[2 * n - 1] - arr[0]) * (arr[n - 1 + i] - arr[i]) set2_ans = min(a, set2_ans) print(min(set1_ans, set2_ans))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER 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 VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
def photo(n, m): if n <= 1: return 0 m = m.split() m = [int(m[i]) for i in range(len(m))] m.sort() x1 = m[len(m) - 1] - m[0] c = m[1 : len(m) - 1] differ = [(c[i + n - 1] - c[i]) for i in range(len(c) + 2 - n - 1)] y1 = min(differ) result = [x1 * y1] x = (m[n - 1] - m[0])...
FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) a = list(map(int, input().split())) a.sort() b = [] for i in range(1, n): b.append(a[i + n - 1] - a[i]) if len(b) != 0: b = min(b) * (a[-1] - a[0]) print(min(b, (a[0] - a[n - 1]) * (a[n] - a[2 * n - 1]))) elif len(b) == 0: print((a[0] - a[n - 1]) * (a[n] - a[2 * n - 1]))
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 LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMB...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) l = sorted(list(map(int, input().split()))) ret = (l[n - 1] - l[0]) * (l[-1] - l[n]) if ret > 0: for x, y in zip(l[1:n], l[n:-1]): ret = min(ret, (y - x) * (l[-1] - l[0])) print(ret)
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 BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR VAR IF VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) a = [] a = input().split() for i in range(len(a)): a[i] = int(a[i]) a.sort() c = 0 ans = (a[n - 1] - a[0]) * (a[2 * n - 1] - a[n]) for i in range(n): ans = min(ans, (a[i + n - 1] - a[i]) * (a[2 * n - 1] - a[0])) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR FOR VAR...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
R = lambda: map(int, input().split()) n = int(input()) arr = sorted(R()) print( min( [(arr[n - 1] - arr[0]) * (arr[-1] - arr[n])] + [((arr[-1] - arr[0]) * (arr[i + n - 1] - arr[i])) for i in range(1, n)] ) if n > 1 else 0 )
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR BIN_OP LIST BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR BIN_OP BIN_OP...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
def main(): n = int(input()) l = sorted(map(int, input().split())) r = (l[n - 1] - l[0]) * (l[-1] - l[n]) if r: r = min(r, min(b - a for a, b in zip(l[1:n], l[n:-1])) * (l[-1] - l[0])) print(r) def __starting_point(): main() __starting_point()
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 BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR VAR IF VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMB...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) a = list(map(int, input().split())) a.sort() ans = (a[n - 1] - a[0]) * (a[-1] - a[n]) tmp = 0 for i in range(1, n): tmp = a[i + n - 1] - a[i] ans = min(ans, tmp * (a[-1] - a[0])) print(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 ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR A...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) a = list(map(int, input().split())) a.sort() f = min([((a[n + i - 1] - a[i]) * (a[-1] - a[0])) for i in range(n)]) print(min((a[-1] - a[n]) * (a[n - 1] - a[0]), f))
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 BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VA...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
def main(): n = int(input()) numbers = list(map(int, input().split(" "))) numbers.sort() r = [(numbers[n - 1 + x] - numbers[x]) for x in range(n + 1)] print(min([r[0] * r[-1], (numbers[-1] - numbers[0]) * min(r)])) main()
FUNC_DEF 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 VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR LIST BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) a = list(map(int, input().split())) a.sort() min_my = 10**9 + 1 cnt = a[2 * n - 1] - a[0] for i in range(1, n): new = a[i + n - 1] - a[i] if new < min_my: min_my = new print(min((a[n - 1] - a[0]) * (a[2 * n - 1] - a[n]), cnt * min_my))
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 BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
def area(x1, x2, y1, y2): return abs(x2 - x1) * abs(y2 - y1) def main(): n = int(input()) a = list(map(int, input().split())) a.sort() m = area(a[0], a[n - 1], a[n], a[-1]) for i in range(1, n): m = min(m, area(a[0], a[-1], a[i], a[n + i - 1])) print(m) main()
FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR 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 ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
def solve(N, A): if N == 1: return 0 A.sort() fh = A[0:N] lh = A[N:] best = (max(fh) - min(fh)) * (max(lh) - min(lh)) for i in range(1, N + 1): area = (A[-1] - A[0]) * (A[i + N - 1] - A[i]) best = min(best, area) return best def main(): N = int(input()) A = ...
FUNC_DEF IF VAR NUMBER RETURN NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR BIN_OP BIN...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) a = [int(v) for v in input().split()] a.sort() if n == 1: ans = 0 else: m = (a[n - 1] - a[0]) * (a[-1] - a[n]) p = a[-1] - a[0] q = p for j in range(1, n): q = min(q, a[j + n - 1] - a[j]) ans = min(m, p * q) 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 VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR A...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) point = [int(item) for item in input().split(" ")] point.sort() a = (point[n - 1] - point[0]) * (point[n + n - 1] - point[n]) b = (point[-1] - point[0]) * min(point[n - 1 + i] - point[i] for i in range(n)) print(min(a, b))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR NU...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input().strip()) d = {} a = list(map(int, input().strip().split(" "))) list.sort(a) min = (a[n - 1] - a[0]) * (a[2 * n - 1] - a[n]) s2 = 0 e2 = 2 * n - 1 width = a[e2] - a[s2] for i in range(1, n): s1 = i e1 = n + i - 1 val = (a[e1] - a[s1]) * width if val < min: min = val print(min)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN...
Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes. Strictly speaking, it makes a photo of all points with coordinates $(x, y)$, such that $x_1 \leq x \leq x_2$ and $y_1 \leq y \leq y_2$, where...
n = int(input()) A = list(map(int, input().split())) A.sort() B = [] t = A[-1] - A[0] B.append((A[n - 1] - A[0]) * (A[-1] - A[n])) for i in range(1, n): B.append(t * (-A[i] + A[i + n - 1])) print(min(B))
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 LIST ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL...
You are given a connected undirected weighted graph consisting of $n$ vertices and $m$ edges. You need to print the $k$-th smallest shortest path in this graph (paths from the vertex to itself are not counted, paths from $i$ to $j$ and from $j$ to $i$ are counted as one). More formally, if $d$ is the matrix of shorte...
import sys input = sys.stdin.readline N, M, K = list(map(int, input().split())) X = [] for _ in range(M): x, y, w = list(map(int, input().split())) X.append([min(x, y), max(x, y), w]) X = (sorted(X, key=lambda x: x[2]) + [[0, 0, 10**20] for _ in range(K)])[:K] D = {} for x, y, w in X: if x: D[x * 1...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VA...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
T = int(input()) for i1 in range(0, T): [Px, Py, Pz, Qx, Qy, Qz, dx, dy, dz, Cx, Cy, Cz, r] = [ int(i) for i in input().split() ] if (Pz == 0 and Qz == 0) and (dz == 0 and Cz == 0): a = Cx * Cx + Px * Px - r * r - 2 * Cx * Px b = 2 * (Cx * Py + Px * Cy - (Cx * Cy + Px * Py)) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN LIST VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP ...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
t = int(input()) for c in range(t): p, q, r, x, y, z, f, g, h, c, d, e, R = input().split() p = int(p) q = int(q) r = int(r) x = int(x) y = int(y) z = int(z) f = int(f) g = int(g) h = int(h) c = int(c) d = int(d) e = int(e) R = int(R) a1 = e * y - d * z + d * ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR 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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VA...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
def dot(ax, ay, az, bx, by, bz): return ax * bx + ay * by + az * bz def findRoot(a, b, c): R1 = (-b + (b * b - 4 * a * c) ** 0.5) / (2 * a) R2 = (-b - (b * b - 4 * a * c) ** 0.5) / (2 * a) return R1, R2 T = int(input()) while T > 0: T -= 1 points = input().split() for i in range(len(poin...
FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER BIN_OP NUMBER VAR RETURN VAR V...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
def StringListToNumList(L): for i in range(0, len(L), 1): L[i] = int(L[i]) return L def DotProduct(Ax, Ay, Az, Bx, By, Bz): Answer = Ax * Bx + Ay * By + Az * Bz return Answer T = int(input("")) for k in range(0, T, 1): Input = input("") Input = Input.split(" ") Px = int(Input[0])...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING A...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
def dot(a, b): r = a[0] * b[0] + a[1] * b[1] + a[2] * b[2] return r for _ in range(int(input())): x1, y1, z1, x2, y2, z2, d1, d2, d3, c1, c2, c3, r = map(float, input().split()) a = x2 - x1 b = y2 - y1 c = z2 - z1 k = x1 - c1 l = y1 - c2 m = z1 - c3 term1 = r**2 * d1**2 + r**2 ...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR ...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
def isSeen(x, y, z, Cx, Cy, Cz, CP2, R): a = x * Cx + y * Cy + z * Cz b = x * x + y * y + z * z return CP2 * b - a * a > R * R * b N = int(input()) for t in range(N): Px, Py, Pz, Qx, Qy, Qz, dx, dy, dz, Cx, Cy, Cz, R = [ int(i) for i in input().split() ] Qx = Qx - Px Qy = Qy - Py ...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR V...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
for _ in range(int(input())): x1, y1, z1, x2, y2, z2, d1, d2, d3, c1, c2, c3, r = map(float, input().split()) cc = z2 - z1 kk = x1 - c1 aa = x2 - x1 bb = y2 - y1 l = y1 - c2 mm = z1 - c3 ta1 = (d1 * l - d2 * kk) ** 2 + (d2 * mm - d3 * l) ** 2 + (d3 * kk - d1 * mm) ** 2 rr = r**2 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BI...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
def dot(a, b): r1 = a[0] * b[0] r2 = a[1] * b[1] r3 = a[2] * b[2] r = r1 + r2 + r3 return r for i in range(int(input())): x1, y1, z1, x2, y2, z2, d1, d2, d3, c1, c2, c3, r = map(float, input().split()) t1 = r**2 * d1**2 + r**2 * d2**2 + r**2 * d3**2 t2 = ( (d1 * (y1 - c2) - d2 ...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_C...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
T = int(input()) while T: px, py, pz, qx, qy, qz, dx, dy, dz, cx, cy, cz, r = map(int, input().split()) x = qx - px y = qy - py z = qz - pz a = px - cx b = py - cy c = pz - cz e = a * a + b * b + c * c x1 = r * r + a * a - e y1 = r * r + b * b - e z1 = r * r + c * c - e A...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
t = int(input()) while t: px, py, pz, qx, qy, qz, dx, dy, dz, cx, cy, cz, r = map(int, input().split()) a = px - cx b = py - cy c = pz - cz d = qx - cx e = qy - cy f = qz - cz alpha = a * d + b * e + c * f - r * r beta = a * dx + b * dy + c * dz k = a * a + b * b + c * c - r * r ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
def snek(s): a1 = x0 + s1 * s - x1 a2 = y0 + s2 * s - y1 a3 = z0 + s3 * s - z1 b = 4 * (a1 * d1 + a2 * d2 + a3 * d3) * (a1 * d1 + a2 * d2 + a3 * d3) a = 4 * (a1 * a1 + a2 * a2 + a3 * a3) v = b - a * c return v t = int(input()) for i in range(t): x1, y1, z1, x0, y0, z0, s1, s2, s3, cx, ...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
t = int(input()) while t: t -= 1 Px, Py, Pz, Qx, Qy, Qz, dx, dy, dz, cx, cy, cz, r = [ int(s) for s in input().split(" ") ] ax = Px - cx x = Qx - Px ay = Py - cy y = Qy - Py az = Pz - cz z = Qz - Pz A = ( (az * dy - ay * dz) * (az * dy - ay * dz) + (az * d...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP ...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
class point: def __init__(self, x, y, z): self.x = x self.y = y self.z = z def sub(p, q): return point(p.x - q.x, p.y - q.y, p.z - q.z) def dot(p, q): return p.x * q.x + p.y * q.y + p.z * q.z def cross(p, q): return point(p.y * q.z - p.z * q.y, p.z * q.x - p.x * q.z, p.x *...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR FUNC_DEF RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BI...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
x = int(input()) for i in range(x): arr = list(map(int, input().split())) px = arr[0] py = arr[1] pz = arr[2] qx = arr[3] - arr[0] qy = arr[4] - arr[1] qz = arr[5] - arr[2] dx = arr[6] dy = arr[7] dz = arr[8] cx = arr[9] cy = arr[10] cz = arr[11] r = arr[12] x...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER AS...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
t = int(input()) for i in range(t): px, py, pz, qx, qy, qz, dx, dy, dz, cx, cy, cz, r = [ float(x) for x in input().split() ] a = cx - px b = cy - py c = cz - pz d = qx - px e = qy - py f = qz - pz A = r * r * (dx * dx + dy * dy + dz * dz) - ( (a * dy - b * dx) ** 2 +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VA...
You are given two points $P$ and $Q$ and an opaque sphere in a three-dimensional space. The point $P$ is not moving, while $Q$ is moving in a straight line with constant velocity. You are also given a direction vector $d$ with the following meaning: the position of $Q$ at time $t$ is $Q(t) = Q(0) + d \cdot t$, where $Q...
t = int(input()) for i in range(t): lis = input() arr = list(map(int, lis.split(" "))) x1 = arr[0] y1 = arr[1] z1 = arr[2] x0 = arr[3] y0 = arr[4] z0 = arr[5] d1 = arr[6] d2 = arr[7] d3 = arr[8] x3 = arr[9] y3 = arr[10] z3 = arr[11] r = arr[12] k = (x0 - x...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR V...
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): start = 1 end = x // 2 + 1 ans = -1 while start <= end: mid = start + (end - start) // 2 square = mid * mid if square == x: ans = mid break elif square > x: ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): low = 1 high = x while low != high: mid = (low + high) // 2 if mid * mid == x: return mid elif mid * mid > x: if high == mid: return mid high = mid...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR RETURN VAR IF BIN_OP VAR VAR VAR IF VAR VAR RETURN VAR ASSIGN VAR VAR IF VAR VAR RETURN VAR ASSIGN VAR VAR RETURN NUMBER
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): s = 0 e = x while s <= e: mid = (s + e) // 2 if mid * mid == x: return mid elif mid * mid > x: e = mid - 1 else: s = mid + 1 return e
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR RETURN VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): l = 1 if x < 4: return 1 r = x mid = (r + l) // 2 while l <= r: if mid * mid > x: r = mid - 1 if mid * mid < x: l = mid + 1 if mid * mid == x: ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR RETURN VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): for i in range(1, int(x**0.5 + 1)): if i * i == x: return i y = int(x**0.5) return y
CLASS_DEF FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN VAR
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): low = 0 high = x mid = (low + high) // 2 ans = -1 while low <= high: s = mid * mid if s == x: return mid if s < x: ans = mid low = mid + 1 ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR RETURN VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): min_, max_ = 1, x result = -1 while min_ <= max_: mid = (min_ + max_) // 2 mids_square = mid * mid if mids_square > x: max_ = mid - 1 elif mids_square < x: min_, result = ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR IF VAR VAR RETURN VAR RETURN VAR
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): st = 0 en = x while st <= en: mid = (st + en) // 2 if mid * mid == x: return int(mid) elif mid * mid < x: st = int(mid + 1) else: en = int(mid - 1) ...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR RETURN FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR VAR
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution(object): def power(self, power, num): val = 1 for _ in range(power): val *= num return val def floorSqrt(self, x): n, m = 2, x left, right = 1, m while left <= right: mid = (left + right) // 2 val = self.power(n...
CLASS_DEF VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR RETURN VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NU...
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): low = 0 high = x ans = float("-inf") while low <= high: mid = low + int((high - low) / 2) mid_sq = mid * mid if mid_sq == x: return mid elif mid_sq > x: high = mid...
CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING WHILE VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR RETURN VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): if x == 0 or x == 1: return x start = 0 end = int(x // 2) ans = 0 while start <= end: mid = start + (end - start) // 2 if mid * mid == x: return mid elif mid * mid < x: ...
CLASS_DEF FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR 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 RETURN VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR ...
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): l, r = 1, x while l <= r: mid = (l + r) // 2 cur = mid * mid if cur == x: return mid elif cur < x: l = mid + 1 else: r = mid - 1 ans = int(x **...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR RETURN VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER RETURN VAR
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): if x == 0 or x == 1: return 1 s = 1 e = x ans = 0 while s <= e: m = (s + e) // 2 if m * m == x: return m elif m * m > x: e = m - 1 else: ...
CLASS_DEF FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR RETURN VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN VAR
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): for j in range(4000): if j**2 == x: return j break elif j**2 < x < (j + 1) ** 2: return j break
CLASS_DEF FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER VAR RETURN VAR IF BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER RETURN VAR
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): temp = x // 2 + 1 temp2 = 1 while temp2 <= temp: if temp2**2 <= x: temp2 += 1 else: break return temp2 - 1
CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER RETURN BIN_OP VAR NUMBER
Given an integer x, find the square root of x. If x is not a perfect square, then return floor(√x). Example 1: Input: x = 5 Output: 2 Explanation: Since, 5 is not a perfect square, floor of square_root of 5 is 2. Example 2: Input: x = 4 Output: 2 Explanation: Since, 4 is a perfect square, so its square root is 2. ...
class Solution: def floorSqrt(self, x): if x == 1 or x == 0: return x ans = 1 res = 1 while res <= x: ans += 1 res = ans * ans return ans - 1
CLASS_DEF FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN BIN_OP VAR NUMBER
You've got a list of program warning logs. Each record of a log stream is a string in this format: "2012-MM-DD HH:MM:SS:MESSAGE" (without the quotes). String "MESSAGE" consists of spaces, uppercase and lowercase English letters and characters "!", ".", ",", "?". String "2012-MM-DD" determines a correct date in the y...
n, m = list(map(int, input().split(" "))) messages = [] months = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] while True: try: s = input() messages.append(s) except: break length = len(messages) pref = [0] for i in range(1, 13): pref.append(pref[i - 1] + months[i]) got = False...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER WHILE NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER FOR VA...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) a = sorted(list(map(int, input().split()))) l = int(pow(a[-1], 1 / (n - 1))) x, y = 0, 0 for i in range(n): item = pow(l, i) x += abs(item - a[i]) for j in range(n): item1 = pow(l + 1, j) y += abs(item1 - a[j]) print(min(x, y))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR V...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
def f(mas, x): out = 0 t = 1 for i in range(len(mas)): out += abs(mas[i] - t) t *= x return out n = int(input()) mas = list(map(int, input().split())) mas.sort() a_max = mas[-1] d = f(mas, 1) w = 1 out = d while w ** (n - 1) <= d + a_max: out = min(out, f(mas, w)) w += 1 print(...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR RETURN 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 VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUM...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) arr = list(map(int, input().split())) arr.sort() m = 0 for i in arr: m += abs(i - 1) c = 2 if n > 10: while c < 20: t = 0 for i in range(n): t += abs(c**i - arr[i]) if t >= m: break if t < m: m = t c += 1 pr...
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 FOR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR ...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
def answer(n, A): A.sort() ans = 10**20 if n <= 32: x = int(A[-1] ** (1 / (n - 1))) + 3 for i in range(1, x): count = 0 for j in range(n): count += abs(A[j] - i**j) ans = min(ans, count) return ans count = 0 for i in range(n...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) a = list(map(int, input().split())) a.sort() res = sum(v - 1 for v in a) if n > 2: c = 2 while True: s = 0 v = 1 ok = True for i in range(n): s += abs(a[i] - v) v *= c if s > res: ok = False brea...
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 BIN_OP VAR NUMBER VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR B...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) z = [int(x) for x in input().split(" ")] z.sort() ans, b = abs(z[0] - 1), abs(z[0] - 1) c = int(pow(z[-1], 1 / (n - 1))) for i in range(1, n): b += abs(pow(c, i) - z[i]) c += 1 for i in range(1, n): ans += abs(pow(c, i) - z[i]) print(min(ans, b))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR N...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) l = list(map(int, input().split())) if n >= 50: s = sum(l) print(s - n) else: l.sort() mi = 1000000000000000 for i in range(1, 100001): ans = 0 x = 1 for j in range(n): ans += abs(x - l[j]) x = x * i mi = min(ans, mi) print...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VA...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) l = sorted(list(map(int, input().split()))) mx = 10 * 10**9 + 9 min_cost = float("inf") c = 1 while c ** (n - 1) < mx: s = 0 for i in range(n): s += abs(l[i] - c**i) c += 1 min_cost = min(s, min_cost) print(min_cost)
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 BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUN...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
import sys input = sys.stdin.readline I = lambda: list(map(int, input().split())) (n,) = I() l = sorted(I()) an = sum(l) - n i = 2 mx = max(l) if n == 2: an = min(an, l[0] - 1) while n > 2: po = 1 cr = 0 if i > 40000: break for j in range(n): cr += abs(l[j] - po) po *= i ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER WHILE VAR NU...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) a = [int(x) for x in input().split()] a.sort() inf = 10**18 ans = inf for k in range(1, 10**5): tmp = 0 for i in range(n): tmp = tmp + abs(a[i] - k**i) if tmp > ans: break if ans > tmp: ans = tmp 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 ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VA...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) s = input() s = s.split() a = [] for e in s: a.append(int(e)) a.sort() ans = 0 for e in a: ans += e - 1 for i in range(2, 100000): temp = 0 flag = 1 for j in range(n): if j == 0: temp += a[j] - 1 continue z = i**j if z > 10000000000000...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR V...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) a = list(map(int, input().split())) a.sort() mxN = 10**20 ans = 10**20 for i in range(1, 10**5): val, res = 1, 0 for j in range(n): if val * i > mxN: print(ans) exit() else: res += abs(val - a[j]) val *= i ans = min(ans, res) p...
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 NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR EXPR...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
def power(n, seq): seq.sort() res = float("inf") c = 1 while True: ans = 0 for i in range(n): ans += abs(c**i - seq[i]) if res > ans: res = ans c += 1 if c ** (n - 1) >= 10**18: break else: break ...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER BIN_OP NUMBER NUMBER RETURN VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) a = [int(x) for x in input().split(" ")[:n]] a.sort() result = 10000000000000 k = 1 while k ** (n - 1) <= 10**10: k += 1 for i in range(1, k): temp = 0 for j in range(0, len(a)): d = i**j temp += abs(a[j] - d) result = min(result, temp) print(result)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR NUMBER BIN_OP NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL V...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) a = list(map(int, input().split(" "))) a.sort() answer = 1e18 flag = True for i in range(1, 500000): ans = 0 for j, val in enumerate(a): x = pow(i, j) ans += abs(x - val) if x > 1e18: flag = False break answer = min(ans, answer) if not fla...
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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR IF...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) l = list(map(int, input().split())) l.sort() v = l[-1] ** (1 / (len(l) - 1)) v1 = int(v) v2 = v1 + 1 cost = 0 for i in range(len(l)): cost += abs(v1**i - l[i]) cost2 = 0 for i in range(len(l)): cost2 += abs(v2**i - l[i]) print(min(cost, cost2))
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 BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) res = sum(a) - n a.sort() for x in range(2, 100000): t = 0 for i in range(n): t += abs(pow(x, i) - a[i]) if t > res: break else: res = min(res, t) print(res)
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 BIN_OP FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VA...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
count = int(input()) numbers = list(map(int, input().split())) numbers.sort() c = int(sum(numbers) ** (1 / (count - 1))) + 1 best = 1000000000000000 counter = 0 while c > 0: counter = 0 for i in range(0, count): counter += abs(numbers[i] - c**i) if counter < best: best = counter c -= 1 p...
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 BIN_OP FUNC_CALL VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) arr = list(map(int, input().split())) arr.sort() ans = 10**18 MAX = 10**15 flag1 = False i = 0 while True: p = 0 curr = 0 for j in range(n): p = pow(i, j) if p > arr[-1]: flag1 = True curr += abs(p - arr[j]) ans = min(ans, curr) i += 1 if flag...
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 NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) arr = list(map(int, input().split())) arr2 = sorted(arr) total = float("inf") f = 1 c = 1 while f and pow(c, n - 1) < 10 * arr2[n - 1]: f = 0 temp = 0 for x in range(n): p = pow(c, x) x_x = pow(c, x) - arr2[x] temp += abs(x_x) if x_x < 0: f = 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 FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) li = list(map(int, input().split())) li.sort() t = li[-1] m = t ** (1 / (n - 1)) m = int(m) s = 0 for i in range(0, n): s += abs(m**i - li[i]) m = int(m) + 1 s1 = s s = 0 for i in range(0, n): s += abs(m**i - li[i]) print(min(s, s1))
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 VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR...
Let's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \le i \le n-1$ then $a_i = c^i$. Given a list of $n$ positive integers $a_0, a_1, ..., a_{n-1}$, you are allowed to: Reorder the list (i.e. pick a permutation $p$ of $\{0,1,...,n -...
n = int(input()) s = [int(x) for x in input().split()] s.sort() tot = 0 for i in range(0, len(s)): tot += s[i] diff = tot - n ans = tot - n for i in range(2, 100005): tt = abs(pow(i, n - 1) - s[-1]) if tt > diff: break sumu = 0 for j in range(0, n): sumu += abs(pow(i, j) - s[j]) ...
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 NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CAL...