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, 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, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 1...
[ [ 71, 2 ], [ 74, 8 ], [ 80, 20 ], [ 75, 23 ], [ 86, 25 ], [ 75, 28 ], [ 77, 30 ], [ 34, 33 ], [ 81, 36 ], [ 87, 38 ], [ 68, 41 ], [ 45, 44 ], [ 72, 47 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\n\na_min = min(a)\na_max = max(a)\n\na_sum = []\nfor i in range(a_min, a_max + 1):\n num=0\n for j in range(n):\n num += (a[j] - i) ** 2\n a_sum.append(num)\nprint(min(a_sum))", "n = int(input())", "n", "int(input())", "int", "input()"...
n = int(input()) a = list(map(int, input().split())) a_min = min(a) a_max = max(a) a_sum = [] for i in range(a_min, a_max + 1): num=0 for j in range(n): num += (a[j] - i) ** 2 a_sum.append(num) print(min(a_sum))
[ 7, 15, 13, 15, 13, 13, 15, 15, 15, 15, 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, 4, 13, 13, 4, 13, 4, 13, 12, 2, 2, 13, 13, 17, 23, 13, ...
[ [ 69, 11 ], [ 60, 17 ], [ 63, 29 ], [ 35, 34 ], [ 66, 40 ], [ 64, 43 ], [ 67, 43 ], [ 34, 51 ], [ 61, 55 ], [ 67, 58 ], [ 64, 58 ], [ 60, 61 ], [ 63, 64 ], [ ...
[ "import sys\nimport heapq, math\nfrom itertools import zip_longest, permutations, combinations, combinations_with_replacement\nfrom itertools import accumulate, dropwhile, takewhile, groupby\nfrom functools import lru_cache\nfrom copy import deepcopy\n\nN = int(input())\nA = list(map(int, input().split()))\n\nans =...
import sys import heapq, math from itertools import zip_longest, permutations, combinations, combinations_with_replacement from itertools import accumulate, dropwhile, takewhile, groupby from functools import lru_cache from copy import deepcopy N = int(input()) A = list(map(int, input().split())) ans = 1 << 28 for i...
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 4, 13, 17, 0, 13, 2, 2, 17, 17, 17, 12, 13, 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, ...
[ [ 90, 11 ], [ 87, 16 ], [ 26, 25 ], [ 32, 31 ], [ 44, 43 ], [ 91, 44 ], [ 47, 46 ], [ 53, 52 ], [ 56, 55 ], [ 25, 58 ], [ 61, 60 ], [ 31, 67 ], [ 55, 68 ], [ ...
[ "import sys\n\nsys.setrecursionlimit(10 ** 7)\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve():\n n = int(input())\n A = list(map(int, input().split()))\n\n res = f_inf\n for y in range(-100, 101):\n cost = 0\n for i in range(n):\n cost += pow(abs(A[i] - y), 2)\n ...
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(input()) A = list(map(int, input().split())) res = f_inf for y in range(-100, 101): cost = 0 for i in range(n): cost += pow(abs(A[i] - y), 2) res = min(res, cos...
[ 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, 28, 13, 13, 0, 13, 13, 0, 13, 2, 13, 13, 14, 2, 2, 13, 4, 13, 13, 17, 0, 13, 4, 13, 13, 0, 13, 2, 4, 13, 13, 17, 0,...
[ [ 100, 2 ], [ 94, 8 ], [ 85, 20 ], [ 79, 23 ], [ 27, 26 ], [ 95, 26 ], [ 76, 29 ], [ 26, 30 ], [ 88, 32 ], [ 77, 34 ], [ 86, 34 ], [ 101, 35 ], [ 89, 39 ], [ ...
[ "# Nの入力受付\nN = int(input())\n# aの入力受付\naN = list(map(int, input().split()))\n# 平均の値を計算\nS = 0\nA = 0\nfor i in aN:\n S += i\nA = S / N\nif A - int(A) < 0.5:\n A = int(A)\nelse:\n A = int(A) + 1\n# Aにすべて書き換えるときのコストを計算\nR = 0\nfor i in aN:\n R += (i - A)**2\nprint(R)", "N = int(input())", "N", "int(...
# Nの入力受付 N = int(input()) # aの入力受付 aN = list(map(int, input().split())) # 平均の値を計算 S = 0 A = 0 for i in aN: S += i A = S / N if A - int(A) < 0.5: A = int(A) else: A = int(A) + 1 # Aにすべて書き換えるときのコストを計算 R = 0 for i in aN: R += (i - A)**2 print(R)
[ 7, 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, 2, 4, 13, 13, 4, 13, 13, 0, 13, 4, 18, 13, 13, 2, 4, 13, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 0...
[ [ 95, 4 ], [ 98, 10 ], [ 92, 22 ], [ 99, 30 ], [ 99, 33 ], [ 83, 35 ], [ 99, 43 ], [ 99, 46 ], [ 89, 48 ], [ 77, 51 ], [ 55, 54 ], [ 99, 54 ], [ 80, 57 ], [ ...
[ "import math\nn = int(input())\nlis = list(map(int, input().split()))\n\navg1 = math.ceil(sum(lis)/len(lis))\navg2 = math.floor(sum(lis)/len(lis))\n\nans1 = 0\nans2 = 0\nfor i in lis:\n ans1 += (i-avg1)**2\n ans2 += (i-avg2)**2\n\nprint(min(ans1, ans2))", "import math", "math", "n = int(input())", "n"...
import math n = int(input()) lis = list(map(int, input().split())) avg1 = math.ceil(sum(lis)/len(lis)) avg2 = math.floor(sum(lis)/len(lis)) ans1 = 0 ans2 = 0 for i in lis: ans1 += (i-avg1)**2 ans2 += (i-avg2)**2 print(min(ans1, ans2))
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 15, 15, 15, 15, 15, 15, 15, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 4, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 39, 4, 13, 12, 13,...
[ [ 150, 4 ], [ 33, 32 ], [ 151, 40 ], [ 46, 45 ], [ 139, 52 ], [ 60, 60 ], [ 64, 64 ], [ 141, 66 ], [ 153, 71 ], [ 162, 78 ], [ 181, 80 ], [ 192, 82 ], [ 139, 84 ]...
[ "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nfrom collections import Counter, deque\nfrom collections import defaultdict\nfrom itertools import combinations, permutations, accumulate, groupby, product\nfrom bisect import bisect_left,bisect_right\nfrom heapq import heapify, heappop, heappus...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math ...
[ 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, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 2, 18, 13, 13, 13, 0, 13, 2, 2, 2, 18, 13,...
[ [ 77, 2 ], [ 74, 8 ], [ 80, 20 ], [ 75, 24 ], [ 78, 25 ], [ 92, 27 ], [ 86, 30 ], [ 34, 33 ], [ 78, 36 ], [ 89, 38 ], [ 75, 42 ], [ 33, 43 ], [ 81, 44 ], [ ...
[ "n = int(input())\nx = list(map(int,input().split()))\nave = sum(x)//n\nsum1=0\nsum2=0\nfor i in range(n):\n sum1+=(x[i]-ave)*(x[i]-ave)\n sum2+=(x[i]-ave-1)*(x[i]-ave-1)\nprint(min(sum1,sum2))", "n = int(input())", "n", "int(input())", "int", "input()", "input", "x = list(map(int,input().split(...
n = int(input()) x = list(map(int,input().split())) ave = sum(x)//n sum1=0 sum2=0 for i in range(n): sum1+=(x[i]-ave)*(x[i]-ave) sum2+=(x[i]-ave-1)*(x[i]-ave-1) print(min(sum1,sum2))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 12, 13, 29, 2, 2, 13, 13, 17, 23, 13, 23, 13, 0, 13, 4, 13, 2, 4, 13, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 0, 13, 4, 13, 13, 13, 4, 13, ...
[ [ 70, 2 ], [ 73, 8 ], [ 28, 24 ], [ 30, 25 ], [ 28, 28 ], [ 30, 30 ], [ 61, 32 ], [ 74, 38 ], [ 74, 41 ], [ 58, 43 ], [ 47, 46 ], [ 74, 46 ], [ 64, 49 ], [ ...
[ "n = int(input())\nnums = list(map(int, input().split()))\n\ndef cost(x,y):\n return (x-y)**2\n\navg = round(sum(nums)/len(nums))\n\nres = 0\nfor n in nums:\n res += cost(n, avg)\nprint(res)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "nums = list(map(int, input().split...
n = int(input()) nums = list(map(int, input().split())) def cost(x,y): return (x-y)**2 avg = round(sum(nums)/len(nums)) res = 0 for n in nums: res += cost(n, avg) print(res)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 18, 13, 17, 2, 18, 13, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, ...
[ [ 62, 2 ], [ 65, 8 ], [ 68, 22 ], [ 26, 25 ], [ 66, 29 ], [ 66, 33 ], [ 59, 37 ], [ 41, 40 ], [ 66, 40 ], [ 71, 43 ], [ 40, 46 ], [ 25, 47 ], [ 74, 50 ], [ ...
[ "N = int(input())\na = sorted(list(map(int, input().split())))\nanswer = 10000000\nfor i in range(a[0], a[-1] + 1):\n cost = 0\n for num in a:\n cost += ((num - i) ** 2)\n answer = min(answer, cost)\nprint(answer)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "a...
N = int(input()) a = sorted(list(map(int, input().split()))) answer = 10000000 for i in range(a[0], a[-1] + 1): cost = 0 for num in a: cost += ((num - i) ** 2) answer = min(answer, cost) print(answer)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 17, 0, 13, 13, 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, ...
[ [ 72, 2 ], [ 75, 8 ], [ 66, 20 ], [ 63, 25 ], [ 67, 26 ], [ 29, 28 ], [ 69, 34 ], [ 38, 37 ], [ 73, 40 ], [ 78, 42 ], [ 28, 45 ], [ 76, 47 ], [ 37, 48 ], [ ...
[ "n=int(input())\na=list(map(int,input().split()))\n\ninf=float('inf')\n\nans=inf\n\nfor b in range(-100,101):\n ch=0\n for i in range(n):\n ch+=(b-a[i])**2\n \n ans=min(ans,ch)\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())) inf=float('inf') ans=inf for b in range(-100,101): ch=0 for i in range(n): ch+=(b-a[i])**2 ans=min(ans,ch) 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, 4, 13, 2, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, ...
[ [ 72, 2 ], [ 66, 8 ], [ 63, 20 ], [ 24, 23 ], [ 73, 26 ], [ 69, 28 ], [ 67, 30 ], [ 23, 31 ], [ 60, 33 ], [ 70, 37 ], [ 64, 37 ], [ 73, 38 ], [ 75, 40 ], [ ...
[ "N = int(input())\na = list(map(int,input().split()))\nb = 0\nfor i in range(N):\n b += a[i]\nr = round(b/N)\nans = 0\nfor i in range(N):\n ans += (a[i]-r)**2\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())) b = 0 for i in range(N): b += a[i] r = round(b/N) ans = 0 for i in range(N): ans += (a[i]-r)**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, 13, 0, 13, 4, 13, 13, 0, 13, 13, 0, 13, 2, 17, 17, 42, 40, 13, 13, 0, 13, 4, 13, 2, 2, 18, 13, 13, 13, 17, 0, 13, 4, 13, 13...
[ [ 74, 2 ], [ 65, 8 ], [ 89, 20 ], [ 66, 23 ], [ 71, 25 ], [ 66, 28 ], [ 68, 30 ], [ 90, 31 ], [ 80, 33 ], [ 69, 39 ], [ 87, 39 ], [ 72, 40 ], [ 83, 42 ], [ ...
[ "n=int(input())\na=list(map(int,input().split()))\nmi=min(a)\nma=max(a)\ni=mi\nans=10**10\nwhile i<=ma:\n x=sum((a[j]-i)**2 for j in range(n))\n ans=min(ans,x)\n i+=1\nprint(ans)\n", "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())) mi=min(a) ma=max(a) i=mi ans=10**10 while i<=ma: x=sum((a[j]-i)**2 for j in range(n)) ans=min(ans,x) i+=1 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, 17, 17, 41, 28, 13, 13, 4, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 4, 13, 13, 4, 13, 13, 10, 2, 13, 10, 4, 1...
[ [ 61, 2 ], [ 55, 8 ], [ 52, 20 ], [ 26, 25 ], [ 33, 32 ], [ 56, 32 ], [ 32, 37 ], [ 25, 38 ], [ 58, 41 ], [ 53, 44 ], [ 59, 44 ], [ 59, 50 ], [ 53, 50 ], [ ...
[ "n = int(input())\narr = list(map(int, input().split()))\n\nans = 10**18\n\nfor y in range(-100, 101):\n ans = min(ans, sum([(x - y) ** 2 for x in arr]))\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "arr = list(map(int, input().split()))", "arr", "list(map(i...
n = int(input()) arr = list(map(int, input().split())) ans = 10**18 for y in range(-100, 101): ans = min(ans, sum([(x - y) ** 2 for x in arr])) 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, 2, 2, 2, 4, 13, 13, 13, 17, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, 13, 13, 10, 17, 13, 10, 2, 13, 10...
[ [ 60, 2 ], [ 63, 8 ], [ 57, 20 ], [ 64, 29 ], [ 61, 30 ], [ 51, 35 ], [ 39, 38 ], [ 64, 38 ], [ 54, 41 ], [ 38, 44 ], [ 58, 45 ], [ 55, 49 ], [ 52, 49 ], [ ...
[ "N = int(input())\nls = list(map(int,input().split()))\nave = int((sum(ls)/N*2+1)//2)\ncost = 0\nfor i in ls:\n cost += (i-ave)**2\nprint(cost)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "ls = list(map(int,input().split()))", "ls", "list(map(int,input().split()))", ...
N = int(input()) ls = list(map(int,input().split())) ave = int((sum(ls)/N*2+1)//2) cost = 0 for i in ls: cost += (i-ave)**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, 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, 2, 13, 10, 17, 13, 10, 4, 13, 1...
[ [ 54, 2 ], [ 57, 8 ], [ 45, 20 ], [ 58, 26 ], [ 55, 27 ], [ 51, 29 ], [ 33, 32 ], [ 58, 32 ], [ 48, 35 ], [ 32, 38 ], [ 46, 39 ], [ 49, 43 ], [ 52, 43 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\n\nm = round(sum(a)/n)\nans = 0\nfor i in a:\n ans += (i-m)**2\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(i...
n = int(input()) a = list(map(int, input().split())) m = round(sum(a)/n) ans = 0 for i in a: ans += (i-m)**2 print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 13, 4, 13, 4, 13, 2, 2, 13, 13, 17, 10, 4, 13, 10, 4, 13 ]
[ [ 31, 2 ], [ 34, 8 ], [ 31, 32 ], [ 34, 35 ] ]
[ "N = int(input())\nA = list(map(int,input().split()))\nprint(min(sum((a-n)**2 for a in A) for n in range(min(A),1+max(A))))", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = list(map(int,input().split()))", "A", "list(map(int,input().split()))", "list", "map(int,input(...
N = int(input()) A = list(map(int,input().split())) print(min(sum((a-n)**2 for a in A) for n in range(min(A),1+max(A))))
[ 7, 15, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 12, 4, 18, 4, 18, 18, 13, 13, 13, 13, 0, 13, 12, 4, 13, 8, 13, 39, 4, 13, 17, 4, 13, 17, 23, 0, 13, 12, 4, 13, 8, 13, ...
[ [ 143, 11 ], [ 149, 16 ], [ 146, 23 ], [ 137, 35 ], [ 131, 50 ], [ 140, 65 ], [ 77, 76 ], [ 147, 80 ], [ 83, 82 ], [ 147, 91 ], [ 95, 94 ], [ 144, 95 ], [ 98, 97 ...
[ "# -*- coding: utf-8 -*-\nimport sys\nsys.setrecursionlimit(10**9)\nINF=10**18\nMOD=10**9+7\ninput=lambda: sys.stdin.readline().rstrip()\nYesNo=lambda b: bool([print('Yes')] if b else print('No'))\nYESNO=lambda b: bool([print('YES')] if b else print('NO'))\nint1=lambda x:int(x)-1\n\ndef main():\n N=int(input())\...
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF=10**18 MOD=10**9+7 input=lambda: sys.stdin.readline().rstrip() YesNo=lambda b: bool([print('Yes')] if b else print('No')) YESNO=lambda b: bool([print('YES')] if b else print('NO')) int1=lambda x:int(x)-1 def main(): N=int(input()) a=list(map(i...
[ 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, 4, 18, 13, 13, 13, 41, 28, 13, 13, 4, 2, 2, 13, 13, 17, 4, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 46, 4 ], [ 49, 10 ], [ 52, 22 ], [ 50, 29 ], [ 33, 32 ], [ 50, 32 ], [ 53, 37 ], [ 32, 38 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ] ]
[ "import statistics\nn=int(input())\na=list(map(int,input().split()))\nnum=round(statistics.mean(a))\nprint(sum([(num-i)**2 for i in a]))", "import statistics", "statistics", "n=int(input())", "n", "int(input())", "int", "input()", "input", "a=list(map(int,input().split()))", "a", "list(map(int...
import statistics n=int(input()) a=list(map(int,input().split())) num=round(statistics.mean(a)) print(sum([(num-i)**2 for i in 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, 2, 4, 13, 13, 13, 17, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17,...
[ [ 82, 2 ], [ 88, 8 ], [ 73, 20 ], [ 89, 24 ], [ 83, 25 ], [ 94, 27 ], [ 89, 33 ], [ 83, 34 ], [ 83, 36 ], [ 85, 38 ], [ 76, 41 ], [ 45, 44 ], [ 83, 47 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\nm1 = sum(a) // n\nm2 = (sum(a) + n - 1) // n\n\nres1 = 0\nres2 = 0\nfor i in range(n):\n res1 += (a[i] - m1) ** 2\n res2 += (a[i] - m2) ** 2\n\nprint(min(res1, res2))", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a ...
n = int(input()) a = list(map(int, input().split())) m1 = sum(a) // n m2 = (sum(a) + n - 1) // n res1 = 0 res2 = 0 for i in range(n): res1 += (a[i] - m1) ** 2 res2 += (a[i] - m2) ** 2 print(min(res1, res2))
[ 7, 0, 13, 4, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 15, 15, 0, 13, 4, 13, 13, 14, 2, 13, 2, 4, 13, 13, 17, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2...
[ [ 64, 2 ], [ 10, 9 ], [ 9, 18 ], [ 76, 20 ], [ 82, 25 ], [ 77, 28 ], [ 83, 31 ], [ 83, 35 ], [ 73, 38 ], [ 83, 41 ], [ 79, 43 ], [ 83, 46 ], [ 67, 48 ], [ 5...
[ "N = int(input())\nA = [int(x) for x in input().split()]\nfrom statistics import mean\nfrom math import floor, ceil\nmeanA = mean(A)\nif meanA < floor(meanA) + 0.5:\n meanA = floor(meanA)\nelse:\n meanA = ceil(meanA)\nans = 0\nfor a in A:\n ans += (a-meanA)**2\nprint(ans)", "N = int(input())", "N", "...
N = int(input()) A = [int(x) for x in input().split()] from statistics import mean from math import floor, ceil meanA = mean(A) if meanA < floor(meanA) + 0.5: meanA = floor(meanA) else: meanA = ceil(meanA) ans = 0 for a in A: ans += (a-meanA)**2 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, 4, 13, 13, 28, 13, 4, 13, 18, 13, 17, 2, 18, 13, 2, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 4, 13, 2, 18, 13, ...
[ [ 83, 2 ], [ 92, 8 ], [ 86, 20 ], [ 95, 23 ], [ 93, 26 ], [ 29, 28 ], [ 96, 32 ], [ 93, 32 ], [ 96, 36 ], [ 93, 36 ], [ 84, 38 ], [ 89, 42 ], [ 46, 45 ], [ ...
[ "n = int(input())\na = list(map(int,input().split()))\nans = 1000000\na = sorted(a)\nfor i in range(a[0],a[n-1]+1):\n counter = 0\n for j in range(n):\n dif = abs(a[j] - i)\n dif *= dif\n counter += dif\n ans = min(ans,counter)\nprint(ans)", "n = int(input())", "n", "int(input())...
n = int(input()) a = list(map(int,input().split())) ans = 1000000 a = sorted(a) for i in range(a[0],a[n-1]+1): counter = 0 for j in range(n): dif = abs(a[j] - i) dif *= dif counter += dif ans = min(ans,counter) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 2, 2, 4, 13, 13, 4, 13, 13, 17, 13, 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,...
[ [ 67, 2 ], [ 82, 8 ], [ 70, 20 ], [ 83, 26 ], [ 83, 29 ], [ 68, 31 ], [ 34, 33 ], [ 83, 38 ], [ 83, 42 ], [ 79, 45 ], [ 49, 48 ], [ 83, 48 ], [ 73, 51 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\ncmin = ((max(a) - min(a)) ** 2) * n\nfor x in range(min(a), max(a) + 1):\n c = 0\n for i in a:\n c += (i - x) ** 2\n cmin = min(c, cmin)\nprint(cmin)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = list(...
n = int(input()) a = list(map(int, input().split())) cmin = ((max(a) - min(a)) ** 2) * n for x in range(min(a), max(a) + 1): c = 0 for i in a: c += (i - x) ** 2 cmin = min(c, cmin) print(cmin)
[ 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, 4, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 1...
[ [ 51, 2 ], [ 45, 8 ], [ 57, 20 ], [ 46, 26 ], [ 52, 27 ], [ 48, 29 ], [ 33, 32 ], [ 46, 32 ], [ 54, 35 ], [ 32, 38 ], [ 58, 39 ], [ 55, 43 ], [ 49, 43 ], [ ...
[ "n=int(input())\nX=list(map(int, input().split()))\ny=round(sum(X)/n)\ncost=0\nfor x in X:\n cost+=(x-y)**2\n\nprint(cost)", "n=int(input())", "n", "int(input())", "int", "input()", "input", "X=list(map(int, input().split()))", "X", "list(map(int, input().split()))", "list", "map(int, input...
n=int(input()) X=list(map(int, input().split())) y=round(sum(X)/n) cost=0 for x in X: cost+=(x-y)**2 print(cost)
[ 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, 2, 4, 13, 13, 4, 13, 13, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 2, 2, 2, 13, 17, 13, 17, 4, 13, 4, 13, ...
[ [ 66, 2 ], [ 78, 8 ], [ 60, 20 ], [ 75, 23 ], [ 63, 26 ], [ 79, 30 ], [ 79, 33 ], [ 36, 35 ], [ 79, 35 ], [ 69, 38 ], [ 64, 41 ], [ 35, 42 ], [ 72, 45 ], [ ...
[ "N = int(input())\nnumber = list(map(int, input().split()))\ntotal_a = 0\ntotal_b = 0\naverage = sum(number)//len(number)\n\nfor i in number:\n total_a += (average-i)**2\n total_b += (average+1-i)**2\n\nprint(min(total_a, total_b))", "N = int(input())", "N", "int(input())", "int", "input()", "inpu...
N = int(input()) number = list(map(int, input().split())) total_a = 0 total_b = 0 average = sum(number)//len(number) for i in number: total_a += (average-i)**2 total_b += (average+1-i)**2 print(min(total_a, total_b))
[ 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, 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, 40, ...
[ [ 71, 2 ], [ 65, 8 ], [ 74, 20 ], [ 77, 23 ], [ 27, 26 ], [ 66, 31 ], [ 66, 35 ], [ 80, 38 ], [ 42, 41 ], [ 72, 44 ], [ 83, 46 ], [ 66, 50 ], [ 41, 51 ], [ ...
[ "#!/usr/bin/env python\n\nn = int(input())\na = list(map(int, input().split()))\n\nans = 1000100\nch = 0 \nfor ch in range(min(a), max(a)+1):\n tmp = 0 \n for i in range(n):\n tmp += (a[i]-ch)**2\n if tmp <= ans:\n ans = tmp \nprint(ans)", "n = int(input())", "n", "int(input())", "int...
#!/usr/bin/env python n = int(input()) a = list(map(int, input().split())) ans = 1000100 ch = 0 for ch in range(min(a), max(a)+1): tmp = 0 for i in range(n): tmp += (a[i]-ch)**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, 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, 28, 13, 4, 13, 4, 13, 13, 0, ...
[ [ 85, 2 ], [ 76, 8 ], [ 91, 20 ], [ 77, 23 ], [ 92, 26 ], [ 73, 29 ], [ 92, 34 ], [ 86, 35 ], [ 88, 38 ], [ 92, 43 ], [ 86, 44 ], [ 79, 47 ], [ 51, 50 ], [ ...
[ "n = int(input())\narr = list(map(int,input().split()))\nadd = sum(arr)\nif add>0:\n\tx = int(add/n + 0.5)\nelse:\n\tx = int(add/n - 0.5)\n\nans = 0\nfor i in range(len(arr)):\n\tans += ((x-arr[i])*(x-arr[i]))\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "arr = lis...
n = int(input()) arr = list(map(int,input().split())) add = sum(arr) if add>0: x = int(add/n + 0.5) else: x = int(add/n - 0.5) ans = 0 for i in range(len(arr)): ans += ((x-arr[i])*(x-arr[i])) 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, 0, 13, 4, 13...
[ [ 75, 2 ], [ 72, 8 ], [ 78, 20 ], [ 26, 25 ], [ 73, 30 ], [ 73, 34 ], [ 69, 37 ], [ 41, 40 ], [ 76, 43 ], [ 66, 45 ], [ 73, 49 ], [ 40, 50 ], [ 25, 51 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\nans = 10**10\nfor i in range(min(a), max(a)+1):\n cnt = 0\n for j in range(n):\n cnt += (a[j]-i) ** 2\n ans = min(ans, cnt)\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = list(map(int, input...
n = int(input()) a = list(map(int, input().split())) ans = 10**10 for i in range(min(a), max(a)+1): cnt = 0 for j in range(n): cnt += (a[j]-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, 17, 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, 14, 2, 13, 17, 0, 13, ...
[ [ 86, 2 ], [ 68, 8 ], [ 80, 20 ], [ 83, 23 ], [ 27, 26 ], [ 71, 32 ], [ 36, 35 ], [ 69, 40 ], [ 74, 42 ], [ 69, 46 ], [ 35, 47 ], [ 26, 48 ], [ 81, 52 ], [ ...
[ "N = int(input())\na = list(map(int, input().split()))\nmin_val = None\nstacks = 0\n\nfor i in range(-100, 101):\n cost_stack = 0\n for j in range(len(a)):\n cost_stack += (a[j] - i) ** 2\n \n if min_val == None:\n min_val = cost_stack\n elif cost_stack < min_val:\n min_val =...
N = int(input()) a = list(map(int, input().split())) min_val = None stacks = 0 for i in range(-100, 101): cost_stack = 0 for j in range(len(a)): cost_stack += (a[j] - i) ** 2 if min_val == None: min_val = cost_stack elif cost_stack < min_val: min_val = cost_stack print...
[ 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, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 17, 13, 10, ...
[ [ 62, 2 ], [ 56, 8 ], [ 59, 20 ], [ 26, 25 ], [ 53, 31 ], [ 35, 34 ], [ 57, 34 ], [ 65, 37 ], [ 34, 40 ], [ 25, 41 ], [ 68, 44 ], [ 66, 47 ], [ 54, 47 ], [ ...
[ "n = int(input())\na = list(map(int,input().split()))\n\nans =10**8\nfor i in range(-100,101):\n cost = 0\n for k in a:\n cost += (k-i)**2\n ans = min(cost,ans)\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 =10**8 for i in range(-100,101): cost = 0 for k in a: cost += (k-i)**2 ans = min(cost,ans) print(ans)
[ 7, 0, 13, 4, 13, 13, 4, 18, 4, 18, 4, 13, 17, 13, 13, 31, 13, 0, 13, 4, 13, 2, 4, 13, 13, 13, 4, 13, 4, 13, 4, 13, 12, 2, 2, 13, 13, 17, 23, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 44, 2 ], [ 44, 15 ], [ 41, 18 ], [ 45, 25 ], [ 42, 36 ], [ 41, 42 ], [ 44, 45 ] ]
[ "n, *A = map(int, open(0).read().split())\nm = round(sum(A) / n)\nprint(sum(map(lambda x: (x-m)**2, A)))", "n, *A = map(int, open(0).read().split())", "n", "map(int, open(0).read().split())", "map", "int", "open(0).read().split()", "(0).read().split", "(0).read()", "(0).read", "(0)", "open", ...
n, *A = map(int, open(0).read().split()) m = round(sum(A) / n) print(sum(map(lambda x: (x-m)**2, A)))
[ 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, 17, 13, 10, ...
[ [ 65, 2 ], [ 68, 8 ], [ 62, 20 ], [ 26, 25 ], [ 53, 31 ], [ 35, 34 ], [ 69, 34 ], [ 59, 37 ], [ 34, 40 ], [ 25, 41 ], [ 56, 44 ], [ 63, 47 ], [ 57, 47 ], [ ...
[ "n=int(input())\na=list(map(int,input().split()))\nans=float(\"inf\")\nfor i in range(-100,101):\n k=0\n for j in a:\n k+=(j-i)**2\n ans=min(ans,k)\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=float("inf") for i in range(-100,101): k=0 for j in a: k+=(j-i)**2 ans=min(ans,k) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 12, 4, 13, 2, 2, 2, 13, 17, 17, 17, 23, 0, 13, 4, 13, 2, 4, 13, 13, 4, 13, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, ...
[ [ 69, 2 ], [ 72, 8 ], [ 75, 20 ], [ 63, 33 ], [ 76, 35 ], [ 73, 39 ], [ 73, 42 ], [ 60, 44 ], [ 48, 47 ], [ 73, 47 ], [ 66, 50 ], [ 47, 53 ], [ 64, 54 ], [ ...
[ "N = int(input())\na = list(map(int, input().split()))\n\nmy_round_int = lambda x: int((x * 2 + 1) // 2)\nm = my_round_int(sum(a)/len(a))\n\ncost = 0\n\nfor i in a:\n cost += (i - m)**2\n\nprint(cost)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "a = list(map(int, input().s...
N = int(input()) a = list(map(int, input().split())) my_round_int = lambda x: int((x * 2 + 1) // 2) m = my_round_int(sum(a)/len(a)) cost = 0 for i in a: cost += (i - m)**2 print(cost)
[ 7, 12, 13, 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, 41, 28, 13, 13, 4, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 13, 4, 13, 13, 14, 2, ...
[ [ 5, 4 ], [ 11, 10 ], [ 23, 22 ], [ 26, 25 ], [ 33, 32 ], [ 10, 32 ], [ 32, 37 ], [ 25, 38 ], [ 42, 41 ], [ 47, 46 ], [ 22, 49 ], [ 46, 49 ], [ 41, 50 ], [ ...
[ "\ndef main():\n n = int(input())\n a_s = list(map(int,input().split()))\n answer = 999999999999999999999999999999999\n\n for i in range(-100,101):\n temp = sum([(a-i) ** 2 for a in a_s ])\n answer = min(answer,temp)\n print(answer)\n\nif __name__ == '__main__':\n main()", "def mai...
def main(): n = int(input()) a_s = list(map(int,input().split())) answer = 999999999999999999999999999999999 for i in range(-100,101): temp = sum([(a-i) ** 2 for a in a_s ]) answer = min(answer,temp) print(answer) 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, 4, 13, 13, 13, 0, 13, 2, 2, 2, 4, 13, 13, 17, 13, 17, 4, 13, 4, 13, 4, 13, 2, 2, 13, 13, 2, 13, 13, 4, 13, 2, 2, 13, 13, 2, 1...
[ [ 60, 2 ], [ 66, 8 ], [ 69, 20 ], [ 67, 24 ], [ 61, 25 ], [ 63, 27 ], [ 67, 33 ], [ 61, 35 ], [ 70, 46 ], [ 70, 49 ], [ 64, 55 ], [ 64, 58 ], [ 60, 61 ], [ ...
[ "N=int(input())\na=list(map(int,input().split()))\n\nA=sum(a)//N\nB=(sum(a)-1)//N+1\n\n\nprint(min(sum((x-A)*(x-A) for x in a),sum((x-B)*(x-B) for x in a)))", "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())) A=sum(a)//N B=(sum(a)-1)//N+1 print(min(sum((x-A)*(x-A) for x in a),sum((x-B)*(x-B) for x in a)))
[ 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, 17, 28, 13, 4, 13, 17, 17, 0, 13, 4, 13, 13, 4, 13, 2, 2, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 13, ...
[ [ 49, 2 ], [ 10, 9 ], [ 9, 18 ], [ 55, 20 ], [ 52, 23 ], [ 29, 28 ], [ 58, 34 ], [ 53, 37 ], [ 59, 37 ], [ 50, 42 ], [ 28, 43 ], [ 59, 47 ], [ 53, 47 ], [ 4...
[ "n = int(input())\nl = [int(i)for i in input().split()]\nr = float(\"inf\")\nfor i in range(-100, 101):\n r = min(r, sum((n - i)**2 for n in l))\nprint(r)", "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()) l = [int(i)for i in input().split()] r = float("inf") for i in range(-100, 101): r = min(r, sum((n - i)**2 for n in l)) print(r)
[ 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, 13, 18, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, ...
[ [ 72, 2 ], [ 60, 7 ], [ 63, 13 ], [ 26, 25 ], [ 57, 31 ], [ 35, 34 ], [ 61, 37 ], [ 69, 39 ], [ 25, 42 ], [ 64, 44 ], [ 34, 45 ], [ 66, 48 ], [ 70, 51 ], [ ...
[ "ans=10**10\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+=(i-a[j])**2\n ans=min(x,ans)\nprint(ans)", "ans=10**10", "ans", "10**10", "10", "10", "n=int(input())", "n", "int(input())", "int", "input()", "input", "a=list(map(i...
ans=10**10 n=int(input()) a=list(map(int,input().split())) for i in range(-100,101): x=0 for j in range(n): x+=(i-a[j])**2 ans=min(x,ans) print(ans)
[ 7, 0, 13, 17, 0, 13, 4, 13, 4, 13, 0, 13, 17, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 4, 13, 13, 13, 0, 13, 2, 13, 17, 28, 13, 13, 0, 13, 2, 4, 13, 2, 13, 13, 17, 0, 13, 2, 4, 13, 2, 13, 13, ...
[ [ 80, 2 ], [ 65, 5 ], [ 68, 11 ], [ 74, 14 ], [ 71, 26 ], [ 75, 30 ], [ 66, 31 ], [ 86, 33 ], [ 72, 35 ], [ 39, 38 ], [ 75, 38 ], [ 77, 41 ], [ 38, 46 ], [ ...
[ "ans=0\nn=int(input())\nres=0\na=list(map(int,input().split()))\nb=sum(a)//n\nc=b+1\nfor i in a:\n ans+=abs(i-b)**2\n res+=abs(i-c)**2\nprint(min(ans,res))", "ans=0", "ans", "0", "n=int(input())", "n", "int(input())", "int", "input()", "input", "res=0", "res", "0", "a=list(map(int,in...
ans=0 n=int(input()) res=0 a=list(map(int,input().split())) b=sum(a)//n c=b+1 for i in a: ans+=abs(i-b)**2 res+=abs(i-c)**2 print(min(ans,res))
[ 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, 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, ...
[ [ 5, 4 ], [ 11, 10 ], [ 23, 22 ], [ 28, 27 ], [ 34, 33 ], [ 37, 36 ], [ 4, 39 ], [ 42, 41 ], [ 10, 45 ], [ 36, 46 ], [ 27, 47 ], [ 51, 50 ], [ 22, 53 ], [ 5...
[ "def main():\n n = int(input())\n As = list(map(int, input().split()))\n ans = float(\"inf\")\n\n for i in range(-100, 101):\n ans_temp = 0\n for j in range(n):\n ans_temp += (As[j] + i)**2\n ans = min(ans, ans_temp)\n print(ans)\n\n\nif __name__ == \"__main__\":\n ...
def main(): n = int(input()) As = list(map(int, input().split())) ans = float("inf") for i in range(-100, 101): ans_temp = 0 for j in range(n): ans_temp += (As[j] + i)**2 ans = min(ans, ans_temp) print(ans) if __name__ == "__main__": main()
[ 7, 15, 13, 12, 13, 0, 13, 4, 13, 17, 28, 13, 4, 13, 17, 17, 0, 13, 4, 13, 13, 4, 13, 2, 2, 13, 13, 17, 29, 13, 23, 13, 23, 13, 12, 13, 12, 13, 28, 13, 18, 13, 13, 28, 13, 4, 18, 13, 13, 27, 13, 0, 13, 4, 13, ...
[ [ 7, 6 ], [ 12, 11 ], [ 18, 17 ], [ 6, 20 ], [ 17, 20 ], [ 11, 26 ], [ 17, 29 ], [ 6, 29 ], [ 31, 31 ], [ 33, 33 ], [ 40, 39 ], [ 45, 44 ], [ 39, 47 ], [ 44...
[ "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, a: \"List[int]\"):\n ans = float(\"inf\")\n for m in range(-100, 101):\n ans = min(ans,\n sum((aa-m)**2 for aa in a))\n return ans\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools\ndef main():\n ...
#!/usr/bin/env python3 import sys def solve(N: int, a: "List[int]"): ans = float("inf") for m in range(-100, 101): ans = min(ans, sum((aa-m)**2 for aa in a)) return ans # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools def main(): def iterate_tokens(): ...
[ 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, 17, 14, 2, 13, 2, 13, 17, 14, 2, 13, 13, 0, ...
[ [ 62, 2 ], [ 71, 8 ], [ 74, 20 ], [ 24, 23 ], [ 65, 29 ], [ 33, 32 ], [ 63, 35 ], [ 68, 37 ], [ 23, 40 ], [ 72, 42 ], [ 32, 43 ], [ 32, 47 ], [ 63, 49 ], [ ...
[ "n=int(input())\na=list(map(int,input().split()))\n# n=2\n# a=[4,8]\nminimum=10000000\nfor i in range(-100,101):\n cost=0\n for j in range(n):\n cost+=(i-(a[j]))**2\n if j==n-1:\n if cost<minimum:\n minimum=cost\n\nprint(minimum)\n\n", "n=int(input())", "n", "int(...
n=int(input()) a=list(map(int,input().split())) # n=2 # a=[4,8] minimum=10000000 for i in range(-100,101): cost=0 for j in range(n): cost+=(i-(a[j]))**2 if j==n-1: if cost<minimum: minimum=cost print(minimum)
[ 7, 15, 13, 12, 13, 29, 4, 13, 4, 18, 4, 13, 13, 12, 13, 29, 4, 13, 4, 13, 13, 4, 18, 4, 18, 4, 13, 13, 13, 17, 12, 13, 0, 13, 4, 13, 0, 13, 4, 13, 0, 13, 2, 4, 13, 13, 13, 0, 13, 12, 4, 13, 2, 4, 13, 2, 1...
[ [ 34, 33 ], [ 93, 35 ], [ 38, 37 ], [ 87, 39 ], [ 42, 41 ], [ 37, 45 ], [ 33, 46 ], [ 49, 48 ], [ 48, 64 ], [ 41, 69 ], [ 48, 71 ], [ 41, 76 ], [ 90, 84 ] ]
[ "import math\n\n\ndef read_int():\n return int(input().strip())\n\n\ndef read_ints():\n return list(map(int, input().strip().split(' ')))\n\n\ndef solve():\n N = read_int()\n A = read_ints()\n avg = sum(A)/N\n cost = lambda M: sum(abs(a-M)**2 for a in A)\n return min(cost(math.floor(avg)), cost...
import math def read_int(): return int(input().strip()) def read_ints(): return list(map(int, input().strip().split(' '))) def solve(): N = read_int() A = read_ints() avg = sum(A)/N cost = lambda M: sum(abs(a-M)**2 for a in A) return min(cost(math.floor(avg)), cost(math.ceil(avg))) i...
[ 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, 4, 13, 10, 17, 13, ...
[ [ 66, 2 ], [ 57, 8 ], [ 54, 20 ], [ 24, 23 ], [ 63, 29 ], [ 33, 32 ], [ 58, 32 ], [ 60, 35 ], [ 32, 38 ], [ 23, 39 ], [ 51, 42 ], [ 55, 45 ], [ 52, 45 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\n\nans = 10000000\nfor i in range(-100, 101):\n sm = 0\n for x in a:\n sm += (x-i) ** 2\n ans = min(ans, sm)\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 = 10000000 for i in range(-100, 101): sm = 0 for x in a: sm += (x-i) ** 2 ans = min(ans, sm) 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, 0, 13, 4, 13, 13, 13, 4, 13, 13, ...
[ [ 60, 2 ], [ 63, 8 ], [ 69, 20 ], [ 26, 25 ], [ 57, 31 ], [ 35, 34 ], [ 61, 37 ], [ 66, 39 ], [ 64, 43 ], [ 34, 44 ], [ 25, 45 ], [ 72, 48 ], [ 70, 51 ], [ ...
[ "n = int(input())\na = list(map(int,input().split()))\nans = float('INF')\nfor i in range(-100,101):\n s = 0\n for j in range(n):\n s += (a[j]-i)**2\n ans = min(ans,s)\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): s = 0 for j in range(n): s += (a[j]-i)**2 ans = min(ans,s) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 18, 13, 13, 12, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 2, 13, 13, 29, 13, 23, 13, 23, 13, 0, 13, 18, 13, 17, 0, 13, 18, 13, 2, ...
[ [ 111, 2 ], [ 105, 8 ], [ 106, 21 ], [ 27, 26 ], [ 30, 29 ], [ 43, 29 ], [ 33, 32 ], [ 29, 35 ], [ 45, 36 ], [ 29, 38 ], [ 45, 39 ], [ 32, 41 ], [ 26, 41 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\n\na.sort()\n\ndef cost(a, y):\n ans = 0\n for i in a:\n ans += (i - y) * (i - y)\n return ans\n\n# binary search\n\nleft = a[0]\nright = a[n-1]\n\nwhile left < right:\n center = (left + right) // 2\n if cost(a, center) < cost(a, center+1)...
n = int(input()) a = list(map(int, input().split())) a.sort() def cost(a, y): ans = 0 for i in a: ans += (i - y) * (i - y) return ans # binary search left = a[0] right = a[n-1] while left < right: center = (left + right) // 2 if cost(a, center) < cost(a, center+1): right = cente...
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 39, 0, 13, 17, 14, 2, 2, 2, 4, 13, 13, 4, 13, 13, 17, 17, 0, 13, 2, 2, 4, 13, 13, 4, 13, 13, 17, 0, 13, 2, 2, 2, 4, 13, 13, 4, 1...
[ [ 104, 2 ], [ 92, 8 ], [ 101, 20 ], [ 110, 23 ], [ 93, 31 ], [ 93, 34 ], [ 95, 38 ], [ 93, 43 ], [ 93, 46 ], [ 98, 49 ], [ 93, 55 ], [ 93, 58 ], [ 63, 62 ], [ ...
[ "N = int(input())\na = list(map(int,input().split()))\nans = []\n\navg = 0\nif (max(a)+min(a))%2 == 0:\n avg = (max(a)+min(a))/2\nelse:\n avg = (max(a)+min(a))/2+1\n\nfor i in range(-100,101,1):\n sum = 0\n for j in a:\n sum += (j-i)**2\n ans.append(sum)\n \nprint(min(ans))", "N = int(inp...
N = int(input()) a = list(map(int,input().split())) ans = [] avg = 0 if (max(a)+min(a))%2 == 0: avg = (max(a)+min(a))/2 else: avg = (max(a)+min(a))/2+1 for i in range(-100,101,1): sum = 0 for j in a: sum += (j-i)**2 ans.append(sum) print(min(ans))
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 15, 15, 15, 15, 15, 15, 15, 12, 13, 12, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 4, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 39, 4, 13, 12, 13,...
[ [ 120, 4 ], [ 33, 32 ], [ 121, 40 ], [ 46, 45 ], [ 163, 52 ], [ 60, 60 ], [ 64, 64 ], [ 165, 66 ], [ 135, 71 ], [ 141, 78 ], [ 160, 80 ], [ 144, 82 ], [ 163, 84 ]...
[ "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nfrom collections import Counter, deque\nfrom collections import defaultdict\nfrom itertools import combinations, permutations, accumulate, groupby, product\nfrom bisect import bisect_left,bisect_right\nfrom heapq import heapify, heappop, heappus...
import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math ...
[ 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 ], [ 60, 8 ], [ 57, 20 ], [ 24, 23 ], [ 63, 29 ], [ 33, 32 ], [ 61, 32 ], [ 51, 35 ], [ 32, 38 ], [ 23, 39 ], [ 54, 42 ], [ 58, 45 ], [ 55, 45 ], [ ...
[ "n=int(input())\na=list(map(int,input().split()))\n\nmin_cost=10000000000\n\nfor x in range(-100,101):\n i=0\n for y in a:\n i+=(y-x)**2\n min_cost=min(min_cost,i)\n \nprint(min_cost)", "n=int(input())", "n", "int(input())", "int", "input()", "input", "a=list(map(int,input().split()...
n=int(input()) a=list(map(int,input().split())) min_cost=10000000000 for x in range(-100,101): i=0 for y in a: i+=(y-x)**2 min_cost=min(min_cost,i) print(min_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, 4, 13, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 4, 13, 10, 17, ...
[ [ 52, 2 ], [ 61, 8 ], [ 55, 20 ], [ 24, 23 ], [ 64, 29 ], [ 33, 32 ], [ 62, 32 ], [ 67, 35 ], [ 23, 39 ], [ 32, 40 ], [ 58, 43 ], [ 56, 46 ], [ 59, 46 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\n\nans = 1e9\nfor p in range(-100, 101):\n sub = 0\n for q in a:\n sub += pow(p - q, 2)\n ans = min(ans, sub)\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 = 1e9 for p in range(-100, 101): sub = 0 for q in a: sub += pow(p - q, 2) ans = min(ans, sub) print(ans)
[ 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, 17, 0, 13, 17, 28, 13, 4, 13, 18, 13, 17, 18, 13, 17, 28, 13, 4, 13, 4, 13, 13, 0, 13, 2, 13, 2, 2, 18, 13, 13, 13, ...
[ [ 79, 2 ], [ 82, 8 ], [ 83, 21 ], [ 85, 24 ], [ 91, 27 ], [ 31, 30 ], [ 83, 34 ], [ 83, 37 ], [ 41, 40 ], [ 83, 45 ], [ 100, 47 ], [ 86, 49 ], [ 101, 49 ], [ ...
[ "n = int(input()) \na_list = list(map(int, input().split()))\na_list.sort()\ncost = 0\nmin_cost=0\n \nfor i in range(a_list[0], a_list[-1]):\n for j in range(len(a_list)):\n cost = cost + (a_list[j] - i)**2\n \n if i == a_list[0]:\n min_cost=cost\n ...
n = int(input()) a_list = list(map(int, input().split())) a_list.sort() cost = 0 min_cost=0 for i in range(a_list[0], a_list[-1]): for j in range(len(a_list)): cost = cost + (a_list[j] - i)**2 if i == a_list[0]: min_cost=cost min_cost = 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, 4, 13, 13, 0, 13, 2, 2, 13, 18, 13, 13, 17, 14, 2, 13, 13, 0, 13, 13, ...
[ [ 60, 2 ], [ 75, 8 ], [ 66, 20 ], [ 26, 25 ], [ 63, 31 ], [ 35, 34 ], [ 76, 39 ], [ 69, 41 ], [ 25, 44 ], [ 76, 46 ], [ 34, 47 ], [ 70, 51 ], [ 64, 51 ], [ ...
[ "N = int(input())\na = list(map(int, input().split()))\nres = 10**9\nfor i in range(-100,101):\n SUM = 0\n for j in range(len(a)):\n SUM += (i-a[j])**2\n if SUM < res:\n res = SUM\nprint(res)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "a = list(map(int...
N = int(input()) a = list(map(int, input().split())) res = 10**9 for i in range(-100,101): SUM = 0 for j in range(len(a)): SUM += (i-a[j])**2 if SUM < res: res = SUM 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, 17, 17, 28, 13, 4, 13, 17, 17, 0, 13, 4, 13, 4, 13, 12, 2, 2, 13, 13, 17, 23, 13, 0, 13, 4, 13, 13, 14, 2, 13, 13, 0, 13, 1...
[ [ 73, 2 ], [ 67, 8 ], [ 64, 20 ], [ 27, 26 ], [ 76, 32 ], [ 26, 41 ], [ 68, 44 ], [ 70, 46 ], [ 77, 49 ], [ 65, 52 ], [ 62, 52 ], [ 71, 53 ], [ 61, 55 ], [ ...
[ "n = int(input())\nlist_A = list(map(int, input().split()))\nans = pow(10, 10)\nfor num in range(-100, 101):\n list_B = list(map(lambda x:(x-num)**2, list_A))\n sum_value = sum(list_B)\n if ans > sum_value:\n ans = sum_value\n\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "...
n = int(input()) list_A = list(map(int, input().split())) ans = pow(10, 10) for num in range(-100, 101): list_B = list(map(lambda x:(x-num)**2, list_A)) sum_value = sum(list_B) if ans > sum_value: ans = sum_value print(ans)
[ 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, 4, 13, 13, 13, 14, 2, 13, 13, 0, 13, 39, 13, 0, 13, 39, 13, 2, 13, 17, 0, 13, 2, 17, 17, 28, 13, 13, 0...
[ [ 104, 2 ], [ 89, 8 ], [ 86, 20 ], [ 90, 24 ], [ 105, 25 ], [ 92, 27 ], [ 90, 31 ], [ 105, 32 ], [ 87, 35 ], [ 93, 36 ], [ 110, 38 ], [ 83, 42 ], [ 93, 46 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\n\nx = sum(a) / n\ny = sum(a) // n\nif x == y:\n cand = [y]\nelse:\n cand = [y, y+1]\n\ncost = 10**18\nfor ave in cand:\n c = 0\n for i in range(n):\n c += (a[i]-ave)**2\n cost = min(cost, c)\n\nprint(cost)", "n = int(input())", "n", "int(i...
n = int(input()) a = list(map(int, input().split())) x = sum(a) / n y = sum(a) // n if x == y: cand = [y] else: cand = [y, y+1] cost = 10**18 for ave in cand: c = 0 for i in range(n): c += (a[i]-ave)**2 cost = min(cost, c) print(cost)
[ 7, 12, 13, 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, 0, 13, 17, 28, 13, 13, 14, 40, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, 18, 13, ...
[ [ 5, 4 ], [ 11, 10 ], [ 23, 22 ], [ 26, 25 ], [ 10, 30 ], [ 10, 34 ], [ 38, 37 ], [ 41, 40 ], [ 10, 40 ], [ 25, 44 ], [ 40, 45 ], [ 48, 47 ], [ 25, 50 ], [ ...
[ "def main():\n n = int(input())\n a = list(map(int,input().split()))\n listcost = []\n \n for i in range(min(a),max(a)+1):\n cost = 0\n for j in a:\n if i != j:\n cost += (i - j) ** 2\n listcost.append(cost)\n print(min(listcost))\n \n \nif __name__==...
def main(): n = int(input()) a = list(map(int,input().split())) listcost = [] for i in range(min(a),max(a)+1): cost = 0 for j in a: if i != j: cost += (i - j) ** 2 listcost.append(cost) print(min(listcost)) 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, 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...
[ [ 65, 2 ], [ 74, 8 ], [ 68, 20 ], [ 75, 23 ], [ 77, 25 ], [ 75, 28 ], [ 71, 30 ], [ 36, 35 ], [ 78, 38 ], [ 69, 40 ], [ 83, 43 ], [ 47, 46 ], [ 75, 46 ], [ ...
[ "n = int(input())\nlst = list(map(int, input().split()))\n\nM = max(lst)\nm = min(lst)\nans = float(\"INF\")\n\nfor i in range(m,M+1):\n num = 0\n for j in lst:\n num += (i-j)**2\n ans = min(ans, num)\n\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "...
n = int(input()) lst = list(map(int, input().split())) M = max(lst) m = min(lst) ans = float("INF") for i in range(m,M+1): num = 0 for j in lst: num += (i-j)**2 ans = min(ans, num) 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, 41, 28, 13, 4, 13, 13, 4, 2, 2, 18, 13, 13, 13, 17, 0, 13, 4, 13, 13, 0, 13, 4, 13, 13, 13, 4, 1...
[ [ 59, 2 ], [ 71, 8 ], [ 68, 20 ], [ 26, 25 ], [ 33, 32 ], [ 60, 35 ], [ 72, 40 ], [ 32, 41 ], [ 25, 42 ], [ 65, 45 ], [ 62, 50 ], [ 69, 53 ], [ 63, 53 ], [ ...
[ "N=int(input())\na=list(map(int, input().split()))\nans = float(\"inf\")\n\nfor num in range(-100, 101):\n tmp = sum([(a[i]-num)**2 for i in range(N)])\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 = float("inf") for num in range(-100, 101): tmp = sum([(a[i]-num)**2 for i in range(N)]) ans = min(ans, tmp) print(ans)
[ 7, 15, 13, 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, 4, 13, 13, 2, 4, 13, 13, 17, 0, 13, 4, 18, 13, 13, 13, 0, 13, 4, 13, 13, 4, 13, 4, 13, 12, 2, 2, 13, 13...
[ [ 70, 4 ], [ 76, 10 ], [ 67, 22 ], [ 26, 25 ], [ 77, 30 ], [ 77, 34 ], [ 64, 37 ], [ 77, 42 ], [ 73, 44 ], [ 68, 47 ], [ 74, 47 ], [ 25, 56 ], [ 65, 59 ], [ ...
[ "import copy\n\nN = int(input())\na = list(map(int,input().split()))\n\nres = 1e+9\nfor i in range(min(a),max(a)+1):\n tmp = copy.copy(a)\n res = min(res,sum(map(lambda x:(x-i)**2,tmp)))\nprint(res)", "import copy", "copy", "N = int(input())", "N", "int(input())", "int", "input()", "input", ...
import copy N = int(input()) a = list(map(int,input().split())) res = 1e+9 for i in range(min(a),max(a)+1): tmp = copy.copy(a) res = min(res,sum(map(lambda x:(x-i)**2,tmp))) print(res)
[ 7, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 15, 13, 12, 13, 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, 4, 13, 13, 0, 13, 2, 4, 13, 2,...
[ [ 17, 16 ], [ 23, 22 ], [ 35, 34 ], [ 38, 37 ], [ 44, 43 ], [ 47, 46 ], [ 16, 49 ], [ 52, 51 ], [ 22, 57 ], [ 46, 58 ], [ 37, 59 ], [ 34, 63 ], [ 51, 65 ], [ ...
[ "import math\nimport collections\nimport fractions\nimport itertools\nimport functools\nimport operator\n\ndef solve():\n n = int(input())\n a = list(map(int, input().split()))\n cost = []\n for i in range(-100, 101):\n ramen = 0\n for j in range(n):\n ramen += abs(a[j]-i)**2\n ...
import math import collections import fractions import itertools import functools import operator def solve(): n = int(input()) a = list(map(int, input().split())) cost = [] for i in range(-100, 101): ramen = 0 for j in range(n): ramen += abs(a[j]-i)**2 cost.append(r...
[ 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, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, 18, 13, 13, 13, 4, 13, 4, 13, 1...
[ [ 67, 2 ], [ 70, 8 ], [ 61, 20 ], [ 24, 23 ], [ 71, 28 ], [ 71, 32 ], [ 58, 35 ], [ 39, 38 ], [ 71, 38 ], [ 64, 41 ], [ 38, 44 ], [ 23, 45 ], [ 62, 49 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\nl = []\nfor i in range(min(a), max(a) + 1):\n c = 0\n for e in a:\n c += (e - i) ** 2\n l.append(c)\nprint(min(l))", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = list(map(int, input().split()))", "a", "list(m...
n = int(input()) a = list(map(int, input().split())) l = [] for i in range(min(a), max(a) + 1): c = 0 for e in a: c += (e - i) ** 2 l.append(c) print(min(l))
[ 7, 15, 13, 12, 13, 12, 13, 0, 13, 4, 13, 0, 13, 4, 13, 0, 13, 2, 4, 13, 13, 13, 0, 13, 2, 13, 17, 4, 13, 4, 13, 4, 13, 2, 2, 13, 13, 17, 4, 13, 2, 2, 13, 13, 17, 10, 2, 13, 10, 4, 13, 10, 12, 13, 10, 4, 1...
[ [ 49, 8 ], [ 53, 10 ], [ 55, 12 ], [ 59, 14 ], [ 61, 16 ], [ 56, 20 ], [ 50, 21 ], [ 46, 23 ], [ 62, 25 ], [ 62, 36 ], [ 47, 43 ], [ 46, 47 ], [ 49, 50 ], [ ...
[ "import sys\ndef I(): return int(sys.stdin.readline().rstrip())\ndef LI(): return list(map(int,sys.stdin.readline().rstrip().split()))\n\nN = I()\na = LI()\n\nx = sum(a)//N\ny = x + 1\n\nprint(min(sum((i-x)**2 for i in a),sum((i-y)**2 for i in a)))", "import sys", "sys", "def I(): return int(sys.stdin.readlin...
import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) N = I() a = LI() x = sum(a)//N y = x + 1 print(min(sum((i-x)**2 for i in a),sum((i-y)**2 for i in a)))
[ 7, 15, 13, 12, 13, 29, 4, 13, 13, 4, 18, 4, 18, 4, 18, 18, 13, 13, 13, 13, 13, 12, 13, 4, 13, 0, 13, 4, 13, 4, 13, 0, 13, 17, 0, 13, 17, 42, 17, 0, 13, 4, 13, 13, 13, 0, 13, 2, 4, 13, 2, 13, 17, 13, 13, 0, ...
[ [ 27, 26 ], [ 111, 30 ], [ 33, 32 ], [ 36, 35 ], [ 41, 40 ], [ 32, 43 ], [ 56, 43 ], [ 26, 44 ], [ 47, 46 ], [ 32, 51 ], [ 56, 51 ], [ 26, 53 ], [ 40, 54 ], [ ...
[ "#!/usr/bin/python\n# -*- coding: UTF-8 -*-\n\nimport sys\n\n\ndef get_ints():\n return map(int, sys.stdin.readline().strip().split())\n\n\ndef _main():\n input()\n an = list(get_ints())\n\n t = 0\n old = 1000000000\n while 1:\n ans = sq(t, an)\n g = sq(t+1, an) - ans\n t -= g...
#!/usr/bin/python # -*- coding: UTF-8 -*- import sys def get_ints(): return map(int, sys.stdin.readline().strip().split()) def _main(): input() an = list(get_ints()) t = 0 old = 1000000000 while 1: ans = sq(t, an) g = sq(t+1, an) - ans t -= g / abs(g) if old...
[ 7, 12, 13, 0, 13, 2, 2, 13, 13, 17, 29, 13, 23, 13, 0, 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, 4, 13, 4, 13, 4, 13, 4, 13, 13, 13, 10, 12, 13, 10, 4, 1...
[ [ 5, 4 ], [ 13, 7 ], [ 4, 11 ], [ 13, 13 ], [ 58, 15 ], [ 55, 19 ], [ 61, 31 ], [ 56, 37 ], [ 59, 40 ], [ 53, 49 ], [ 56, 50 ], [ 55, 56 ], [ 58, 59 ], [ 61...
[ "def cost(x):\n cost = (x - ave)**2\n return cost\n\n\nn = input()\na = list(map(int, input().split()))\nave = round(sum(a)/int(n))\nprint(sum(list(map(cost, a))))", "def cost(x):\n cost = (x - ave)**2\n return cost", "cost", "cost = (x - ave)**2", "cost", "(x - ave)**2", "x - ave", "x", ...
def cost(x): cost = (x - ave)**2 return cost n = input() a = list(map(int, input().split())) ave = round(sum(a)/int(n)) print(sum(list(map(cost, a))))
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 4, 13, 2, 4, 13, 13, 13, 17, 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...
[ [ 51, 2 ], [ 54, 8 ], [ 60, 20 ], [ 55, 28 ], [ 52, 29 ], [ 57, 32 ], [ 36, 35 ], [ 55, 35 ], [ 48, 38 ], [ 35, 41 ], [ 61, 42 ], [ 49, 46 ], [ 58, 46 ], [ ...
[ "n=int(input())\na=list(map(int,input().split()))\nm=int(round(sum(a)/n,0))\nans=0\nfor i in a:\n ans+=(i-m)**2\nprint(ans)", "n=int(input())", "n", "int(input())", "int", "input()", "input", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().s...
n=int(input()) a=list(map(int,input().split())) m=int(round(sum(a)/n,0)) ans=0 for i in a: ans+=(i-m)**2 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, 13, 0, 13, 4, 13, 13, 0, 13, 2, 17, 17, 28, 13, 4, 13, 13, 2, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2...
[ [ 78, 2 ], [ 10, 9 ], [ 9, 18 ], [ 81, 20 ], [ 72, 23 ], [ 82, 26 ], [ 90, 28 ], [ 82, 31 ], [ 84, 33 ], [ 39, 38 ], [ 91, 41 ], [ 73, 43 ], [ 93, 46 ], [ 5...
[ "N=int(input())\nA=[int(x) for x in input().split()]\nmaxA=max(A)\nminA=min(A)\nans=10**9\nfor i in range(minA,maxA+1):\n kouho=0\n for j in range(N):\n kouho+=(i-A[j])**2\n ans=min(ans,kouho)\nprint(ans)", "N=int(input())", "N", "int(input())", "int", "input()", "input", "int(x) for x...
N=int(input()) A=[int(x) for x in input().split()] maxA=max(A) minA=min(A) ans=10**9 for i in range(minA,maxA+1): kouho=0 for j in range(N): kouho+=(i-A[j])**2 ans=min(ans,kouho) 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, 13, 2, 2, 13, 13, 17, 28, 13, 4, 13, 13, 2, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13,...
[ [ 91, 2 ], [ 85, 8 ], [ 70, 20 ], [ 86, 23 ], [ 76, 25 ], [ 86, 28 ], [ 73, 30 ], [ 92, 32 ], [ 71, 35 ], [ 77, 36 ], [ 40, 39 ], [ 77, 42 ], [ 71, 44 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\nmax = max(a)\nmin = min(a)\ncost_min = n * (max - min)**2\nfor m in range(min, max+1):\n cost = 0\n for x in a:\n cost += (x - m)**2\n if cost < cost_min:\n cost_min = cost\nprint(cost_min)", "n = int(input())", "n", "int(input())"...
n = int(input()) a = list(map(int, input().split())) max = max(a) min = min(a) cost_min = n * (max - min)**2 for m in range(min, max+1): cost = 0 for x in a: cost += (x - m)**2 if cost < cost_min: cost_min = cost print(cost_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, 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, 39, ...
[ [ 58, 2 ], [ 10, 9 ], [ 9, 18 ], [ 64, 20 ], [ 55, 23 ], [ 27, 26 ], [ 61, 32 ], [ 36, 35 ], [ 65, 35 ], [ 67, 38 ], [ 35, 41 ], [ 26, 42 ], [ 56, 46 ], [ 6...
[ "n=int(input())\na=[int(i)for i in input().split()]\ncost=[]\nfor i in range(-100,101):\n tmp=0\n for j in a:\n tmp+=(j-i)**2\n cost.append(tmp)\nprint(min(cost))", "n=int(input())", "n", "int(input())", "int", "input()", "input", "int(i)for i in input().split()", "for i in input().s...
n=int(input()) a=[int(i)for i in input().split()] cost=[] for i in range(-100,101): tmp=0 for j in a: tmp+=(j-i)**2 cost.append(tmp) print(min(cost))
[ 7, 15, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 12, 13, 0, 13, 4, 18, 13, 13, 2, 4, 13, 13, 13, 0, 13, 4, 18, 13, 13, 2, 4, 13, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, ...
[ [ 91, 4 ], [ 97, 10 ], [ 25, 24 ], [ 85, 32 ], [ 83, 33 ], [ 36, 35 ], [ 85, 43 ], [ 83, 44 ], [ 47, 46 ], [ 50, 49 ], [ 53, 52 ], [ 83, 55 ], [ 58, 57 ], [ ...
[ "import math\nN = int(input())\nARR = list(map(int,input().split()))\n\ndef calculate(n, arr):\n\n a1 = math.floor(sum(arr)/n)\n a2 = math.ceil(sum(arr)/n)\n\n result1 = 0\n result2 = 0\n for i in range(n):\n result1 += pow(arr[i] - a1,2)\n result2 += pow(arr[i] - a2,2)\n\n print(min...
import math N = int(input()) ARR = list(map(int,input().split())) def calculate(n, arr): a1 = math.floor(sum(arr)/n) a2 = math.ceil(sum(arr)/n) result1 = 0 result2 = 0 for i in range(n): result1 += pow(arr[i] - a1,2) result2 += pow(arr[i] - a2,2) print(min(result1,result2)) ...
[ 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, 2, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 0, 13, 4, 13, 13, 1...
[ [ 67, 2 ], [ 64, 8 ], [ 79, 20 ], [ 26, 25 ], [ 73, 30 ], [ 25, 32 ], [ 70, 35 ], [ 39, 38 ], [ 68, 41 ], [ 61, 43 ], [ 65, 47 ], [ 38, 48 ], [ 74, 49 ], [ ...
[ "n = int(input())\nlst = list(map(int, input().split()))\nm = 10 ** 10\nfor i in range(201):\n a = i - 100\n temp = 0\n for j in range(n):\n temp += ((lst[j] - a) ** 2)\n m = min(m, temp)\nprint(m)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "lst = list(map(int, input(...
n = int(input()) lst = list(map(int, input().split())) m = 10 ** 10 for i in range(201): a = i - 100 temp = 0 for j in range(n): temp += ((lst[j] - a) ** 2) m = min(m, temp) print(m)
[ 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...
[ [ 62, 2 ], [ 71, 8 ], [ 59, 20 ], [ 26, 25 ], [ 72, 30 ], [ 72, 34 ], [ 74, 37 ], [ 41, 40 ], [ 72, 40 ], [ 68, 43 ], [ 40, 46 ], [ 25, 47 ], [ 65, 50 ], [ ...
[ "N=int(input())\nalist=list(map(int,input().split()))\n\nmin_answer=float(\"inf\")\nfor i in range(min(alist),max(alist)+1):\n answer=0\n for a in alist:\n answer+=(a-i)**2\n \n min_answer=min(answer,min_answer)\nprint(min_answer)", "N=int(input())", "N", "int(input())", "int", "input()", "inpu...
N=int(input()) alist=list(map(int,input().split())) min_answer=float("inf") for i in range(min(alist),max(alist)+1): answer=0 for a in alist: answer+=(a-i)**2 min_answer=min(answer,min_answer) print(min_answer)
[ 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, 4, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 0, 13, 2, 13, 2, 2, 4, 13, 18, 13, 13, 13, 17, 14, 40, 13, ...
[ [ 73, 2 ], [ 76, 8 ], [ 23, 22 ], [ 26, 25 ], [ 32, 31 ], [ 35, 34 ], [ 63, 39 ], [ 42, 41 ], [ 31, 43 ], [ 41, 43 ], [ 63, 49 ], [ 34, 50 ], [ 25, 51 ], [ ...
[ "N = int(input())\na = list(map(int,input().split()))\n\ndef minimize(list):\n min = 1000000\n for i in range(-100,101):\n num = 0\n for j in range(len(list)):\n num = num + (int(list[j]) - i)**2\n if min >= num:\n min = num\n return min\n\nprint(minimize(a))", ...
N = int(input()) a = list(map(int,input().split())) def minimize(list): min = 1000000 for i in range(-100,101): num = 0 for j in range(len(list)): num = num + (int(list[j]) - i)**2 if min >= num: min = num return min print(minimize(a))
[ 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, 17, 13, 17, 0, 13, 4, 18, 13, 13, 4, 18, 13, 13, 13, 0, 13, 4, 18, 13, 13, 4, 18, 13, 13, 13, 28, 13, 4, 13, 13, 0, ...
[ [ 92, 6 ], [ 86, 12 ], [ 95, 24 ], [ 89, 26 ], [ 101, 29 ], [ 87, 38 ], [ 80, 40 ], [ 87, 49 ], [ 52, 51 ], [ 93, 54 ], [ 98, 56 ], [ 87, 60 ], [ 51, 61 ], [ ...
[ "import statistics\nimport math\nn = int(input())\na = list(map(int,input().split()))\nans1,ans2 = 0,0\na_avr1 = math.ceil((statistics.mean(a)))\na_avr2 = math.floor((statistics.mean(a)))\nfor i in range(n):\n ans1 += (a[i] - a_avr1)**2\n ans2 += (a[i] - a_avr2)**2\nprint(min(ans1,ans2))", "import statistics", ...
import statistics import math n = int(input()) a = list(map(int,input().split())) ans1,ans2 = 0,0 a_avr1 = math.ceil((statistics.mean(a))) a_avr2 = math.floor((statistics.mean(a))) for i in range(n): ans1 += (a[i] - a_avr1)**2 ans2 += (a[i] - a_avr2)**2 print(min(ans1,ans2))
[ 7, 12, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 13, 13, 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, 4, 13, 2...
[ [ 5, 4 ], [ 11, 10 ], [ 25, 24 ], [ 10, 27 ], [ 29, 28 ], [ 10, 31 ], [ 34, 33 ], [ 39, 38 ], [ 24, 41 ], [ 28, 43 ], [ 47, 46 ], [ 50, 49 ], [ 10, 49 ], [ ...
[ "def resolve():\n N = int(input())\n A = sorted(list(map(int, input().split())))\n start, end = min(A), max(A)\n mincost = float(\"inf\")\n for i in range(start, end+1):\n _cost = 0\n for a in A:\n _cost += abs(a-i)**2\n mincost = min(mincost, _cost)\n print(mincost...
def resolve(): N = int(input()) A = sorted(list(map(int, input().split()))) start, end = min(A), max(A) mincost = float("inf") for i in range(start, end+1): _cost = 0 for a in A: _cost += abs(a-i)**2 mincost = min(mincost, _cost) print(mincost) if '__main__'...
[ 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, ...
[ [ 65, 2 ], [ 62, 8 ], [ 53, 20 ], [ 26, 25 ], [ 59, 31 ], [ 35, 34 ], [ 63, 34 ], [ 68, 37 ], [ 34, 40 ], [ 25, 41 ], [ 56, 44 ], [ 69, 47 ], [ 60, 47 ], [ ...
[ "N = int(input())\nA = list(map(int, input().split()))\ncost = float(\"inf\")\nfor i in range(-100, 101):\n tmp_cost = 0\n for a in A:\n tmp_cost += (a - i) ** 2\n cost = min(tmp_cost, cost)\nprint(cost)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = list(ma...
N = int(input()) A = list(map(int, input().split())) cost = float("inf") for i in range(-100, 101): tmp_cost = 0 for a in A: tmp_cost += (a - i) ** 2 cost = min(tmp_cost, cost) print(cost)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 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, 41, 28, 13, 13, 4, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 0, 13, 4, 13,...
[ [ 72, 2 ], [ 75, 8 ], [ 69, 22 ], [ 28, 27 ], [ 76, 32 ], [ 76, 36 ], [ 41, 40 ], [ 76, 40 ], [ 40, 45 ], [ 27, 46 ], [ 66, 49 ], [ 63, 54 ], [ 70, 57 ], [ ...
[ "n = int(input())\na = sorted(list(map(int, input().split())))\n\nans = 10 ** 10\nfor i in range(min(a), max(a) + 1):\n val = sum([(x - i) ** 2 for x in a])\n ans = min(ans, val)\n\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = sorted(list(map(int, input()...
n = int(input()) a = sorted(list(map(int, input().split()))) ans = 10 ** 10 for i in range(min(a), max(a) + 1): val = sum([(x - i) ** 2 for x in a]) ans = min(ans, val) print(ans)
[ 7, 15, 12, 13, 12, 13, 12, 13, 12, 13, 12, 13, 29, 4, 13, 2, 13, 13, 17, 23, 13, 23, 13, 0, 13, 4, 13, 0, 13, 4, 13, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 18, 13, 13, 0, 13, 4, 13, 2, 13, 13, 14, 40, 2, 13, ...
[ [ 20, 16 ], [ 22, 17 ], [ 20, 20 ], [ 22, 22 ], [ 115, 24 ], [ 113, 26 ], [ 118, 28 ], [ 86, 30 ], [ 88, 32 ], [ 36, 35 ], [ 116, 38 ], [ 91, 40 ], [ 119, 42 ], ...
[ "from sys import stdin\n\ndef S(): return stdin.readline().rstrip()\ndef I(): return int(stdin.readline().rstrip())\ndef LS(): return list(stdin.readline().rstrip().split())\ndef LI(): return list(map(int,stdin.readline().rstrip().split()))\n\ndef cost(x,y):\n return pow(x-y,2)\nn = I()\na = LI()\n\nsum = 0\nfor...
from sys import stdin def S(): return stdin.readline().rstrip() def I(): return int(stdin.readline().rstrip()) def LS(): return list(stdin.readline().rstrip().split()) def LI(): return list(map(int,stdin.readline().rstrip().split())) def cost(x,y): return pow(x-y,2) n = I() a = LI() sum = 0 for i in range(n): ...
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 2, 2, 4, 13, 13, 4, 13, 13, 2, 4, 13, 13, 4, 13, 13, 14, 40, 13, 17, 0, 13, 2, 2, 4, 13, 13, 4, 13, 13, 17, 0, 13, 2, 4, 13, 13, ...
[ [ 81, 2 ], [ 96, 8 ], [ 93, 20 ], [ 97, 25 ], [ 97, 28 ], [ 97, 32 ], [ 97, 35 ], [ 94, 38 ], [ 84, 41 ], [ 97, 46 ], [ 97, 49 ], [ 87, 52 ], [ 97, 56 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\n\n\ndecimal = sum(a) / len(a) - sum(a) // len(a)\nif decimal >= 0.5:\n m = sum(a) // len(a) + 1\nelse:\n m = sum(a) // len(a)\n\nans = 0\nfor i in range(n):\n ans += (a[i] - m)**2\n\nprint(ans)", "n = int(input())", "n", "int(input())", "int",...
n = int(input()) a = list(map(int, input().split())) decimal = sum(a) / len(a) - sum(a) // len(a) if decimal >= 0.5: m = sum(a) // len(a) + 1 else: m = sum(a) // len(a) ans = 0 for i in range(n): ans += (a[i] - m)**2 print(ans)
[ 7, 15, 13, 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, 17, 0, 13, 17, 0, 13, 39, 28, 13, 13, 0, 13, 4, 18, 13, 13, 2, 13, 13, 17, 4, 18, 13, 13, 13, 28, ...
[ [ 98, 4 ], [ 89, 10 ], [ 83, 22 ], [ 90, 26 ], [ 99, 27 ], [ 92, 29 ], [ 86, 32 ], [ 95, 35 ], [ 39, 38 ], [ 90, 38 ], [ 101, 41 ], [ 38, 47 ], [ 84, 48 ], [ ...
[ "import math\nN = int(input())\nA = list(map(int, input().split()))\n\nave = sum(A)//N\ncost1 = 0\ncost2 = 0\ncost = []\nfor i in A:\n cost1 += math.pow((i - ave), 2)\ncost.append(cost1)\n\nfor i in A:\n cost2 += math.pow((i - ave - 1), 2)\ncost.append(cost2)\n\n\nprint(int(min(cost)))", "import math", "m...
import math N = int(input()) A = list(map(int, input().split())) ave = sum(A)//N cost1 = 0 cost2 = 0 cost = [] for i in A: cost1 += math.pow((i - ave), 2) cost.append(cost1) for i in A: cost2 += math.pow((i - ave - 1), 2) cost.append(cost2) print(int(min(cost)))
[ 7, 12, 13, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 17, 0, 13, 4, 13, 13, 0, 13, 2, 13, 13, 13, 2, 2, 13, 13, 17, 41, 28, 13, 13, 4, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 41, 28, 13, ...
[ [ 5, 4 ], [ 11, 10 ], [ 24, 23 ], [ 10, 26 ], [ 29, 28 ], [ 23, 30 ], [ 4, 31 ], [ 33, 32 ], [ 23, 35 ], [ 4, 36 ], [ 41, 40 ], [ 10, 40 ], [ 40, 45 ], [ 28...
[ "def main():\n N = int(input())\n A = list(map(int, input().split(' ')))\n sum_A = sum(A)\n left, right = sum_A // N, sum_A // N + 1\n loss_1 = sum([(a - left) ** 2 for a in A])\n loss_2 = sum([(a - right) ** 2 for a in A])\n if loss_1 < loss_2:\n print(loss_1)\n else:\n print(...
def main(): N = int(input()) A = list(map(int, input().split(' '))) sum_A = sum(A) left, right = sum_A // N, sum_A // N + 1 loss_1 = sum([(a - left) ** 2 for a in A]) loss_2 = sum([(a - right) ** 2 for a in A]) if loss_1 < loss_2: print(loss_1) else: print(loss_2) if __...
[ 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, 2, 13, 2, 17, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 4, 13, 13, 10, 17...
[ [ 59, 2 ], [ 65, 8 ], [ 68, 20 ], [ 66, 23 ], [ 62, 25 ], [ 69, 30 ], [ 60, 33 ], [ 60, 34 ], [ 56, 36 ], [ 40, 39 ], [ 60, 42 ], [ 71, 44 ], [ 66, 48 ], [ ...
[ "N = int(input())\na = list(map(int,input().split()))\nb = sum(a)\nb = int((b+0.5*N) // N)\nans = 0\nfor i in range(N):\n ans += (a[i]-b)**2\nprint(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())) b = sum(a) b = int((b+0.5*N) // N) ans = 0 for i in range(N): ans += (a[i]-b)**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, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 0, 13, 4, 13, 13, 13, 0, 13, 17, 28, ...
[ [ 82, 2 ], [ 94, 8 ], [ 91, 20 ], [ 26, 25 ], [ 100, 30 ], [ 34, 33 ], [ 83, 36 ], [ 103, 38 ], [ 95, 42 ], [ 33, 43 ], [ 25, 44 ], [ 79, 47 ], [ 92, 50 ], [ ...
[ "n = int(input())\na = list(map(int,input().split()))\nans = int(1e18)\nfor i in range(101):\n cnt = 0\n for j in range(n):\n cnt += (a[j]-i)**2\n ans = min(ans,cnt)\n cnt = 0\n for j in range(n):\n cnt += (a[j]+i) **2\n ans = min(ans,cnt)\nprint(ans)", "n = int(input())", "n", ...
n = int(input()) a = list(map(int,input().split())) ans = int(1e18) for i in range(101): cnt = 0 for j in range(n): cnt += (a[j]-i)**2 ans = min(ans,cnt) cnt = 0 for j in range(n): cnt += (a[j]+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, 17, 13, 10, ...
[ [ 68, 2 ], [ 56, 8 ], [ 62, 20 ], [ 26, 25 ], [ 53, 31 ], [ 35, 34 ], [ 57, 34 ], [ 59, 37 ], [ 34, 40 ], [ 25, 41 ], [ 65, 44 ], [ 63, 47 ], [ 66, 47 ], [ ...
[ "N = int(input())\nA = list(map(int,input().split()))\nMIN = float('inf')\nfor i in range(-100,101):\n tmp = 0\n for a in A:\n tmp += (a-i)**2\n MIN = min(MIN,tmp)\nprint(MIN)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = list(map(int,input().split()))", ...
N = int(input()) A = list(map(int,input().split())) MIN = float('inf') for i in range(-100,101): tmp = 0 for a in A: tmp += (a-i)**2 MIN = min(MIN,tmp) print(MIN)
[ 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, 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, 1...
[ [ 65, 2 ], [ 59, 8 ], [ 74, 20 ], [ 28, 27 ], [ 71, 33 ], [ 37, 36 ], [ 66, 39 ], [ 68, 41 ], [ 60, 45 ], [ 36, 46 ], [ 27, 47 ], [ 62, 50 ], [ 69, 53 ], [ ...
[ "N = int(input())\nA = list(map(int, input().split()))\n\nmin_cost = 10 ** 9 + 7\nfor i in range(-100, 101):\n cost = 0\n for j in range(N):\n cost += (A[j] - i) ** 2\n min_cost = min(cost, min_cost)\n\nprint(min_cost)", "N = int(input())", "N", "int(input())", "int", "input()", "input",...
N = int(input()) A = list(map(int, input().split())) min_cost = 10 ** 9 + 7 for i in range(-100, 101): cost = 0 for j in range(N): cost += (A[j] - i) ** 2 min_cost = min(cost, min_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, 4, 13, 2, 4, 13, 13, 13, 0, 13, 4, 13, 4, 13, 12, 2, 2, 13, 13, 17, 23, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ...
[ [ 46, 2 ], [ 49, 8 ], [ 52, 20 ], [ 50, 26 ], [ 47, 27 ], [ 55, 29 ], [ 53, 37 ], [ 50, 41 ], [ 56, 44 ], [ 46, 47 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ] ]
[ "n = int(input())\na = sorted(map(int, input().split()))\n\nave = round(sum(a) / n)\nans = sum(map(lambda x: (ave - x) ** 2, a))\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = sorted(map(int, input().split()))", "a", "sorted(map(int, input().split()))", "s...
n = int(input()) a = sorted(map(int, input().split())) ave = round(sum(a) / n) ans = sum(map(lambda x: (ave - x) ** 2, a)) print(ans)
[ 7, 15, 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, 13, 13, 0, 13, 4, 18, 13, 13, 4, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 13, ...
[ [ 80, 5 ], [ 13, 12 ], [ 12, 21 ], [ 89, 23 ], [ 92, 26 ], [ 90, 33 ], [ 95, 35 ], [ 90, 42 ], [ 83, 44 ], [ 98, 47 ], [ 51, 50 ], [ 90, 50 ], [ 77, 53 ], [ ...
[ "from statistics import mean \nimport math\nn=int(input())\narr=[int(x) for x in input().split()]\na=math.ceil(mean(arr))\nb=math.floor(mean(arr))\ns1=0\ns2=0\nfor x in arr:\n s1=s1+((x-a)**2)\n s2=s2+((x-b)**2)\nprint(min(s1,s2))", "from statistics import mean", "import math", "math", "n=int(input())...
from statistics import mean import math n=int(input()) arr=[int(x) for x in input().split()] a=math.ceil(mean(arr)) b=math.floor(mean(arr)) s1=0 s2=0 for x in arr: s1=s1+((x-a)**2) s2=s2+((x-b)**2) print(min(s1,s2))
[ 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 ], [ 25, 40 ], [ 34, 41 ], [ 65, 44 ], [ 54, 47 ], [ 66, 47 ], [ ...
[ "N = int(input())\na = list(map(int,(input().split())))\nnim = float(\"inf\")\nfor i in range(-100,101):\n s = 0\n for j in a:\n s += (i-j)**2\n nim = min(nim,s)\nprint(nim)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "a = list(map(int,(input().split())))", ...
N = int(input()) a = list(map(int,(input().split()))) nim = float("inf") for i in range(-100,101): s = 0 for j in a: s += (i-j)**2 nim = min(nim,s) print(nim)
[ 7, 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, 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, 14, 2, 13, 13, ...
[ [ 5, 4 ], [ 12, 11 ], [ 11, 20 ], [ 23, 22 ], [ 26, 25 ], [ 31, 30 ], [ 37, 36 ], [ 40, 39 ], [ 4, 42 ], [ 45, 44 ], [ 30, 47 ], [ 22, 49 ], [ 39, 50 ], [ 4...
[ "def main():\n N = int(input())\n A = [int(a) for a in input().split()]\n\n cost = 10**10\n\n for a in range(-200, 201):\n c = 0\n for i in range(N):\n c += (a - A[i])**2\n if c < cost:\n cost = c\n print(cost)\nif __name__ == \"__main__\":\n main()", "...
def main(): N = int(input()) A = [int(a) for a in input().split()] cost = 10**10 for a in range(-200, 201): c = 0 for i in range(N): c += (a - A[i])**2 if c < cost: cost = c print(cost) if __name__ == "__main__": main()
[ 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, 0, 13, 4, 13, 13, 0, 13, 2, 17, 17, 28, 13, 4, 13, 2, 2, 13, 13, 17, 0, 13, 17, 0, 13, 2, 13, 13, 28, 13, 4, 13...
[ [ 5, 4 ], [ 11, 10 ], [ 23, 22 ], [ 10, 25 ], [ 28, 27 ], [ 10, 30 ], [ 33, 32 ], [ 38, 37 ], [ 27, 42 ], [ 22, 43 ], [ 47, 46 ], [ 50, 49 ], [ 22, 51 ], [ ...
[ "def main():\n n = int(input())\n a_lst = list(map(int, input().split()))\n minimum = min(a_lst)\n maximum = max(a_lst)\n\n cost = 10 ** 9\n for i in range(maximum - minimum + 1):\n tmp_cost = 0\n std = minimum + i\n for j in range(n):\n a = a_lst[j]\n tm...
def main(): n = int(input()) a_lst = list(map(int, input().split())) minimum = min(a_lst) maximum = max(a_lst) cost = 10 ** 9 for i in range(maximum - minimum + 1): tmp_cost = 0 std = minimum + i for j in range(n): a = a_lst[j] tmp_cost += (a - st...
[ 7, 12, 13, 29, 4, 13, 4, 13, 12, 13, 29, 4, 13, 13, 4, 18, 4, 13, 13, 12, 13, 29, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 12, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 4, 13, 29, 13, 23, 13, 12, 13, 29, 4, 18, 4, 18...
[ [ 37, 36 ], [ 48, 39 ], [ 48, 48 ], [ 141, 83 ], [ 150, 90 ], [ 163, 92 ], [ 159, 94 ], [ 148, 96 ], [ 168, 98 ], [ 104, 103 ], [ 156, 109 ], [ 113, 112 ], [ 151, 1...
[ "def getN():\n return int(input())\ndef getNM():\n return map(int, input().split())\ndef getList():\n return list(map(int, input().split()))\ndef getArray(intn):\n return [int(input()) for i in range(intn)]\ndef input():\n return sys.stdin.readline().rstrip()\n\nfrom collections import defaultdict, d...
def getN(): return int(input()) def getNM(): return map(int, input().split()) def getList(): return list(map(int, input().split())) def getArray(intn): return [int(input()) for i in range(intn)] def input(): return sys.stdin.readline().rstrip() from collections import defaultdict, deque, Counter fr...
[ 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, ...
[ [ 59, 2 ], [ 53, 8 ], [ 56, 20 ], [ 26, 25 ], [ 62, 31 ], [ 35, 34 ], [ 54, 34 ], [ 68, 37 ], [ 34, 40 ], [ 25, 41 ], [ 65, 44 ], [ 57, 47 ], [ 66, 47 ], [ ...
[ "n = int(input())\nan = list(map(int, input().split()))\nans = float('inf')\nfor i in range(-100, 101):\n check = 0\n for a in an:\n check += (a-i)**2\n ans = min(ans, check)\nprint(ans)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "an = list(map(int, input().s...
n = int(input()) an = list(map(int, input().split())) ans = float('inf') for i in range(-100, 101): check = 0 for a in an: check += (a-i)**2 ans = min(ans, check) print(ans)
[ 7, 15, 13, 15, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 0, 13, 4, 18, 13, 13, 4, 18, 13, 13, 13, 0, 13, 2, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 17, 4, 13, 13, 0, 13, 2, 13, 2, ...
[ [ 80, 10 ], [ 86, 22 ], [ 81, 31 ], [ 83, 33 ], [ 87, 35 ], [ 95, 38 ], [ 92, 41 ], [ 45, 44 ], [ 81, 50 ], [ 98, 52 ], [ 96, 54 ], [ 99, 54 ], [ 81, 58 ], [ ...
[ "import statistics as st\nimport math\nint(input())\ns = list(map(int, input().split()))\nmd = math.floor(st.mean(s))\nmu = md + 1\nsd = 0\nsu = 0\nfor i in range(0, len(s)):\n sd = sd + (s[i] - md) ** 2\n su = su + (s[i] - mu) ** 2\nprint(min(sd, su))", "import statistics as st", "statistics", "import ...
import statistics as st import math int(input()) s = list(map(int, input().split())) md = math.floor(st.mean(s)) mu = md + 1 sd = 0 su = 0 for i in range(0, len(s)): sd = sd + (s[i] - md) ** 2 su = su + (s[i] - mu) ** 2 print(min(sd, su))
[ 7, 12, 13, 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, 18, 13, 13, 13, 17, 14, 2, 13, 13, 0, 13, 13, ...
[ [ 5, 4 ], [ 11, 10 ], [ 23, 22 ], [ 28, 27 ], [ 34, 33 ], [ 37, 36 ], [ 4, 39 ], [ 42, 41 ], [ 10, 45 ], [ 36, 46 ], [ 27, 47 ], [ 41, 51 ], [ 33, 51 ], [ 2...
[ "def main():\n n = int(input())\n inlis = list(map(int, input().split()))\n\n ans = 10 ** 10\n\n for kouho1 in range(-100,101):\n tmp1 = 0\n for i in range(n):\n tmp1 += (inlis[i]- kouho1) ** 2\n if tmp1 < ans:\n ans = tmp1\n print(ans)\n\n\n\nif __name__ ==...
def main(): n = int(input()) inlis = list(map(int, input().split())) ans = 10 ** 10 for kouho1 in range(-100,101): tmp1 = 0 for i in range(n): tmp1 += (inlis[i]- kouho1) ** 2 if tmp1 < ans: ans = tmp1 print(ans) if __name__ == "__main__": 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, 2, 2, 17, 17, 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, ...
[ [ 58, 2 ], [ 10, 9 ], [ 9, 18 ], [ 70, 20 ], [ 73, 23 ], [ 31, 30 ], [ 61, 36 ], [ 40, 39 ], [ 71, 39 ], [ 67, 42 ], [ 39, 45 ], [ 30, 46 ], [ 64, 49 ], [ 7...
[ "N = int(input())\nA = [int(i) for i in input().split()]\n\nans = 200**2 * 100\nfor y in range(-100, 101):\n a = 0\n for x in A:\n a += (x-y)**2\n ans = min(ans, a)\n\nprint(ans)\n\n", "N = int(input())", "N", "int(input())", "int", "input()", "input", "int(i) for i in input().split()", "for i...
N = int(input()) A = [int(i) for i in input().split()] ans = 200**2 * 100 for y in range(-100, 101): a = 0 for x in A: a += (x-y)**2 ans = min(ans, a) 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, 28, 13, 13, 0, 13, 13, 0, 13, 13, 14, 40, 13, 2, 4, 13, 13, 17, 0, 13, 2, 4, 13, 13, 17, 0, 13, 4, 13, 13, 28, 13, ...
[ [ 89, 2 ], [ 77, 8 ], [ 74, 20 ], [ 86, 23 ], [ 27, 26 ], [ 78, 26 ], [ 80, 29 ], [ 26, 30 ], [ 92, 32 ], [ 90, 33 ], [ 93, 36 ], [ 81, 36 ], [ 75, 36 ], [ ...
[ "n=int(input())\nlis=list(map(int,input().split()))\nave=0\nans=0\nfor i in lis:\n ave+=i\nave/=n\nif ave>=int(ave)+0.5:\n ave=int(ave)+1\nelse:\n ave=int(ave)\nfor i in lis:\n ans+=(i-ave)**2\nprint(ans)", "n=int(input())", "n", "int(input())", "int", "input()", "input", "lis=list(map(int,input()...
n=int(input()) lis=list(map(int,input().split())) ave=0 ans=0 for i in lis: ave+=i ave/=n if ave>=int(ave)+0.5: ave=int(ave)+1 else: ave=int(ave) for i in lis: ans+=(i-ave)**2 print(ans)
[ 7, 15, 13, 0, 13, 4, 13, 41, 28, 13, 4, 18, 4, 13, 13, 4, 4, 13, 13, 0, 13, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 39, 28, 13, 4, 13, 13, 2, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, ...
[ [ 79, 4 ], [ 10, 9 ], [ 9, 18 ], [ 88, 20 ], [ 91, 23 ], [ 89, 28 ], [ 97, 30 ], [ 89, 35 ], [ 82, 37 ], [ 41, 40 ], [ 92, 43 ], [ 98, 45 ], [ 85, 48 ], [ 5...
[ "import numpy as np\n\nn=input()\na=[int(x) for x in input().split()]\n\na_min=np.min(a)\na_max=np.max(a)\n\ncost_list=[]\nfor i in range(a_min, a_max+1):\n \n cost=0\n for val in a:\n cost+=(val-i)**2\n \n cost_list.append(cost)\n \nmin_cost=np.min(cost_list)\n\nprint(min_cost)", "import numpy as np",...
import numpy as np n=input() a=[int(x) for x in input().split()] a_min=np.min(a) a_max=np.max(a) cost_list=[] for i in range(a_min, a_max+1): cost=0 for val in a: cost+=(val-i)**2 cost_list.append(cost) min_cost=np.min(cost_list) print(min_cost)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 13, 13, 4, 13, 4, 13, 4, 13, 4, 13, 12, 2, 2, 13, 13, 2, 13, 13, 23, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 38, 2 ], [ 41, 8 ], [ 42, 36 ], [ 38, 39 ], [ 41, 42 ] ]
[ "n = int(input())\na = list(map(int, input().split()))\n\nprint(min(sum(map(lambda x: (x - i) * (x - i), a)) for i in range(-100, 101)))", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", ...
n = int(input()) a = list(map(int, input().split())) print(min(sum(map(lambda x: (x - i) * (x - i), a)) 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, 4, 18, 13, 13, 0, 13, 39, 28, 13, 4, 13, 18, 13, 17, 2, 18, 13, 2, 13, 17, 17, 0, 13, 17, 28, 13, 4, 13, 4, 13, 13, 0, 13, 2, 13, 2, 2, 1...
[ [ 75, 2 ], [ 81, 8 ], [ 82, 21 ], [ 72, 24 ], [ 28, 27 ], [ 82, 31 ], [ 82, 35 ], [ 76, 37 ], [ 84, 41 ], [ 45, 44 ], [ 82, 49 ], [ 78, 51 ], [ 85, 53 ], [ ...
[ "n = int(input())\na = list(map(int, input().split()))\na.sort()\nb = []\nfor i in range(a[0], a[n-1]+1) :\n\tans = 0\n\tfor j in range(len(a)) :\n\t\tans = ans + (a[j]-i)**2\n\tb.append(ans)\nprint(min(b)) \n", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a = list(map(int, inp...
n = int(input()) a = list(map(int, input().split())) a.sort() b = [] for i in range(a[0], a[n-1]+1) : ans = 0 for j in range(len(a)) : ans = ans + (a[j]-i)**2 b.append(ans) print(min(b))
[ 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, 40, 2, 13, 17, 17, 15, 13, 0, 13, 4, 18, 13, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 4, 13, 2, 1...
[ [ 65, 2 ], [ 71, 8 ], [ 74, 20 ], [ 72, 24 ], [ 66, 25 ], [ 75, 29 ], [ 83, 35 ], [ 75, 40 ], [ 80, 42 ], [ 68, 45 ], [ 49, 48 ], [ 72, 48 ], [ 77, 51 ], [ ...
[ "n=int(input())\nlst=list(map(int,input().split()))\nave=sum(lst)/n\nif ave%1>=0.5:\n import math\n ave=math.ceil(ave)\nelse:\n ave//=1\nans=0\nfor i in lst:\n ans+=(abs(i-ave))**2\nprint(int(ans))", "n=int(input())", "n", "int(input())", "int", "input()", "input", "lst=list(map(int,input(...
n=int(input()) lst=list(map(int,input().split())) ave=sum(lst)/n if ave%1>=0.5: import math ave=math.ceil(ave) else: ave//=1 ans=0 for i in lst: ans+=(abs(i-ave))**2 print(int(ans))
[ 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, 4, 13, 13, 12, 13, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 29, 13, 23, 13, 23, 13, 0, 13, 4, 13, 13, 13, 0, ...
[ [ 73, 2 ], [ 82, 8 ], [ 88, 20 ], [ 83, 24 ], [ 83, 27 ], [ 32, 31 ], [ 35, 34 ], [ 48, 34 ], [ 38, 37 ], [ 46, 40 ], [ 34, 41 ], [ 37, 44 ], [ 31, 44 ], [ ...
[ "N = int(input())\n\nA = list(map(int,input().split()))\n\nmean = sum(A)//len(A)\n\ndef std_div(mean, A):\n total = 0\n for x in A:\n total += (mean-x)**2\n return total\n\nmin1 = std_div(mean,A)\nmin2 = std_div(mean+1,A)\n\nans = min(min1,min2)\nprint(ans)", "N = int(input())", "N", "int(inpu...
N = int(input()) A = list(map(int,input().split())) mean = sum(A)//len(A) def std_div(mean, A): total = 0 for x in A: total += (mean-x)**2 return total min1 = std_div(mean,A) min2 = std_div(mean+1,A) ans = min(min1,min2) print(ans)
[ 7, 15, 13, 0, 13, 18, 18, 13, 13, 13, 0, 13, 18, 18, 13, 13, 13, 0, 13, 18, 18, 13, 13, 13, 4, 18, 13, 13, 2, 17, 17, 0, 13, 2, 17, 17, 0, 13, 17, 12, 13, 0, 13, 4, 13, 13, 4, 18, 4, 13, 13, 31, 13, 0, 13, ...
[ [ 108, 4 ], [ 99, 11 ], [ 102, 18 ], [ 105, 32 ], [ 96, 37 ], [ 43, 42 ], [ 109, 49 ], [ 43, 51 ], [ 55, 54 ], [ 106, 55 ], [ 58, 57 ], [ 64, 63 ], [ 67, 66 ], ...
[ "import sys\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10 ** 9)\nINF = 1 << 60\nMOD = 1000000007\n\n\ndef main():\n N, *A = map(int, read().split())\n\n ans = INF\n for x in range(-100, 101):\n tmp = 0\n for a in A:\n ...
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N, *A = map(int, read().split()) ans = INF for x in range(-100, 101): tmp = 0 for a in A: tmp += (x - a) **...
[ 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, 17, 28, 13, 4, 13, 17, 17, 41, 28, 13, 13, 4, 2, 2, 13, 13, 17, 0, 13, 4, 13, 4, 13, 13, 13, 4, 13, 13, 10, 4, ...
[ [ 55, 2 ], [ 10, 9 ], [ 9, 18 ], [ 64, 20 ], [ 61, 23 ], [ 29, 28 ], [ 36, 35 ], [ 65, 35 ], [ 35, 40 ], [ 28, 41 ], [ 58, 44 ], [ 62, 50 ], [ 59, 50 ], [ 5...
[ "N = int(input())\na = [int(i) for i in input().split()]\nans = float(\"inf\")\nfor i in range(-100, 101):\n ans = min(sum([(n - i)** 2 for n in a]), ans)\nprint(ans)", "N = int(input())", "N", "int(input())", "int", "input()", "input", "int(i) for i in input().split()", "for i in input().split()...
N = int(input()) a = [int(i) for i in input().split()] ans = float("inf") for i in range(-100, 101): ans = min(sum([(n - i)** 2 for n in a]), ans) print(ans)
[ 7, 0, 13, 4, 13, 4, 13, 0, 13, 4, 13, 4, 13, 13, 4, 18, 4, 18, 4, 13, 13, 13, 17, 0, 13, 17, 0, 13, 17, 28, 13, 13, 0, 13, 13, 0, 13, 13, 0, 13, 2, 2, 13, 17, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, 1...
[ [ 76, 2 ], [ 64, 8 ], [ 82, 24 ], [ 61, 27 ], [ 31, 30 ], [ 65, 30 ], [ 67, 33 ], [ 30, 34 ], [ 70, 36 ], [ 77, 37 ], [ 79, 39 ], [ 71, 42 ], [ 68, 42 ], [ ...
[ "N = int(input())\nA = list(map(int,input().rstrip().split(\" \")))\nave = 0\nans = 0\nfor i in A:\n ave += i\nave /= N\nave = (ave + 0.5) // 1\nfor i in A:\n ans += (i - ave) ** 2\nprint(int(ans))", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = list(map(int,input().rs...
N = int(input()) A = list(map(int,input().rstrip().split(" "))) ave = 0 ans = 0 for i in A: ave += i ave /= N ave = (ave + 0.5) // 1 for i in A: ans += (i - ave) ** 2 print(int(ans))