node_ids
listlengths
4
1.4k
edge_index
listlengths
1
2.22k
text
listlengths
4
1.4k
source
stringlengths
14
427k
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 14, 2, 4, 13, 13, 4, 13, 13, 4, 13, 17, 4, 13, 0, 13, 2, 2, 4, 13, 13, 4, 13, 13, 13, 28, 13, 4, 13, 4, 13, 13, 2, 4, 13, 13, 17, 0, 13, ...
[ [ 87, 2 ], [ 90, 8 ], [ 91, 23 ], [ 91, 26 ], [ 93, 33 ], [ 91, 38 ], [ 91, 41 ], [ 88, 42 ], [ 45, 44 ], [ 91, 49 ], [ 91, 53 ], [ 99, 56 ], [ 60, 59 ], [ ...
[ "n = int(input())\n# n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\n# abc = [int(input()) for i in range(5)]\nif min(a) == max(a):\n print(0)\n exit()\n\nans = (max(a)*max(a))*n\nfor i in range(min(a), max(a)+1):\n total = 0\n for j in range(n):\n total += (a[j]-i)*(...
n = int(input()) # n, k = list(map(int, input().split())) a = list(map(int, input().split())) # abc = [int(input()) for i in range(5)] if min(a) == max(a): print(0) exit() ans = (max(a)*max(a))*n for i in range(min(a), max(a)+1): total = 0 for j in range(n): total += (a[j]-i)*(a[j]-i) if to...
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 13, 17, 0, 13, 2, 13, 13, 0, 13, 2, 13, 17, 0, 13, 2, 2, 2, 13, 2, 13, 17, 2, 2, 17, ...
[ [ 91, 2 ], [ 100, 8 ], [ 85, 20 ], [ 101, 23 ], [ 103, 25 ], [ 29, 28 ], [ 101, 28 ], [ 94, 31 ], [ 28, 33 ], [ 106, 36 ], [ 86, 38 ], [ 92, 39 ], [ 82, 41 ], [...
[ "n = int(input())\na = list(map(int,input().split()))\nasum = sum(a)\na2sum = 0\nfor m in a:\n a2sum += m**2\nx1 = asum//n\nx2 = x1+1\nz1 = n*x1**2-2*asum*x1+a2sum\nz2 = n*x2**2-2*asum*x2+a2sum\nprint(min(z1,z2))", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = list(map(int,...
n = int(input()) a = list(map(int,input().split())) asum = sum(a) a2sum = 0 for m in a: a2sum += m**2 x1 = asum//n x2 = x1+1 z1 = n*x1**2-2*asum*x1+a2sum z2 = n*x2**2-2*asum*x2+a2sum print(min(z1,z2))
[ 7, 15, 13, 15, 13, 15, 13, 15, 12, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 17, 29, 13, 23, 13, 12, 13, 0, 13, 4, 18, 4, 13, 2, 4, 13, 13, 13, 13, 4, 13, 17, 0, 13, 13, 0, 13, 17, 28, 13, 13, 0, 13, 4, ...
[ [ 12, 11 ], [ 15, 14 ], [ 18, 17 ], [ 25, 17 ], [ 21, 20 ], [ 20, 23 ], [ 14, 23 ], [ 11, 23 ], [ 25, 25 ], [ 30, 29 ], [ 65, 37 ], [ 63, 38 ], [ 45, 44 ], [ ...
[ "# -*- coding: utf-8 -*-\n\nimport io\nimport sys\nimport math\nfrom decimal import Decimal, ROUND_HALF_UP\n\n\ndef format_multi_line_answer(lst):\n ans = \"\"\n ans += f\"{len(lst)}\\n\" # Line count\n for y in lst:\n ans += f\"{y}\\n\"\n return ans\n\ndef solve(n,n_lst):\n # implement proce...
# -*- coding: utf-8 -*- import io import sys import math from decimal import Decimal, ROUND_HALF_UP def format_multi_line_answer(lst): ans = "" ans += f"{len(lst)}\n" # Line count for y in lst: ans += f"{y}\n" return ans def solve(n,n_lst): # implement process #中央値を取り、四捨五入する ...
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 39, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, ...
[ [ 52, 2 ], [ 55, 8 ], [ 64, 20 ], [ 24, 23 ], [ 61, 29 ], [ 33, 32 ], [ 56, 32 ], [ 58, 35 ], [ 32, 38 ], [ 23, 39 ], [ 65, 43 ], [ 59, 45 ], [ 62, 45 ], [ ...
[ "N = int(input())\na = list(map(int, input().split()))\nb = []\nfor i in range(-100, 101):\n\tt = 0\n\tfor j in a:\n\t\tt += (j - i) ** 2\n\tb.append(t)\nprint(min(b))", "N = int(input())", "N", "int(input())", "int", "input()", "input", "a = list(map(int, input().split()))", "a", "list(map(int, i...
N = int(input()) a = list(map(int, input().split())) b = [] for i in range(-100, 101): t = 0 for j in a: t += (j - i) ** 2 b.append(t) print(min(b))
[ 7, 0, 13, 4, 13, 17, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 13, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, ...
[ [ 71, 2 ], [ 62, 7 ], [ 59, 13 ], [ 68, 25 ], [ 72, 26 ], [ 29, 28 ], [ 65, 34 ], [ 38, 37 ], [ 60, 37 ], [ 56, 40 ], [ 37, 43 ], [ 28, 44 ], [ 74, 47 ], [ ...
[ "inf = float('inf')\nn = int(input())\narr = list(map(int, input().split()))\n\nmin_cost = inf\nfor i in range(-100, 101):\n cost = 0\n for j in arr:\n cost += (j - i)**2\n min_cost = min(min_cost, cost)\nprint(min_cost)", "inf = float('inf')", "inf", "float('inf')", "float", "'inf'", "n...
inf = float('inf') n = int(input()) arr = list(map(int, input().split())) min_cost = inf for i in range(-100, 101): cost = 0 for j in arr: cost += (j - i)**2 min_cost = min(min_cost, cost) print(min_cost)
[ 7, 0, 13, 2, 17, 17, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 2, 13, 10, ...
[ [ 53, 2 ], [ 56, 7 ], [ 59, 13 ], [ 26, 25 ], [ 68, 31 ], [ 35, 34 ], [ 60, 34 ], [ 62, 37 ], [ 34, 40 ], [ 25, 41 ], [ 65, 44 ], [ 54, 47 ], [ 66, 47 ], [ ...
[ "ans = 10 ** 9\nn = int(input())\nA = list(map(int,input().split()))\nfor i in range(-100,101):\n X = 0\n for j in A:\n X += (j - i) ** 2\n ans = min(ans,X)\nprint(ans)", "ans = 10 ** 9", "ans", "10 ** 9", "10", "9", "n = int(input())", "n", "int(input())", "int", "input()", "input", "...
ans = 10 ** 9 n = int(input()) A = list(map(int,input().split())) for i in range(-100,101): X = 0 for j in A: X += (j - i) ** 2 ans = min(ans,X) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 2, 17, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 13, 2, 2, 18, 13, 13...
[ [ 69, 2 ], [ 75, 8 ], [ 87, 20 ], [ 76, 23 ], [ 84, 25 ], [ 76, 28 ], [ 90, 30 ], [ 34, 33 ], [ 78, 41 ], [ 45, 44 ], [ 70, 47 ], [ 72, 49 ], [ 79, 51 ], [ ...
[ "n = int(input())\narr = list(map(int, input().split()))\n\nmini = min(arr)\nmaxi = max(arr)\ncost = 10000000000\n\nfor i in range(-100, 101+1):\n add = 0\n for j in range(n):\n add = add + (arr[j] - i)**2\n cost = min(cost, add)\nprint(cost)", "n = int(input())", "n", "int(input())", "int",...
n = int(input()) arr = list(map(int, input().split())) mini = min(arr) maxi = max(arr) cost = 10000000000 for i in range(-100, 101+1): add = 0 for j in range(n): add = add + (arr[j] - i)**2 cost = min(cost, add) print(cost)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 2, 13, 10, 4, 13, ...
[ [ 66, 2 ], [ 57, 8 ], [ 60, 20 ], [ 24, 23 ], [ 63, 29 ], [ 33, 32 ], [ 58, 32 ], [ 51, 35 ], [ 23, 38 ], [ 32, 39 ], [ 54, 42 ], [ 61, 45 ], [ 55, 45 ], [ ...
[ "N = int(input())\na = list(map(int,input().split()))\n\n\nans = 1e10\nfor i in range(-100,101):\n tmp = 0\n for j in a:\n tmp += (i-j)**2\n ans = min(ans,tmp)\n\nprint(ans)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "a = list(map(int,input().split()))", "a...
N = int(input()) a = list(map(int,input().split())) ans = 1e10 for i in range(-100,101): tmp = 0 for j in a: tmp += (i-j)**2 ans = min(ans,tmp) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 2, 4, 13, 13, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 13, 2, 2, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4...
[ [ 53, 2 ], [ 56, 8 ], [ 47, 20 ], [ 57, 26 ], [ 54, 27 ], [ 50, 29 ], [ 33, 32 ], [ 57, 32 ], [ 59, 35 ], [ 51, 37 ], [ 60, 37 ], [ 32, 40 ], [ 48, 41 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\nmean = round(sum(a) / n)\nans = 0\nfor i in a:\n ans = ans + (i-mean)**2\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "li...
n = int(input()) a = list(map(int, input().split())) mean = round(sum(a) / n) ans = 0 for i in a: ans = ans + (i-mean)**2 print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 4, 13, 12, 4, 13, 13, 23, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 2, 17, 13, 28, 13, 4, 13, 13, 2, 13, 17, 17, 0, 13, 17, 28, 13, 13, ...
[ [ 76, 2 ], [ 82, 8 ], [ 79, 15 ], [ 83, 25 ], [ 94, 27 ], [ 80, 30 ], [ 100, 32 ], [ 80, 35 ], [ 88, 37 ], [ 77, 40 ], [ 43, 42 ], [ 101, 45 ], [ 95, 47 ], [ ...
[ "N = int(input())\nb = input().split()\na = list(map((lambda x: int(x)), b))\n\n_max = max(a)\n_min = min(a)\nresult = 20000 * N\n\nfor i in range(_min,_max+1,1):\n _result = 0\n for j in a:\n _result += (i - int(j))**2\n if _result <= result:\n result = _result\nprint(result)", "N = int(input())", "N"...
N = int(input()) b = input().split() a = list(map((lambda x: int(x)), b)) _max = max(a) _min = min(a) result = 20000 * N for i in range(_min,_max+1,1): _result = 0 for j in a: _result += (i - int(j))**2 if _result <= result: result = _result print(result)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 14, 2, 2, 4, 13, 13, 13, 17, 0, 13, 2, 4, 13, 13, 13, 28, 13, 4, 13, 13, 0, 13, 2, 2, 13, 18, 13, 13, 17, 4, 13, 13, 0, 13, 2,...
[ [ 113, 2 ], [ 110, 8 ], [ 128, 20 ], [ 111, 27 ], [ 114, 28 ], [ 122, 31 ], [ 111, 35 ], [ 114, 36 ], [ 39, 38 ], [ 114, 41 ], [ 131, 43 ], [ 123, 46 ], [ 111, 48 ...
[ "N = int(input())\nA = list(map(int, input().split()))\nans = 0\n\nif sum(A)%N == 0:\n x = sum(A)//N\n for i in range(N):\n ans += (x-A[i])**2\n print(ans)\nelse:\n x = sum(A)//N\n b = sum(A)//N+1\n if sum(A)/N - x > b - sum(A)/N:\n x = b\n for i in range(N):\n ans += (x-A[...
N = int(input()) A = list(map(int, input().split())) ans = 0 if sum(A)%N == 0: x = sum(A)//N for i in range(N): ans += (x-A[i])**2 print(ans) else: x = sum(A)//N b = sum(A)//N+1 if sum(A)/N - x > b - sum(A)/N: x = b for i in range(N): ans += (x-A[i])**2 prin...
[ 7, 15, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 18, 13, 13, 2, 4, 13, 13, 13, 0, 13, 4, 18, 13, 13, 2, 4, 13, 13, 13, 41, 28, 13, 13, 4, 2, 2, 13, 13...
[ [ 87, 4 ], [ 102, 10 ], [ 90, 22 ], [ 103, 25 ], [ 99, 27 ], [ 103, 35 ], [ 91, 36 ], [ 88, 36 ], [ 93, 38 ], [ 103, 46 ], [ 91, 47 ], [ 88, 47 ], [ 51, 50 ], [...
[ "import numpy as np\nn = int(input())\na = list(map(int, input().split()))\nn = len(a)\nMean1 = np.floor(sum(a) / n)\nMean2 = np.ceil(sum(a) / n)\nsum1 = sum([(x-Mean1)**2 for x in a])\nsum2 = sum([(x-Mean2)**2 for x in a])\nprint(int(min(sum1, sum2)))", "import numpy as np", "numpy", "n = int(input())", "n...
import numpy as np n = int(input()) a = list(map(int, input().split())) n = len(a) Mean1 = np.floor(sum(a) / n) Mean2 = np.ceil(sum(a) / n) sum1 = sum([(x-Mean1)**2 for x in a]) sum2 = sum([(x-Mean2)**2 for x in a]) print(int(min(sum1, sum2)))
[ 7, 15, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 2, 2, 4, 13, 13, 13, 2, 4, 18, 13, 13, 4, 13, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17...
[ [ 73, 4 ], [ 67, 10 ], [ 70, 22 ], [ 68, 29 ], [ 74, 30 ], [ 68, 38 ], [ 61, 41 ], [ 45, 44 ], [ 74, 47 ], [ 64, 49 ], [ 68, 53 ], [ 44, 54 ], [ 71, 55 ], [ ...
[ "import numpy as np\nn = int(input())\na = list(map(int, input().split()))\nmean = int(sum(a) / n + np.sign(sum(a)) * 0.5)\n#print(mean)\nans = 0\nfor i in range(n):\n ans += (a[i] - mean) ** 2\n\nprint(ans)", "import numpy as np", "numpy", "n = int(input())", "n", "int(input())", "int", "input()",...
import numpy as np n = int(input()) a = list(map(int, input().split())) mean = int(sum(a) / n + np.sign(sum(a)) * 0.5) #print(mean) ans = 0 for i in range(n): ans += (a[i] - mean) ** 2 print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 39, 17, 17, 28, 13, 13, 28, 13, 4, 13, 17, 17, 0, 18, 13, 2, 13, 17, 2, 2, 13, 13, 17, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, ...
[ [ 51, 2 ], [ 54, 8 ], [ 57, 20 ], [ 27, 26 ], [ 55, 26 ], [ 30, 29 ], [ 40, 35 ], [ 58, 36 ], [ 29, 38 ], [ 26, 42 ], [ 29, 43 ], [ 58, 49 ], [ 51, 52 ], [ ...
[ "n=int(input())\nA=list(map(int,input().split()))\nans = [0]*201\nfor a in A:\n for i in range(-100,101):\n ans[i+100] += (a-i)**2\nprint(min(ans))", "n=int(input())", "n", "int(input())", "int", "input()", "input", "A=list(map(int,input().split()))", "A", "list(map(int,input().split()))", "...
n=int(input()) A=list(map(int,input().split())) ans = [0]*201 for a in A: for i in range(-100,101): ans[i+100] += (a-i)**2 print(min(ans))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 17, 17, 28, 13, 4, 13, 17, 17, 41, 28, 13, 13, 4, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 4, 1...
[ [ 55, 2 ], [ 67, 8 ], [ 61, 20 ], [ 26, 25 ], [ 33, 32 ], [ 68, 32 ], [ 25, 37 ], [ 32, 38 ], [ 64, 41 ], [ 58, 46 ], [ 62, 49 ], [ 59, 49 ], [ 65, 50 ], [ ...
[ "N=int(input())\na = list(map(int,input().split()))\nres = 10**18\nfor val in range(-100,101):\n tmp = sum([(val-val2)**2 for val2 in a])\n res = min(res,tmp)\nprint(res)", "N=int(input())", "N", "int(input())", "int", "input()", "input", "a = list(map(int,input().split()))", "a", "list(map(...
N=int(input()) a = list(map(int,input().split())) res = 10**18 for val in range(-100,101): tmp = sum([(val-val2)**2 for val2 in a]) res = min(res,tmp) print(res)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 2, 4, 13, 13, 13, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 1...
[ [ 48, 2 ], [ 57, 8 ], [ 51, 20 ], [ 58, 26 ], [ 49, 27 ], [ 60, 28 ], [ 32, 31 ], [ 49, 34 ], [ 54, 36 ], [ 58, 40 ], [ 31, 41 ], [ 52, 42 ], [ 55, 46 ], [ ...
[ "N = int(input())\nA = list(map(int,input().split()))\nX,out = round(sum(A)/N),0\nfor i in range(N):\n out += (A[i]-X)**2\nprint(out)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = list(map(int,input().split()))", "A", "list(map(int,input().split()))", "list", "m...
N = int(input()) A = list(map(int,input().split())) X,out = round(sum(A)/N),0 for i in range(N): out += (A[i]-X)**2 print(out)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 17, 28, 13, 4, 13, 13, 2, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13...
[ [ 77, 2 ], [ 71, 8 ], [ 80, 20 ], [ 72, 23 ], [ 83, 25 ], [ 72, 28 ], [ 65, 30 ], [ 36, 35 ], [ 81, 38 ], [ 84, 40 ], [ 74, 43 ], [ 47, 46 ], [ 72, 46 ], [ ...
[ "N = int(input())\nA = list(map(int,input().split()))\n\nmin_a = min(A)\nmax_a = max(A)\n\nans = float(\"inf\")\nfor i in range(min_a, max_a+1):\n tmp = 0\n for j in A:\n tmp += (i - j) ** 2\n ans = min(ans, tmp)\n \nprint(ans)", "N = int(input())", "N", "int(input())", "int", "input()", "input",...
N = int(input()) A = list(map(int,input().split())) min_a = min(A) max_a = max(A) ans = float("inf") for i in range(min_a, max_a+1): tmp = 0 for j in A: tmp += (i - j) ** 2 ans = min(ans, tmp) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 18, 13, 13, 0, 13, 2, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 13, 0, 13, 17, 28, 13, ...
[ [ 93, 2 ], [ 78, 8 ], [ 84, 20 ], [ 24, 23 ], [ 94, 26 ], [ 102, 28 ], [ 79, 30 ], [ 23, 31 ], [ 105, 33 ], [ 103, 35 ], [ 85, 35 ], [ 94, 36 ], [ 87, 38 ], [ ...
[ "N=int(input())\nList = list(map(int, input().split()))\nsumS = 0\nfor i in range(N):\n sumS +=List[i]\ntrial = sumS // N\nmid = 0\nres = 10000000\nfor i in range(N):\n trial += i\n mid = 0 \n for j in range(N):\n mid += (trial - List[j])**2\n res = min(res, mid)\nprint(res)", "N=int(input())", "N", "...
N=int(input()) List = list(map(int, input().split())) sumS = 0 for i in range(N): sumS +=List[i] trial = sumS // N mid = 0 res = 10000000 for i in range(N): trial += i mid = 0 for j in range(N): mid += (trial - List[j])**2 res = min(res, mid) print(res)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 2, 4, 13, 13, 13, 0, 13, 4, 13, 2, 4, 13, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17,...
[ [ 94, 2 ], [ 73, 8 ], [ 76, 20 ], [ 74, 26 ], [ 95, 27 ], [ 91, 29 ], [ 74, 35 ], [ 95, 36 ], [ 79, 38 ], [ 88, 41 ], [ 45, 44 ], [ 95, 47 ], [ 85, 49 ], [ ...
[ "n = int(input())\na = list(map(int,input().split()))\n\na_u = round(sum(a)/n)\na_d = int(sum(a)/n)\nans_u = 0\nans_d = 0\nfor i in range(n):\n ans_u += (a[i]-a_u)**2\n ans_d += (a[i]-a_d)**2\nprint(min(ans_u,ans_d))\n#print(round(-2.5),int(-2.5))", "n = int(input())", "n", "int(input())", "int", "i...
n = int(input()) a = list(map(int,input().split())) a_u = round(sum(a)/n) a_d = int(sum(a)/n) ans_u = 0 ans_d = 0 for i in range(n): ans_u += (a[i]-a_u)**2 ans_d += (a[i]-a_d)**2 print(min(ans_u,ans_d)) #print(round(-2.5),int(-2.5))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 12, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 29, 13, 23, 13, 23, 13, 12, 13, 14, 40, 2, 13, 13, 17, 29, 4, 13, 4, 13, 13, 13, 4,...
[ [ 141, 2 ], [ 138, 8 ], [ 23, 22 ], [ 26, 25 ], [ 37, 25 ], [ 29, 28 ], [ 39, 31 ], [ 25, 32 ], [ 28, 35 ], [ 22, 35 ], [ 37, 37 ], [ 39, 39 ], [ 95, 45 ], [ ...
[ "N=int(input())\na=list(map(int,input().split()))\ndef change(a,x):\n sum=0\n for i in a:\n sum+=(x-i)**2\n return sum\n\ndef binarysearch(left,right,a):\n if right-left<=1:\n return min(change(a,left),change(a,right))\n else:\n center=left+(right-left)//2\n if change(a,ce...
N=int(input()) a=list(map(int,input().split())) def change(a,x): sum=0 for i in a: sum+=(x-i)**2 return sum def binarysearch(left,right,a): if right-left<=1: return min(change(a,left),change(a,right)) else: center=left+(right-left)//2 if change(a,center)<=change(a,ce...
[ 7, 15, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 18, 13, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 4, 13, 4, 18, 13, 13, 2, 2, 13, 13, 17, 13, 4, 13, 13, 10, 4, 13, ...
[ [ 60, 4 ], [ 57, 10 ], [ 63, 26 ], [ 32, 31 ], [ 54, 37 ], [ 58, 46 ], [ 31, 47 ], [ 64, 49 ], [ 55, 49 ], [ 55, 52 ], [ 64, 52 ], [ 54, 55 ], [ 57, 58 ], [ ...
[ "import numpy as np\nn = int(input())\na = np.asarray(list(map(int, input().split())))\nm = float('inf')\n\nfor i in range(-100, 101):\n m = min(np.sum((a-i)**2), m)\nprint(m)", "import numpy as np", "numpy", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = np.asarray(li...
import numpy as np n = int(input()) a = np.asarray(list(map(int, input().split()))) m = float('inf') for i in range(-100, 101): m = min(np.sum((a-i)**2), m) print(m)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 17, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 13, 18, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, ...
[ [ 57, 2 ], [ 63, 8 ], [ 66, 20 ], [ 26, 25 ], [ 72, 31 ], [ 35, 34 ], [ 58, 37 ], [ 69, 39 ], [ 25, 42 ], [ 64, 44 ], [ 34, 45 ], [ 60, 48 ], [ 67, 51 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\n\nans = 10**9\nfor num in range(-100, 101):\n temp = 0\n for i in range(n):\n temp += (num - a[i])**2\n ans = min(ans, temp)\n\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = list(map(int, in...
n = int(input()) a = list(map(int, input().split())) ans = 10**9 for num in range(-100, 101): temp = 0 for i in range(n): temp += (num - a[i])**2 ans = min(ans, temp) print(ans)
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 39, 28, 13, 4, 13, 4, 13, 13, 2, 4, 13, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 4, 18, 13, 13, 13, ...
[ [ 62, 2 ], [ 68, 6 ], [ 65, 18 ], [ 22, 21 ], [ 69, 26 ], [ 69, 30 ], [ 74, 33 ], [ 37, 36 ], [ 69, 41 ], [ 71, 43 ], [ 69, 47 ], [ 36, 48 ], [ 21, 49 ], [ ...
[ "N = input()\nlist1 = list(map(int,input().split()))\nlist2 = []\nfor i in range(min(list1),max(list1)+1):\n a = 0\n for j in range(len(list1)):\n a += (list1[j] - i)**2\n list2.append(a)\nprint(min(list2))", "N = input()", "N", "input()", "input", "list1 = list(map(int,input().split()))",...
N = input() list1 = list(map(int,input().split())) list2 = [] for i in range(min(list1),max(list1)+1): a = 0 for j in range(len(list1)): a += (list1[j] - i)**2 list2.append(a) print(min(list2))
[ 7, 0, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 4, 13, 2, 4, 13, 13, 4, 13, 13, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 13, 4, 13, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10...
[ [ 54, 2 ], [ 48, 6 ], [ 60, 18 ], [ 57, 21 ], [ 49, 27 ], [ 49, 30 ], [ 33, 32 ], [ 49, 32 ], [ 51, 35 ], [ 32, 38 ], [ 58, 39 ], [ 63, 42 ], [ 52, 43 ], [ ...
[ "s=input();a=list(map(int,input().split()));ans=0\nmean=round(sum(a)/len(a))\n\nfor i in a:\n p=(i-mean)**2\n ans+=p\n \nprint(ans)", "s=input()", "s", "input()", "input", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "...
s=input();a=list(map(int,input().split()));ans=0 mean=round(sum(a)/len(a)) for i in a: p=(i-mean)**2 ans+=p print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 17, 28, 13, 4, 13, 17, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 4, 13, ...
[ [ 63, 2 ], [ 69, 8 ], [ 66, 20 ], [ 26, 25 ], [ 57, 32 ], [ 36, 35 ], [ 70, 35 ], [ 60, 38 ], [ 35, 41 ], [ 25, 42 ], [ 54, 45 ], [ 61, 48 ], [ 58, 48 ], [ ...
[ "n = int(input())\nA = list(map(int, input().split()))\n\nans = float('inf')\nfor x in range(-100, 101, 1):\n c = 0\n for a in A:\n c += (a - x) ** 2\n ans = min(c, ans)\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "A = list(map(int, input().split()...
n = int(input()) A = list(map(int, input().split())) ans = float('inf') for x in range(-100, 101, 1): c = 0 for a in A: c += (a - x) ** 2 ans = min(c, ans) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 2, 4, 13, 13, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, 13, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 1...
[ [ 57, 2 ], [ 51, 8 ], [ 48, 20 ], [ 52, 26 ], [ 58, 27 ], [ 54, 29 ], [ 33, 32 ], [ 52, 32 ], [ 45, 35 ], [ 32, 38 ], [ 49, 39 ], [ 46, 43 ], [ 55, 43 ], [ ...
[ "N = int(input())\nlst = list(map(int, input().split()))\navg = round(sum(lst) / N)\n\nresult = 0\nfor i in lst:\n result += (i - avg)**2\n\nprint(result)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "lst = list(map(int, input().split()))", "lst", "list(map(int, input()...
N = int(input()) lst = list(map(int, input().split())) avg = round(sum(lst) / N) result = 0 for i in lst: result += (i - avg)**2 print(result)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 4, 13, 10, ...
[ [ 53, 2 ], [ 65, 8 ], [ 56, 20 ], [ 26, 25 ], [ 68, 31 ], [ 35, 34 ], [ 66, 34 ], [ 59, 37 ], [ 34, 40 ], [ 25, 41 ], [ 62, 44 ], [ 57, 47 ], [ 63, 47 ], [ ...
[ "n = int(input())\nA = list(map(int, input().split()))\nmin_cost = float(\"inf\")\nfor num in range(-100, 101):\n cost = 0\n for a in A:\n cost += (a - num) ** 2\n min_cost = min(min_cost, cost)\nprint(min_cost)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "A =...
n = int(input()) A = list(map(int, input().split())) min_cost = float("inf") for num in range(-100, 101): cost = 0 for a in A: cost += (a - num) ** 2 min_cost = min(min_cost, cost) print(min_cost)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 0, 13, 2, 13, 17, 0, 13, 4, 13, 17, 28, 13, 39, 13, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4...
[ [ 67, 2 ], [ 82, 8 ], [ 73, 20 ], [ 83, 24 ], [ 68, 25 ], [ 85, 27 ], [ 74, 29 ], [ 76, 32 ], [ 38, 37 ], [ 70, 42 ], [ 46, 45 ], [ 83, 45 ], [ 64, 48 ], [ ...
[ "n = int(input())\na_ls = list(map(int, input().split()))\nsmall = sum(a_ls)//n\nbig = small + 1\nans = float('inf')\nfor goal in [big, small]:\n Sum = 0\n for a in a_ls:\n Sum += (goal - a) ** 2\n ans = min(ans, Sum)\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()",...
n = int(input()) a_ls = list(map(int, input().split())) small = sum(a_ls)//n big = small + 1 ans = float('inf') for goal in [big, small]: Sum = 0 for a in a_ls: Sum += (goal - a) ** 2 ans = min(ans, Sum) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 41, 28, 13, 4, 13, 17, 4, 39, 0, 13, 13, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 13, 2, 2, 13, 18, 13, 13, 17, 0, ...
[ [ 77, 2 ], [ 80, 8 ], [ 22, 21 ], [ 68, 28 ], [ 32, 31 ], [ 74, 37 ], [ 41, 40 ], [ 78, 43 ], [ 71, 45 ], [ 75, 47 ], [ 72, 47 ], [ 31, 50 ], [ 81, 52 ], [ ...
[ "N = int(input())\nl = list(map(int,input().split()))\nl_ans = [[] for _ in range(201)]\n\nfor i in range(-100,101):\n sum = 0\n\n for j in range(N):\n sum = sum + (i-l[j])**2\n\n l_ans[i+100] = sum\n\nprint(min(l_ans))", "N = int(input())", "N", "int(input())", "int", "input()", "input"...
N = int(input()) l = list(map(int,input().split())) l_ans = [[] for _ in range(201)] for i in range(-100,101): sum = 0 for j in range(N): sum = sum + (i-l[j])**2 l_ans[i+100] = sum print(min(l_ans))
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 12, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 18, 4, 13, 13, 13, 0, 13, 2, 17, 17, 28, 13, 4, 13, 4, 13, 13, 2, 4, 13, 13, 17, 41, 28, 13, 13, 4, 2, ...
[ [ 81, 4 ], [ 14, 13 ], [ 82, 17 ], [ 20, 19 ], [ 82, 30 ], [ 35, 34 ], [ 40, 39 ], [ 19, 44 ], [ 19, 48 ], [ 53, 52 ], [ 19, 52 ], [ 52, 57 ], [ 39, 58 ], [ ...
[ "import sys\nreadline = sys.stdin.readline\n\ndef main():\n N = int(readline())\n A = list(map(int, readline().rstrip().split()))\n ans = 10 ** 7\n for i in range(min(A), max(A)+1):\n c = sum([(a-i)**2 for a in A])\n ans = min(ans, c)\n \n print(ans)\n\n\nif __name__ == '__main__':\n...
import sys readline = sys.stdin.readline def main(): N = int(readline()) A = list(map(int, readline().rstrip().split())) ans = 10 ** 7 for i in range(min(A), max(A)+1): c = sum([(a-i)**2 for a in A]) ans = min(ans, c) print(ans) if __name__ == '__main__': main()
[ 7, 0, 13, 4, 18, 4, 18, 4, 13, 17, 13, 13, 31, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 4, 13, 13, 13, 0, 13, 39, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 18, 13, 13, 13, 0, 13, 2, 13, 17, ...
[ [ 94, 2 ], [ 94, 12 ], [ 76, 15 ], [ 95, 18 ], [ 85, 20 ], [ 82, 28 ], [ 32, 31 ], [ 88, 37 ], [ 41, 40 ], [ 77, 43 ], [ 95, 43 ], [ 97, 45 ], [ 86, 48 ], [ ...
[ "N,*a = open(0).read().split()\n\nN=int(N)\n\nlist1=list(map(int,a))\n\n#print(N)\n\n#print(list1)\n\na=[]\n\nfor i in range(-100,101):\n int1=0\n for n in range(N):\n x = (list1[n]-i)\n y = x**2\n int1+=y\n if n==N-1:\n a.append(int1)\n \n#print(a)\n\n#print(max(a))\...
N,*a = open(0).read().split() N=int(N) list1=list(map(int,a)) #print(N) #print(list1) a=[] for i in range(-100,101): int1=0 for n in range(N): x = (list1[n]-i) y = x**2 int1+=y if n==N-1: a.append(int1) #print(a) #print(max(a)) print(min(a))
[ 7, 15, 13, 13, 13, 0, 13, 18, 18, 13, 13, 13, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 4, 18, 13, 13, 4, 18, 13, 13, 13, 0, 13, 4, 18, 13, 13, 4, 18, 13, 13, 13, 41...
[ [ 98, 6 ], [ 110, 13 ], [ 99, 17 ], [ 21, 20 ], [ 99, 24 ], [ 20, 29 ], [ 92, 31 ], [ 101, 34 ], [ 93, 43 ], [ 95, 45 ], [ 93, 54 ], [ 58, 57 ], [ 93, 57 ], [ ...
[ "# -*- coding:utf-8 -*-\nimport sys,math,statistics\ninput = sys.stdin.readline\nn = int(input())\na = [int(_) for _ in input().split()]\nc1 = math.floor(statistics.mean(a))\nc2 = math.ceil(statistics.mean(a))\na1 = sum([(i-c1)**2 for i in a])\na2 = sum([(i-c2)**2 for i in a])\nprint(min(a1,a2))", "import sys,mat...
# -*- coding:utf-8 -*- import sys,math,statistics input = sys.stdin.readline n = int(input()) a = [int(_) for _ in input().split()] c1 = math.floor(statistics.mean(a)) c2 = math.ceil(statistics.mean(a)) a1 = sum([(i-c1)**2 for i in a]) a2 = sum([(i-c2)**2 for i in a]) print(min(a1,a2))
[ 7, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 4, 13, 13, 0, 13, 2, 13, 13, 0, 13, 2, 2, 2, 13, 13, 17, 13, 0, 13, 8, 2, 4, 13, 2, 13, 2, 13, 13, 4, 13, 2, 13, 2, ...
[ [ 87, 2 ], [ 10, 9 ], [ 9, 18 ], [ 84, 20 ], [ 96, 23 ], [ 85, 26 ], [ 99, 28 ], [ 97, 30 ], [ 88, 31 ], [ 78, 33 ], [ 97, 37 ], [ 88, 38 ], [ 88, 40 ], [ 9...
[ "n = int(input())\na_list = [int(x) for x in input().split()]\n\na_sum = sum(a_list)\nf = a_sum // n\nc = (a_sum + n - 1) // n\nb = f if abs(a_sum - f * n) < abs(a_sum - c * n) else c\n\nans = 0\nfor a in a_list:\n ans += (a - b) ** 2\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input...
n = int(input()) a_list = [int(x) for x in input().split()] a_sum = sum(a_list) f = a_sum // n c = (a_sum + n - 1) // n b = f if abs(a_sum - f * n) < abs(a_sum - c * n) else c ans = 0 for a in a_list: ans += (a - b) ** 2 print(ans)
[ 7, 15, 0, 13, 17, 13, 17, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 4, 13, 13, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 2,...
[ [ 77, 3 ], [ 83, 5 ], [ 71, 8 ], [ 89, 14 ], [ 68, 26 ], [ 90, 30 ], [ 90, 33 ], [ 86, 35 ], [ 69, 38 ], [ 92, 40 ], [ 69, 43 ], [ 46, 45 ], [ 90, 45 ], [ 7...
[ "from math import ceil,floor\nansc,ansf = 0,0\nn = int(input())\na = list(map(int,input().split()))\n \ngp = sum(a)/len(a)\nc = ceil(gp)\nf = floor(gp)\n\nfor i in a:\n ansc += (i-c)**2\n ansf += (i-f)**2\n \nprint(min(ansc,ansf))", "from math import ceil,floor", "ansc,ansf = 0,0", "ansc", "0", "ansf",...
from math import ceil,floor ansc,ansf = 0,0 n = int(input()) a = list(map(int,input().split())) gp = sum(a)/len(a) c = ceil(gp) f = floor(gp) for i in a: ansc += (i-c)**2 ansf += (i-f)**2 print(min(ansc,ansf))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 12, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 29, 13, 23, 13, 0, 13, 2, 17, 17, 28, 13, 4, 13, 17, 17, 0, 13, 4, 13, 13, 14, 2, ...
[ [ 74, 2 ], [ 77, 8 ], [ 23, 22 ], [ 26, 25 ], [ 78, 25 ], [ 29, 28 ], [ 25, 31 ], [ 37, 32 ], [ 28, 35 ], [ 22, 35 ], [ 37, 37 ], [ 68, 39 ], [ 45, 44 ], [ ...
[ "N = int(input())\nA = list(map(int,input().split()))\n\ndef ans_one(i):\n ans=0\n for a in A:\n ans += (a-i)**2\n return ans\n\nans=10**20\nfor i in range(-102,103):\n ans_ = ans_one(i)\n if ans_ < ans:\n ans =ans_\nprint(ans)", "N = int(input())", "N", "int(input())", "int", ...
N = int(input()) A = list(map(int,input().split())) def ans_one(i): ans=0 for a in A: ans += (a-i)**2 return ans ans=10**20 for i in range(-102,103): ans_ = ans_one(i) if ans_ < ans: ans =ans_ print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 2, 13, 10, ...
[ [ 65, 2 ], [ 59, 8 ], [ 56, 20 ], [ 26, 25 ], [ 68, 31 ], [ 35, 34 ], [ 60, 34 ], [ 53, 37 ], [ 34, 40 ], [ 25, 41 ], [ 62, 44 ], [ 57, 47 ], [ 63, 47 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\n\nres = float('inf')\nfor i in range(-100, 101):\n s = 0\n for v in a:\n s += (v - i) ** 2\n res = min(res, s)\n\nprint(res)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = list(map(int, input().split())...
n = int(input()) a = list(map(int, input().split())) res = float('inf') for i in range(-100, 101): s = 0 for v in a: s += (v - i) ** 2 res = min(res, s) print(res)
[ 7, 15, 13, 13, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 12, 13, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 12, 13, 23, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 4, 13, 17, 0, 13, 2, 2, 17, 17, 17, 0, ...
[ [ 25, 24 ], [ 107, 30 ], [ 34, 34 ], [ 118, 43 ], [ 121, 48 ], [ 112, 55 ], [ 116, 57 ], [ 97, 59 ], [ 95, 61 ], [ 124, 63 ], [ 119, 64 ], [ 67, 66 ], [ 109, 72 ]...
[ "import sys, re\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2\nfrom collections import deque, defaultdict, Counter\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemge...
import sys, re from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2 from collections import deque, defaultdict, Counter from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby from operator import itemgetter, mul...
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 14, 40, 13, 13, 0, 13, 2, 2, 13, 13, 2, 13, 13, 14, 2, 13, 13, 0, 13, 13, 4, 13, ...
[ [ 67, 2 ], [ 64, 8 ], [ 58, 20 ], [ 24, 23 ], [ 70, 29 ], [ 33, 32 ], [ 65, 32 ], [ 23, 36 ], [ 32, 37 ], [ 61, 39 ], [ 32, 42 ], [ 23, 43 ], [ 32, 45 ], [ ...
[ "num = int(input())\nl = list(map(int,input().split()))\nmin = 1000000\nfor n in range(-100,101):\n sum = 0\n for i in l:\n if n !=i:\n sum += (i-n)*(i-n)\n \n if min > sum:\n min = sum\n\nprint(min)", "num = int(input())", "num", "int(input())", "int", "input()", "input", "l = list(map...
num = int(input()) l = list(map(int,input().split())) min = 1000000 for n in range(-100,101): sum = 0 for i in l: if n !=i: sum += (i-n)*(i-n) if min > sum: min = sum print(min)
[ 7, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 2, 4, 13, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 13, 2, 2, 18, 13, 13, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, ...
[ [ 87, 2 ], [ 10, 9 ], [ 9, 18 ], [ 84, 20 ], [ 96, 23 ], [ 85, 27 ], [ 88, 28 ], [ 105, 30 ], [ 34, 33 ], [ 88, 36 ], [ 93, 38 ], [ 106, 40 ], [ 94, 40 ], [ ...
[ "\nN = int(input())\nlist = [int(a) for a in input().split()]\n\nA = sum(list)//N\nans = 0\n\nfor k in range(N):\n ans = ans + (list[k] - A) ** 2\n\nfor i in range(-100,100):\n sum_new = 0\n for j in range(N):\n sum_new = sum_new + (list[j] - i) ** 2\n if(ans > sum_new):\n ans = sum_new\n\...
N = int(input()) list = [int(a) for a in input().split()] A = sum(list)//N ans = 0 for k in range(N): ans = ans + (list[k] - A) ** 2 for i in range(-100,100): sum_new = 0 for j in range(N): sum_new = sum_new + (list[j] - i) ** 2 if(ans > sum_new): ans = sum_new print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 13, 18, 13, 13, 2, 13, 18, 13, 13, 0, 13, 4, 13, 13, 13, 4, ...
[ [ 62, 2 ], [ 59, 8 ], [ 65, 20 ], [ 24, 23 ], [ 68, 29 ], [ 33, 32 ], [ 63, 35 ], [ 71, 37 ], [ 23, 40 ], [ 60, 42 ], [ 32, 43 ], [ 23, 45 ], [ 60, 47 ], [ ...
[ "n = int(input())\nA = list(map(int, input().split()))\n\nans = 1000000000\n\nfor i in range(-101, 101):\n tmp = 0\n for j in range (n):\n tmp += (i - A[j]) * (i - A[j])\n ans = min(ans, tmp)\n\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "A = list(...
n = int(input()) A = list(map(int, input().split())) ans = 1000000000 for i in range(-101, 101): tmp = 0 for j in range (n): tmp += (i - A[j]) * (i - A[j]) ans = min(ans, tmp) print(ans)
[ 7, 15, 13, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 17, 4, 4, 13, 13, 0, 13, 13, 0, 13, 2, 4, 13, 13, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 4, 18, 13, 13, 13, 41, 28, 13, 13, 4, 2, 2, 13, 13, 17, ...
[ [ 96, 4 ], [ 12, 11 ], [ 11, 21 ], [ 84, 23 ], [ 87, 26 ], [ 85, 30 ], [ 97, 31 ], [ 99, 33 ], [ 88, 38 ], [ 93, 40 ], [ 88, 45 ], [ 49, 48 ], [ 85, 48 ], [ ...
[ "import math\n \nN = int(input())\nA = [int(a) for a in input().split(\" \")]\nave = sum(A) / N\ncan1 = math.floor(ave)\ncan2 = math.ceil(ave)\n \ncost1 = sum([(a - can1) ** 2 for a in A])\ncost2 = sum([(a - can2) ** 2 for a in A])\nprint(min([cost1, cost2]))", "import math", "math", "N = int(input())", "N"...
import math N = int(input()) A = [int(a) for a in input().split(" ")] ave = sum(A) / N can1 = math.floor(ave) can2 = math.ceil(ave) cost1 = sum([(a - can1) ** 2 for a in A]) cost2 = sum([(a - can2) ** 2 for a in A]) print(min([cost1, cost2]))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 17, 0, 13, 39, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 17, 28, 13, 4, 13, 4, 13, 13, 2, 4, 13, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, 18, 13, 13, 13, 0, 13, 17, ...
[ [ 65, 2 ], [ 74, 8 ], [ 68, 11 ], [ 77, 14 ], [ 28, 27 ], [ 78, 32 ], [ 78, 36 ], [ 40, 39 ], [ 78, 39 ], [ 71, 42 ], [ 27, 45 ], [ 39, 46 ], [ 69, 50 ], [ ...
[ "count = int(input())\nsum_n = 0\nsum_list = []\n\nli = list(map(int, input().split(\" \")))\n\nfor i in range(min(li),max(li) + 1):\n for j in li:\n sum_n += (i - j)**2\n sum_list.append(sum_n)\n sum_n = 0\n \nprint(min(sum_list))", "count = int(input())", "count", "int(input())", "int", "input(...
count = int(input()) sum_n = 0 sum_list = [] li = list(map(int, input().split(" "))) for i in range(min(li),max(li) + 1): for j in li: sum_n += (i - j)**2 sum_list.append(sum_n) sum_n = 0 print(min(sum_list))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 2, 17, 17, 0, 13, 17, 28, 13, 4, 13, 17, 17, 28, 13, 4, 13, 4, 13, 13, 0, 13, 2, 2, 4, 13, 18, 13, 13, 13, 17, 14, 2, 13, 13, 0, 1...
[ [ 80, 2 ], [ 71, 8 ], [ 74, 17 ], [ 83, 20 ], [ 77, 25 ], [ 29, 28 ], [ 35, 34 ], [ 72, 39 ], [ 92, 41 ], [ 72, 47 ], [ 34, 48 ], [ 28, 49 ], [ 84, 53 ], [ ...
[ "n = int(input())\nl = list(input().split())\nsum = 0\nmin_sum = 10**10\nnum = 0\nfor i in range(-100,101):\n for j in range(len(l)):\n sum += (int(l[j]) - i)**2\n if min_sum > sum:\n min_sum = sum\n num = i\n sum = 0\n\nprint(min_sum)", "n = int(input())", "n", "int(input())", ...
n = int(input()) l = list(input().split()) sum = 0 min_sum = 10**10 num = 0 for i in range(-100,101): for j in range(len(l)): sum += (int(l[j]) - i)**2 if min_sum > sum: min_sum = sum num = i sum = 0 print(min_sum)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 18, 13, 13, 0, 13, 2, 13, 13, 14, 40, 13, 4, 13, 13, 14, 40, 13, 2, 4, 13, 13, 17, 0, 13, 2, 4, 13, ...
[ [ 107, 2 ], [ 95, 8 ], [ 98, 20 ], [ 24, 23 ], [ 108, 26 ], [ 104, 28 ], [ 96, 30 ], [ 23, 31 ], [ 92, 33 ], [ 105, 35 ], [ 99, 35 ], [ 108, 36 ], [ 93, 39 ], [...
[ "n = int(input())\nAs = list(map(int, input().split()))\n\ntotal = 0\nfor i in range(n):\n total += As[i]\n\n# detect optimal number\nave = total / n\n\nif ave != int(ave):\n if ave >= int(ave)+0.5:\n ave = int(ave)+1\n else:\n ave = int(ave)\n\nans = 0\nfor i in range(n):\n ans += (ave-As...
n = int(input()) As = list(map(int, input().split())) total = 0 for i in range(n): total += As[i] # detect optimal number ave = total / n if ave != int(ave): if ave >= int(ave)+0.5: ave = int(ave)+1 else: ave = int(ave) ans = 0 for i in range(n): ans += (ave-As[i])**2 print(int(ans)...
[ 7, 0, 13, 2, 17, 17, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, ...
[ [ 69, 2 ], [ 66, 7 ], [ 60, 13 ], [ 26, 25 ], [ 72, 31 ], [ 35, 34 ], [ 67, 37 ], [ 63, 39 ], [ 61, 43 ], [ 34, 44 ], [ 25, 45 ], [ 57, 48 ], [ 70, 51 ], [ ...
[ "ans = 10 ** 9\nn = int(input())\nA = list(map(int,input().split()))\nfor i in range(-100,101):\n X = 0\n for j in range(n):\n X += (A[j] - i) ** 2\n ans = min(ans,X)\nprint(ans)", "ans = 10 ** 9", "ans", "10 ** 9", "10", "9", "n = int(input())", "n", "int(input())", "int", "input()", "i...
ans = 10 ** 9 n = int(input()) A = list(map(int,input().split())) for i in range(-100,101): X = 0 for j in range(n): X += (A[j] - i) ** 2 ans = min(ans,X) print(ans)
[ 7, 15, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 18, 13, 13, 0, 13, 18, 13, 13, 28, 13, 4, 13, 18, 13, 17, 2, 18, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, ...
[ [ 74, 4 ], [ 86, 10 ], [ 87, 23 ], [ 77, 26 ], [ 32, 31 ], [ 87, 35 ], [ 87, 39 ], [ 80, 43 ], [ 47, 46 ], [ 75, 49 ], [ 83, 51 ], [ 87, 55 ], [ 46, 56 ], [ ...
[ "import math\nN = int(input())\na = list(map(int, input().split()))\na.sort()\n\nans = math.inf\nfor i in range(a[0], a[-1]+1):\n tmp = 0\n for j in range(N):\n tmp += (a[j]-i) ** 2\n if ans >= tmp:\n ans = tmp\n else:\n break\nprint(ans)", "import math", "math", "N = int(input())", "N", "int...
import math N = int(input()) a = list(map(int, input().split())) a.sort() ans = math.inf for i in range(a[0], a[-1]+1): tmp = 0 for j in range(N): tmp += (a[j]-i) ** 2 if ans >= tmp: ans = tmp else: break print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 2, 2, 13, 17, 13, 28, 13, 4, 13, 13, 2, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 4, 13, 2, 13,...
[ [ 88, 2 ], [ 73, 8 ], [ 82, 20 ], [ 74, 23 ], [ 76, 25 ], [ 74, 28 ], [ 91, 30 ], [ 83, 33 ], [ 89, 35 ], [ 38, 37 ], [ 77, 40 ], [ 83, 42 ], [ 79, 45 ], [ ...
[ "N=int(input())\na=list(map(int,input().split()))\nmaxi=max(a)\nmini=min(a)\nans1=(maxi**2)*N\nfor i in range(mini,maxi+1):\n ans=0\n for j in a:\n ans+=abs(j-i)**2\n if ans<ans1:\n ans1=ans\nprint(ans1)", "N=int(input())", "N", "int(input())", "int", "input()", "input", "a=list...
N=int(input()) a=list(map(int,input().split())) maxi=max(a) mini=min(a) ans1=(maxi**2)*N for i in range(mini,maxi+1): ans=0 for j in a: ans+=abs(j-i)**2 if ans<ans1: ans1=ans print(ans1)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 39, 28, 13, 4, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 4, 18, 13, 13, 13, 0, 13, 17, 28, 13, 4, 13, ...
[ [ 92, 2 ], [ 89, 8 ], [ 83, 20 ], [ 24, 23 ], [ 77, 28 ], [ 32, 31 ], [ 93, 34 ], [ 95, 36 ], [ 90, 40 ], [ 31, 41 ], [ 23, 42 ], [ 84, 46 ], [ 96, 48 ], [ ...
[ "N = int(input())\nA = list(map(int,input().split()))\ncosts = []\n\nfor i in range(101):\n cost = 0\n for j in range(N):\n cost += (A[j]-i)**2\n costs.append(cost)\n cost = 0\n for j in range(N):\n cost += (A[j]+i)**2\n costs.append(cost)\n\nprint(min(costs))", "N = int(input())", "N", "int(input...
N = int(input()) A = list(map(int,input().split())) costs = [] for i in range(101): cost = 0 for j in range(N): cost += (A[j]-i)**2 costs.append(cost) cost = 0 for j in range(N): cost += (A[j]+i)**2 costs.append(cost) print(min(costs))
[ 7, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 4, 13, 2, 4, 13, 13, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, 13, 13, 10, 2, 13, 10, 13, 13, 10, 4, 13, ...
[ [ 54, 2 ], [ 10, 9 ], [ 9, 18 ], [ 51, 20 ], [ 57, 23 ], [ 52, 29 ], [ 55, 30 ], [ 60, 32 ], [ 36, 35 ], [ 52, 35 ], [ 48, 38 ], [ 35, 41 ], [ 58, 42 ], [ 4...
[ "n = int(input())\nA = [int(i) for i in input().split()]\nave = round(sum(A) / n)\nans = 0\nfor x in A:\n ans += (x-ave)**2\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "int(i) for i in input().split()", "for i in input().split()", "i", "input().split()", ...
n = int(input()) A = [int(i) for i in input().split()] ave = round(sum(A) / n) ans = 0 for x in A: ans += (x-ave)**2 print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 39, 28, 13, 4, 13, 4, 13, 13, 2, 4, 13, 13, 17, 41, 28, 13, 13, 4, 2, 2, 13, 13, 17, 4, 18, 13, 13, 4, 13, 13, 4, 13, 4, 13, 13, 1...
[ [ 57, 2 ], [ 60, 8 ], [ 63, 20 ], [ 24, 23 ], [ 61, 28 ], [ 61, 32 ], [ 37, 36 ], [ 61, 36 ], [ 36, 41 ], [ 23, 42 ], [ 64, 46 ], [ 64, 55 ], [ 57, 58 ], [ ...
[ "N = int(input())\nA = list(map(int,input().split()))\ncost = []\n\nfor n in range(min(A),max(A)+1):\n cost.append(sum([(a-n)**2 for a in A]))\n\nprint(min(cost))", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = list(map(int,input().split()))", "A", "list(map(int,input()...
N = int(input()) A = list(map(int,input().split())) cost = [] for n in range(min(A),max(A)+1): cost.append(sum([(a-n)**2 for a in A])) print(min(cost))
[ 7, 15, 13, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 4, 13, 4, 18, 13, 13, 13, 0, 13, 2, 13, 17, 41, 28, 13, 13, 4, 2, 2, 13, 13, 17, 4, 13, 4, 13, 4, 13, 13, 4, 1...
[ [ 59, 4 ], [ 12, 11 ], [ 11, 20 ], [ 68, 22 ], [ 62, 25 ], [ 69, 32 ], [ 65, 34 ], [ 63, 36 ], [ 41, 40 ], [ 69, 40 ], [ 40, 45 ], [ 63, 46 ], [ 59, 60 ], [ ...
[ "import numpy as np\nn = int(input())\nxs = [int(x) for x in input().split()]\na = int(np.average(xs))\nb = a + 1\nprint(min(sum([(x - a) ** 2 for x in xs]), sum([(x - b) ** 2 for x in xs])))", "import numpy as np", "numpy", "n = int(input())", "n", "int(input())", "int", "input()", "input", "int(...
import numpy as np n = int(input()) xs = [int(x) for x in input().split()] a = int(np.average(xs)) b = a + 1 print(min(sum([(x - a) ** 2 for x in xs]), sum([(x - b) ** 2 for x in xs])))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, ...
[ [ 69, 2 ], [ 72, 8 ], [ 66, 20 ], [ 24, 23 ], [ 57, 29 ], [ 33, 32 ], [ 73, 37 ], [ 60, 39 ], [ 73, 43 ], [ 32, 44 ], [ 23, 45 ], [ 63, 48 ], [ 67, 51 ], [ ...
[ "N = int(input())\nA = list(map(int,input().split()))\nans=10000000\nfor i in range(-100, 101):\n sum=0\n for a in range(len(A)):\n sum+=(A[a]-i)**2\n ans=min(ans,sum)\nprint(ans)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = list(map(int,input().split()))"...
N = int(input()) A = list(map(int,input().split())) ans=10000000 for i in range(-100, 101): sum=0 for a in range(len(A)): sum+=(A[a]-i)**2 ans=min(ans,sum) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 14, 2, 13, 13, 0, 13, 13, 4, 13, 13, 10, ...
[ [ 56, 2 ], [ 65, 8 ], [ 59, 20 ], [ 24, 23 ], [ 68, 29 ], [ 33, 32 ], [ 57, 35 ], [ 62, 37 ], [ 66, 41 ], [ 32, 42 ], [ 23, 43 ], [ 63, 47 ], [ 69, 47 ], [ ...
[ "n=int(input())\na=list(map(int,input().split()))\nans=10000000\nfor i in range(-100,101):\n tmp=0\n for j in range(n):\n tmp+=(a[j]-i)**2\n if tmp<ans:\n ans=tmp\nprint(ans)", "n=int(input())", "n", "int(input())", "int", "input()", "input", "a=list(map(int,input().split()))", ...
n=int(input()) a=list(map(int,input().split())) ans=10000000 for i in range(-100,101): tmp=0 for j in range(n): tmp+=(a[j]-i)**2 if tmp<ans: ans=tmp print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 2, 17, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 14, 2, 13, 13, 0, 13, 13, 0, 13, 13, ...
[ [ 63, 2 ], [ 81, 8 ], [ 78, 20 ], [ 69, 23 ], [ 29, 28 ], [ 72, 34 ], [ 38, 37 ], [ 82, 37 ], [ 75, 40 ], [ 37, 43 ], [ 28, 44 ], [ 76, 48 ], [ 73, 48 ], [ ...
[ "n = int(input())\na = list(map(int,input().split()))\n\nans = -100\ntmp = 10**10\n\nfor i in range(-100, 101):\n t = 0\n for j in a:\n t += (j - i) ** 2\n if t < tmp:\n ans = i\n tmp = t\n\nprint(tmp)", "n = int(input())", "n", "int(input())", "int", "input()", "input", ...
n = int(input()) a = list(map(int,input().split())) ans = -100 tmp = 10**10 for i in range(-100, 101): t = 0 for j in a: t += (j - i) ** 2 if t < tmp: ans = i tmp = t print(tmp)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 14, 2, 40, 13, 17, 40, 2, 13, 17, 17, 0, 13, 2, 4, 13, 13, 17, 14, 2, 2, 13, 17, 40, 2, 40, 13, 17, 17, 0, 13, 2...
[ [ 92, 2 ], [ 98, 8 ], [ 101, 20 ], [ 99, 24 ], [ 93, 25 ], [ 102, 29 ], [ 102, 33 ], [ 95, 37 ], [ 102, 41 ], [ 102, 46 ], [ 102, 51 ], [ 86, 55 ], [ 102, 59 ], ...
[ "N=int(input())\na=list(map(int,input().split()))\nave=sum(a)/N\nif ave>=0 and ave%1>=0.5:\n ave=int(ave)+1\nelif ave<0 and -ave%1>=0.5:\n ave=int(ave)-1\nelse:\n ave=int(ave)\nans=0\nfor i in a:\n ans+=(i-ave)**2\nprint(ans)", "N=int(input())", "N", "int(input())", "int", "input()", "input"...
N=int(input()) a=list(map(int,input().split())) ave=sum(a)/N if ave>=0 and ave%1>=0.5: ave=int(ave)+1 elif ave<0 and -ave%1>=0.5: ave=int(ave)-1 else: ave=int(ave) ans=0 for i in a: ans+=(i-ave)**2 print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 2, 13, 10, ...
[ [ 59, 2 ], [ 62, 8 ], [ 68, 20 ], [ 26, 25 ], [ 65, 31 ], [ 35, 34 ], [ 63, 34 ], [ 53, 37 ], [ 34, 40 ], [ 25, 41 ], [ 56, 44 ], [ 69, 47 ], [ 57, 47 ], [ ...
[ "N = int(input())\nA = list(map(int,input().split()))\nans = float('inf')\nfor i in range(-100, 101):\n cnt = 0\n for a in A:\n cnt += (a - i) ** 2\n ans = min(ans, cnt)\nprint(ans)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = list(map(int,input().split())...
N = int(input()) A = list(map(int,input().split())) ans = float('inf') for i in range(-100, 101): cnt = 0 for a in A: cnt += (a - i) ** 2 ans = min(ans, cnt) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 4, 13, 10, ...
[ [ 68, 2 ], [ 59, 8 ], [ 53, 20 ], [ 26, 25 ], [ 62, 31 ], [ 35, 34 ], [ 60, 34 ], [ 56, 37 ], [ 34, 40 ], [ 25, 41 ], [ 65, 44 ], [ 54, 47 ], [ 66, 47 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\n\nans = float(\"inf\")\nfor y in range(-100, 101):\n res = 0\n for x in a:\n res += (x - y)**2\n ans = min(ans, res)\n\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = list(map(int, input().split()))", ...
n = int(input()) a = list(map(int, input().split())) ans = float("inf") for y in range(-100, 101): res = 0 for x in a: res += (x - y)**2 ans = min(ans, res) print(ans)
[ 7, 15, 13, 4, 13, 0, 13, 4, 18, 13, 13, 4, 18, 4, 13, 13, 0, 13, 18, 13, 13, 4, 13, 4, 13, 4, 18, 2, 13, 13, 13, 2, 13, 13, 10, 4, 13 ]
[ [ 35, 6 ], [ 18, 17 ], [ 36, 28 ], [ 36, 32 ], [ 35, 36 ] ]
[ "import numpy as np\ninput()\nA = np.array(input().split(), dtype=np.int32)\nprint(min((A - i).dot(A - i) for i in range(-100, 101)))", "import numpy as np", "numpy", "input()", "input", "A = np.array(input().split(), dtype=np.int32)", "A", "np.array(input().split(), dtype=np.int32)", "np.array", ...
import numpy as np input() A = np.array(input().split(), dtype=np.int32) print(min((A - i).dot(A - i) for i in range(-100, 101)))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 2, 13, 13, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 17, 13, 10, ...
[ [ 65, 2 ], [ 68, 8 ], [ 62, 20 ], [ 24, 23 ], [ 53, 29 ], [ 33, 32 ], [ 69, 32 ], [ 56, 35 ], [ 23, 38 ], [ 32, 39 ], [ 23, 41 ], [ 32, 42 ], [ 59, 44 ], [ ...
[ "n=int(input())\na=list(map(int,input().split()))\nans=100000000\nfor i in range(-100,101):\n now=0\n for k in a:\n now+=(i-k)*(i-k)\n ans=min(ans,now)\nprint(ans)", "n=int(input())", "n", "int(input())", "int", "input()", "input", "a=list(map(int,input().split()))", "a", "list(map...
n=int(input()) a=list(map(int,input().split())) ans=100000000 for i in range(-100,101): now=0 for k in a: now+=(i-k)*(i-k) ans=min(ans,now) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 17, 0, 13, 39, 14, 2, 4, 18, 13, 13, 18, 13, 17, 4, 13, 13, 4, 13, 17, 4, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 13, 14, ...
[ [ 97, 2 ], [ 100, 8 ], [ 103, 21 ], [ 101, 27 ], [ 101, 30 ], [ 101, 34 ], [ 43, 42 ], [ 94, 48 ], [ 52, 51 ], [ 98, 54 ], [ 101, 58 ], [ 51, 59 ], [ 42, 60 ], ...
[ "N = int(input())\nA = list(map(int, input().split(' ')))\nans = []\nif A.count(A[0]) == len(A):\n print(0)\n exit(0)\nfor i in range(-100,101):\n cost = 0\n for j in range(N):\n if A[j] == i:\n continue\n else:\n cost += (A[j] - i)**2\n ans.append(cost)\nimport he...
N = int(input()) A = list(map(int, input().split(' '))) ans = [] if A.count(A[0]) == len(A): print(0) exit(0) for i in range(-100,101): cost = 0 for j in range(N): if A[j] == i: continue else: cost += (A[j] - i)**2 ans.append(cost) import heapq heapq.heapify(a...
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 0, 13, 2, 2, 4, 13, 13, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 4, 13, 2, 18, 13, 13, 13, 17,...
[ [ 81, 2 ], [ 93, 8 ], [ 75, 20 ], [ 94, 24 ], [ 82, 25 ], [ 84, 27 ], [ 94, 32 ], [ 82, 33 ], [ 87, 36 ], [ 96, 39 ], [ 43, 42 ], [ 82, 45 ], [ 90, 47 ], [ ...
[ "n = int(input())\na = list(map(int,input().split()))\n\navg1 = sum(a) // n\navg2 = (sum(a) // n) + 1\nans1 = 0\nans2 = 0\nfor i in range(n):\n ans1 += abs(a[i] - avg1) ** 2\n ans2 += abs(a[i] - avg2) ** 2\n\nprint(min(ans1,ans2))", "n = int(input())", "n", "int(input())", "int", "input()", "input...
n = int(input()) a = list(map(int,input().split())) avg1 = sum(a) // n avg2 = (sum(a) // n) + 1 ans1 = 0 ans2 = 0 for i in range(n): ans1 += abs(a[i] - avg1) ** 2 ans2 += abs(a[i] - avg2) ** 2 print(min(ans1,ans2))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 0, 13, 13, 4, 13, 13, 10, 13, 1...
[ [ 61, 2 ], [ 73, 8 ], [ 58, 20 ], [ 74, 24 ], [ 62, 25 ], [ 64, 27 ], [ 59, 30 ], [ 70, 32 ], [ 36, 35 ], [ 62, 38 ], [ 67, 40 ], [ 74, 44 ], [ 35, 45 ], [ ...
[ "n=int(input())\na = list(map(int,input().split()))\n_sum =sum(a) / n\ns = round(_sum)\nans = 0\n#print(s)\nfor i in range(n):\n v =(a[i]-s)**2\n ans += v\nprint(ans)", "n=int(input())", "n", "int(input())", "int", "input()", "input", "a = list(map(int,input().split()))", "a", "list(map(int...
n=int(input()) a = list(map(int,input().split())) _sum =sum(a) / n s = round(_sum) ans = 0 #print(s) for i in range(n): v =(a[i]-s)**2 ans += v print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 13, 4, 13, 13, 14, 2, 13, 13, 0, 13, 17, 41, 28, 13, 13, 4, 2, 2, 13, 13, 2, 13, 13, 28, 13, 4, 13, 13, 2, 13, 17, 4, 1...
[ [ 68, 2 ], [ 71, 8 ], [ 65, 20 ], [ 72, 23 ], [ 62, 24 ], [ 72, 27 ], [ 66, 30 ], [ 63, 31 ], [ 59, 33 ], [ 38, 37 ], [ 72, 37 ], [ 37, 43 ], [ 37, 46 ], [ ...
[ "n= int(input())\na= list(map(int,input().split()))\nmaxa,mina=max(a),min(a)\nif maxa==mina:print(0)\nelse:\n gmin=9999999\n for c in range(mina,maxa+1):gmin=min(gmin,sum([(c-b)*(c-b) for b in a]))\n print(gmin)", "n= int(input())", "n", "int(input())", "int", "input()", "input", "a= list(map...
n= int(input()) a= list(map(int,input().split())) maxa,mina=max(a),min(a) if maxa==mina:print(0) else: gmin=9999999 for c in range(mina,maxa+1):gmin=min(gmin,sum([(c-b)*(c-b) for b in a])) print(gmin)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 17, 13, 0, 13, 2, 17, 13, 28, 13, 4, 13, 17, 2, 17, 17, 41, 28, 13, 13, 4, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13...
[ [ 65, 2 ], [ 71, 8 ], [ 74, 20 ], [ 66, 23 ], [ 62, 25 ], [ 66, 28 ], [ 31, 30 ], [ 40, 39 ], [ 72, 39 ], [ 39, 44 ], [ 30, 45 ], [ 68, 48 ], [ 77, 53 ], [ ...
[ "N = int(input())\nan = list(map(int, input().split()))\n\ncost = 10000*N\nans = 10000*N\nfor i in range(-100,100+1):\n cost = sum([(j - i)**2 for j in an])\n ans = min(ans, cost)\n\nprint(ans)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "an = list(map(int, input().spli...
N = int(input()) an = list(map(int, input().split())) cost = 10000*N ans = 10000*N for i in range(-100,100+1): cost = sum([(j - i)**2 for j in an]) ans = min(ans, cost) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 0, 13, 17, 42, 2, 13, 13, 0, 13, 18, 13, 13, 0, 13, 17, 0, 13, 2, 13, 13, 0, 13, 2, 13, 17, 0, 13, 17, 0...
[ [ 125, 2 ], [ 152, 8 ], [ 149, 20 ], [ 122, 23 ], [ 143, 26 ], [ 128, 29 ], [ 150, 33 ], [ 147, 33 ], [ 126, 34 ], [ 134, 36 ], [ 153, 38 ], [ 150, 39 ], [ 147, 39 ...
[ "n = int(input())\na = list(map(int, input().split()))\n\ni = 0\nm = 100\nM = -100\n\ns = 0\nwhile i < n:\n s += a[i]\n i+=1\n\ns1 = s//n\ns2 = s1 + 1\n\ni = 0\nx1 = 0\nx2 = 0\nwhile i < n:\n x1 += (s1-a[i])**2\n x2 += (s2-a[i])**2\n i+=1\n\nif x1<x2:\n ans = x1\nelse:\n ans = x2\nprint(ans)\n"...
n = int(input()) a = list(map(int, input().split())) i = 0 m = 100 M = -100 s = 0 while i < n: s += a[i] i+=1 s1 = s//n s2 = s1 + 1 i = 0 x1 = 0 x2 = 0 while i < n: x1 += (s1-a[i])**2 x2 += (s2-a[i])**2 i+=1 if x1<x2: ans = x1 else: ans = x2 print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 13, 0, 13, 2, 13, 13, 0, 13, 40, 2, 40, 13, 13, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, ...
[ [ 88, 2 ], [ 82, 8 ], [ 73, 20 ], [ 76, 23 ], [ 91, 26 ], [ 30, 29 ], [ 83, 29 ], [ 97, 32 ], [ 29, 33 ], [ 79, 35 ], [ 98, 37 ], [ 74, 37 ], [ 89, 38 ], [ ...
[ "n=int(input())\na=list(map(int,input().split()))\ntotal=0\nans1=0\nans2=0\nfor i in a:\n total+=i\ntmp1=total//n\ntmp2=-(-total//n)\nfor i in a:\n ans1+=(i-tmp1)**2\nfor i in a:\n ans2+=(i-tmp2)**2\nprint(min(ans1,ans2))", "n=int(input())", "n", "int(input())", "int", "input()", "input", "a=...
n=int(input()) a=list(map(int,input().split())) total=0 ans1=0 ans2=0 for i in a: total+=i tmp1=total//n tmp2=-(-total//n) for i in a: ans1+=(i-tmp1)**2 for i in a: ans2+=(i-tmp2)**2 print(min(ans1,ans2))
[ 7, 14, 2, 13, 17, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 2, 17, 17, 2, 17, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 2, 13, 13, 0, 13, 4, 13...
[ [ 69, 6 ], [ 75, 12 ], [ 72, 24 ], [ 34, 33 ], [ 66, 39 ], [ 43, 42 ], [ 76, 42 ], [ 63, 45 ], [ 33, 48 ], [ 42, 49 ], [ 33, 51 ], [ 42, 52 ], [ 78, 54 ], [ ...
[ "if __name__ == '__main__':\n n = int(input())\n lst = list(map(int, input().split()))\n\n ans = (50*100)*(50*100)\n for i in range(-100,101):\n mn = 0\n for c in lst:\n mn += (i-c)*(i-c)\n ans = min(ans,mn)\n\n print(ans)", "if __name__ == '__main__':\n n = int(i...
if __name__ == '__main__': n = int(input()) lst = list(map(int, input().split())) ans = (50*100)*(50*100) for i in range(-100,101): mn = 0 for c in lst: mn += (i-c)*(i-c) ans = min(ans,mn) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 14, 2, 13, 13, 0, 13, 13, 4, 13, ...
[ [ 64, 2 ], [ 67, 8 ], [ 58, 20 ], [ 26, 25 ], [ 73, 31 ], [ 35, 34 ], [ 65, 37 ], [ 61, 39 ], [ 68, 43 ], [ 34, 44 ], [ 25, 45 ], [ 59, 49 ], [ 71, 49 ], [ ...
[ "N = int(input())\nA = list(map(int, input().split()))\n\nans = float('inf')\nfor i in range(-100, 101):\n tmp = 0\n for j in range(N):\n tmp += (A[j] - i)**2\n if ans > tmp:\n ans = tmp\n\nprint(ans)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = lis...
N = int(input()) A = list(map(int, input().split())) ans = float('inf') for i in range(-100, 101): tmp = 0 for j in range(N): tmp += (A[j] - i)**2 if ans > tmp: ans = tmp print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 4, 13, 2, 4, 13, 13, 13, 0, 13, 17, 28, 13, 13, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13 ]
[ [ 41, 2 ], [ 10, 9 ], [ 9, 18 ], [ 50, 20 ], [ 47, 23 ], [ 51, 29 ], [ 42, 30 ], [ 44, 32 ], [ 36, 35 ], [ 51, 35 ], [ 45, 39 ], [ 41, 42 ], [ 44, 45 ], [ 4...
[ "N = int(input())\nA = [int(x) for x in input().split()]\naverage = round(sum(A) / N)\nans = 0\nfor x in A: ans += (average-x)**2\nprint(ans)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "int(x) for x in input().split()", "for x in input().split()", "x", "input().split()...
N = int(input()) A = [int(x) for x in input().split()] average = round(sum(A) / N) ans = 0 for x in A: ans += (average-x)**2 print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 0, 13, 39, 0, 13, 39, 0, 13, 2, 2, 18, 13, 17, 18, 13, 17, 17, 28, 13, 4, 13, 13, 4, 18, 13, 13, 2, 18, 13, 17, 13, 14, ...
[ [ 111, 2 ], [ 120, 8 ], [ 108, 22 ], [ 102, 25 ], [ 123, 28 ], [ 114, 31 ], [ 121, 35 ], [ 121, 38 ], [ 43, 42 ], [ 115, 45 ], [ 124, 48 ], [ 121, 52 ], [ 42, 54 ...
[ "n = int(input())\na = sorted(list(map(int,input().split())))\nsum = 0\nList_sum = []\nCounter = []\nCount_num = (a[-1] - a[0])+1\nfor i in range(Count_num):\n Counter.append(a[0]+i)\n if Counter[-1] == a[-1]:\n break\nif len(set(a)) == 1:\n print(0)\nelse:\n for i in Counter:\n for j in a...
n = int(input()) a = sorted(list(map(int,input().split()))) sum = 0 List_sum = [] Counter = [] Count_num = (a[-1] - a[0])+1 for i in range(Count_num): Counter.append(a[0]+i) if Counter[-1] == a[-1]: break if len(set(a)) == 1: print(0) else: for i in Counter: for j in a: sum +...
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 18, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 39, 28, 13, 4, 13, 13, 2, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 2...
[ [ 82, 2 ], [ 70, 8 ], [ 71, 21 ], [ 73, 24 ], [ 71, 27 ], [ 88, 29 ], [ 71, 32 ], [ 76, 34 ], [ 38, 37 ], [ 74, 40 ], [ 89, 42 ], [ 85, 45 ], [ 49, 48 ], [ ...
[ "# -*- coding : utf-8 -*-\n\nN = int(input())\nL = list(map(int, input().split()))\n\nL.sort()\nm = min(L)\nM = max(L)\n\nA = []\nfor i in range(m,M+1):\n k=0\n for j in L:\n k += (j-i)*(j-i)\n A.append(k)\n \nprint(min(A))", "N = int(input())", "N", "int(input())", "int", "input()", "input", "...
# -*- coding : utf-8 -*- N = int(input()) L = list(map(int, input().split())) L.sort() m = min(L) M = max(L) A = [] for i in range(m,M+1): k=0 for j in L: k += (j-i)*(j-i) A.append(k) print(min(A))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 17, ...
[ [ 70, 2 ], [ 67, 8 ], [ 55, 20 ], [ 24, 23 ], [ 61, 29 ], [ 33, 32 ], [ 71, 35 ], [ 64, 37 ], [ 68, 41 ], [ 32, 42 ], [ 23, 43 ], [ 58, 46 ], [ 56, 49 ], [ ...
[ "n=int(input())\na=list(map(int,input().split()))\nans=1000000\n\nfor i in range(-100,101):\n cou=0\n for j in range(n):\n cou+=(a[j]-i)**2\n ans=min(ans,cou)\n \nprint(ans)", "n=int(input())", "n", "int(input())", "int", "input()", "input", "a=list(map(int,input().split()))", "a", "list(ma...
n=int(input()) a=list(map(int,input().split())) ans=1000000 for i in range(-100,101): cou=0 for j in range(n): cou+=(a[j]-i)**2 ans=min(ans,cou) print(ans)
[ 7, 15, 13, 15, 13, 12, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 2, 4, 13, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 0, 13, 4, 13, 2, 13, 13, 17, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, ...
[ [ 11, 10 ], [ 23, 22 ], [ 10, 28 ], [ 10, 31 ], [ 34, 33 ], [ 37, 36 ], [ 10, 36 ], [ 40, 39 ], [ 36, 43 ], [ 22, 44 ], [ 39, 48 ], [ 33, 48 ], [ 57, 54 ] ]
[ "import sys\nimport math\n\ndef main():\n\n input()\n a = list(map(int, input().split()))\n\n y = round(sum(a)/len(a))\n\n ans = 0\n for i in a:\n ans += pow((i - y), 2)\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "import math", "math", "def m...
import sys import math def main(): input() a = list(map(int, input().split())) y = round(sum(a)/len(a)) ans = 0 for i in a: ans += pow((i - y), 2) print(ans) if __name__ == '__main__': main()
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 17, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 13, 2, 2, 13, 13, 2, 13, 13, 0, 13, 4, 13, 13, 13, 4, 13, 13, 1...
[ [ 60, 2 ], [ 63, 8 ], [ 72, 20 ], [ 26, 25 ], [ 57, 31 ], [ 35, 34 ], [ 64, 34 ], [ 66, 37 ], [ 58, 39 ], [ 67, 39 ], [ 25, 42 ], [ 34, 43 ], [ 25, 45 ], [ ...
[ "n = int(input())\narr =list(map(int , input().split()))\nans = 10001*10001\nfor i in range(-100 ,101):\n\ttot =0\n\tfor j in arr:\n\t\ttot = tot+(i-j)*(i-j)\n\tans = min(ans, tot)\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "arr =list(map(int , input().split()))"...
n = int(input()) arr =list(map(int , input().split())) ans = 10001*10001 for i in range(-100 ,101): tot =0 for j in arr: tot = tot+(i-j)*(i-j) ans = min(ans, tot) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 2, 13, 4, 13, 13, 14, 2, 2, 2, 13, 17, 2, 13, 4, 13, 13, 2, 2, 13, 4, 13, 13, 13, 0, 13, 17, 0, 13, 17, ...
[ [ 90, 2 ], [ 81, 8 ], [ 78, 20 ], [ 82, 23 ], [ 84, 25 ], [ 79, 29 ], [ 82, 32 ], [ 85, 37 ], [ 79, 40 ], [ 82, 43 ], [ 79, 46 ], [ 82, 49 ], [ 85, 50 ], [ ...
[ "N = int(input())\na = list(map(int, input().split()))\ns = sum(a)\nx = int(s / len(a))\n\nif (x + 1) - (s / len(a)) < (s / len(a)) - x:\n x += 1\ncost = 0\nfor y in a:\n cost += pow(y - x, 2)\n\nprint(cost)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "a = list(map(int,...
N = int(input()) a = list(map(int, input().split())) s = sum(a) x = int(s / len(a)) if (x + 1) - (s / len(a)) < (s / len(a)) - x: x += 1 cost = 0 for y in a: cost += pow(y - x, 2) print(cost)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 39, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 4, 13, 10, 17, ...
[ [ 52, 2 ], [ 61, 8 ], [ 58, 20 ], [ 24, 23 ], [ 55, 29 ], [ 33, 32 ], [ 62, 32 ], [ 64, 35 ], [ 32, 38 ], [ 23, 39 ], [ 59, 43 ], [ 65, 45 ], [ 56, 45 ], [ ...
[ "n=int(input())\nl=list(map(int,input().split()))\ncost=[]\nfor i in range(-100,101):\n count=0\n for j in l:\n count+=(j-i)**2\n cost.append(count)\nprint(min(cost))", "n=int(input())", "n", "int(input())", "int", "input()", "input", "l=list(map(int,input().split()))", "l", "list(...
n=int(input()) l=list(map(int,input().split())) cost=[] for i in range(-100,101): count=0 for j in l: count+=(j-i)**2 cost.append(count) print(min(cost))
[ 7, 12, 13, 0, 13, 17, 18, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 13, 42, 40, 13, 13, 0, 13, 17, 0, 13, 17, 42, 2, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 0, 13, 17, 14, 2, 40, 13, 13, 2, 13, 13, 0, 13, 13, 0...
[ [ 5, 4 ], [ 63, 7 ], [ 11, 10 ], [ 14, 13 ], [ 17, 16 ], [ 10, 17 ], [ 16, 20 ], [ 56, 20 ], [ 13, 21 ], [ 24, 23 ], [ 27, 26 ], [ 26, 30 ], [ 42, 30 ], [ 6...
[ "def keisan(N,A):\n \n KAI = 0\n A.sort\n \n min = -100\n max = 101\n \n i = min\n \n while i <= max:\n kari = 0\n j = 0\n while j < N:\n kari += (A[j]-i)**2\n j += 1\n \n \n if kari <= KAI or i == min:\n ...
def keisan(N,A): KAI = 0 A.sort min = -100 max = 101 i = min while i <= max: kari = 0 j = 0 while j < N: kari += (A[j]-i)**2 j += 1 if kari <= KAI or i == min: KAI = kari ...
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 17, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 13, 18, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, ...
[ [ 63, 2 ], [ 60, 8 ], [ 57, 20 ], [ 26, 25 ], [ 69, 31 ], [ 35, 34 ], [ 64, 37 ], [ 66, 39 ], [ 25, 42 ], [ 61, 44 ], [ 34, 45 ], [ 72, 48 ], [ 58, 51 ], [ ...
[ "N = int(input())\nA = list(map(int, input().split()))\nans = 10**9\nfor i in range(-100, 101):\n tmp = 0\n for j in range(N):\n tmp += (i-A[j])**2\n ans = min(ans, tmp)\nprint(ans)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = list(map(int, input().split()))", "A"...
N = int(input()) A = list(map(int, input().split())) ans = 10**9 for i in range(-100, 101): tmp = 0 for j in range(N): tmp += (i-A[j])**2 ans = min(ans, tmp) print(ans)
[ 7, 15, 13, 15, 13, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 4, 18, 13, 13, 4, 18, 13, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, ...
[ [ 95, 6 ], [ 14, 13 ], [ 13, 22 ], [ 77, 24 ], [ 89, 27 ], [ 78, 36 ], [ 92, 38 ], [ 80, 41 ], [ 45, 44 ], [ 78, 49 ], [ 83, 51 ], [ 78, 55 ], [ 44, 56 ], [ ...
[ "import math\nimport statistics\nN = int(input())\nA = [int(x) for x in input().split()]\navg = math.floor(statistics.mean(A))\na = 0\nb = 0\nfor i in range(len(A)):\n a += (A[i] - avg)**2\n b += (A[i] - avg - 1)**2\nprint(min(a,b))", "import math", "math", "import statistics", "statistics", "N = in...
import math import statistics N = int(input()) A = [int(x) for x in input().split()] avg = math.floor(statistics.mean(A)) a = 0 b = 0 for i in range(len(A)): a += (A[i] - avg)**2 b += (A[i] - avg - 1)**2 print(min(a,b))
[ 7, 12, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 13, 4, 13, 13, 0, 13, 39, 14, 2, 13, 13, 29, 17, 28, 13, 4, 13, 13, 2, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, ...
[ [ 5, 4 ], [ 11, 10 ], [ 23, 22 ], [ 10, 25 ], [ 27, 26 ], [ 10, 29 ], [ 32, 31 ], [ 22, 35 ], [ 26, 36 ], [ 41, 40 ], [ 22, 43 ], [ 26, 45 ], [ 49, 48 ], [ ...
[ "def main():\n n = int(input())\n a = list(map(int, input().split()))\n n_min, n_max = min(a), max(a)\n ans = []\n\n if n_min == n_max:\n return 0\n\n for y in range(n_min, n_max+1):\n cost = 0\n for x in a:\n cost += (x-y)**2\n ans.append(cost)\n\n return...
def main(): n = int(input()) a = list(map(int, input().split())) n_min, n_max = min(a), max(a) ans = [] if n_min == n_max: return 0 for y in range(n_min, n_max+1): cost = 0 for x in a: cost += (x-y)**2 ans.append(cost) return min(ans) if __nam...
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 2, 4, 13, 13, 13, 0, 13, 2, 13, 17, 0, 13, 2, 13, 17, 41, 28, 13, 13, 4, 2, 2, 13, 13, 17, 0, 13, 13, 41, 28, 13, 13, 4, 2,...
[ [ 110, 2 ], [ 95, 8 ], [ 113, 20 ], [ 96, 26 ], [ 111, 27 ], [ 92, 29 ], [ 114, 31 ], [ 98, 34 ], [ 114, 36 ], [ 41, 40 ], [ 96, 40 ], [ 40, 45 ], [ 114, 46 ], ...
[ "n = int(input())\nlist_int = list(map(int, input().split()))\nave0 = int(sum(list_int)/n)\nave1 = ave0 + 1\nave2 = ave0 - 1\n\nlist_cost0 = [(i-ave0)**2 for i in list_int]\nlist_cost1 = [(i-ave1)**2 for i in list_int]\nlist_cost2 = [(i-ave2)**2 for i in list_int]\nprint(min([sum(list_cost0), sum(list_cost1), sum(l...
n = int(input()) list_int = list(map(int, input().split())) ave0 = int(sum(list_int)/n) ave1 = ave0 + 1 ave2 = ave0 - 1 list_cost0 = [(i-ave0)**2 for i in list_int] list_cost1 = [(i-ave1)**2 for i in list_int] list_cost2 = [(i-ave2)**2 for i in list_int] print(min([sum(list_cost0), sum(list_cost1), sum(list_cost2)]))
[ 7, 15, 13, 12, 13, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 17, 0, 13, 17, 0, 13, 2, 4, 13, 13, 13, 14, 2, 2, 4, 13, 13, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, ...
[ [ 7, 6 ], [ 14, 13 ], [ 13, 22 ], [ 25, 24 ], [ 28, 27 ], [ 31, 30 ], [ 34, 33 ], [ 24, 37 ], [ 6, 38 ], [ 24, 44 ], [ 6, 45 ], [ 49, 48 ], [ 52, 51 ], [ 6,...
[ "#! python3\nimport math\n\ndef main():\n N = int(input())\n alist = [int(num) for num in input().split()]\n ans1 = 0\n ans2 = 0\n m = sum(alist) / N\n\n if sum(alist) % N == 0:\n ans = 0\n for i in range(N):\n ans += (alist[i] - m)**2\n else:\n mu = math.floor(m...
#! python3 import math def main(): N = int(input()) alist = [int(num) for num in input().split()] ans1 = 0 ans2 = 0 m = sum(alist) / N if sum(alist) % N == 0: ans = 0 for i in range(N): ans += (alist[i] - m)**2 else: mu = math.floor(m) mo = math....
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 17, 28, 13, 4, 13, 4, 13, 13, 2, 4, 13, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13...
[ [ 65, 2 ], [ 62, 8 ], [ 68, 20 ], [ 26, 25 ], [ 63, 30 ], [ 63, 34 ], [ 71, 37 ], [ 41, 40 ], [ 63, 40 ], [ 59, 43 ], [ 25, 46 ], [ 40, 47 ], [ 74, 50 ], [ ...
[ "n = int(input())\nA = list(map(int, input().split()))\n\nans = float(\"INF\")\nfor i in range(min(A), max(A)+1):\n tmp = 0\n for a in A:\n tmp += (i - a) ** 2\n ans = min(tmp, ans)\n\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "A = list(map(int, i...
n = int(input()) A = list(map(int, input().split())) ans = float("INF") for i in range(min(A), max(A)+1): tmp = 0 for a in A: tmp += (i - a) ** 2 ans = min(tmp, ans) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 4, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, ...
[ [ 56, 2 ], [ 59, 8 ], [ 71, 20 ], [ 26, 25 ], [ 68, 31 ], [ 60, 38 ], [ 62, 40 ], [ 25, 43 ], [ 65, 47 ], [ 72, 50 ], [ 66, 50 ], [ 63, 51 ], [ 69, 51 ], [ ...
[ "N = int(input())\nA = list(map(int, input().split()))\nans = float('inf')\n\nfor target in range(-100, 101):\n cost = 0\n for j, a in enumerate(A):\n cost += (target - a)**2\n ans = min(ans, cost)\n\nprint(ans)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = list(map(...
N = int(input()) A = list(map(int, input().split())) ans = float('inf') for target in range(-100, 101): cost = 0 for j, a in enumerate(A): cost += (target - a)**2 ans = min(ans, cost) print(ans)
[ 7, 15, 13, 15, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, ...
[ [ 89, 6 ], [ 74, 12 ], [ 92, 24 ], [ 75, 29 ], [ 80, 31 ], [ 93, 36 ], [ 86, 38 ], [ 93, 43 ], [ 83, 45 ], [ 98, 48 ], [ 52, 51 ], [ 75, 51 ], [ 95, 54 ], [ ...
[ "import numpy as np\nimport math\n\nN = int(input())\n\na = list(map(int, input().split()))\n\navr = np.average(a)\n\nav1 = math.floor(avr)\nav2 = math.ceil(avr)\n\nres1 = 0\nres2 = 0\n\nfor num in a:\n res1 += (num - av1) ** 2\n res2 += (num - av2) ** 2\n\nprint(min(res1, res2))", "import numpy as np", "...
import numpy as np import math N = int(input()) a = list(map(int, input().split())) avr = np.average(a) av1 = math.floor(avr) av2 = math.ceil(avr) res1 = 0 res2 = 0 for num in a: res1 += (num - av1) ** 2 res2 += (num - av2) ** 2 print(min(res1, res2))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 0, 13, 4, 13, 17, 28, 13, 4, 13, 13, 2, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 4, 13, 2, 13, 13, 17, 0, 13, 4,...
[ [ 64, 2 ], [ 79, 8 ], [ 70, 20 ], [ 80, 24 ], [ 65, 25 ], [ 67, 27 ], [ 33, 32 ], [ 71, 35 ], [ 71, 37 ], [ 73, 40 ], [ 44, 43 ], [ 80, 43 ], [ 82, 46 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\n\nm = sum(a)//n\nans = float(\"inf\")\nfor i in range(m, m+2):\n t = 0\n for j in a:\n t += abs(j-i)**2\n ans = min(t,ans)\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = list(map(int, input().split())...
n = int(input()) a = list(map(int, input().split())) m = sum(a)//n ans = float("inf") for i in range(m, m+2): t = 0 for j in a: t += abs(j-i)**2 ans = min(t,ans) print(ans)
[ 7, 15, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 14, 2, 4, 13, 2, 4, 13, 13, 13, 4, 13, 2, 4, 13, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, ...
[ [ 88, 3 ], [ 85, 9 ], [ 73, 21 ], [ 86, 25 ], [ 89, 26 ], [ 74, 34 ], [ 74, 35 ], [ 74, 41 ], [ 74, 42 ], [ 82, 44 ], [ 74, 47 ], [ 79, 49 ], [ 74, 52 ], [ ...
[ "from math import floor, ceil\n\n\nn = int(input())\nA = list(map(int, input().split()))\n\nx = sum(A) / n\nif abs(floor(x) - x) < abs(ceil(x) - x):\n x = floor(x)\nelse:\n x = ceil(x)\n\nanswer = 0\nfor a in A:\n answer += (a - x)**2\n\nprint(answer)", "from math import floor, ceil", "n = int(input())...
from math import floor, ceil n = int(input()) A = list(map(int, input().split())) x = sum(A) / n if abs(floor(x) - x) < abs(ceil(x) - x): x = floor(x) else: x = ceil(x) answer = 0 for a in A: answer += (a - x)**2 print(answer)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 2, 17, 17, 13, 28, 13, 4, 13, 4, 13, 13, 2, 4, 13, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 4, 13, 2, 18, 13, 13, 13, 17...
[ [ 77, 2 ], [ 80, 8 ], [ 83, 20 ], [ 78, 25 ], [ 28, 27 ], [ 81, 32 ], [ 81, 36 ], [ 71, 39 ], [ 43, 42 ], [ 78, 45 ], [ 68, 47 ], [ 81, 53 ], [ 42, 54 ], [ ...
[ "n=int(input())\na=list(map(int,input().split()))\nmins=100**2*n\nfor i in range(min(a),max(a)+1):\n sum=0\n for j in range(n):\n sum+=abs(a[j]-i)**2\n if sum<mins:\n mins=sum\nprint(mins)", "n=int(input())", "n", "int(input())", "int", "input()", "input", "a=list(map(int,input().split()))", ...
n=int(input()) a=list(map(int,input().split())) mins=100**2*n for i in range(min(a),max(a)+1): sum=0 for j in range(n): sum+=abs(a[j]-i)**2 if sum<mins: mins=sum print(mins)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 17, 17, 28, 13, 4, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 2, 13, 17, 17, 0, 13, 4, 13, 13, 13, 4, 13, 1...
[ [ 61, 2 ], [ 58, 8 ], [ 73, 20 ], [ 26, 25 ], [ 64, 30 ], [ 34, 33 ], [ 62, 36 ], [ 70, 38 ], [ 59, 42 ], [ 33, 43 ], [ 25, 45 ], [ 67, 49 ], [ 74, 52 ], [ ...
[ "n=int(input())\na=list(map(int,input().split()))\nans=10**10\nfor i in range(201):\n cnt=0\n for j in range(n):\n cnt+=(a[j]-(i-100))**2\n ans=min(ans,cnt)\nprint(ans)", "n=int(input())", "n", "int(input())", "int", "input()", "input", "a=list(map(int,input().split()))", "a", "list(map(int,...
n=int(input()) a=list(map(int,input().split())) ans=10**10 for i in range(201): cnt=0 for j in range(n): cnt+=(a[j]-(i-100))**2 ans=min(ans,cnt) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 17, 17, 28, 13, 4, 13, 4, 13, 13, 2, 4, 13, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 14, 2, 13, 1...
[ [ 76, 2 ], [ 64, 8 ], [ 67, 20 ], [ 26, 25 ], [ 65, 30 ], [ 65, 34 ], [ 70, 37 ], [ 41, 40 ], [ 77, 43 ], [ 73, 45 ], [ 65, 49 ], [ 40, 50 ], [ 25, 51 ], [ ...
[ "N =int(input())\na = list(map(int,input().split()))\nans = (10**9)\nfor av in range(min(a),max(a)+1):\n Sum = 0\n for i in range(N):\n Sum += (a[i]-av)**2\n if Sum < ans:\n ans = Sum\nprint(ans)", "N =int(input())", "N", "int(input())", "int", "input()", "input", "a = list(ma...
N =int(input()) a = list(map(int,input().split())) ans = (10**9) for av in range(min(a),max(a)+1): Sum = 0 for i in range(N): Sum += (a[i]-av)**2 if Sum < ans: ans = Sum print(ans)
[ 7, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 17, 28, 13, 4, 13, 4, 13, 13, 2, 4, 13, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 4, 1...
[ [ 61, 4 ], [ 58, 16 ], [ 22, 21 ], [ 62, 26 ], [ 62, 30 ], [ 67, 33 ], [ 37, 36 ], [ 62, 36 ], [ 64, 39 ], [ 36, 42 ], [ 21, 43 ], [ 55, 46 ], [ 65, 49 ], [ ...
[ "input();a=list(map(int,input().split()));r=float('inf')\nfor i in range(min(a),max(a)+1):\n n=0\n for j in a:\n n+=(j-i)**2\n r=min(n,r)\nprint(r)", "input()", "input", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int...
input();a=list(map(int,input().split()));r=float('inf') for i in range(min(a),max(a)+1): n=0 for j in a: n+=(j-i)**2 r=min(n,r) print(r)
[ 7, 15, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, ...
[ [ 50, 3 ], [ 59, 9 ], [ 47, 21 ], [ 60, 24 ], [ 62, 26 ], [ 48, 29 ], [ 53, 31 ], [ 35, 34 ], [ 60, 34 ], [ 56, 37 ], [ 34, 40 ], [ 63, 41 ], [ 48, 41 ], [ ...
[ "from statistics import mean\n\nn = int(input())\n\nnum_list = list(map(int, input().split()))\n\nm = mean(num_list)\n\nm = round(m)\n\ncost = 0\nfor num in num_list:\n cost += (num - m)**2\n\nprint(cost)", "from statistics import mean", "n = int(input())", "n", "int(input())", "int", "input()", "i...
from statistics import mean n = int(input()) num_list = list(map(int, input().split())) m = mean(num_list) m = round(m) cost = 0 for num in num_list: cost += (num - m)**2 print(cost)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 4, 13, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 4, 13, ...
[ [ 60, 2 ], [ 69, 8 ], [ 54, 20 ], [ 26, 25 ], [ 57, 31 ], [ 35, 34 ], [ 70, 34 ], [ 63, 37 ], [ 34, 41 ], [ 25, 42 ], [ 66, 45 ], [ 55, 48 ], [ 67, 48 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\nans = float('inf')\nfor i in range(-100, 101):\n dummy = 0\n for a_i in a:\n dummy += pow((a_i-i), 2)\n ans = min(ans, dummy)\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = list(map(int, inp...
n = int(input()) a = list(map(int, input().split())) ans = float('inf') for i in range(-100, 101): dummy = 0 for a_i in a: dummy += pow((a_i-i), 2) ans = min(ans, dummy) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 18, 13, 13, 12, 13, 29, 39, 2, 4, 13, 13, 4, 13, 13, 2, 2, 4, 13, 13, 4, 13, 13, 17, 2, 2, 4, 13, 13, 4, 13, 13, 17, 14, 2, 4, 13, 13, 17, 29...
[ [ 140, 2 ], [ 137, 8 ], [ 138, 19 ], [ 100, 28 ], [ 100, 31 ], [ 100, 36 ], [ 100, 39 ], [ 100, 45 ], [ 100, 48 ], [ 100, 54 ], [ 100, 59 ], [ 100, 63 ], [ 67, 66 ...
[ "\nn = int(raw_input())\nais = map(int, raw_input().split())\nais.sort()\n\ndef f(ais):\n\treturn [sum(ais)/len(ais),sum(ais)/len(ais)+1,sum(ais)/len(ais)-1]\n\tif len(ais) % 2:\n\t\treturn [ais[len(ais)/2]]\n\t\n\tv = ais[len(ais)/2 -1] + ais[len(ais)/2]\n\treturn [v/2,v/2-1,v/2+1]\ndef g(ais,m):\n\ts= 0\n\tfor ai...
n = int(raw_input()) ais = map(int, raw_input().split()) ais.sort() def f(ais): return [sum(ais)/len(ais),sum(ais)/len(ais)+1,sum(ais)/len(ais)-1] if len(ais) % 2: return [ais[len(ais)/2]] v = ais[len(ais)/2 -1] + ais[len(ais)/2] return [v/2,v/2-1,v/2+1] def g(ais,m): s= 0 for ai in ais: s+=abs(ai - m) **2 ...
[ 7, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 2, 4, 13, 13, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, 13, 13, 10, 2, 13, 10, 4...
[ [ 56, 2 ], [ 10, 9 ], [ 9, 18 ], [ 68, 20 ], [ 65, 23 ], [ 69, 27 ], [ 69, 30 ], [ 59, 32 ], [ 66, 35 ], [ 62, 37 ], [ 41, 40 ], [ 69, 40 ], [ 53, 43 ], [ 4...
[ "n = int(input())\na = [int(i) for i in input().split()]\n\nm = sum(a) / len(a)\nnum = round(m)\n\nloss = 0\nfor n in a:\n\tloss += (n - num)**2\n\nprint(loss)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "int(i) for i in input().split()", "for i in input().split()", "i", ...
n = int(input()) a = [int(i) for i in input().split()] m = sum(a) / len(a) num = round(m) loss = 0 for n in a: loss += (n - num)**2 print(loss)
[ 7, 15, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 2, 4, 13, 13, 13, 0, 13, 2, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 13, 18, 13, 13, 17, 28, 13, 4...
[ [ 78, 3 ], [ 75, 9 ], [ 87, 21 ], [ 76, 27 ], [ 79, 28 ], [ 90, 30 ], [ 88, 32 ], [ 84, 35 ], [ 93, 38 ], [ 42, 41 ], [ 79, 44 ], [ 81, 46 ], [ 88, 49 ], [ ...
[ "from math import *\nn=int(input())\nl=list(map(int,input().split()))\ns=ceil(sum(l)/n)\nss=s-1\nc=0\nx=0\nfor i in range(n):\n c+=(s-l[i])**2\nfor i in range(n):\n x+=(ss-l[i])**2\nprint(min(c,x))", "from math import *", "n=int(input())", "n", "int(input())", "int", "input()", "input", "l=lis...
from math import * n=int(input()) l=list(map(int,input().split())) s=ceil(sum(l)/n) ss=s-1 c=0 x=0 for i in range(n): c+=(s-l[i])**2 for i in range(n): x+=(ss-l[i])**2 print(min(c,x))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 14, 2, 13, 17, 0, 13, 4, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 2, 2, 13, 13, 17, 0, 13, 17, 14, 2, 2, ...
[ [ 110, 2 ], [ 98, 8 ], [ 89, 20 ], [ 99, 23 ], [ 92, 25 ], [ 90, 28 ], [ 99, 28 ], [ 93, 31 ], [ 104, 34 ], [ 93, 39 ], [ 111, 40 ], [ 101, 43 ], [ 93, 48 ], [ ...
[ "N = int(input())\na = list(map(int, input().split()))\na = sorted(a)\n\nx = sum(a)\nif x > 0:\n x = int(x/N+0.5)\nelse:\n x = int(x/N-0.5)\n\ntotal = 0\nif a[0] == x and a[-1] == x:\n print(0)\nelse: \n for i in range(N):\n total += (x-a[i])**2\n print(int(total))", "N = int(input())", "N", "int(inp...
N = int(input()) a = list(map(int, input().split())) a = sorted(a) x = sum(a) if x > 0: x = int(x/N+0.5) else: x = int(x/N-0.5) total = 0 if a[0] == x and a[-1] == x: print(0) else: for i in range(N): total += (x-a[i])**2 print(int(total))
[ 7, 15, 13, 15, 12, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 29, 13, 23, 13, 23, 13, 12, 13, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 17, 28, 13, 13, 0, 1...
[ [ 8, 7 ], [ 11, 10 ], [ 24, 10 ], [ 14, 13 ], [ 22, 16 ], [ 10, 17 ], [ 13, 20 ], [ 7, 20 ], [ 22, 22 ], [ 24, 24 ], [ 29, 28 ], [ 36, 35 ], [ 35, 44 ], [ 4...
[ "import math\nfrom datetime import date\n\ndef f(x, a):\n\tans = 0\n\tfor y in a:\n\t\tans += (x - y) ** 2\n\n\treturn ans\n\ndef main():\n\t\n\tn = int(input())\n\ta = [int(x) for x in input().split()]\n\ts = 0\n\tfor x in a:\n\t\ts += x\n\n\ts = s // n\n\tans = 10**17\n\n\tfor x in range(s - 2, s + 3):\n\t\tans =...
import math from datetime import date def f(x, a): ans = 0 for y in a: ans += (x - y) ** 2 return ans def main(): n = int(input()) a = [int(x) for x in input().split()] s = 0 for x in a: s += x s = s // n ans = 10**17 for x in range(s - 2, s + 3): ans = min(ans, f(x, a)) print(ans) main()
[ 7, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 4, 13, 2, 4, 13, 13, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13, ...
[ [ 57, 2 ], [ 10, 9 ], [ 9, 18 ], [ 60, 20 ], [ 48, 23 ], [ 61, 29 ], [ 58, 30 ], [ 51, 32 ], [ 36, 35 ], [ 61, 35 ], [ 54, 38 ], [ 35, 41 ], [ 49, 42 ], [ 5...
[ "n = int(input())\na = [ int(x) for x in input().split() ]\n\navg = round(sum(a) / n)\n\ncost = 0\n\nfor e in a:\n cost += (e-avg)**2\n\nprint(cost)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "int(x) for x in input().split()", "for x in input().split()", "x", "input...
n = int(input()) a = [ int(x) for x in input().split() ] avg = round(sum(a) / n) cost = 0 for e in a: cost += (e-avg)**2 print(cost)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 2, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 2, 13, 13, 14, 2...
[ [ 69, 2 ], [ 84, 8 ], [ 66, 20 ], [ 85, 23 ], [ 72, 25 ], [ 85, 28 ], [ 75, 30 ], [ 34, 33 ], [ 67, 36 ], [ 73, 38 ], [ 81, 41 ], [ 45, 44 ], [ 85, 44 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\n\nmn = min(a)\nmx = max(a)\n\nans = 10000000\nfor i in range(mn, mx+1):\n p = 0\n for j in a:\n p += (j-i) * (j-i)\n if ans > p:\n ans = p\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a...
n = int(input()) a = list(map(int, input().split())) mn = min(a) mx = max(a) ans = 10000000 for i in range(mn, mx+1): p = 0 for j in a: p += (j-i) * (j-i) if ans > p: ans = p print(ans)