node_ids
sequencelengths
4
1.4k
edge_index
sequencelengths
1
2.22k
text
sequencelengths
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, 17, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 39, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 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 ], [ 83, 49 ], [ 75, 53 ], [ 44, 54 ], [ 33, 55 ], [ 78, 59 ], [ 84, 61 ], [ 69, 61 ], [ 78, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ] ]
[ "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()", "input", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a_min = min(a)", "a_min", "min(a)", "min", "a", "a_max = max(a)", "a_max", "max(a)", "max", "a", "a_sum = []", "a_sum", "[]", "for 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)", "i", "range(a_min, a_max + 1)", "range", "a_min", "a_max + 1", "a_max", "1", "num=0", "num", "0", "for j in range(n):\n num += (a[j] - i) ** 2\n ", "j", "range(n)", "range", "n", "num += (a[j] - i) ** 2", "num", "(a[j] - i) ** 2", "a[j] - i", "a[j]", "a", "j", "i", "2", "a_sum.append(num)", "a_sum.append", "a_sum", "append", "num", "print(min(a_sum))", "print", "min(a_sum)", "min", "a_sum", "num=0", "0", "num", "n = int(input())", "int(input())", "n", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "a_sum = []", "[]", "a_sum", "a_min = min(a)", "min(a)", "a_min", "num += (a[j] - i) ** 2", "(a[j] - i) ** 2", "num", "a_max = max(a)", "max(a)", "a_max" ]
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, 4, 13, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 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 ], [ 66, 67 ], [ 69, 70 ] ]
[ "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 = 1 << 28\n\nfor i in range(-100, 101):\n ans = min(ans, sum(map(lambda x: (i - x) ** 2, A)))\n\nprint(ans)", "import sys", "sys", "import heapq, math", "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())", "N", "int(input())", "int", "input()", "input", "A = list(map(int, input().split()))", "A", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = 1 << 28", "ans", "1 << 28", "1", "28", "for i in range(-100, 101):\n ans = min(ans, sum(map(lambda x: (i - x) ** 2, A)))", "i", "range(-100, 101)", "range", "-100", "101", "ans = min(ans, sum(map(lambda x: (i - x) ** 2, A)))", "ans", "min(ans, sum(map(lambda x: (i - x) ** 2, A)))", "min", "ans", "sum(map(lambda x: (i - x) ** 2, A))", "sum", "map(lambda x: (i - x) ** 2, A)", "map", "lambda x: (i - x) ** 2", "(i - x) ** 2", "i - x", "i", "x", "2", "x", "A", "print(ans)", "print", "ans", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "ans = 1 << 28", "1 << 28", "ans", "ans = min(ans, sum(map(lambda x: (i - x) ** 2, A)))", "min(ans, sum(map(lambda x: (i - x) ** 2, A)))", "ans", "N = int(input())", "int(input())", "N" ]
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 in range(-100, 101): ans = min(ans, sum(map(lambda x: (i - x) ** 2, A))) print(ans)
[ 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, 4, 13, 13, 0, 13, 4, 13, 4, 13, 2, 18, 13, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 2, 13, 10, 4, 13, 10, 12, 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 ], [ 46, 69 ], [ 73, 72 ], [ 43, 75 ], [ 72, 75 ], [ 60, 76 ], [ 52, 76 ], [ 72, 79 ], [ 43, 79 ], [ 94, 85 ], [ 87, 88 ], [ 90, 91 ] ]
[ "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 res = min(res, cost)\n print(res)\n\n\nif __name__ == '__main__':\n resolve()", "import sys", "sys", "sys.setrecursionlimit(10 ** 7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 7", "10", "7", "f_inf = float('inf')", "f_inf", "float('inf')", "float", "'inf'", "mod = 10 ** 9 + 7", "mod", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "def 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 res = min(res, cost)\n print(res)", "resolve", "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().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "res = f_inf", "res", "f_inf", "for y in range(-100, 101):\n cost = 0\n for i in range(n):\n cost += pow(abs(A[i] - y), 2)\n res = min(res, cost)\n ", "y", "range(-100, 101)", "range", "-100", "101", "cost = 0", "cost", "0", "for i in range(n):\n cost += pow(abs(A[i] - y), 2)\n ", "i", "range(n)", "range", "n", "cost += pow(abs(A[i] - y), 2)", "cost", "pow(abs(A[i] - y), 2)", "pow", "abs(A[i] - y)", "abs", "A[i] - y", "A[i]", "A", "i", "y", "2", "res = min(res, cost)", "res", "min(res, cost)", "min", "res", "cost", "print(res)", "print", "res", "if __name__ == '__main__':\n resolve()", "__name__ == '__main__'", "__name__", "'__main__'", "resolve()", "resolve", "mod = 10 ** 9 + 7", "10 ** 9 + 7", "mod", "f_inf = float('inf')", "float('inf')", "f_inf", "def 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 res = min(res, cost)\n print(res)", "def 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 res = min(res, cost)\n print(res)", "resolve" ]
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, cost) print(res) if __name__ == '__main__': resolve()
[ 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, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 4, 13, 13, 10, 2, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 2, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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 ], [ 80, 39 ], [ 89, 42 ], [ 80, 42 ], [ 97, 45 ], [ 89, 48 ], [ 80, 48 ], [ 91, 50 ], [ 89, 54 ], [ 80, 54 ], [ 82, 57 ], [ 61, 60 ], [ 95, 60 ], [ 73, 63 ], [ 60, 66 ], [ 92, 67 ], [ 98, 67 ], [ 89, 67 ], [ 80, 67 ], [ 74, 71 ], [ 83, 71 ], [ 73, 74 ], [ 26, 76 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ], [ 88, 89 ], [ 91, 92 ], [ 94, 95 ], [ 97, 98 ], [ 100, 101 ] ]
[ "# 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(input())", "int", "input()", "input", "aN = list(map(int, input().split()))", "aN", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "S = 0", "S", "0", "A = 0", "A", "0", "for i in aN:\n S += i", "i", "aN", "S += i", "S", "i", "A = S / N", "A", "S / N", "S", "N", "if A - int(A) < 0.5:\n A = int(A)\nelse:\n A = int(A) + 1\n# Aにすべて書き換えるときのコストを計算", "A - int(A) < 0.5", "A - int(A)", "A", "int(A)", "int", "A", "0.5", "A = int(A)", "A", "int(A)", "int", "A", "A = int(A) + 1", "A", "int(A) + 1", "int(A)", "int", "A", "1", "R = 0", "R", "0", "for i in aN:\n R += (i - A)**2", "i", "aN", "R += (i - A)**2", "R", "(i - A)**2", "i - A", "i", "A", "2", "print(R)", "print", "R", "R += (i - A)**2", "(i - A)**2", "R", "S += i", "i", "S", "A = 0", "0", "A", "R = 0", "0", "R", "S = 0", "0", "S", "A = S / N", "S / N", "A", "A = int(A) + 1", "int(A) + 1", "A", "aN = list(map(int, input().split()))", "list(map(int, input().split()))", "aN", "A = int(A)", "int(A)", "A", "N = int(input())", "int(input())", "N" ]
# 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, 13, 2, 2, 13, 13, 17, 0, 13, 2, 2, 13, 13, 17, 4, 13, 4, 13, 13, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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 ], [ 54, 60 ], [ 93, 61 ], [ 86, 64 ], [ 54, 67 ], [ 84, 68 ], [ 81, 74 ], [ 90, 74 ], [ 87, 75 ], [ 78, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 92, 93 ], [ 95, 96 ], [ 98, 99 ] ]
[ "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", "int(input())", "int", "input()", "input", "lis = list(map(int, input().split()))", "lis", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "avg1 = math.ceil(sum(lis)/len(lis))", "avg1", "math.ceil(sum(lis)/len(lis))", "math.ceil", "math", "ceil", "sum(lis)/len(lis)", "sum(lis)", "sum", "lis", "len(lis)", "len", "lis", "avg2 = math.floor(sum(lis)/len(lis))", "avg2", "math.floor(sum(lis)/len(lis))", "math.floor", "math", "floor", "sum(lis)/len(lis)", "sum(lis)", "sum", "lis", "len(lis)", "len", "lis", "ans1 = 0", "ans1", "0", "ans2 = 0", "ans2", "0", "for i in lis:\n ans1 += (i-avg1)**2\n ans2 += (i-avg2)**2", "i", "lis", "ans1 += (i-avg1)**2", "ans1", "(i-avg1)**2", "i-avg1", "i", "avg1", "2", "ans2 += (i-avg2)**2", "ans2", "(i-avg2)**2", "i-avg2", "i", "avg2", "2", "print(min(ans1, ans2))", "print", "min(ans1, ans2)", "min", "ans1", "ans2", "ans2 = 0", "0", "ans2", "ans1 += (i-avg1)**2", "(i-avg1)**2", "ans1", "avg2 = math.floor(sum(lis)/len(lis))", "math.floor(sum(lis)/len(lis))", "avg2", "ans2 += (i-avg2)**2", "(i-avg2)**2", "ans2", "ans1 = 0", "0", "ans1", "avg1 = math.ceil(sum(lis)/len(lis))", "math.ceil(sum(lis)/len(lis))", "avg1", "n = int(input())", "int(input())", "n", "lis = list(map(int, input().split()))", "list(map(int, input().split()))", "lis" ]
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, 12, 13, 12, 13, 23, 13, 12, 13, 23, 13, 0, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 4, 13, 0, 13, 4, 13, 0, 13, 17, 13, 17, 0, 13, 4, 13, 2, 4, 13, 13, 13, 0, 13, 4, 13, 2, 4, 13, 13, 13, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 0, 13, 2, 2, 18, 13, 13, 13, 17, 4, 13, 4, 13, 13, 13, 10, 12, 13, 10, 2, 13, 10, 12, 13, 10, 2, 13, 10, 18, 13, 10, 2, 13, 10, 2, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 17, 13, 10, 4, 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 ], [ 189, 86 ], [ 171, 88 ], [ 183, 91 ], [ 193, 97 ], [ 163, 98 ], [ 174, 100 ], [ 193, 106 ], [ 163, 107 ], [ 110, 109 ], [ 163, 112 ], [ 147, 114 ], [ 193, 118 ], [ 109, 119 ], [ 184, 120 ], [ 156, 123 ], [ 193, 127 ], [ 109, 128 ], [ 175, 129 ], [ 148, 135 ], [ 190, 135 ], [ 157, 136 ], [ 172, 136 ], [ 141, 142 ], [ 147, 148 ], [ 150, 151 ], [ 153, 154 ], [ 156, 157 ], [ 162, 163 ], [ 171, 172 ], [ 174, 175 ], [ 183, 184 ], [ 189, 190 ], [ 192, 193 ] ]
[ "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, heappush\nfrom math import floor, ceil,pi,factorial\nfrom operator import itemgetter\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI2(): return [int(input()) for i in range(n)]\ndef MXI(): return [[LI()]for i in range(n)]\ndef SI(): return input().rstrip()\ndef printns(x): print('\\n'.join(x))\ndef printni(x): print('\\n'.join(list(map(str,x))))\ninf = 10**17\nmod = 10**9 + 7\n\nn=I()\nlis=LI()\nU,V=0,0\nu=ceil(sum(lis)/n)\nv=int(sum(lis)/n)\nfor i in range(n):\n U+=(lis[i]-u)**2\n V+=(lis[i]-v)**2\nprint(min(U,V))", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "sys.setrecursionlimit(10**7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**7", "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 import floor, ceil,pi,factorial", "from operator import itemgetter", "def I(): return int(input())", "I", "def MI(): return map(int, input().split())", "MI", "def LI(): return list(map(int, input().split()))", "LI", "int(input()) for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "int(input())", "int", "input()", "input", "def LI2(): return [int(input()) for i in range(n)]", "LI2", "[LI()]for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "[LI()]", "LI()", "LI", "def MXI(): return [[LI()]for i in range(n)]", "MXI", "def SI(): return input().rstrip()", "SI", "def printns(x): print('\\n'.join(x))", "printns", "x", "x", "def printni(x): print('\\n'.join(list(map(str,x))))", "printni", "x", "x", "inf = 10**17", "inf", "10**17", "10", "17", "mod = 10**9 + 7", "mod", "10**9 + 7", "10**9", "10", "9", "7", "n=I()", "n", "I()", "I", "lis=LI()", "lis", "LI()", "LI", "U,V=0,0", "U", "0", "V", "0", "u=ceil(sum(lis)/n)", "u", "ceil(sum(lis)/n)", "ceil", "sum(lis)/n", "sum(lis)", "sum", "lis", "n", "v=int(sum(lis)/n)", "v", "int(sum(lis)/n)", "int", "sum(lis)/n", "sum(lis)", "sum", "lis", "n", "for i in range(n):\n U+=(lis[i]-u)**2\n V+=(lis[i]-v)**2", "i", "range(n)", "range", "n", "U+=(lis[i]-u)**2", "U", "(lis[i]-u)**2", "lis[i]-u", "lis[i]", "lis", "i", "u", "2", "V+=(lis[i]-v)**2", "V", "(lis[i]-v)**2", "lis[i]-v", "lis[i]", "lis", "i", "v", "2", "print(min(U,V))", "print", "min(U,V)", "min", "U", "V", "def LI(): return list(map(int, input().split()))", "def LI(): return list(map(int, input().split()))", "LI", "inf = 10**17", "10**17", "inf", "def MXI(): return [[LI()]for i in range(n)]", "def MXI(): return [[LI()]for i in range(n)]", "MXI", "U+=(lis[i]-u)**2", "(lis[i]-u)**2", "U", "input = sys.stdin.readline", "sys.stdin.readline", "input", "mod = 10**9 + 7", "10**9 + 7", "mod", "V+=(lis[i]-v)**2", "(lis[i]-v)**2", "V", "def printns(x): print('\\n'.join(x))", "def printns(x): print('\\n'.join(x))", "printns", "n=I()", "I()", "n", "def MI(): return map(int, input().split())", "def MI(): return map(int, input().split())", "MI", "def printni(x): print('\\n'.join(list(map(str,x))))", "def printni(x): print('\\n'.join(list(map(str,x))))", "printni", "V=0,0", "0", "V", "v=int(sum(lis)/n)", "int(sum(lis)/n)", "v", "def LI2(): return [int(input()) for i in range(n)]", "def LI2(): return [int(input()) for i in range(n)]", "LI2", "def I(): return int(input())", "def I(): return int(input())", "I", "u=ceil(sum(lis)/n)", "ceil(sum(lis)/n)", "u", "def SI(): return input().rstrip()", "def SI(): return input().rstrip()", "SI", "U,V=0,0", "0", "U", "lis=LI()", "LI()", "lis" ]
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 import floor, ceil,pi,factorial from operator import itemgetter def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def LI2(): return [int(input()) for i in range(n)] def MXI(): return [[LI()]for i in range(n)] def SI(): return input().rstrip() def printns(x): print('\n'.join(x)) def printni(x): print('\n'.join(list(map(str,x)))) inf = 10**17 mod = 10**9 + 7 n=I() lis=LI() U,V=0,0 u=ceil(sum(lis)/n) v=int(sum(lis)/n) for i in range(n): U+=(lis[i]-u)**2 V+=(lis[i]-v)**2 print(min(U,V))
[ 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, 13, 13, 17, 2, 2, 18, 13, 13, 13, 17, 4, 13, 4, 13, 13, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 2, 13, 10, 17, 13, 10, 2, 13, 10, 17, 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 ], [ 75, 47 ], [ 33, 48 ], [ 81, 49 ], [ 83, 51 ], [ 75, 56 ], [ 33, 57 ], [ 81, 58 ], [ 75, 63 ], [ 33, 64 ], [ 81, 65 ], [ 90, 71 ], [ 93, 71 ], [ 84, 72 ], [ 87, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 92, 93 ] ]
[ "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()))", "x", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ave = sum(x)//n", "ave", "sum(x)//n", "sum(x)", "sum", "x", "n", "sum1=0", "sum1", "0", "sum2=0", "sum2", "0", "for i in range(n):\n sum1+=(x[i]-ave)*(x[i]-ave)\n sum2+=(x[i]-ave-1)*(x[i]-ave-1)", "i", "range(n)", "range", "n", "sum1+=(x[i]-ave)*(x[i]-ave)", "sum1", "(x[i]-ave)*(x[i]-ave)", "x[i]-ave", "x[i]", "x", "i", "ave", "x[i]-ave", "x[i]", "x", "i", "ave", "sum2+=(x[i]-ave-1)*(x[i]-ave-1)", "sum2", "(x[i]-ave-1)*(x[i]-ave-1)", "x[i]-ave-1", "x[i]-ave", "x[i]", "x", "i", "ave", "1", "x[i]-ave-1", "x[i]-ave", "x[i]", "x", "i", "ave", "1", "print(min(sum1,sum2))", "print", "min(sum1,sum2)", "min", "sum1", "sum2", "x = list(map(int,input().split()))", "list(map(int,input().split()))", "x", "n = int(input())", "int(input())", "n", "ave = sum(x)//n", "sum(x)//n", "ave", "sum2+=(x[i]-ave-1)*(x[i]-ave-1)", "(x[i]-ave-1)*(x[i]-ave-1)", "sum2", "sum2=0", "0", "sum2", "sum1+=(x[i]-ave)*(x[i]-ave)", "(x[i]-ave)*(x[i]-ave)", "sum1", "sum1=0", "0", "sum1" ]
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, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 12, 13, 10, 4, 13, 10, 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 ], [ 68, 51 ], [ 46, 52 ], [ 62, 53 ], [ 65, 56 ], [ 59, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 70, 71 ], [ 73, 74 ] ]
[ "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()))", "nums", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "def cost(x,y):\n return (x-y)**2", "cost", "return (x-y)**2", "(x-y)**2", "x-y", "x", "y", "2", "x", "x", "y", "y", "avg = round(sum(nums)/len(nums))", "avg", "round(sum(nums)/len(nums))", "round", "sum(nums)/len(nums)", "sum(nums)", "sum", "nums", "len(nums)", "len", "nums", "res = 0", "res", "0", "for n in nums:\n res += cost(n, avg)", "n", "nums", "res += cost(n, avg)", "res", "cost(n, avg)", "cost", "n", "avg", "print(res)", "print", "res", "res = 0", "0", "res", "avg = round(sum(nums)/len(nums))", "round(sum(nums)/len(nums))", "avg", "res += cost(n, avg)", "cost(n, avg)", "res", "def cost(x,y):\n return (x-y)**2", "def cost(x,y):\n return (x-y)**2", "cost", "n = int(input())", "int(input())", "n", "nums = list(map(int, input().split()))", "list(map(int, input().split()))", "nums" ]
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, 13, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 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 ], [ 69, 53 ], [ 75, 53 ], [ 72, 54 ], [ 60, 54 ], [ 75, 57 ], [ 69, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ] ]
[ "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 = sorted(list(map(int, input().split())))", "a", "sorted(list(map(int, input().split())))", "sorted", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "answer = 10000000", "answer", "10000000", "for 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)", "i", "range(a[0], a[-1] + 1)", "range", "a[0]", "a", "0", "a[-1] + 1", "a[-1]", "a", "-1", "1", "cost = 0", "cost", "0", "for num in a:\n cost += ((num - i) ** 2)\n ", "num", "a", "cost += ((num - i) ** 2)", "cost", "(num - i) ** 2", "num - i", "num", "i", "2", "answer = min(answer, cost)", "answer", "min(answer, cost)", "min", "answer", "cost", "print(answer)", "print", "answer", "cost = 0", "0", "cost", "N = int(input())", "int(input())", "N", "a = sorted(list(map(int, input().split())))", "sorted(list(map(int, input().split())))", "a", "answer = 10000000", "10000000", "answer", "cost += ((num - i) ** 2)", "(num - i) ** 2", "cost", "answer = min(answer, cost)", "min(answer, cost)", "answer" ]
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, 4, 13, 13, 10, 4, 13, 10, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 2, 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 ], [ 60, 51 ], [ 64, 54 ], [ 61, 54 ], [ 79, 55 ], [ 70, 55 ], [ 61, 58 ], [ 64, 58 ], [ 60, 61 ], [ 67, 63 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ] ]
[ "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()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "inf=float('inf')", "inf", "float('inf')", "float", "'inf'", "ans=inf", "ans", "inf", "for 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 ", "b", "range(-100,101)", "range", "-100", "101", "ch=0", "ch", "0", "for i in range(n):\n ch+=(b-a[i])**2\n \n ", "i", "range(n)", "range", "n", "ch+=(b-a[i])**2", "ch", "(b-a[i])**2", "b-a[i]", "b", "a[i]", "a", "i", "2", "ans=min(ans,ch)", "ans", "min(ans,ch)", "min", "ans", "ch", "print(ans)", "print", "ans", "ans=min(ans,ch)", "min(ans,ch)", "ans", "ans=inf", "inf", "ans", "inf=float('inf')", "float('inf')", "inf", "ch=0", "0", "ch", "n=int(input())", "int(input())", "n", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "ch+=(b-a[i])**2", "(b-a[i])**2", "ch" ]
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, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 18, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13 ]
[ [ 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 ], [ 44, 43 ], [ 73, 46 ], [ 78, 48 ], [ 67, 52 ], [ 43, 53 ], [ 61, 54 ], [ 79, 58 ], [ 76, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ] ]
[ "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(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "b = 0", "b", "0", "for i in range(N):\n b += a[i]", "i", "range(N)", "range", "N", "b += a[i]", "b", "a[i]", "a", "i", "r = round(b/N)", "r", "round(b/N)", "round", "b/N", "b", "N", "ans = 0", "ans", "0", "for i in range(N):\n ans += (a[i]-r)**2", "i", "range(N)", "range", "N", "ans += (a[i]-r)**2", "ans", "(a[i]-r)**2", "a[i]-r", "a[i]", "a", "i", "r", "2", "print(ans)", "print", "ans", "r = round(b/N)", "round(b/N)", "r", "b = 0", "0", "b", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "b += a[i]", "a[i]", "b", "N = int(input())", "int(input())", "N", "ans = 0", "0", "ans", "ans += (a[i]-r)**2", "(a[i]-r)**2", "ans" ]
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, 13, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 4, 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 ], [ 66, 48 ], [ 69, 50 ], [ 87, 50 ], [ 77, 53 ], [ 81, 56 ], [ 78, 56 ], [ 84, 57 ], [ 86, 59 ], [ 78, 63 ], [ 81, 63 ], [ 65, 66 ], [ 90, 68 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ] ]
[ "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", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "mi=min(a)", "mi", "min(a)", "min", "a", "ma=max(a)", "ma", "max(a)", "max", "a", "i=mi", "i", "mi", "ans=10**10", "ans", "10**10", "10", "10", "while i<=ma:\n x=sum((a[j]-i)**2 for j in range(n))\n ans=min(ans,x)\n i+=1", "i<=ma", "i", "ma", "x=sum((a[j]-i)**2 for j in range(n))", "x", "sum((a[j]-i)**2 for j in range(n))", "sum", "(a[j]-i)**2", "a[j]-i", "a[j]", "a", "j", "i", "2", "ans=min(ans,x)", "ans", "min(ans,x)", "min", "ans", "x", "i+=1", "i", "1", "print(ans)", "print", "ans", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "i=mi", "mi", "i", "ma=max(a)", "max(a)", "ma", "n=int(input())", "int(input())", "n", "ans=min(ans,x)", "min(ans,x)", "ans", "ans=10**10", "10**10", "ans", "x=sum((a[j]-i)**2 for j in range(n))", "sum((a[j]-i)**2 for j in range(n))", "x", "i+=1", "1", "i", "mi=min(a)", "min(a)", "mi" ]
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, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ] ]
[ "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(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = 10**18", "ans", "10**18", "10", "18", "for y in range(-100, 101):\n ans = min(ans, sum([(x - y) ** 2 for x in arr]))", "y", "range(-100, 101)", "range", "-100", "101", "(x - y) ** 2 for x in arr", "for x in arr", "x", "arr", "for x in arr", "(x - y) ** 2", "x - y", "x", "y", "2", "ans = min(ans, sum([(x - y) ** 2 for x in arr]))", "ans", "min(ans, sum([(x - y) ** 2 for x in arr]))", "min", "ans", "sum([(x - y) ** 2 for x in arr])", "sum", "[(x - y) ** 2 for x in arr]", "print(ans)", "print", "ans", "ans = 10**18", "10**18", "ans", "arr = list(map(int, input().split()))", "list(map(int, input().split()))", "arr", "ans = min(ans, sum([(x - y) ** 2 for x in arr]))", "min(ans, sum([(x - y) ** 2 for x in arr]))", "ans", "n = int(input())", "int(input())", "n" ]
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, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ] ]
[ "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()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ave = int((sum(ls)/N*2+1)//2)", "ave", "int((sum(ls)/N*2+1)//2)", "int", "(sum(ls)/N*2+1)//2", "sum(ls)/N*2+1", "sum(ls)/N*2", "sum(ls)/N", "sum(ls)", "sum", "ls", "N", "2", "1", "2", "cost = 0", "cost", "0", "for i in ls:\n cost += (i-ave)**2", "i", "ls", "cost += (i-ave)**2", "cost", "(i-ave)**2", "i-ave", "i", "ave", "2", "print(cost)", "print", "cost", "cost = 0", "0", "cost", "cost += (i-ave)**2", "(i-ave)**2", "cost", "ave = int((sum(ls)/N*2+1)//2)", "int((sum(ls)/N*2+1)//2)", "ave", "N = int(input())", "int(input())", "N", "ls = list(map(int,input().split()))", "list(map(int,input().split()))", "ls" ]
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, 10, 4, 13 ]
[ [ 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 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "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(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "m = round(sum(a)/n)", "m", "round(sum(a)/n)", "round", "sum(a)/n", "sum(a)", "sum", "a", "n", "ans = 0", "ans", "0", "for i in a:\n ans += (i-m)**2", "i", "a", "ans += (i-m)**2", "ans", "(i-m)**2", "i-m", "i", "m", "2", "print(ans)", "print", "ans", "m = round(sum(a)/n)", "round(sum(a)/n)", "m", "ans += (i-m)**2", "(i-m)**2", "ans", "ans = 0", "0", "ans", "n = int(input())", "int(input())", "n", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a" ]
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().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "print(min(sum((a-n)**2 for a in A) for n in range(min(A),1+max(A))))", "print", "min(sum((a-n)**2 for a in A) for n in range(min(A),1+max(A)))", "min", "sum((a-n)**2 for a in A)", "sum", "(a-n)**2", "a-n", "a", "n", "2", "N = int(input())", "int(input())", "N", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A" ]
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, 39, 4, 13, 17, 4, 13, 17, 23, 0, 13, 12, 2, 4, 13, 13, 17, 23, 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, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 2, 13, 10, 12, 13, 10, 2, 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 ], [ 104, 103 ], [ 107, 106 ], [ 82, 106 ], [ 110, 109 ], [ 106, 112 ], [ 97, 113 ], [ 117, 116 ], [ 94, 119 ], [ 116, 119 ], [ 109, 120 ], [ 103, 120 ], [ 116, 123 ], [ 94, 123 ], [ 135, 129 ], [ 131, 132 ], [ 137, 138 ], [ 140, 141 ], [ 143, 144 ], [ 146, 147 ], [ 149, 150 ] ]
[ "# -*- 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())\n a=list(map(int,input().split()))\n ans=INF\n for i in range(-100,101):\n tmp=0\n for x in a:\n tmp+=(x-i)**2\n ans=min(ans,tmp)\n print(ans)\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "sys.setrecursionlimit(10**9)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**9", "10", "9", "INF=10**18", "INF", "10**18", "10", "18", "MOD=10**9+7", "MOD", "10**9+7", "10**9", "10", "9", "7", "input=lambda: sys.stdin.readline().rstrip()", "input", "lambda: sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "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'))", "bool([print('Yes')] if b else print('No'))", "bool", "[print('Yes')] if b else print('No')", "b", "[print('Yes')]", "print('Yes')", "print", "'Yes'", "print('No')", "print", "'No'", "b", "YESNO=lambda b: bool([print('YES')] if b else print('NO'))", "YESNO", "lambda b: bool([print('YES')] if b else print('NO'))", "bool([print('YES')] if b else print('NO'))", "bool", "[print('YES')] if b else print('NO')", "b", "[print('YES')]", "print('YES')", "print", "'YES'", "print('NO')", "print", "'NO'", "b", "int1=lambda x:int(x)-1", "int1", "lambda x:int(x)-1", "int(x)-1", "int(x)", "int", "x", "1", "x", "def main():\n N=int(input())\n a=list(map(int,input().split()))\n ans=INF\n for i in range(-100,101):\n tmp=0\n for x in a:\n tmp+=(x-i)**2\n ans=min(ans,tmp)\n print(ans)", "main", "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().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans=INF", "ans", "INF", "for i in range(-100,101):\n tmp=0\n for x in a:\n tmp+=(x-i)**2\n ans=min(ans,tmp)\n ", "i", "range(-100,101)", "range", "-100", "101", "tmp=0", "tmp", "0", "for x in a:\n tmp+=(x-i)**2\n ", "x", "a", "tmp+=(x-i)**2", "tmp", "(x-i)**2", "x-i", "x", "i", "2", "ans=min(ans,tmp)", "ans", "min(ans,tmp)", "min", "ans", "tmp", "print(ans)", "print", "ans", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "YESNO=lambda b: bool([print('YES')] if b else print('NO'))", "lambda b: bool([print('YES')] if b else print('NO'))", "YESNO", "def main():\n N=int(input())\n a=list(map(int,input().split()))\n ans=INF\n for i in range(-100,101):\n tmp=0\n for x in a:\n tmp+=(x-i)**2\n ans=min(ans,tmp)\n print(ans)", "def main():\n N=int(input())\n a=list(map(int,input().split()))\n ans=INF\n for i in range(-100,101):\n tmp=0\n for x in a:\n tmp+=(x-i)**2\n ans=min(ans,tmp)\n print(ans)", "main", "YesNo=lambda b: bool([print('Yes')] if b else print('No'))", "lambda b: bool([print('Yes')] if b else print('No'))", "YesNo", "int1=lambda x:int(x)-1", "lambda x:int(x)-1", "int1", "INF=10**18", "10**18", "INF", "input=lambda: sys.stdin.readline().rstrip()", "lambda: sys.stdin.readline().rstrip()", "input", "MOD=10**9+7", "10**9+7", "MOD" ]
# -*- 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(int,input().split())) ans=INF for i in range(-100,101): tmp=0 for x in a: tmp+=(x-i)**2 ans=min(ans,tmp) print(ans) if __name__ == '__main__': main()
[ 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,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "num=round(statistics.mean(a))", "num", "round(statistics.mean(a))", "round", "statistics.mean(a)", "statistics.mean", "statistics", "mean", "a", "(num-i)**2 for i in a", "for i in a", "i", "a", "for i in a", "(num-i)**2", "num-i", "num", "i", "2", "print(sum([(num-i)**2 for i in a]))", "print", "sum([(num-i)**2 for i in a])", "sum", "[(num-i)**2 for i in a]", "n=int(input())", "int(input())", "n", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "num=round(statistics.mean(a))", "round(statistics.mean(a))", "num" ]
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, 0, 13, 2, 2, 18, 13, 13, 13, 17, 4, 13, 4, 13, 13, 13, 10, 2, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 10, 2, 13 ]
[ [ 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 ], [ 79, 49 ], [ 89, 53 ], [ 44, 54 ], [ 74, 55 ], [ 91, 58 ], [ 89, 62 ], [ 44, 63 ], [ 95, 64 ], [ 80, 70 ], [ 86, 70 ], [ 92, 71 ], [ 77, 71 ], [ 73, 74 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ], [ 88, 89 ], [ 91, 92 ], [ 94, 95 ] ]
[ "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 = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "m1 = sum(a) // n", "m1", "sum(a) // n", "sum(a)", "sum", "a", "n", "m2 = (sum(a) + n - 1) // n", "m2", "(sum(a) + n - 1) // n", "sum(a) + n - 1", "sum(a) + n", "sum(a)", "sum", "a", "n", "1", "n", "res1 = 0", "res1", "0", "res2 = 0", "res2", "0", "for i in range(n):\n res1 += (a[i] - m1) ** 2\n res2 += (a[i] - m2) ** 2", "i", "range(n)", "range", "n", "res1 += (a[i] - m1) ** 2", "res1", "(a[i] - m1) ** 2", "a[i] - m1", "a[i]", "a", "i", "m1", "2", "res2 += (a[i] - m2) ** 2", "res2", "(a[i] - m2) ** 2", "a[i] - m2", "a[i]", "a", "i", "m2", "2", "print(min(res1, res2))", "print", "min(res1, res2)", "min", "res1", "res2", "m1 = sum(a) // n", "sum(a) // n", "m1", "res2 = 0", "0", "res2", "res1 += (a[i] - m1) ** 2", "(a[i] - m1) ** 2", "res1", "n = int(input())", "int(input())", "n", "res1 = 0", "0", "res1", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "res2 += (a[i] - m2) ** 2", "(a[i] - m2) ** 2", "res2", "m2 = (sum(a) + n - 1) // n", "(sum(a) + n - 1) // n", "m2" ]
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, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 13, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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 ], [ 52, 51 ], [ 77, 51 ], [ 70, 54 ], [ 51, 57 ], [ 80, 58 ], [ 74, 58 ], [ 83, 58 ], [ 71, 62 ], [ 68, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ] ]
[ "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", "int(input())", "int", "input()", "input", "int(x) for x in input().split()", "for x in input().split()", "x", "input().split()", "().split", "()", "input", "split", "for x in input().split()", "int(x)", "int", "x", "A = [int(x) for x in input().split()]", "A", "[int(x) for x in input().split()]", "from statistics import mean", "from math import floor, ceil", "meanA = mean(A)", "meanA", "mean(A)", "mean", "A", "if meanA < floor(meanA) + 0.5:\n meanA = floor(meanA)\nelse:\n meanA = ceil(meanA)", "meanA < floor(meanA) + 0.5", "meanA", "floor(meanA) + 0.5", "floor(meanA)", "floor", "meanA", "0.5", "meanA = floor(meanA)", "meanA", "floor(meanA)", "floor", "meanA", "meanA = ceil(meanA)", "meanA", "ceil(meanA)", "ceil", "meanA", "ans = 0", "ans", "0", "for a in A:\n ans += (a-meanA)**2", "a", "A", "ans += (a-meanA)**2", "ans", "(a-meanA)**2", "a-meanA", "a", "meanA", "2", "print(ans)", "print", "ans", "N = int(input())", "int(input())", "N", "ans = 0", "0", "ans", "ans += (a-meanA)**2", "(a-meanA)**2", "ans", "meanA = floor(meanA)", "floor(meanA)", "meanA", "A = [int(x) for x in input().split()]", "[int(x) for x in input().split()]", "A", "meanA = ceil(meanA)", "ceil(meanA)", "meanA", "meanA = mean(A)", "mean(A)", "meanA" ]
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, 13, 13, 0, 13, 13, 0, 13, 13, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 13, 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 ], [ 84, 48 ], [ 80, 50 ], [ 96, 55 ], [ 93, 55 ], [ 45, 56 ], [ 28, 57 ], [ 98, 59 ], [ 99, 60 ], [ 81, 60 ], [ 74, 62 ], [ 99, 63 ], [ 81, 63 ], [ 77, 65 ], [ 87, 68 ], [ 78, 68 ], [ 75, 69 ], [ 90, 69 ], [ 78, 72 ], [ 87, 72 ], [ 99, 74 ], [ 81, 74 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 92, 93 ], [ 95, 96 ], [ 99, 98 ], [ 81, 98 ], [ 98, 99 ] ]
[ "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())", "int", "input()", "input", "a = list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = 1000000", "ans", "1000000", "a = sorted(a)", "a", "sorted(a)", "sorted", "a", "for 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)", "i", "range(a[0],a[n-1]+1)", "range", "a[0]", "a", "0", "a[n-1]+1", "a[n-1]", "a", "n-1", "n", "1", "1", "counter = 0", "counter", "0", "for j in range(n):\n dif = abs(a[j] - i)\n dif *= dif\n counter += dif\n ", "j", "range(n)", "range", "n", "dif = abs(a[j] - i)", "dif", "abs(a[j] - i)", "abs", "a[j] - i", "a[j]", "a", "j", "i", "dif *= dif", "dif", "dif", "counter += dif", "counter", "dif", "ans = min(ans,counter)", "ans", "min(ans,counter)", "min", "ans", "counter", "print(ans)", "print", "ans", "counter += dif", "dif", "counter", "ans = min(ans,counter)", "min(ans,counter)", "ans", "dif = abs(a[j] - i)", "abs(a[j] - i)", "dif", "n = int(input())", "int(input())", "n", "ans = 1000000", "1000000", "ans", "counter = 0", "0", "counter", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "a = sorted(a)", "sorted(a)", "a", "dif *= dif", "dif", "dif" ]
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, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 4, 13, 10, 2, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 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 ], [ 48, 54 ], [ 33, 55 ], [ 76, 58 ], [ 74, 61 ], [ 80, 61 ], [ 71, 62 ], [ 77, 62 ], [ 77, 65 ], [ 71, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ] ]
[ "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(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "cmin = ((max(a) - min(a)) ** 2) * n", "cmin", "((max(a) - min(a)) ** 2) * n", "(max(a) - min(a)) ** 2", "max(a) - min(a)", "max(a)", "max", "a", "min(a)", "min", "a", "2", "n", "for 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)", "x", "range(min(a), max(a) + 1)", "range", "min(a)", "min", "a", "max(a) + 1", "max(a)", "max", "a", "1", "c = 0", "c", "0", "for i in a:\n c += (i - x) ** 2\n ", "i", "a", "c += (i - x) ** 2", "c", "(i - x) ** 2", "i - x", "i", "x", "2", "cmin = min(c, cmin)", "cmin", "min(c, cmin)", "min", "c", "cmin", "print(cmin)", "print", "cmin", "n = int(input())", "int(input())", "n", "cmin = ((max(a) - min(a)) ** 2) * n", "((max(a) - min(a)) ** 2) * n", "cmin", "c += (i - x) ** 2", "(i - x) ** 2", "c", "cmin = min(c, cmin)", "min(c, cmin)", "cmin", "c = 0", "0", "c", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a" ]
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, 10, 4, 13 ]
[ [ 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 ], [ 45, 46 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ] ]
[ "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().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "y=round(sum(X)/n)", "y", "round(sum(X)/n)", "round", "sum(X)/n", "sum(X)", "sum", "X", "n", "cost=0", "cost", "0", "for x in X:\n cost+=(x-y)**2", "x", "X", "cost+=(x-y)**2", "cost", "(x-y)**2", "x-y", "x", "y", "2", "print(cost)", "print", "cost", "X=list(map(int, input().split()))", "list(map(int, input().split()))", "X", "cost=0", "0", "cost", "n=int(input())", "int(input())", "n", "cost+=(x-y)**2", "(x-y)**2", "cost", "y=round(sum(X)/n)", "round(sum(X)/n)", "y" ]
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, 13, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13, 10, 2, 13, 10, 17, 13, 10, 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 ], [ 64, 49 ], [ 35, 51 ], [ 70, 57 ], [ 61, 57 ], [ 73, 58 ], [ 76, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ] ]
[ "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()", "input", "number = list(map(int, input().split()))", "number", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "total_a = 0", "total_a", "0", "total_b = 0", "total_b", "0", "average = sum(number)//len(number)", "average", "sum(number)//len(number)", "sum(number)", "sum", "number", "len(number)", "len", "number", "for i in number:\n total_a += (average-i)**2\n total_b += (average+1-i)**2", "i", "number", "total_a += (average-i)**2", "total_a", "(average-i)**2", "average-i", "average", "i", "2", "total_b += (average+1-i)**2", "total_b", "(average+1-i)**2", "average+1-i", "average+1", "average", "1", "i", "2", "print(min(total_a, total_b))", "print", "min(total_a, total_b)", "min", "total_a", "total_b", "total_a = 0", "0", "total_a", "average = sum(number)//len(number)", "sum(number)//len(number)", "average", "N = int(input())", "int(input())", "N", "total_a += (average-i)**2", "(average-i)**2", "total_a", "total_b += (average+1-i)**2", "(average+1-i)**2", "total_b", "total_b = 0", "0", "total_b", "number = list(map(int, input().split()))", "list(map(int, input().split()))", "number" ]
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, 13, 13, 0, 13, 13, 4, 13, 13, 10, 4, 13, 10, 13, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 2, 13 ]
[ [ 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 ], [ 26, 52 ], [ 84, 56 ], [ 81, 56 ], [ 75, 57 ], [ 69, 57 ], [ 68, 59 ], [ 84, 60 ], [ 81, 60 ], [ 69, 63 ], [ 75, 63 ], [ 65, 66 ], [ 84, 68 ], [ 81, 68 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ] ]
[ "#!/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", "input()", "input", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = 1000100", "ans", "1000100", "ch = 0", "ch", "0", "for 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 ", "ch", "range(min(a), max(a)+1)", "range", "min(a)", "min", "a", "max(a)+1", "max(a)", "max", "a", "1", "tmp = 0", "tmp", "0", "for i in range(n):\n tmp += (a[i]-ch)**2\n ", "i", "range(n)", "range", "n", "tmp += (a[i]-ch)**2", "tmp", "(a[i]-ch)**2", "a[i]-ch", "a[i]", "a", "i", "ch", "2", "if tmp <= ans:\n ans = tmp ", "tmp <= ans", "tmp", "ans", "ans = tmp", "ans", "tmp", "print(ans)", "print", "ans", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "ans = tmp", "tmp", "ans", "n = int(input())", "int(input())", "n", "ans = 1000100", "1000100", "ans", "ch = 0", "0", "ch", "tmp = 0", "0", "tmp", "tmp += (a[i]-ch)**2", "(a[i]-ch)**2", "tmp" ]
#!/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, 13, 2, 2, 13, 18, 13, 13, 2, 13, 18, 13, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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 ], [ 77, 55 ], [ 82, 57 ], [ 89, 60 ], [ 74, 60 ], [ 77, 62 ], [ 50, 63 ], [ 89, 65 ], [ 74, 65 ], [ 77, 67 ], [ 50, 68 ], [ 83, 71 ], [ 80, 71 ], [ 73, 74 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ], [ 88, 89 ], [ 91, 92 ] ]
[ "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 = list(map(int,input().split()))", "arr", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "add = sum(arr)", "add", "sum(arr)", "sum", "arr", "if add>0:\n\tx = int(add/n + 0.5)\nelse:\n\tx = int(add/n - 0.5)", "add>0", "add", "0", "x = int(add/n + 0.5)", "x", "int(add/n + 0.5)", "int", "add/n + 0.5", "add/n", "add", "n", "0.5", "x = int(add/n - 0.5)", "x", "int(add/n - 0.5)", "int", "add/n - 0.5", "add/n", "add", "n", "0.5", "ans = 0", "ans", "0", "for i in range(len(arr)):\n\tans += ((x-arr[i])*(x-arr[i]))", "i", "range(len(arr))", "range", "len(arr)", "len", "arr", "ans += ((x-arr[i])*(x-arr[i]))", "ans", "(x-arr[i])*(x-arr[i])", "x-arr[i]", "x", "arr[i]", "arr", "i", "x-arr[i]", "x", "arr[i]", "arr", "i", "print(ans)", "print", "ans", "x = int(add/n + 0.5)", "int(add/n + 0.5)", "x", "arr = list(map(int,input().split()))", "list(map(int,input().split()))", "arr", "ans = 0", "0", "ans", "ans += ((x-arr[i])*(x-arr[i]))", "(x-arr[i])*(x-arr[i])", "ans", "n = int(input())", "int(input())", "n", "x = int(add/n - 0.5)", "int(add/n - 0.5)", "x", "add = sum(arr)", "sum(arr)", "add" ]
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, 13, 13, 4, 13, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 2, 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 ], [ 63, 54 ], [ 79, 57 ], [ 64, 57 ], [ 67, 58 ], [ 70, 58 ], [ 64, 61 ], [ 79, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ] ]
[ "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().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = 10**10", "ans", "10**10", "10", "10", "for 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)", "i", "range(min(a), max(a)+1)", "range", "min(a)", "min", "a", "max(a)+1", "max(a)", "max", "a", "1", "cnt = 0", "cnt", "0", "for j in range(n):\n cnt += (a[j]-i) ** 2\n ", "j", "range(n)", "range", "n", "cnt += (a[j]-i) ** 2", "cnt", "(a[j]-i) ** 2", "a[j]-i", "a[j]", "a", "j", "i", "2", "ans = min(ans, cnt)", "ans", "min(ans, cnt)", "min", "ans", "cnt", "print(ans)", "print", "ans", "ans = min(ans, cnt)", "min(ans, cnt)", "ans", "cnt += (a[j]-i) ** 2", "(a[j]-i) ** 2", "cnt", "cnt = 0", "0", "cnt", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "n = int(input())", "int(input())", "n", "ans = 10**10", "10**10", "ans" ]
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, 13, 14, 2, 13, 13, 0, 13, 13, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13, 10, 13, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 13, 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 ], [ 90, 52 ], [ 78, 52 ], [ 77, 55 ], [ 75, 56 ], [ 72, 56 ], [ 75, 59 ], [ 72, 59 ], [ 81, 60 ], [ 90, 60 ], [ 78, 60 ], [ 89, 62 ], [ 75, 63 ], [ 72, 63 ], [ 90, 66 ], [ 78, 66 ], [ 81, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 75, 77 ], [ 72, 77 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 75, 89 ], [ 72, 89 ], [ 89, 90 ] ]
[ "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 = cost_stack\n\nprint(min_val)", "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().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "min_val = None", "min_val", "None", "stacks = 0", "stacks", "0", "for 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 = cost_stack", "i", "range(-100, 101)", "range", "-100", "101", "cost_stack = 0", "cost_stack", "0", "for j in range(len(a)):\n cost_stack += (a[j] - i) ** 2\n \n ", "j", "range(len(a))", "range", "len(a)", "len", "a", "cost_stack += (a[j] - i) ** 2", "cost_stack", "(a[j] - i) ** 2", "a[j] - i", "a[j]", "a", "j", "i", "2", "if min_val == None:\n min_val = cost_stack\n elif cost_stack < min_val:\n min_val = cost_stack", "min_val == None", "min_val", "None", "min_val = cost_stack", "min_val", "cost_stack", "elif cost_stack < min_val:\n min_val = cost_stack", "cost_stack < min_val", "cost_stack", "min_val", "min_val = cost_stack", "min_val", "cost_stack", "print(min_val)", "print", "min_val", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "cost_stack = 0", "0", "cost_stack", "cost_stack += (a[j] - i) ** 2", "(a[j] - i) ** 2", "cost_stack", "min_val = cost_stack", "cost_stack", "min_val", "min_val = None", "None", "min_val", "stacks = 0", "0", "stacks", "N = int(input())", "int(input())", "N", "min_val = cost_stack", "cost_stack", "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(min_val)
[ 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, 4, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 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 ], [ 60, 48 ], [ 69, 48 ], [ 69, 51 ], [ 60, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "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()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans =10**8", "ans", "10**8", "10", "8", "for i in range(-100,101):\n cost = 0\n for k in a:\n cost += (k-i)**2\n ans = min(cost,ans)", "i", "range(-100,101)", "range", "-100", "101", "cost = 0", "cost", "0", "for k in a:\n cost += (k-i)**2\n ", "k", "a", "cost += (k-i)**2", "cost", "(k-i)**2", "k-i", "k", "i", "2", "ans = min(cost,ans)", "ans", "min(cost,ans)", "min", "cost", "ans", "print(ans)", "print", "ans", "cost = 0", "0", "cost", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "ans =10**8", "10**8", "ans", "n = int(input())", "int(input())", "n", "cost += (k-i)**2", "(k-i)**2", "cost", "ans = min(cost,ans)", "min(cost,ans)", "ans" ]
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", "0", "read", "split", "*A", "A", "m = round(sum(A) / n)", "m", "round(sum(A) / n)", "round", "sum(A) / n", "sum(A)", "sum", "A", "n", "print(sum(map(lambda x: (x-m)**2, A)))", "print", "sum(map(lambda x: (x-m)**2, A))", "sum", "map(lambda x: (x-m)**2, A)", "map", "lambda x: (x-m)**2", "(x-m)**2", "x-m", "x", "m", "2", "x", "A", "m = round(sum(A) / n)", "round(sum(A) / n)", "m", "n, *A = map(int, open(0).read().split())", "map(int, open(0).read().split())", "n" ]
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, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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 ], [ 60, 48 ], [ 54, 48 ], [ 57, 51 ], [ 63, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "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,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans=float(\"inf\")", "ans", "float(\"inf\")", "float", "\"inf\"", "for i in range(-100,101):\n k=0\n for j in a:\n k+=(j-i)**2\n ans=min(ans,k)", "i", "range(-100,101)", "range", "-100", "101", "k=0", "k", "0", "for j in a:\n k+=(j-i)**2\n ", "j", "a", "k+=(j-i)**2", "k", "(j-i)**2", "j-i", "j", "i", "2", "ans=min(ans,k)", "ans", "min(ans,k)", "min", "ans", "k", "print(ans)", "print", "ans", "k=0", "0", "k", "ans=min(ans,k)", "min(ans,k)", "ans", "k+=(j-i)**2", "(j-i)**2", "k", "ans=float(\"inf\")", "float(\"inf\")", "ans", "n=int(input())", "int(input())", "n", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a" ]
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, 13, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 12, 13 ]
[ [ 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 ], [ 67, 58 ], [ 61, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ] ]
[ "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().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "my_round_int = lambda x: int((x * 2 + 1) // 2)", "my_round_int", "lambda x: int((x * 2 + 1) // 2)", "int((x * 2 + 1) // 2)", "int", "(x * 2 + 1) // 2", "x * 2 + 1", "x * 2", "x", "2", "1", "2", "x", "m = my_round_int(sum(a)/len(a))", "m", "my_round_int(sum(a)/len(a))", "my_round_int", "sum(a)/len(a)", "sum(a)", "sum", "a", "len(a)", "len", "a", "cost = 0", "cost", "0", "for i in a:\n cost += (i - m)**2", "i", "a", "cost += (i - m)**2", "cost", "(i - m)**2", "i - m", "i", "m", "2", "print(cost)", "print", "cost", "cost = 0", "0", "cost", "m = my_round_int(sum(a)/len(a))", "my_round_int(sum(a)/len(a))", "m", "cost += (i - m)**2", "(i - m)**2", "cost", "N = int(input())", "int(input())", "N", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "my_round_int = lambda x: int((x * 2 + 1) // 2)", "lambda x: int((x * 2 + 1) // 2)", "my_round_int" ]
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, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 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 ], [ 46, 53 ], [ 22, 53 ], [ 62, 59 ] ]
[ "\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 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)", "main", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a_s = list(map(int,input().split()))", "a_s", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "answer = 999999999999999999999999999999999", "answer", "999999999999999999999999999999999", "for i in range(-100,101):\n temp = sum([(a-i) ** 2 for a in a_s ])\n answer = min(answer,temp)\n ", "i", "range(-100,101)", "range", "-100", "101", "(a-i) ** 2 for a in a_s", "for a in a_s", "a", "a_s", "for a in a_s", "(a-i) ** 2", "a-i", "a", "i", "2", "temp = sum([(a-i) ** 2 for a in a_s ])", "temp", "sum([(a-i) ** 2 for a in a_s ])", "sum", "[(a-i) ** 2 for a in a_s ]", "answer = min(answer,temp)", "answer", "min(answer,temp)", "min", "answer", "temp", "print(answer)", "print", "answer", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def 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)", "def 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)", "main" ]
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, 13, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 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 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ] ]
[ "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()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "A=sum(a)//N", "A", "sum(a)//N", "sum(a)", "sum", "a", "N", "B=(sum(a)-1)//N+1", "B", "(sum(a)-1)//N+1", "(sum(a)-1)//N", "sum(a)-1", "sum(a)", "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)))", "print", "min(sum((x-A)*(x-A) for x in a),sum((x-B)*(x-B) for x in a))", "min", "sum((x-A)*(x-A) for x in a)", "sum", "(x-A)*(x-A)", "x-A", "x", "A", "x-A", "x", "A", "sum((x-B)*(x-B) for x in a)", "sum", "(x-B)*(x-B)", "x-B", "x", "B", "x-B", "x", "B", "N=int(input())", "int(input())", "N", "B=(sum(a)-1)//N+1", "(sum(a)-1)//N+1", "B", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "A=sum(a)//N", "sum(a)//N", "A" ]
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, 13, 10, 4, 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 ], [ 49, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ] ]
[ "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", "input().split()", "().split", "()", "input", "split", "for i in input().split()", "int(i)", "int", "i", "l = [int(i)for i in input().split()]", "l", "[int(i)for i in input().split()]", "r = float(\"inf\")", "r", "float(\"inf\")", "float", "\"inf\"", "for i in range(-100, 101):\n r = min(r, sum((n - i)**2 for n in l))", "i", "range(-100, 101)", "range", "-100", "101", "r = min(r, sum((n - i)**2 for n in l))", "r", "min(r, sum((n - i)**2 for n in l))", "min", "r", "sum((n - i)**2 for n in l)", "sum", "(n - i)**2", "n - i", "n", "i", "2", "print(r)", "print", "r", "n = int(input())", "int(input())", "n", "r = float(\"inf\")", "float(\"inf\")", "r", "l = [int(i)for i in input().split()]", "[int(i)for i in input().split()]", "l", "r = min(r, sum((n - i)**2 for n in l))", "min(r, sum((n - i)**2 for n in l))", "r" ]
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, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 2, 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 ], [ 58, 51 ], [ 73, 52 ], [ 67, 52 ], [ 67, 55 ], [ 73, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ] ]
[ "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(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "for 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)", "i", "range(-100,101)", "range", "-100", "101", "x=0", "x", "0", "for j in range(n):\n x+=(i-a[j])**2\n ", "j", "range(n)", "range", "n", "x+=(i-a[j])**2", "x", "(i-a[j])**2", "i-a[j]", "i", "a[j]", "a", "j", "2", "ans=min(x,ans)", "ans", "min(x,ans)", "min", "x", "ans", "print(ans)", "print", "ans", "x=0", "0", "x", "n=int(input())", "int(input())", "n", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "ans=min(x,ans)", "min(x,ans)", "ans", "x+=(i-a[j])**2", "(i-a[j])**2", "x", "ans=10**10", "10**10", "ans" ]
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, 17, 4, 13, 4, 13, 13, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 2, 13, 10, 2, 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 ], [ 72, 47 ], [ 83, 50 ], [ 38, 55 ], [ 87, 56 ], [ 78, 62 ], [ 81, 62 ], [ 84, 63 ], [ 69, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ] ]
[ "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,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "b=sum(a)//n", "b", "sum(a)//n", "sum(a)", "sum", "a", "n", "c=b+1", "c", "b+1", "b", "1", "for i in a:\n ans+=abs(i-b)**2\n res+=abs(i-c)**2", "i", "a", "ans+=abs(i-b)**2", "ans", "abs(i-b)**2", "abs(i-b)", "abs", "i-b", "i", "b", "2", "res+=abs(i-c)**2", "res", "abs(i-c)**2", "abs(i-c)", "abs", "i-c", "i", "c", "2", "print(min(ans,res))", "print", "min(ans,res)", "min", "ans", "res", "n=int(input())", "int(input())", "n", "res=0", "0", "res", "b=sum(a)//n", "sum(a)//n", "b", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "ans+=abs(i-b)**2", "abs(i-b)**2", "ans", "ans=0", "0", "ans", "res+=abs(i-c)**2", "abs(i-c)**2", "res", "c=b+1", "b+1", "c" ]
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, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 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 ], [ 50, 53 ], [ 41, 54 ], [ 33, 54 ], [ 50, 57 ], [ 22, 57 ], [ 66, 63 ] ]
[ "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 main()", "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)", "main", "n = int(input())", "n", "int(input())", "int", "input()", "input", "As = list(map(int, input().split()))", "As", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = float(\"inf\")", "ans", "float(\"inf\")", "float", "\"inf\"", "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 ", "i", "range(-100, 101)", "range", "-100", "101", "ans_temp = 0", "ans_temp", "0", "for j in range(n):\n ans_temp += (As[j] + i)**2\n ", "j", "range(n)", "range", "n", "ans_temp += (As[j] + i)**2", "ans_temp", "(As[j] + i)**2", "As[j] + i", "As[j]", "As", "j", "i", "2", "ans = min(ans, ans_temp)", "ans", "min(ans, ans_temp)", "min", "ans", "ans_temp", "print(ans)", "print", "ans", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "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)", "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)", "main" ]
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, 0, 13, 4, 13, 4, 13, 13, 41, 28, 13, 4, 13, 13, 4, 4, 13, 4, 13, 13, 0, 13, 13, 4, 13, 4, 13, 13, 13, 12, 13, 15, 13, 4, 18, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 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, 50 ], [ 53, 52 ], [ 37, 54 ], [ 57, 56 ], [ 52, 61 ], [ 65, 64 ], [ 56, 67 ], [ 52, 73 ], [ 76, 75 ], [ 99, 80 ], [ 56, 81 ], [ 75, 82 ], [ 105, 96 ] ]
[ "#!/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 def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n a = [int(next(tokens)) for _ in range(N)] # type: \"List[int]\"\n print(solve(N, a))\n\ndef test():\n import doctest\n doctest.testmod()\n\nif __name__ == '__main__':\n #test()\n main()", "import sys", "sys", "def 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", "solve", "ans = float(\"inf\")", "ans", "float(\"inf\")", "float", "\"inf\"", "for m in range(-100, 101):\n ans = min(ans,\n sum((aa-m)**2 for aa in a))\n ", "m", "range(-100, 101)", "range", "-100", "101", "ans = min(ans,\n sum((aa-m)**2 for aa in a))", "ans", "min(ans,\n sum((aa-m)**2 for aa in a))", "min", "ans", "sum((aa-m)**2 for aa in a)", "sum", "(aa-m)**2", "aa-m", "aa", "m", "2", "return ans", "ans", "N: int", "N", "a: \"List[int]\"", "a", "def main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n a = [int(next(tokens)) for _ in range(N)] # type: \"List[int]\"\n print(solve(N, a))", "main", "def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n ", "iterate_tokens", "for line in sys.stdin:\n for word in line.split():\n yield word\n ", "line", "sys.stdin", "sys", "stdin", "for word in line.split():\n yield word\n ", "word", "line.split()", "line.split", "line", "split", "yield word", "word", "tokens = iterate_tokens()", "tokens", "iterate_tokens()", "iterate_tokens", "N = int(next(tokens))", "N", "int(next(tokens))", "int", "next(tokens)", "next", "tokens", "int(next(tokens)) for _ in range(N)", "for _ in range(N)", "_", "range(N)", "range", "N", "for _ in range(N)", "int(next(tokens))", "int", "next(tokens)", "next", "tokens", "a = [int(next(tokens)) for _ in range(N)]", "a", "[int(next(tokens)) for _ in range(N)]", "print(solve(N, a))", "print", "solve(N, a)", "solve", "N", "a", "def test():\n import doctest\n doctest.testmod()", "test", "import doctest", "doctest", "doctest.testmod()", "doctest.testmod", "doctest", "testmod", "if __name__ == '__main__':\n #test()\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def 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", "def 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", "solve", "def test():\n import doctest\n doctest.testmod()", "def test():\n import doctest\n doctest.testmod()", "test", "def main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n a = [int(next(tokens)) for _ in range(N)] # type: \"List[int]\"\n print(solve(N, a))", "def main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n a = [int(next(tokens)) for _ in range(N)] # type: \"List[int]\"\n print(solve(N, a))", "main" ]
#!/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(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int a = [int(next(tokens)) for _ in range(N)] # type: "List[int]" print(solve(N, a)) def test(): import doctest doctest.testmod() if __name__ == '__main__': #test() main()
[ 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, 13, 13, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 13, 13 ]
[ [ 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 ], [ 69, 53 ], [ 66, 53 ], [ 75, 54 ], [ 78, 54 ], [ 77, 56 ], [ 69, 57 ], [ 66, 57 ], [ 78, 60 ], [ 75, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 69, 77 ], [ 66, 77 ], [ 77, 78 ] ]
[ "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(input())", "int", "input()", "input", "a=list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "minimum=10000000", "minimum", "10000000", "for 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", "i", "range(-100,101)", "range", "-100", "101", "cost=0", "cost", "0", "for j in range(n):\n cost+=(i-(a[j]))**2\n if j==n-1:\n if cost<minimum:\n minimum=cost", "j", "range(n)", "range", "n", "cost+=(i-(a[j]))**2", "cost", "(i-(a[j]))**2", "i-(a[j])", "i", "a[j]", "a", "j", "2", "if j==n-1:\n if cost<minimum:\n minimum=cost", "j==n-1", "j", "n-1", "n", "1", "if cost<minimum:\n minimum=cost", "cost<minimum", "cost", "minimum", "minimum=cost", "minimum", "cost", "print(minimum)", "print", "minimum", "n=int(input())", "int(input())", "n", "cost=0", "0", "cost", "cost+=(i-(a[j]))**2", "(i-(a[j]))**2", "cost", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "minimum=10000000", "10000000", "minimum", "minimum=cost", "cost", "minimum" ]
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, 13, 13, 17, 23, 29, 4, 13, 4, 13, 4, 18, 13, 13, 13, 4, 13, 4, 18, 13, 13, 13, 14, 2, 13, 17, 4, 13, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 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(math.ceil(avg)))\n\n\nif __name__ == '__main__':\n print(solve())", "import math", "math", "def read_int():\n return int(input().strip())", "read_int", "return int(input().strip())", "int(input().strip())", "int", "input().strip()", "().strip", "()", "input", "strip", "def read_ints():\n return list(map(int, input().strip().split(' ')))", "read_ints", "return list(map(int, input().strip().split(' ')))", "list(map(int, input().strip().split(' ')))", "list", "map(int, input().strip().split(' '))", "map", "int", "input().strip().split(' ')", "().strip().split", "().strip()", "().strip", "()", "input", "strip", "split", "' '", "def 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(math.ceil(avg)))", "solve", "N = read_int()", "N", "read_int()", "read_int", "A = read_ints()", "A", "read_ints()", "read_ints", "avg = sum(A)/N", "avg", "sum(A)/N", "sum(A)", "sum", "A", "N", "cost = lambda M: sum(abs(a-M)**2 for a in A)", "cost", "lambda M: sum(abs(a-M)**2 for a in A)", "sum(abs(a-M)**2 for a in A)", "sum", "abs(a-M)**2", "abs(a-M)", "abs", "a-M", "a", "M", "2", "M", "return min(cost(math.floor(avg)), cost(math.ceil(avg)))", "min(cost(math.floor(avg)), cost(math.ceil(avg)))", "min", "cost(math.floor(avg))", "cost", "math.floor(avg)", "math.floor", "math", "floor", "avg", "cost(math.ceil(avg))", "cost", "math.ceil(avg)", "math.ceil", "math", "ceil", "avg", "if __name__ == '__main__':\n print(solve())", "__name__ == '__main__'", "__name__", "'__main__'", "print(solve())", "print", "solve()", "solve", "def read_ints():\n return list(map(int, input().strip().split(' ')))", "def read_ints():\n return list(map(int, input().strip().split(' ')))", "read_ints", "def 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(math.ceil(avg)))", "def 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(math.ceil(avg)))", "solve", "def read_int():\n return int(input().strip())", "def read_int():\n return int(input().strip())", "read_int" ]
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))) if __name__ == '__main__': print(solve())
[ 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, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 4, 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 ], [ 61, 46 ], [ 64, 46 ], [ 52, 49 ], [ 55, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ] ]
[ "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", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = 10000000", "ans", "10000000", "for i in range(-100, 101):\n sm = 0\n for x in a:\n sm += (x-i) ** 2\n ans = min(ans, sm)\n ", "i", "range(-100, 101)", "range", "-100", "101", "sm = 0", "sm", "0", "for x in a:\n sm += (x-i) ** 2\n ", "x", "a", "sm += (x-i) ** 2", "sm", "(x-i) ** 2", "x-i", "x", "i", "2", "ans = min(ans, sm)", "ans", "min(ans, sm)", "min", "ans", "sm", "print(ans)", "print", "ans", "ans = min(ans, sm)", "min(ans, sm)", "ans", "ans = 10000000", "10000000", "ans", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "sm += (x-i) ** 2", "(x-i) ** 2", "sm", "sm = 0", "0", "sm", "n = int(input())", "int(input())", "n" ]
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, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 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 ], [ 73, 51 ], [ 67, 52 ], [ 58, 52 ], [ 73, 55 ], [ 70, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ] ]
[ "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()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = float('INF')", "ans", "float('INF')", "float", "'INF'", "for 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)", "i", "range(-100,101)", "range", "-100", "101", "s = 0", "s", "0", "for j in range(n):\n s += (a[j]-i)**2\n ", "j", "range(n)", "range", "n", "s += (a[j]-i)**2", "s", "(a[j]-i)**2", "a[j]-i", "a[j]", "a", "j", "i", "2", "ans = min(ans,s)", "ans", "min(ans,s)", "min", "ans", "s", "print(ans)", "print", "ans", "s = 0", "0", "s", "n = int(input())", "int(input())", "n", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "s += (a[j]-i)**2", "(a[j]-i)**2", "s", "ans = float('INF')", "float('INF')", "ans", "ans = min(ans,s)", "min(ans,s)", "ans" ]
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, 13, 17, 42, 2, 13, 13, 0, 13, 2, 2, 13, 13, 17, 14, 2, 4, 13, 13, 13, 4, 13, 13, 2, 13, 17, 0, 13, 13, 0, 13, 2, 13, 17, 4, 13, 4, 13, 13, 13, 10, 12, 13, 10, 18, 13, 10, 2, 13, 10, 4, 13, 10, 13, 13, 10, 4, 13, 10, 2, 13, 10, 18, 13 ]
[ [ 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 ], [ 43, 43 ], [ 45, 45 ], [ 117, 47 ], [ 106, 49 ], [ 99, 52 ], [ 106, 54 ], [ 112, 56 ], [ 118, 60 ], [ 115, 60 ], [ 100, 61 ], [ 109, 61 ], [ 102, 63 ], [ 118, 66 ], [ 115, 66 ], [ 100, 67 ], [ 109, 67 ], [ 97, 72 ], [ 106, 73 ], [ 103, 74 ], [ 97, 76 ], [ 106, 77 ], [ 103, 79 ], [ 108, 82 ], [ 103, 83 ], [ 114, 85 ], [ 103, 87 ], [ 97, 92 ], [ 106, 93 ], [ 115, 94 ], [ 118, 94 ], [ 99, 100 ], [ 102, 103 ], [ 105, 106 ], [ 103, 108 ], [ 108, 109 ], [ 111, 112 ], [ 114, 115 ], [ 117, 118 ] ]
[ "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 right = center\n else:\n left = center + 1\n\nprint(cost(a, left))", "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().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a.sort()", "a.sort", "a", "sort", "def cost(a, y):\n ans = 0\n for i in a:\n ans += (i - y) * (i - y)\n return ans\n\n# binary search", "cost", "ans = 0", "ans", "0", "for i in a:\n ans += (i - y) * (i - y)\n ", "i", "a", "ans += (i - y) * (i - y)", "ans", "(i - y) * (i - y)", "i - y", "i", "y", "i - y", "i", "y", "return ans", "ans", "a", "a", "y", "y", "left = a[0]", "left", "a[0]", "a", "0", "right = a[n-1]", "right", "a[n-1]", "a", "n-1", "n", "1", "while left < right:\n center = (left + right) // 2\n if cost(a, center) < cost(a, center+1):\n right = center\n else:\n left = center + 1", "left < right", "left", "right", "center = (left + right) // 2", "center", "(left + right) // 2", "left + right", "left", "right", "2", "if cost(a, center) < cost(a, center+1):\n right = center\n else:\n left = center + 1", "cost(a, center) < cost(a, center+1)", "cost(a, center)", "cost", "a", "center", "cost(a, center+1)", "cost", "a", "center+1", "center", "1", "right = center", "right", "center", "left = center + 1", "left", "center + 1", "center", "1", "print(cost(a, left))", "print", "cost(a, left)", "cost", "a", "left", "def cost(a, y):\n ans = 0\n for i in a:\n ans += (i - y) * (i - y)\n return ans\n\n# binary search", "def cost(a, y):\n ans = 0\n for i in a:\n ans += (i - y) * (i - y)\n return ans\n\n# binary search", "cost", "right = a[n-1]", "a[n-1]", "right", "center = (left + right) // 2", "(left + right) // 2", "center", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "right = center", "center", "right", "n = int(input())", "int(input())", "n", "left = center + 1", "center + 1", "left", "left = a[0]", "a[0]", "left" ]
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 = center else: left = center + 1 print(cost(a, left))
[ 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, 13, 13, 17, 17, 28, 13, 4, 13, 17, 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, 2, 13, 10, 2, 13, 10, 39, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 2, 13 ]
[ [ 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 ], [ 107, 69 ], [ 73, 72 ], [ 93, 72 ], [ 113, 75 ], [ 72, 78 ], [ 62, 79 ], [ 102, 83 ], [ 114, 85 ], [ 108, 85 ], [ 102, 90 ], [ 92, 93 ], [ 95, 96 ], [ 98, 99 ], [ 101, 102 ], [ 104, 105 ], [ 107, 108 ], [ 110, 111 ], [ 113, 114 ] ]
[ "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(input())", "N", "int(input())", "int", "input()", "input", "a = list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = []", "ans", "[]", "avg = 0", "avg", "0", "if (max(a)+min(a))%2 == 0:\n avg = (max(a)+min(a))/2\nelse:\n avg = (max(a)+min(a))/2+1", "(max(a)+min(a))%2 == 0", "(max(a)+min(a))%2", "max(a)+min(a)", "max(a)", "max", "a", "min(a)", "min", "a", "2", "0", "avg = (max(a)+min(a))/2", "avg", "(max(a)+min(a))/2", "max(a)+min(a)", "max(a)", "max", "a", "min(a)", "min", "a", "2", "avg = (max(a)+min(a))/2+1", "avg", "(max(a)+min(a))/2+1", "(max(a)+min(a))/2", "max(a)+min(a)", "max(a)", "max", "a", "min(a)", "min", "a", "2", "1", "for i in range(-100,101,1):\n sum = 0\n for j in a:\n sum += (j-i)**2\n ans.append(sum)\n ", "i", "range(-100,101,1)", "range", "-100", "101", "1", "sum = 0", "sum", "0", "for j in a:\n sum += (j-i)**2\n ", "j", "a", "sum += (j-i)**2", "sum", "(j-i)**2", "j-i", "j", "i", "2", "ans.append(sum)", "ans.append", "ans", "append", "sum", "print(min(ans))", "print", "min(ans)", "min", "ans", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "avg = (max(a)+min(a))/2", "(max(a)+min(a))/2", "avg", "avg = (max(a)+min(a))/2+1", "(max(a)+min(a))/2+1", "avg", "ans = []", "[]", "ans", "N = int(input())", "int(input())", "N", "sum = 0", "0", "sum", "avg = 0", "0", "avg", "sum += (j-i)**2", "(j-i)**2", "sum" ]
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, 12, 13, 12, 13, 23, 13, 12, 13, 23, 13, 0, 13, 2, 17, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 4, 13, 0, 13, 4, 13, 0, 13, 13, 28, 13, 4, 13, 17, 2, 17, 17, 0, 13, 17, 28, 13, 13, 0, 13, 2, 2, 13, 13, 17, 14, 2, 13, 13, 0, 13, 13, 4, 13, 13, 10, 18, 13, 10, 12, 13, 10, 17, 13, 10, 12, 13, 10, 13, 13, 10, 2, 13, 10, 12, 13, 10, 4, 13, 10, 4, 13, 10, 13, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13, 10, 2, 13, 10, 2, 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 ], [ 147, 86 ], [ 166, 87 ], [ 90, 89 ], [ 126, 97 ], [ 101, 100 ], [ 145, 100 ], [ 168, 103 ], [ 100, 106 ], [ 89, 107 ], [ 169, 111 ], [ 127, 111 ], [ 148, 112 ], [ 133, 112 ], [ 132, 114 ], [ 169, 115 ], [ 127, 115 ], [ 133, 118 ], [ 148, 118 ], [ 120, 121 ], [ 126, 127 ], [ 169, 132 ], [ 127, 132 ], [ 132, 133 ], [ 135, 136 ], [ 141, 142 ], [ 144, 145 ], [ 166, 147 ], [ 147, 148 ], [ 165, 166 ], [ 168, 169 ] ]
[ "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, heappush\nfrom math import floor, ceil,pi,factorial\nfrom operator import itemgetter\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI2(): return [int(input()) for i in range(n)]\ndef MXI(): return [[LI()]for i in range(n)]\ndef SI(): return input().rstrip()\ndef printns(x): print('\\n'.join(x))\ndef printni(x): print('\\n'.join(list(map(str,x))))\ninf = 10**17\nmod = 10**9 + 7\n\nn=I()\nlis=LI()\nmn=inf\nfor i in range(-100,100+1):\n sm=0\n for s in lis:\n sm+=(s-i)**2\n if sm<mn:\n mn=sm\nprint(mn)", "import sys", "sys", "input = sys.stdin.readline", "input", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "sys.setrecursionlimit(10**7)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10**7", "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 import floor, ceil,pi,factorial", "from operator import itemgetter", "def I(): return int(input())", "I", "def MI(): return map(int, input().split())", "MI", "def LI(): return list(map(int, input().split()))", "LI", "int(input()) for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "int(input())", "int", "input()", "input", "def LI2(): return [int(input()) for i in range(n)]", "LI2", "[LI()]for i in range(n)", "for i in range(n)", "i", "range(n)", "range", "n", "for i in range(n)", "[LI()]", "LI()", "LI", "def MXI(): return [[LI()]for i in range(n)]", "MXI", "def SI(): return input().rstrip()", "SI", "def printns(x): print('\\n'.join(x))", "printns", "x", "x", "def printni(x): print('\\n'.join(list(map(str,x))))", "printni", "x", "x", "inf = 10**17", "inf", "10**17", "10", "17", "mod = 10**9 + 7", "mod", "10**9 + 7", "10**9", "10", "9", "7", "n=I()", "n", "I()", "I", "lis=LI()", "lis", "LI()", "LI", "mn=inf", "mn", "inf", "for i in range(-100,100+1):\n sm=0\n for s in lis:\n sm+=(s-i)**2\n if sm<mn:\n mn=sm", "i", "range(-100,100+1)", "range", "-100", "100+1", "100", "1", "sm=0", "sm", "0", "for s in lis:\n sm+=(s-i)**2\n ", "s", "lis", "sm+=(s-i)**2", "sm", "(s-i)**2", "s-i", "s", "i", "2", "if sm<mn:\n mn=sm", "sm<mn", "sm", "mn", "mn=sm", "mn", "sm", "print(mn)", "print", "mn", "input = sys.stdin.readline", "sys.stdin.readline", "input", "def printni(x): print('\\n'.join(list(map(str,x))))", "def printni(x): print('\\n'.join(list(map(str,x))))", "printni", "sm=0", "0", "sm", "def SI(): return input().rstrip()", "def SI(): return input().rstrip()", "SI", "mn=sm", "sm", "mn", "mod = 10**9 + 7", "10**9 + 7", "mod", "def LI2(): return [int(input()) for i in range(n)]", "def LI2(): return [int(input()) for i in range(n)]", "LI2", "n=I()", "I()", "n", "lis=LI()", "LI()", "lis", "mn=inf", "inf", "mn", "def printns(x): print('\\n'.join(x))", "def printns(x): print('\\n'.join(x))", "printns", "def MI(): return map(int, input().split())", "def MI(): return map(int, input().split())", "MI", "def MXI(): return [[LI()]for i in range(n)]", "def MXI(): return [[LI()]for i in range(n)]", "MXI", "def I(): return int(input())", "def I(): return int(input())", "I", "def LI(): return list(map(int, input().split()))", "def LI(): return list(map(int, input().split()))", "LI", "inf = 10**17", "10**17", "inf", "sm+=(s-i)**2", "(s-i)**2", "sm" ]
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 import floor, ceil,pi,factorial from operator import itemgetter def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def LI2(): return [int(input()) for i in range(n)] def MXI(): return [[LI()]for i in range(n)] def SI(): return input().rstrip() def printns(x): print('\n'.join(x)) def printni(x): print('\n'.join(list(map(str,x)))) inf = 10**17 mod = 10**9 + 7 n=I() lis=LI() mn=inf for i in range(-100,100+1): sm=0 for s in lis: sm+=(s-i)**2 if sm<mn: mn=sm print(mn)
[ 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, 10, 17, 13, 10, 4, 13, 10, 17, 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 ], [ 52, 46 ], [ 64, 46 ], [ 55, 49 ], [ 58, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ] ]
[ "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()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "min_cost=10000000000", "min_cost", "10000000000", "for 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 ", "x", "range(-100,101)", "range", "-100", "101", "i=0", "i", "0", "for y in a:\n i+=(y-x)**2\n ", "y", "a", "i+=(y-x)**2", "i", "(y-x)**2", "y-x", "y", "x", "2", "min_cost=min(min_cost,i)", "min_cost", "min(min_cost,i)", "min", "min_cost", "i", "print(min_cost)", "print", "min_cost", "i+=(y-x)**2", "(y-x)**2", "i", "min_cost=min(min_cost,i)", "min(min_cost,i)", "min_cost", "min_cost=10000000000", "10000000000", "min_cost", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "i=0", "0", "i", "n=int(input())", "int(input())", "n" ]
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, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 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 ], [ 68, 47 ], [ 65, 47 ], [ 59, 50 ], [ 56, 50 ], [ 52, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ] ]
[ "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", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = 1e9", "ans", "1e9", "for p in range(-100, 101):\n sub = 0\n for q in a:\n sub += pow(p - q, 2)\n ans = min(ans, sub)", "p", "range(-100, 101)", "range", "-100", "101", "sub = 0", "sub", "0", "for q in a:\n sub += pow(p - q, 2)\n ", "q", "a", "sub += pow(p - q, 2)", "sub", "pow(p - q, 2)", "pow", "p - q", "p", "q", "2", "ans = min(ans, sub)", "ans", "min(ans, sub)", "min", "ans", "sub", "print(ans)", "print", "ans", "n = int(input())", "int(input())", "n", "ans = 1e9", "1e9", "ans", "ans = min(ans, sub)", "min(ans, sub)", "ans", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "sub = 0", "0", "sub", "sub += pow(p - q, 2)", "pow(p - q, 2)", "sub" ]
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, 17, 14, 2, 13, 18, 13, 17, 0, 13, 13, 0, 13, 4, 13, 13, 13, 0, 13, 17, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 17, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13, 10, 2, 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 ], [ 89, 49 ], [ 83, 53 ], [ 40, 54 ], [ 30, 55 ], [ 30, 59 ], [ 83, 61 ], [ 97, 64 ], [ 101, 65 ], [ 86, 65 ], [ 89, 65 ], [ 94, 67 ], [ 101, 70 ], [ 86, 70 ], [ 89, 70 ], [ 98, 71 ], [ 92, 71 ], [ 95, 71 ], [ 88, 73 ], [ 95, 77 ], [ 98, 77 ], [ 92, 77 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ], [ 88, 89 ], [ 91, 92 ], [ 94, 95 ], [ 101, 97 ], [ 86, 97 ], [ 89, 97 ], [ 97, 98 ], [ 100, 101 ] ]
[ "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 min_cost = min(cost, min_cost)\n cost = 0\n \nprint(min_cost)", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a_list = list(map(int, input().split()))", "a_list", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a_list.sort()", "a_list.sort", "a_list", "sort", "cost = 0", "cost", "0", "min_cost=0", "min_cost", "0", "for 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 min_cost = min(cost, min_cost)\n cost = 0\n ", "i", "range(a_list[0], a_list[-1])", "range", "a_list[0]", "a_list", "0", "a_list[-1]", "a_list", "-1", "for j in range(len(a_list)):\n cost = cost + (a_list[j] - i)**2\n \n ", "j", "range(len(a_list))", "range", "len(a_list)", "len", "a_list", "cost = cost + (a_list[j] - i)**2", "cost", "cost + (a_list[j] - i)**2", "cost", "(a_list[j] - i)**2", "a_list[j] - i", "a_list[j]", "a_list", "j", "i", "2", "if i == a_list[0]:\n min_cost=cost\n \n ", "i == a_list[0]", "i", "a_list[0]", "a_list", "0", "min_cost=cost", "min_cost", "cost", "min_cost = min(cost, min_cost)", "min_cost", "min(cost, min_cost)", "min", "cost", "min_cost", "cost = 0", "cost", "0", "print(min_cost)", "print", "min_cost", "n = int(input())", "int(input())", "n", "a_list = list(map(int, input().split()))", "list(map(int, input().split()))", "a_list", "cost = 0", "0", "cost", "cost = 0", "0", "cost", "min_cost=0", "0", "min_cost", "min_cost = min(cost, min_cost)", "min(cost, min_cost)", "min_cost", "min_cost=cost", "cost", "min_cost", "cost = cost + (a_list[j] - i)**2", "cost + (a_list[j] - i)**2", "cost" ]
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 = min(cost, min_cost) cost = 0 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, 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, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13, 10, 2, 13, 10, 13, 13, 10, 4, 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 ], [ 67, 52 ], [ 73, 52 ], [ 72, 54 ], [ 70, 55 ], [ 64, 55 ], [ 73, 58 ], [ 67, 58 ], [ 60, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 70, 72 ], [ 64, 72 ], [ 72, 73 ], [ 75, 76 ] ]
[ "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, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "res = 10**9", "res", "10**9", "10", "9", "for 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", "i", "range(-100,101)", "range", "-100", "101", "SUM = 0", "SUM", "0", "for j in range(len(a)):\n SUM += (i-a[j])**2\n ", "j", "range(len(a))", "range", "len(a)", "len", "a", "SUM += (i-a[j])**2", "SUM", "(i-a[j])**2", "i-a[j]", "i", "a[j]", "a", "j", "2", "if SUM < res:\n res = SUM", "SUM < res", "SUM", "res", "res = SUM", "res", "SUM", "print(res)", "print", "res", "N = int(input())", "int(input())", "N", "SUM = 0", "0", "SUM", "res = 10**9", "10**9", "res", "SUM += (i-a[j])**2", "(i-a[j])**2", "SUM", "res = SUM", "SUM", "res", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a" ]
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, 13, 4, 13, 13, 10, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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 ], [ 71, 56 ], [ 62, 59 ], [ 65, 59 ], [ 71, 61 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ] ]
[ "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", "input()", "input", "list_A = list(map(int, input().split()))", "list_A", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = pow(10, 10)", "ans", "pow(10, 10)", "pow", "10", "10", "for 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", "num", "range(-100, 101)", "range", "-100", "101", "list_B = list(map(lambda x:(x-num)**2, list_A))", "list_B", "list(map(lambda x:(x-num)**2, list_A))", "list", "map(lambda x:(x-num)**2, list_A)", "map", "lambda x:(x-num)**2", "(x-num)**2", "x-num", "x", "num", "2", "x", "list_A", "sum_value = sum(list_B)", "sum_value", "sum(list_B)", "sum", "list_B", "if ans > sum_value:\n ans = sum_value", "ans > sum_value", "ans", "sum_value", "ans = sum_value", "ans", "sum_value", "print(ans)", "print", "ans", "ans = sum_value", "sum_value", "ans", "ans = pow(10, 10)", "pow(10, 10)", "ans", "list_A = list(map(int, input().split()))", "list(map(int, input().split()))", "list_A", "sum_value = sum(list_B)", "sum(list_B)", "sum_value", "n = int(input())", "int(input())", "n", "list_B = list(map(lambda x:(x-num)**2, list_A))", "list(map(lambda x:(x-num)**2, list_A))", "list_B" ]
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, 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, 39, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 10, 39, 13 ]
[ [ 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 ], [ 107, 49 ], [ 55, 54 ], [ 84, 54 ], [ 111, 54 ], [ 101, 57 ], [ 61, 60 ], [ 105, 63 ], [ 95, 65 ], [ 90, 69 ], [ 60, 70 ], [ 54, 71 ], [ 98, 74 ], [ 108, 77 ], [ 99, 77 ], [ 96, 78 ], [ 102, 78 ], [ 99, 81 ], [ 108, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 92, 93 ], [ 95, 96 ], [ 98, 99 ], [ 101, 102 ], [ 104, 105 ], [ 107, 108 ], [ 110, 111 ] ]
[ "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(input())", "int", "input()", "input", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "x = sum(a) / n", "x", "sum(a) / n", "sum(a)", "sum", "a", "n", "y = sum(a) // n", "y", "sum(a) // n", "sum(a)", "sum", "a", "n", "if x == y:\n cand = [y]\nelse:\n cand = [y, y+1]", "x == y", "x", "y", "cand = [y]", "cand", "[y]", "y", "cand = [y, y+1]", "cand", "[y, y+1]", "y", "y+1", "y", "1", "cost = 10**18", "cost", "10**18", "10", "18", "for ave in cand:\n c = 0\n for i in range(n):\n c += (a[i]-ave)**2\n cost = min(cost, c)", "ave", "cand", "c = 0", "c", "0", "for i in range(n):\n c += (a[i]-ave)**2\n ", "i", "range(n)", "range", "n", "c += (a[i]-ave)**2", "c", "(a[i]-ave)**2", "a[i]-ave", "a[i]", "a", "i", "ave", "2", "cost = min(cost, c)", "cost", "min(cost, c)", "min", "cost", "c", "print(cost)", "print", "cost", "cand = [y, y+1]", "[y, y+1]", "cand", "x = sum(a) / n", "sum(a) / n", "x", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "y = sum(a) // n", "sum(a) // n", "y", "c += (a[i]-ave)**2", "(a[i]-ave)**2", "c", "cost = min(cost, c)", "min(cost, c)", "cost", "c = 0", "0", "c", "n = int(input())", "int(input())", "n", "cost = 10**18", "10**18", "cost", "cand = [y]", "[y]", "cand" ]
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, 13, 13, 4, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 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 ], [ 40, 51 ], [ 22, 55 ], [ 47, 57 ], [ 37, 57 ], [ 22, 62 ], [ 71, 68 ] ]
[ "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__=='__main__':\n main()", "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 ", "main", "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().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "listcost = []", "listcost", "[]", "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 ", "i", "range(min(a),max(a)+1)", "range", "min(a)", "min", "a", "max(a)+1", "max(a)", "max", "a", "1", "cost = 0", "cost", "0", "for j in a:\n if i != j:\n cost += (i - j) ** 2\n ", "j", "a", "if i != j:\n cost += (i - j) ** 2\n ", "i != j", "i", "j", "cost += (i - j) ** 2", "cost", "(i - j) ** 2", "i - j", "i", "j", "2", "listcost.append(cost)", "listcost.append", "listcost", "append", "cost", "print(min(listcost))", "print", "min(listcost)", "min", "listcost", "if __name__=='__main__':\n main()", "__name__=='__main__'", "__name__", "'__main__'", "main()", "main", "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 ", "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 ", "main" ]
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, 4, 13, 13, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 4, 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 ], [ 80, 49 ], [ 35, 52 ], [ 46, 53 ], [ 86, 56 ], [ 72, 59 ], [ 87, 59 ], [ 81, 60 ], [ 84, 60 ], [ 87, 63 ], [ 72, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ] ]
[ "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", "lst = list(map(int, input().split()))", "lst", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "M = max(lst)", "M", "max(lst)", "max", "lst", "m = min(lst)", "m", "min(lst)", "min", "lst", "ans = float(\"INF\")", "ans", "float(\"INF\")", "float", "\"INF\"", "for i in range(m,M+1):\n num = 0\n for j in lst:\n num += (i-j)**2\n ans = min(ans, num)", "i", "range(m,M+1)", "range", "m", "M+1", "M", "1", "num = 0", "num", "0", "for j in lst:\n num += (i-j)**2\n ", "j", "lst", "num += (i-j)**2", "num", "(i-j)**2", "i-j", "i", "j", "2", "ans = min(ans, num)", "ans", "min(ans, num)", "min", "ans", "num", "print(ans)", "print", "ans", "n = int(input())", "int(input())", "n", "M = max(lst)", "max(lst)", "M", "ans = float(\"INF\")", "float(\"INF\")", "ans", "lst = list(map(int, input().split()))", "list(map(int, input().split()))", "lst", "m = min(lst)", "min(lst)", "m", "num += (i-j)**2", "(i-j)**2", "num", "num = 0", "0", "num", "ans = min(ans, num)", "min(ans, num)", "ans" ]
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, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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 ], [ 66, 54 ], [ 63, 57 ], [ 69, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ] ]
[ "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", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = float(\"inf\")", "ans", "float(\"inf\")", "float", "\"inf\"", "for num in range(-100, 101):\n tmp = sum([(a[i]-num)**2 for i in range(N)])\n ans = min(ans, tmp)", "num", "range(-100, 101)", "range", "-100", "101", "(a[i]-num)**2 for i in range(N)", "for i in range(N)", "i", "range(N)", "range", "N", "for i in range(N)", "(a[i]-num)**2", "a[i]-num", "a[i]", "a", "i", "num", "2", "tmp = sum([(a[i]-num)**2 for i in range(N)])", "tmp", "sum([(a[i]-num)**2 for i in range(N)])", "sum", "[(a[i]-num)**2 for i in range(N)]", "ans = min(ans, tmp)", "ans", "min(ans, tmp)", "min", "ans", "tmp", "print(ans)", "print", "ans", "N=int(input())", "int(input())", "N", "ans = min(ans, tmp)", "min(ans, tmp)", "ans", "tmp = sum([(a[i]-num)**2 for i in range(N)])", "sum([(a[i]-num)**2 for i in range(N)])", "tmp", "ans = float(\"inf\")", "float(\"inf\")", "ans", "a=list(map(int, input().split()))", "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, 17, 23, 13, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 4, 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 ], [ 74, 62 ], [ 68, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ] ]
[ "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", "a = list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "res = 1e+9", "res", "1e+9", "for 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)))", "i", "range(min(a),max(a)+1)", "range", "min(a)", "min", "a", "max(a)+1", "max(a)", "max", "a", "1", "tmp = copy.copy(a)", "tmp", "copy.copy(a)", "copy.copy", "copy", "copy", "a", "res = min(res,sum(map(lambda x:(x-i)**2,tmp)))", "res", "min(res,sum(map(lambda x:(x-i)**2,tmp)))", "min", "res", "sum(map(lambda x:(x-i)**2,tmp))", "sum", "map(lambda x:(x-i)**2,tmp)", "map", "lambda x:(x-i)**2", "(x-i)**2", "x-i", "x", "i", "2", "x", "tmp", "print(res)", "print", "res", "tmp = copy.copy(a)", "copy.copy(a)", "tmp", "res = 1e+9", "1e+9", "res", "N = int(input())", "int(input())", "N", "res = min(res,sum(map(lambda x:(x-i)**2,tmp)))", "min(res,sum(map(lambda x:(x-i)**2,tmp)))", "res", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a" ]
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, 18, 13, 13, 13, 17, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 29, 17, 14, 2, 13, 17, 4, 13, 10, 12, 13 ]
[ [ 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 ], [ 43, 65 ], [ 34, 70 ], [ 81, 78 ] ]
[ "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 cost.append(ramen)\n print(min(cost))\n return 0\n\nif __name__ == \"__main__\":\n solve()", "import math", "math", "import collections", "collections", "import fractions", "fractions", "import itertools", "itertools", "import functools", "functools", "import operator", "operator", "def 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 cost.append(ramen)\n print(min(cost))\n return 0", "solve", "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().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "cost = []", "cost", "[]", "for i in range(-100, 101):\n ramen = 0\n for j in range(n):\n ramen += abs(a[j]-i)**2\n cost.append(ramen)\n ", "i", "range(-100, 101)", "range", "-100", "101", "ramen = 0", "ramen", "0", "for j in range(n):\n ramen += abs(a[j]-i)**2\n ", "j", "range(n)", "range", "n", "ramen += abs(a[j]-i)**2", "ramen", "abs(a[j]-i)**2", "abs(a[j]-i)", "abs", "a[j]-i", "a[j]", "a", "j", "i", "2", "cost.append(ramen)", "cost.append", "cost", "append", "ramen", "print(min(cost))", "print", "min(cost)", "min", "cost", "return 0", "0", "if __name__ == \"__main__\":\n solve()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "solve()", "solve", "def 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 cost.append(ramen)\n print(min(cost))\n return 0", "def 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 cost.append(ramen)\n print(min(cost))\n return 0", "solve" ]
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(ramen) print(min(cost)) return 0 if __name__ == "__main__": solve()
[ 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, 13, 10, 17, 13, 10, 39, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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 ], [ 65, 51 ], [ 59, 51 ], [ 62, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ] ]
[ "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(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "l = []", "l", "[]", "for 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)", "i", "range(min(a), max(a) + 1)", "range", "min(a)", "min", "a", "max(a) + 1", "max(a)", "max", "a", "1", "c = 0", "c", "0", "for e in a:\n c += (e - i) ** 2\n ", "e", "a", "c += (e - i) ** 2", "c", "(e - i) ** 2", "e - i", "e", "i", "2", "l.append(c)", "l.append", "l", "append", "c", "print(min(l))", "print", "min(l)", "min", "l", "c = 0", "0", "c", "l = []", "[]", "l", "c += (e - i) ** 2", "(e - i) ** 2", "c", "n = int(input())", "int(input())", "n", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a" ]
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, 13, 10, 12, 13, 10, 2, 13 ]
[ [ 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 ], [ 55, 56 ], [ 61, 62 ] ]
[ "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.readline().rstrip())", "I", "def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))", "LI", "N = I()", "N", "I()", "I", "a = LI()", "a", "LI()", "LI", "x = sum(a)//N", "x", "sum(a)//N", "sum(a)", "sum", "a", "N", "y = x + 1", "y", "x + 1", "x", "1", "print(min(sum((i-x)**2 for i in a),sum((i-y)**2 for i in a)))", "print", "min(sum((i-x)**2 for i in a),sum((i-y)**2 for i in a))", "min", "sum((i-x)**2 for i in a)", "sum", "(i-x)**2", "i-x", "i", "x", "2", "sum((i-y)**2 for i in a)", "sum", "(i-y)**2", "i-y", "i", "y", "2", "y = x + 1", "x + 1", "y", "N = I()", "I()", "N", "def I(): return int(sys.stdin.readline().rstrip())", "def I(): return int(sys.stdin.readline().rstrip())", "I", "a = LI()", "LI()", "a", "def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))", "def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))", "LI", "x = sum(a)//N", "sum(a)//N", "x" ]
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, 13, 2, 13, 4, 13, 13, 14, 2, 13, 13, 0, 13, 13, 3, 4, 13, 4, 13, 13, 12, 13, 0, 13, 17, 28, 13, 13, 0, 13, 4, 13, 2, 13, 13, 17, 29, 13, 23, 13, 23, 13, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 12, 13, 10, 12, 13 ]
[ [ 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 ], [ 57, 56 ], [ 46, 58 ], [ 46, 61 ], [ 35, 64 ], [ 67, 64 ], [ 40, 65 ], [ 68, 67 ], [ 40, 68 ], [ 67, 74 ], [ 35, 74 ], [ 79, 78 ], [ 82, 81 ], [ 96, 81 ], [ 85, 84 ], [ 81, 88 ], [ 94, 89 ], [ 84, 92 ], [ 78, 92 ], [ 94, 94 ], [ 96, 96 ], [ 105, 102 ] ]
[ "#!/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 / abs(g)\n if old > ans:\n old = ans\n else:\n break\n print(int(old))\n\n\ndef sq(t, an):\n ans = 0\n for ai in an:\n ans += pow(ai - t, 2)\n return ans\n\n\nif __name__ == \"__main__\":\n _main()", "import sys", "sys", "def get_ints():\n return map(int, sys.stdin.readline().strip().split())", "get_ints", "return map(int, sys.stdin.readline().strip().split())", "map(int, sys.stdin.readline().strip().split())", "map", "int", "sys.stdin.readline().strip().split()", "sys.stdin.readline().strip().split", "sys.stdin.readline().strip()", "sys.stdin.readline().strip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "strip", "split", "def _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 / abs(g)\n if old > ans:\n old = ans\n else:\n break\n print(int(old))", "_main", "input()", "input", "an = list(get_ints())", "an", "list(get_ints())", "list", "get_ints()", "get_ints", "t = 0", "t", "0", "old = 1000000000", "old", "1000000000", "while 1:\n ans = sq(t, an)\n g = sq(t+1, an) - ans\n t -= g / abs(g)\n if old > ans:\n old = ans\n else:\n break\n ", "1", "ans = sq(t, an)", "ans", "sq(t, an)", "sq", "t", "an", "g = sq(t+1, an) - ans", "g", "sq(t+1, an) - ans", "sq(t+1, an)", "sq", "t+1", "t", "1", "an", "ans", "t -= g / abs(g)", "t", "g / abs(g)", "g", "abs(g)", "abs", "g", "if old > ans:\n old = ans\n else:\n break\n ", "old > ans", "old", "ans", "old = ans", "old", "ans", "break", "print(int(old))", "print", "int(old)", "int", "old", "def sq(t, an):\n ans = 0\n for ai in an:\n ans += pow(ai - t, 2)\n return ans", "sq", "ans = 0", "ans", "0", "for ai in an:\n ans += pow(ai - t, 2)\n ", "ai", "an", "ans += pow(ai - t, 2)", "ans", "pow(ai - t, 2)", "pow", "ai - t", "ai", "t", "2", "return ans", "ans", "t", "t", "an", "an", "if __name__ == \"__main__\":\n _main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "_main()", "_main", "def _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 / abs(g)\n if old > ans:\n old = ans\n else:\n break\n print(int(old))", "def _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 / abs(g)\n if old > ans:\n old = ans\n else:\n break\n print(int(old))", "_main", "def sq(t, an):\n ans = 0\n for ai in an:\n ans += pow(ai - t, 2)\n return ans", "def sq(t, an):\n ans = 0\n for ai in an:\n ans += pow(ai - t, 2)\n return ans", "sq", "def get_ints():\n return map(int, sys.stdin.readline().strip().split())", "def get_ints():\n return map(int, sys.stdin.readline().strip().split())", "get_ints" ]
#!/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 > ans: old = ans else: break print(int(old)) def sq(t, an): ans = 0 for ai in an: ans += pow(ai - t, 2) return ans if __name__ == "__main__": _main()
[ 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, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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, 62 ] ]
[ "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", "ave", "2", "return cost", "cost", "x", "x", "n = input()", "n", "input()", "input", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ave = round(sum(a)/int(n))", "ave", "round(sum(a)/int(n))", "round", "sum(a)/int(n)", "sum(a)", "sum", "a", "int(n)", "int", "n", "print(sum(list(map(cost, a))))", "print", "sum(list(map(cost, a)))", "sum", "list(map(cost, a))", "list", "map(cost, a)", "map", "cost", "a", "def cost(x):\n cost = (x - ave)**2\n return cost", "def cost(x):\n cost = (x - ave)**2\n return cost", "cost", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "n = input()", "input()", "n", "ave = round(sum(a)/int(n))", "round(sum(a)/int(n))", "ave" ]
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, 17, 13, 10, 4, 13 ]
[ [ 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 ], [ 48, 49 ], [ 51, 52 ], [ 54, 55 ], [ 57, 58 ], [ 60, 61 ] ]
[ "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().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "m=int(round(sum(a)/n,0))", "m", "int(round(sum(a)/n,0))", "int", "round(sum(a)/n,0)", "round", "sum(a)/n", "sum(a)", "sum", "a", "n", "0", "ans=0", "ans", "0", "for i in a:\n ans+=(i-m)**2", "i", "a", "ans+=(i-m)**2", "ans", "(i-m)**2", "i-m", "i", "m", "2", "print(ans)", "print", "ans", "ans+=(i-m)**2", "(i-m)**2", "ans", "n=int(input())", "int(input())", "n", "a=list(map(int,input().split()))", "list(map(int,input().split()))", "a", "ans=0", "0", "ans", "m=int(round(sum(a)/n,0))", "int(round(sum(a)/n,0))", "m" ]
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, 13, 18, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 13, 13, 10, 2, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 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 ], [ 50, 49 ], [ 79, 52 ], [ 87, 54 ], [ 38, 57 ], [ 82, 59 ], [ 49, 60 ], [ 75, 63 ], [ 85, 66 ], [ 76, 66 ], [ 88, 67 ], [ 94, 67 ], [ 76, 70 ], [ 85, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ], [ 81, 82 ], [ 84, 85 ], [ 87, 88 ], [ 90, 91 ], [ 93, 94 ] ]
[ "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 in input().split()", "for x in input().split()", "x", "input().split()", "().split", "()", "input", "split", "for x in input().split()", "int(x)", "int", "x", "A=[int(x) for x in input().split()]", "A", "[int(x) for x in input().split()]", "maxA=max(A)", "maxA", "max(A)", "max", "A", "minA=min(A)", "minA", "min(A)", "min", "A", "ans=10**9", "ans", "10**9", "10", "9", "for 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)", "i", "range(minA,maxA+1)", "range", "minA", "maxA+1", "maxA", "1", "kouho=0", "kouho", "0", "for j in range(N):\n kouho+=(i-A[j])**2\n ", "j", "range(N)", "range", "N", "kouho+=(i-A[j])**2", "kouho", "(i-A[j])**2", "i-A[j]", "i", "A[j]", "A", "j", "2", "ans=min(ans,kouho)", "ans", "min(ans,kouho)", "min", "ans", "kouho", "print(ans)", "print", "ans", "maxA=max(A)", "max(A)", "maxA", "ans=min(ans,kouho)", "min(ans,kouho)", "ans", "N=int(input())", "int(input())", "N", "A=[int(x) for x in input().split()]", "[int(x) for x in input().split()]", "A", "ans=10**9", "10**9", "ans", "kouho+=(i-A[j])**2", "(i-A[j])**2", "kouho", "minA=min(A)", "min(A)", "minA", "kouho=0", "0", "kouho" ]
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, 13, 17, 14, 2, 13, 13, 0, 13, 13, 4, 13, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13, 10, 4, 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 ], [ 82, 47 ], [ 51, 50 ], [ 86, 50 ], [ 79, 53 ], [ 50, 56 ], [ 39, 57 ], [ 80, 61 ], [ 83, 61 ], [ 74, 62 ], [ 89, 62 ], [ 88, 64 ], [ 80, 65 ], [ 83, 65 ], [ 89, 68 ], [ 74, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ], [ 80, 88 ], [ 83, 88 ], [ 88, 89 ], [ 91, 92 ] ]
[ "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())", "int", "input()", "input", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "max = max(a)", "max", "max(a)", "max", "a", "min = min(a)", "min", "min(a)", "min", "a", "cost_min = n * (max - min)**2", "cost_min", "n * (max - min)**2", "n", "(max - min)**2", "max - min", "max", "min", "2", "for 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", "m", "range(min, max+1)", "range", "min", "max+1", "max", "1", "cost = 0", "cost", "0", "for x in a:\n cost += (x - m)**2\n ", "x", "a", "cost += (x - m)**2", "cost", "(x - m)**2", "x - m", "x", "m", "2", "if cost < cost_min:\n cost_min = cost", "cost < cost_min", "cost", "cost_min", "cost_min = cost", "cost_min", "cost", "print(cost_min)", "print", "cost_min", "max = max(a)", "max(a)", "max", "cost_min = n * (max - min)**2", "n * (max - min)**2", "cost_min", "min = min(a)", "min(a)", "min", "cost += (x - m)**2", "(x - m)**2", "cost", "cost = 0", "0", "cost", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "cost_min = cost", "cost", "cost_min", "n = int(input())", "int(input())", "n" ]
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, 13, 10, 4, 13, 10, 17, 13, 10, 13, 13, 10, 2, 13 ]
[ [ 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 ], [ 68, 48 ], [ 62, 48 ], [ 56, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ] ]
[ "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().split()", "i", "input().split()", "().split", "()", "input", "split", "for i in input().split()", "int(i)", "int", "i", "a=[int(i)for i in input().split()]", "a", "[int(i)for i in input().split()]", "cost=[]", "cost", "[]", "for i in range(-100,101):\n tmp=0\n for j in a:\n tmp+=(j-i)**2\n cost.append(tmp)", "i", "range(-100,101)", "range", "-100", "101", "tmp=0", "tmp", "0", "for j in a:\n tmp+=(j-i)**2\n ", "j", "a", "tmp+=(j-i)**2", "tmp", "(j-i)**2", "j-i", "j", "i", "2", "cost.append(tmp)", "cost.append", "cost", "append", "tmp", "print(min(cost))", "print", "min(cost)", "min", "cost", "cost=[]", "[]", "cost", "n=int(input())", "int(input())", "n", "tmp=0", "0", "tmp", "a=[int(i)for i in input().split()]", "[int(i)for i in input().split()]", "a", "tmp+=(j-i)**2", "(j-i)**2", "tmp" ]
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, 0, 13, 4, 13, 2, 18, 13, 13, 13, 17, 0, 13, 4, 13, 2, 18, 13, 13, 13, 17, 4, 13, 4, 13, 13, 13, 23, 13, 23, 13, 4, 13, 13, 13, 10, 4, 13, 10, 12, 13, 10, 4, 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 ], [ 85, 62 ], [ 52, 63 ], [ 24, 64 ], [ 68, 67 ], [ 85, 72 ], [ 52, 73 ], [ 35, 74 ], [ 57, 80 ], [ 46, 80 ], [ 67, 81 ], [ 49, 81 ], [ 83, 83 ], [ 85, 85 ], [ 95, 87 ], [ 92, 88 ], [ 98, 89 ], [ 91, 92 ], [ 97, 98 ] ]
[ "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(result1,result2))\n\n\ncalculate(N, ARR)", "import math", "math", "N = int(input())", "N", "int(input())", "int", "input()", "input", "ARR = list(map(int,input().split()))", "ARR", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "def 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(result1,result2))", "calculate", "a1 = math.floor(sum(arr)/n)", "a1", "math.floor(sum(arr)/n)", "math.floor", "math", "floor", "sum(arr)/n", "sum(arr)", "sum", "arr", "n", "a2 = math.ceil(sum(arr)/n)", "a2", "math.ceil(sum(arr)/n)", "math.ceil", "math", "ceil", "sum(arr)/n", "sum(arr)", "sum", "arr", "n", "result1 = 0", "result1", "0", "result2 = 0", "result2", "0", "for i in range(n):\n result1 += pow(arr[i] - a1,2)\n result2 += pow(arr[i] - a2,2)\n\n ", "i", "range(n)", "range", "n", "result1 += pow(arr[i] - a1,2)", "result1", "pow(arr[i] - a1,2)", "pow", "arr[i] - a1", "arr[i]", "arr", "i", "a1", "2", "result2 += pow(arr[i] - a2,2)", "result2", "pow(arr[i] - a2,2)", "pow", "arr[i] - a2", "arr[i]", "arr", "i", "a2", "2", "print(min(result1,result2))", "print", "min(result1,result2)", "min", "result1", "result2", "n", "n", "arr", "arr", "calculate(N, ARR)", "calculate", "N", "ARR", "N = int(input())", "int(input())", "N", "def 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(result1,result2))", "def 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(result1,result2))", "calculate", "ARR = list(map(int,input().split()))", "list(map(int,input().split()))", "ARR" ]
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)) calculate(N, ARR)
[ 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, 13, 4, 13, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 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 ], [ 76, 52 ], [ 80, 55 ], [ 77, 55 ], [ 62, 56 ], [ 71, 56 ], [ 77, 59 ], [ 80, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ], [ 79, 80 ] ]
[ "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().split()))", "lst", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "m = 10 ** 10", "m", "10 ** 10", "10", "10", "for 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)", "i", "range(201)", "range", "201", "a = i - 100", "a", "i - 100", "i", "100", "temp = 0", "temp", "0", "for j in range(n):\n temp += ((lst[j] - a) ** 2)\n ", "j", "range(n)", "range", "n", "temp += ((lst[j] - a) ** 2)", "temp", "(lst[j] - a) ** 2", "lst[j] - a", "lst[j]", "lst", "j", "a", "2", "m = min(m, temp)", "m", "min(m, temp)", "min", "m", "temp", "print(m)", "print", "m", "temp += ((lst[j] - a) ** 2)", "(lst[j] - a) ** 2", "temp", "lst = list(map(int, input().split()))", "list(map(int, input().split()))", "lst", "n = int(input())", "int(input())", "n", "temp = 0", "0", "temp", "a = i - 100", "i - 100", "a", "m = min(m, temp)", "min(m, temp)", "m", "m = 10 ** 10", "10 ** 10", "m" ]
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, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 17, 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 ], [ 69, 53 ], [ 75, 53 ], [ 60, 54 ], [ 66, 54 ], [ 66, 57 ], [ 60, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ] ]
[ "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()", "input", "alist=list(map(int,input().split()))", "alist", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "min_answer=float(\"inf\")", "min_answer", "float(\"inf\")", "float", "\"inf\"", "for 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)", "i", "range(min(alist),max(alist)+1)", "range", "min(alist)", "min", "alist", "max(alist)+1", "max(alist)", "max", "alist", "1", "answer=0", "answer", "0", "for a in alist:\n answer+=(a-i)**2\n \n ", "a", "alist", "answer+=(a-i)**2", "answer", "(a-i)**2", "a-i", "a", "i", "2", "min_answer=min(answer,min_answer)", "min_answer", "min(answer,min_answer)", "min", "answer", "min_answer", "print(min_answer)", "print", "min_answer", "min_answer=float(\"inf\")", "float(\"inf\")", "min_answer", "N=int(input())", "int(input())", "N", "min_answer=min(answer,min_answer)", "min(answer,min_answer)", "min_answer", "answer+=(a-i)**2", "(a-i)**2", "answer", "alist=list(map(int,input().split()))", "list(map(int,input().split()))", "alist", "answer=0", "0", "answer" ]
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, 13, 0, 13, 13, 29, 13, 23, 13, 4, 13, 4, 13, 13, 10, 12, 13, 10, 4, 13, 10, 4, 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 ], [ 22, 55 ], [ 58, 55 ], [ 41, 56 ], [ 31, 56 ], [ 59, 58 ], [ 41, 59 ], [ 31, 59 ], [ 58, 61 ], [ 22, 61 ], [ 63, 63 ], [ 71, 67 ], [ 77, 68 ], [ 73, 74 ], [ 76, 77 ] ]
[ "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())", "N", "int(input())", "int", "input()", "input", "a = list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "def 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", "minimize", "min = 1000000", "min", "1000000", "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 ", "i", "range(-100,101)", "range", "-100", "101", "num = 0", "num", "0", "for j in range(len(list)):\n num = num + (int(list[j]) - i)**2\n ", "j", "range(len(list))", "range", "len(list)", "len", "list", "num = num + (int(list[j]) - i)**2", "num", "num + (int(list[j]) - i)**2", "num", "(int(list[j]) - i)**2", "int(list[j]) - i", "int(list[j])", "int", "list[j]", "list", "j", "i", "2", "if min >= num:\n min = num\n ", "min >= num", "min", "num", "min = num", "min", "num", "return min", "min", "list", "list", "print(minimize(a))", "print", "minimize(a)", "minimize", "a", "def 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", "def 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", "minimize", "N = int(input())", "int(input())", "N", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "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, 13, 2, 2, 18, 13, 13, 13, 17, 0, 13, 2, 2, 18, 13, 13, 13, 17, 4, 13, 4, 13, 13, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 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 ], [ 102, 62 ], [ 83, 65 ], [ 87, 69 ], [ 51, 70 ], [ 81, 71 ], [ 99, 77 ], [ 96, 77 ], [ 84, 78 ], [ 90, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 92, 93 ], [ 95, 96 ], [ 98, 99 ], [ 101, 102 ] ]
[ "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", "statistics", "import math", "math", "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().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans1,ans2 = 0,0", "ans1", "0", "ans2", "0", "a_avr1 = math.ceil((statistics.mean(a)))", "a_avr1", "math.ceil((statistics.mean(a)))", "math.ceil", "math", "ceil", "statistics.mean(a)", "statistics.mean", "statistics", "mean", "a", "a_avr2 = math.floor((statistics.mean(a)))", "a_avr2", "math.floor((statistics.mean(a)))", "math.floor", "math", "floor", "statistics.mean(a)", "statistics.mean", "statistics", "mean", "a", "for i in range(n):\n ans1 += (a[i] - a_avr1)**2\n ans2 += (a[i] - a_avr2)**2", "i", "range(n)", "range", "n", "ans1 += (a[i] - a_avr1)**2", "ans1", "(a[i] - a_avr1)**2", "a[i] - a_avr1", "a[i]", "a", "i", "a_avr1", "2", "ans2 += (a[i] - a_avr2)**2", "ans2", "(a[i] - a_avr2)**2", "a[i] - a_avr2", "a[i]", "a", "i", "a_avr2", "2", "print(min(ans1,ans2))", "print", "min(ans1,ans2)", "min", "ans1", "ans2", "a_avr2 = math.floor((statistics.mean(a)))", "math.floor((statistics.mean(a)))", "a_avr2", "ans2 += (a[i] - a_avr2)**2", "(a[i] - a_avr2)**2", "ans2", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "ans2 = 0,0", "0", "ans2", "n = int(input())", "int(input())", "n", "ans1,ans2 = 0,0", "0", "ans1", "ans1 += (a[i] - a_avr1)**2", "(a[i] - a_avr1)**2", "ans1", "a_avr1 = math.ceil((statistics.mean(a)))", "math.ceil((statistics.mean(a)))", "a_avr1" ]
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, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 14, 2, 17, 13, 4, 13, 10, 12, 13 ]
[ [ 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 ], [ 53, 52 ], [ 49, 57 ], [ 38, 58 ], [ 62, 61 ], [ 33, 64 ], [ 61, 64 ], [ 52, 65 ], [ 46, 65 ], [ 61, 68 ], [ 33, 68 ], [ 77, 74 ] ]
[ "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)\n\n\nif '__main__' == __name__:\n resolve()\n", "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)", "resolve", "N = int(input())", "N", "int(input())", "int", "input()", "input", "A = sorted(list(map(int, input().split())))", "A", "sorted(list(map(int, input().split())))", "sorted", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "start, end = min(A), max(A)", "start", "min(A)", "min", "A", "end", "max(A)", "max", "A", "mincost = float(\"inf\")", "mincost", "float(\"inf\")", "float", "\"inf\"", "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 ", "i", "range(start, end+1)", "range", "start", "end+1", "end", "1", "_cost = 0", "_cost", "0", "for a in A:\n _cost += abs(a-i)**2\n ", "a", "A", "_cost += abs(a-i)**2", "_cost", "abs(a-i)**2", "abs(a-i)", "abs", "a-i", "a", "i", "2", "mincost = min(mincost, _cost)", "mincost", "min(mincost, _cost)", "min", "mincost", "_cost", "print(mincost)", "print", "mincost", "if '__main__' == __name__:\n resolve()", "'__main__' == __name__", "'__main__'", "__name__", "resolve()", "resolve", "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 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)", "resolve" ]
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__' == __name__: resolve()
[ 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, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 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 ], [ 54, 48 ], [ 57, 48 ], [ 57, 51 ], [ 54, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "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(map(int, input().split()))", "A", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "cost = float(\"inf\")", "cost", "float(\"inf\")", "float", "\"inf\"", "for 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)", "i", "range(-100, 101)", "range", "-100", "101", "tmp_cost = 0", "tmp_cost", "0", "for a in A:\n tmp_cost += (a - i) ** 2\n ", "a", "A", "tmp_cost += (a - i) ** 2", "tmp_cost", "(a - i) ** 2", "a - i", "a", "i", "2", "cost = min(tmp_cost, cost)", "cost", "min(tmp_cost, cost)", "min", "tmp_cost", "cost", "print(cost)", "print", "cost", "cost = float(\"inf\")", "float(\"inf\")", "cost", "cost = min(tmp_cost, cost)", "min(tmp_cost, cost)", "cost", "tmp_cost = 0", "0", "tmp_cost", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "N = int(input())", "int(input())", "N", "tmp_cost += (a - i) ** 2", "(a - i) ** 2", "tmp_cost" ]
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, 13, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 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 ], [ 64, 57 ], [ 67, 58 ], [ 64, 61 ], [ 70, 61 ], [ 63, 64 ], [ 66, 67 ], [ 69, 70 ], [ 72, 73 ], [ 75, 76 ] ]
[ "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().split())))", "a", "sorted(list(map(int, input().split())))", "sorted", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = 10 ** 10", "ans", "10 ** 10", "10", "10", "for i in range(min(a), max(a) + 1):\n val = sum([(x - i) ** 2 for x in a])\n ans = min(ans, val)", "i", "range(min(a), max(a) + 1)", "range", "min(a)", "min", "a", "max(a) + 1", "max(a)", "max", "a", "1", "(x - i) ** 2 for x in a", "for x in a", "x", "a", "for x in a", "(x - i) ** 2", "x - i", "x", "i", "2", "val = sum([(x - i) ** 2 for x in a])", "val", "sum([(x - i) ** 2 for x in a])", "sum", "[(x - i) ** 2 for x in a]", "ans = min(ans, val)", "ans", "min(ans, val)", "min", "ans", "val", "print(ans)", "print", "ans", "ans = min(ans, val)", "min(ans, val)", "ans", "val = sum([(x - i) ** 2 for x in a])", "sum([(x - i) ** 2 for x in a])", "val", "ans = 10 ** 10", "10 ** 10", "ans", "n = int(input())", "int(input())", "n", "a = sorted(list(map(int, input().split())))", "sorted(list(map(int, input().split())))", "a" ]
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, 17, 2, 13, 13, 0, 13, 17, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 4, 13, 18, 13, 13, 13, 4, 13, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 18, 13, 10, 17, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 17, 13, 10, 4, 13, 10, 12, 13, 10, 4, 13, 10, 4, 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 ], [ 35, 43 ], [ 97, 45 ], [ 92, 49 ], [ 89, 49 ], [ 116, 50 ], [ 98, 54 ], [ 92, 57 ], [ 89, 57 ], [ 116, 58 ], [ 106, 60 ], [ 94, 63 ], [ 67, 66 ], [ 116, 69 ], [ 109, 71 ], [ 104, 73 ], [ 119, 75 ], [ 66, 76 ], [ 107, 77 ], [ 98, 77 ], [ 110, 80 ], [ 95, 80 ], [ 88, 89 ], [ 91, 92 ], [ 94, 95 ], [ 97, 98 ], [ 106, 107 ], [ 109, 110 ], [ 115, 116 ], [ 118, 119 ] ]
[ "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 i in range(n):\n sum += a[i]\n\nave = round(sum/n)\nif ave+0.5 <= sum/n:\n ave += 1\n\nans = 0\nfor i in range(n):\n ans += cost(a[i],ave)\n\nprint(ans)", "from sys import stdin", "def S(): return stdin.readline().rstrip()", "S", "def I(): return int(stdin.readline().rstrip())", "I", "def LS(): return list(stdin.readline().rstrip().split())", "LS", "def LI(): return list(map(int,stdin.readline().rstrip().split()))", "LI", "def cost(x,y):\n return pow(x-y,2)", "cost", "return pow(x-y,2)", "pow(x-y,2)", "pow", "x-y", "x", "y", "2", "x", "x", "y", "y", "n = I()", "n", "I()", "I", "a = LI()", "a", "LI()", "LI", "sum = 0", "sum", "0", "for i in range(n):\n sum += a[i]", "i", "range(n)", "range", "n", "sum += a[i]", "sum", "a[i]", "a", "i", "ave = round(sum/n)", "ave", "round(sum/n)", "round", "sum/n", "sum", "n", "if ave+0.5 <= sum/n:\n ave += 1", "ave+0.5 <= sum/n", "ave+0.5", "ave", "0.5", "sum/n", "sum", "n", "ave += 1", "ave", "1", "ans = 0", "ans", "0", "for i in range(n):\n ans += cost(a[i],ave)", "i", "range(n)", "range", "n", "ans += cost(a[i],ave)", "ans", "cost(a[i],ave)", "cost", "a[i]", "a", "i", "ave", "print(ans)", "print", "ans", "def S(): return stdin.readline().rstrip()", "def S(): return stdin.readline().rstrip()", "S", "def LI(): return list(map(int,stdin.readline().rstrip().split()))", "def LI(): return list(map(int,stdin.readline().rstrip().split()))", "LI", "sum = 0", "0", "sum", "sum += a[i]", "a[i]", "sum", "ans = 0", "0", "ans", "ave = round(sum/n)", "round(sum/n)", "ave", "def LS(): return list(stdin.readline().rstrip().split())", "def LS(): return list(stdin.readline().rstrip().split())", "LS", "def cost(x,y):\n return pow(x-y,2)", "def cost(x,y):\n return pow(x-y,2)", "cost", "ave += 1", "1", "ave", "ans += cost(a[i],ave)", "cost(a[i],ave)", "ans", "def I(): return int(stdin.readline().rstrip())", "def I(): return int(stdin.readline().rstrip())", "I", "n = I()", "I()", "n", "a = LI()", "LI()", "a" ]
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): sum += a[i] ave = round(sum/n) if ave+0.5 <= sum/n: ave += 1 ans = 0 for i in range(n): ans += cost(a[i],ave) 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, 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, 4, 13, 13, 0, 13, 17, 28, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 4, 13, 13, 10, 4, 13, 10, 2, 13, 10, 2, 13, 10, 2, 13, 10, 2, 13, 10, 4, 13, 10, 17, 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 ], [ 97, 59 ], [ 99, 61 ], [ 65, 64 ], [ 82, 67 ], [ 90, 69 ], [ 97, 73 ], [ 64, 74 ], [ 88, 75 ], [ 85, 75 ], [ 91, 79 ], [ 100, 79 ], [ 81, 82 ], [ 84, 85 ], [ 87, 88 ], [ 90, 91 ], [ 93, 94 ], [ 96, 97 ], [ 99, 100 ] ]
[ "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", "input()", "input", "a = list(map(int, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "decimal = sum(a) / len(a) - sum(a) // len(a)", "decimal", "sum(a) / len(a) - sum(a) // len(a)", "sum(a) / len(a)", "sum(a)", "sum", "a", "len(a)", "len", "a", "sum(a) // len(a)", "sum(a)", "sum", "a", "len(a)", "len", "a", "if decimal >= 0.5:\n m = sum(a) // len(a) + 1\nelse:\n m = sum(a) // len(a)", "decimal >= 0.5", "decimal", "0.5", "m = sum(a) // len(a) + 1", "m", "sum(a) // len(a) + 1", "sum(a) // len(a)", "sum(a)", "sum", "a", "len(a)", "len", "a", "1", "m = sum(a) // len(a)", "m", "sum(a) // len(a)", "sum(a)", "sum", "a", "len(a)", "len", "a", "ans = 0", "ans", "0", "for i in range(n):\n ans += (a[i] - m)**2", "i", "range(n)", "range", "n", "ans += (a[i] - m)**2", "ans", "(a[i] - m)**2", "a[i] - m", "a[i]", "a", "i", "m", "2", "print(ans)", "print", "ans", "n = int(input())", "int(input())", "n", "m = sum(a) // len(a) + 1", "sum(a) // len(a) + 1", "m", "m = sum(a) // len(a)", "sum(a) // len(a)", "m", "ans += (a[i] - m)**2", "(a[i] - m)**2", "ans", "decimal = sum(a) / len(a) - sum(a) // len(a)", "sum(a) / len(a) - sum(a) // len(a)", "decimal", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "ans = 0", "0", "ans" ]
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, 13, 13, 0, 13, 4, 18, 13, 13, 2, 2, 13, 13, 17, 17, 4, 18, 13, 13, 13, 4, 13, 4, 13, 4, 13, 13, 10, 2, 13, 10, 17, 13, 10, 4, 13, 10, 17, 13, 10, 39, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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 ], [ 96, 52 ], [ 102, 54 ], [ 93, 54 ], [ 57, 56 ], [ 90, 56 ], [ 104, 59 ], [ 56, 66 ], [ 84, 67 ], [ 96, 72 ], [ 105, 74 ], [ 87, 74 ], [ 96, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 92, 93 ], [ 95, 96 ], [ 98, 99 ], [ 101, 102 ], [ 104, 105 ] ]
[ "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", "math", "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().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ave = sum(A)//N", "ave", "sum(A)//N", "sum(A)", "sum", "A", "N", "cost1 = 0", "cost1", "0", "cost2 = 0", "cost2", "0", "cost = []", "cost", "[]", "for i in A:\n cost1 += math.pow((i - ave), 2)", "i", "A", "cost1 += math.pow((i - ave), 2)", "cost1", "math.pow((i - ave), 2)", "math.pow", "math", "pow", "i - ave", "i", "ave", "2", "cost.append(cost1)", "cost.append", "cost", "append", "cost1", "for i in A:\n cost2 += math.pow((i - ave - 1), 2)", "i", "A", "cost2 += math.pow((i - ave - 1), 2)", "cost2", "math.pow((i - ave - 1), 2)", "math.pow", "math", "pow", "i - ave - 1", "i - ave", "i", "ave", "1", "2", "cost.append(cost2)", "cost.append", "cost", "append", "cost2", "print(int(min(cost)))", "print", "int(min(cost))", "int", "min(cost)", "min", "cost", "ave = sum(A)//N", "sum(A)//N", "ave", "cost2 = 0", "0", "cost2", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "cost1 = 0", "0", "cost1", "cost = []", "[]", "cost", "N = int(input())", "int(input())", "N", "cost1 += math.pow((i - ave), 2)", "math.pow((i - ave), 2)", "cost1", "cost2 += math.pow((i - ave - 1), 2)", "math.pow((i - ave - 1), 2)", "cost2" ]
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, 13, 4, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 14, 2, 13, 13, 4, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 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, 46 ], [ 50, 49 ], [ 56, 55 ], [ 10, 55 ], [ 55, 60 ], [ 32, 61 ], [ 65, 64 ], [ 49, 70 ], [ 64, 71 ], [ 49, 74 ], [ 64, 77 ], [ 86, 83 ] ]
[ "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(loss_2)\n\n\nif __name__ == '__main__':\n main()", "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(loss_2)", "main", "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().split(' '))", "map", "int", "input().split(' ')", "().split", "()", "input", "split", "' '", "sum_A = sum(A)", "sum_A", "sum(A)", "sum", "A", "left, right = sum_A // N, sum_A // N + 1", "left", "sum_A // N", "sum_A", "N", "right", "sum_A // N + 1", "sum_A // N", "sum_A", "N", "1", "(a - left) ** 2 for a in A", "for a in A", "a", "A", "for a in A", "(a - left) ** 2", "a - left", "a", "left", "2", "loss_1 = sum([(a - left) ** 2 for a in A])", "loss_1", "sum([(a - left) ** 2 for a in A])", "sum", "[(a - left) ** 2 for a in A]", "(a - right) ** 2 for a in A", "for a in A", "a", "A", "for a in A", "(a - right) ** 2", "a - right", "a", "right", "2", "loss_2 = sum([(a - right) ** 2 for a in A])", "loss_2", "sum([(a - right) ** 2 for a in A])", "sum", "[(a - right) ** 2 for a in A]", "if loss_1 < loss_2:\n print(loss_1)\n else:\n print(loss_2)", "loss_1 < loss_2", "loss_1", "loss_2", "print(loss_1)", "print", "loss_1", "print(loss_2)", "print", "loss_2", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "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(loss_2)", "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(loss_2)", "main" ]
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 __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, 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, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 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 ], [ 39, 49 ], [ 63, 50 ], [ 69, 50 ], [ 72, 54 ], [ 57, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ] ]
[ "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()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "b = sum(a)", "b", "sum(a)", "sum", "a", "b = int((b+0.5*N) // N)", "b", "int((b+0.5*N) // N)", "int", "(b+0.5*N) // N", "b+0.5*N", "b", "0.5*N", "0.5", "N", "N", "ans = 0", "ans", "0", "for i in range(N):\n ans += (a[i]-b)**2", "i", "range(N)", "range", "N", "ans += (a[i]-b)**2", "ans", "(a[i]-b)**2", "a[i]-b", "a[i]", "a", "i", "b", "2", "print(ans)", "print", "ans", "ans = 0", "0", "ans", "N = int(input())", "int(input())", "N", "b = int((b+0.5*N) // N)", "int((b+0.5*N) // N)", "b", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "b = sum(a)", "sum(a)", "b", "ans += (a[i]-b)**2", "(a[i]-b)**2", "ans" ]
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, 13, 4, 13, 13, 0, 13, 2, 2, 18, 13, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13 ]
[ [ 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 ], [ 98, 50 ], [ 80, 50 ], [ 104, 51 ], [ 101, 51 ], [ 89, 51 ], [ 86, 51 ], [ 85, 53 ], [ 57, 56 ], [ 83, 59 ], [ 88, 61 ], [ 95, 65 ], [ 56, 66 ], [ 25, 67 ], [ 97, 70 ], [ 80, 73 ], [ 92, 73 ], [ 98, 73 ], [ 89, 74 ], [ 86, 74 ], [ 104, 74 ], [ 101, 74 ], [ 98, 77 ], [ 80, 77 ], [ 92, 77 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ], [ 88, 89 ], [ 91, 92 ], [ 94, 95 ], [ 97, 98 ], [ 100, 101 ], [ 103, 104 ] ]
[ "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", "int(input())", "int", "input()", "input", "a = list(map(int,input().split()))", "a", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = int(1e18)", "ans", "int(1e18)", "int", "1e18", "for 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)", "i", "range(101)", "range", "101", "cnt = 0", "cnt", "0", "for j in range(n):\n cnt += (a[j]-i)**2\n ", "j", "range(n)", "range", "n", "cnt += (a[j]-i)**2", "cnt", "(a[j]-i)**2", "a[j]-i", "a[j]", "a", "j", "i", "2", "ans = min(ans,cnt)", "ans", "min(ans,cnt)", "min", "ans", "cnt", "cnt = 0", "cnt", "0", "for j in range(n):\n cnt += (a[j]+i) **2\n ", "j", "range(n)", "range", "n", "cnt += (a[j]+i) **2", "cnt", "(a[j]+i) **2", "a[j]+i", "a[j]", "a", "j", "i", "2", "ans = min(ans,cnt)", "ans", "min(ans,cnt)", "min", "ans", "cnt", "print(ans)", "print", "ans", "ans = min(ans,cnt)", "min(ans,cnt)", "ans", "n = int(input())", "int(input())", "n", "cnt = 0", "0", "cnt", "cnt += (a[j]+i) **2", "(a[j]+i) **2", "cnt", "ans = int(1e18)", "int(1e18)", "ans", "a = list(map(int,input().split()))", "list(map(int,input().split()))", "a", "ans = min(ans,cnt)", "min(ans,cnt)", "ans", "cnt = 0", "0", "cnt", "cnt += (a[j]-i)**2", "(a[j]-i)**2", "cnt" ]
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, 4, 13, 10, 2, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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 ], [ 60, 48 ], [ 54, 48 ], [ 66, 51 ], [ 63, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "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()))", "A", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "MIN = float('inf')", "MIN", "float('inf')", "float", "'inf'", "for i in range(-100,101):\n tmp = 0\n for a in A:\n tmp += (a-i)**2\n MIN = min(MIN,tmp)", "i", "range(-100,101)", "range", "-100", "101", "tmp = 0", "tmp", "0", "for a in A:\n tmp += (a-i)**2\n ", "a", "A", "tmp += (a-i)**2", "tmp", "(a-i)**2", "a-i", "a", "i", "2", "MIN = min(MIN,tmp)", "MIN", "min(MIN,tmp)", "min", "MIN", "tmp", "print(MIN)", "print", "MIN", "tmp = 0", "0", "tmp", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A", "tmp += (a-i)**2", "(a-i)**2", "tmp", "MIN = float('inf')", "float('inf')", "MIN", "MIN = min(MIN,tmp)", "min(MIN,tmp)", "MIN", "N = int(input())", "int(input())", "N" ]
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, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 2, 13 ]
[ [ 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 ], [ 72, 53 ], [ 75, 54 ], [ 63, 54 ], [ 63, 57 ], [ 75, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ] ]
[ "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", "A = list(map(int, input().split()))", "A", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "min_cost = 10 ** 9 + 7", "min_cost", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "for 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)", "i", "range(-100, 101)", "range", "-100", "101", "cost = 0", "cost", "0", "for j in range(N):\n cost += (A[j] - i) ** 2\n ", "j", "range(N)", "range", "N", "cost += (A[j] - i) ** 2", "cost", "(A[j] - i) ** 2", "A[j] - i", "A[j]", "A", "j", "i", "2", "min_cost = min(cost, min_cost)", "min_cost", "min(cost, min_cost)", "min", "cost", "min_cost", "print(min_cost)", "print", "min_cost", "A = list(map(int, input().split()))", "list(map(int, input().split()))", "A", "min_cost = min(cost, min_cost)", "min(cost, min_cost)", "min_cost", "N = int(input())", "int(input())", "N", "cost += (A[j] - i) ** 2", "(A[j] - i) ** 2", "cost", "cost = 0", "0", "cost", "min_cost = 10 ** 9 + 7", "10 ** 9 + 7", "min_cost" ]
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()))", "sorted", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ave = round(sum(a) / n)", "ave", "round(sum(a) / n)", "round", "sum(a) / n", "sum(a)", "sum", "a", "n", "ans = sum(map(lambda x: (ave - x) ** 2, a))", "ans", "sum(map(lambda x: (ave - x) ** 2, a))", "sum", "map(lambda x: (ave - x) ** 2, a)", "map", "lambda x: (ave - x) ** 2", "(ave - x) ** 2", "ave - x", "ave", "x", "2", "x", "a", "print(ans)", "print", "ans", "n = int(input())", "int(input())", "n", "a = sorted(map(int, input().split()))", "sorted(map(int, input().split()))", "a", "ave = round(sum(a) / n)", "round(sum(a) / n)", "ave", "ans = sum(map(lambda x: (ave - x) ** 2, a))", "sum(map(lambda x: (ave - x) ** 2, a))", "ans" ]
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, 2, 2, 13, 13, 17, 0, 13, 2, 13, 2, 2, 13, 13, 17, 4, 13, 4, 13, 13, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 2, 13, 10, 13, 13, 10, 4, 13, 10, 4, 13, 10, 17, 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 ], [ 84, 55 ], [ 78, 55 ], [ 50, 58 ], [ 93, 59 ], [ 86, 62 ], [ 99, 64 ], [ 87, 64 ], [ 50, 67 ], [ 96, 68 ], [ 78, 74 ], [ 84, 74 ], [ 87, 75 ], [ 99, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 92, 93 ], [ 95, 96 ], [ 98, 99 ] ]
[ "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())", "n", "int(input())", "int", "input()", "input", "int(x) for x in input().split()", "for x in input().split()", "x", "input().split()", "().split", "()", "input", "split", "for x in input().split()", "int(x)", "int", "x", "arr=[int(x) for x in input().split()]", "arr", "[int(x) for x in input().split()]", "a=math.ceil(mean(arr))", "a", "math.ceil(mean(arr))", "math.ceil", "math", "ceil", "mean(arr)", "mean", "arr", "b=math.floor(mean(arr))", "b", "math.floor(mean(arr))", "math.floor", "math", "floor", "mean(arr)", "mean", "arr", "s1=0", "s1", "0", "s2=0", "s2", "0", "for x in arr:\n s1=s1+((x-a)**2)\n s2=s2+((x-b)**2)", "x", "arr", "s1=s1+((x-a)**2)", "s1", "s1+((x-a)**2)", "s1", "(x-a)**2", "x-a", "x", "a", "2", "s2=s2+((x-b)**2)", "s2", "s2+((x-b)**2)", "s2", "(x-b)**2", "x-b", "x", "b", "2", "print(min(s1,s2))", "print", "min(s1,s2)", "min", "s1", "s2", "s1=s1+((x-a)**2)", "s1+((x-a)**2)", "s1", "n=int(input())", "int(input())", "n", "s1=0", "0", "s1", "s2=s2+((x-b)**2)", "s2+((x-b)**2)", "s2", "arr=[int(x) for x in input().split()]", "[int(x) for x in input().split()]", "arr", "a=math.ceil(mean(arr))", "math.ceil(mean(arr))", "a", "b=math.floor(mean(arr))", "math.floor(mean(arr))", "b", "s2=0", "0", "s2" ]
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, 2, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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 ], [ 57, 48 ], [ 63, 48 ], [ 66, 51 ], [ 54, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "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())))", "a", "list(map(int,(input().split())))", "list", "map(int,(input().split()))", "map", "int", "input().split()", "().split", "()", "input", "split", "nim = float(\"inf\")", "nim", "float(\"inf\")", "float", "\"inf\"", "for i in range(-100,101):\n s = 0\n for j in a:\n s += (i-j)**2\n nim = min(nim,s)", "i", "range(-100,101)", "range", "-100", "101", "s = 0", "s", "0", "for j in a:\n s += (i-j)**2\n ", "j", "a", "s += (i-j)**2", "s", "(i-j)**2", "i-j", "i", "j", "2", "nim = min(nim,s)", "nim", "min(nim,s)", "min", "nim", "s", "print(nim)", "print", "nim", "nim = float(\"inf\")", "float(\"inf\")", "nim", "s += (i-j)**2", "(i-j)**2", "s", "a = list(map(int,(input().split())))", "list(map(int,(input().split())))", "a", "s = 0", "0", "s", "nim = min(nim,s)", "min(nim,s)", "nim", "N = int(input())", "int(input())", "N" ]
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, 0, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 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 ], [ 44, 54 ], [ 36, 54 ], [ 25, 55 ], [ 57, 55 ], [ 58, 57 ], [ 44, 58 ], [ 36, 58 ], [ 57, 61 ], [ 25, 61 ], [ 70, 67 ] ]
[ "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 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)", "main", "N = int(input())", "N", "int(input())", "int", "input()", "input", "int(a) for a in input().split()", "for a in input().split()", "a", "input().split()", "().split", "()", "input", "split", "for a in input().split()", "int(a)", "int", "a", "A = [int(a) for a in input().split()]", "A", "[int(a) for a in input().split()]", "cost = 10**10", "cost", "10**10", "10", "10", "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 ", "a", "range(-200, 201)", "range", "-200", "201", "c = 0", "c", "0", "for i in range(N):\n c += (a - A[i])**2\n ", "i", "range(N)", "range", "N", "c += (a - A[i])**2", "c", "(a - A[i])**2", "a - A[i]", "a", "A[i]", "A", "i", "2", "if c < cost:\n cost = c\n ", "c < cost", "c", "cost", "cost = c", "cost", "c", "print(cost)", "print", "cost", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "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)", "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)", "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, 13, 0, 13, 18, 13, 13, 0, 13, 2, 2, 13, 13, 17, 0, 13, 4, 13, 13, 13, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 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 ], [ 37, 52 ], [ 55, 54 ], [ 4, 57 ], [ 60, 59 ], [ 10, 61 ], [ 54, 62 ], [ 65, 64 ], [ 59, 67 ], [ 49, 68 ], [ 72, 71 ], [ 64, 74 ], [ 46, 74 ], [ 32, 75 ], [ 71, 75 ], [ 71, 78 ], [ 32, 78 ], [ 87, 84 ] ]
[ "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 tmp_cost += (a - std) ** 2\n cost = min(tmp_cost, cost)\n\n print(cost)\n\n\nif __name__ == '__main__':\n main()", "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 tmp_cost += (a - std) ** 2\n cost = min(tmp_cost, cost)\n\n print(cost)", "main", "n = int(input())", "n", "int(input())", "int", "input()", "input", "a_lst = list(map(int, input().split()))", "a_lst", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "minimum = min(a_lst)", "minimum", "min(a_lst)", "min", "a_lst", "maximum = max(a_lst)", "maximum", "max(a_lst)", "max", "a_lst", "cost = 10 ** 9", "cost", "10 ** 9", "10", "9", "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 tmp_cost += (a - std) ** 2\n cost = min(tmp_cost, cost)\n\n ", "i", "range(maximum - minimum + 1)", "range", "maximum - minimum + 1", "maximum - minimum", "maximum", "minimum", "1", "tmp_cost = 0", "tmp_cost", "0", "std = minimum + i", "std", "minimum + i", "minimum", "i", "for j in range(n):\n a = a_lst[j]\n tmp_cost += (a - std) ** 2\n ", "j", "range(n)", "range", "n", "a = a_lst[j]", "a", "a_lst[j]", "a_lst", "j", "tmp_cost += (a - std) ** 2", "tmp_cost", "(a - std) ** 2", "a - std", "a", "std", "2", "cost = min(tmp_cost, cost)", "cost", "min(tmp_cost, cost)", "min", "tmp_cost", "cost", "print(cost)", "print", "cost", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "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 tmp_cost += (a - std) ** 2\n cost = min(tmp_cost, cost)\n\n print(cost)", "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 tmp_cost += (a - std) ** 2\n cost = min(tmp_cost, cost)\n\n print(cost)", "main" ]
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 - std) ** 2 cost = min(tmp_cost, cost) print(cost) if __name__ == '__main__': main()
[ 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, 18, 13, 13, 13, 13, 15, 15, 15, 13, 15, 13, 15, 13, 15, 13, 15, 15, 15, 15, 15, 13, 4, 18, 13, 13, 17, 0, 13, 2, 2, 17, 17, 17, 0, 13, 4, 13, 0, 13, 4, 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, 10, 12, 13, 10, 4, 13, 10, 2, 13, 10, 2, 13, 10, 12, 13, 10, 4, 13, 10, 12, 13, 10, 17, 13, 10, 4, 13, 10, 12, 13, 10, 12, 13, 10, 4, 13 ]
[ [ 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, 115 ], [ 144, 117 ], [ 160, 121 ], [ 112, 122 ], [ 103, 123 ], [ 138, 126 ], [ 169, 129 ], [ 139, 129 ], [ 145, 130 ], [ 157, 130 ], [ 139, 133 ], [ 169, 133 ], [ 138, 139 ], [ 141, 142 ], [ 144, 145 ], [ 150, 151 ], [ 156, 157 ], [ 159, 160 ], [ 168, 169 ] ]
[ "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, deque, Counter\nfrom sys import exit\nimport heapq\nimport math\nimport fractions\nimport copy\nfrom itertools import permutations\nfrom operator import mul\nfrom functools import reduce\nfrom bisect import bisect_left, bisect_right\n\nimport sys\nsys.setrecursionlimit(1000000000)\nmod = 10 ** 9 + 7\n\nN = getN()\nA = getList()\n\nans = float('inf')\nfor i in range(-100, 101):\n opt = 0\n for k in range(N):\n opt += (A[k] - i) ** 2\n ans = min(ans, opt)\nprint(ans)", "def getN():\n return int(input())", "getN", "return int(input())", "int(input())", "int", "input()", "input", "def getNM():\n return map(int, input().split())", "getNM", "return map(int, input().split())", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "def getList():\n return list(map(int, input().split()))", "getList", "return list(map(int, input().split()))", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "def getArray(intn):\n return [int(input()) for i in range(intn)]", "getArray", "int(input()) for i in range(intn)", "for i in range(intn)", "i", "range(intn)", "range", "intn", "for i in range(intn)", "int(input())", "int", "input()", "input", "return [int(input()) for i in range(intn)]", "[int(input()) for i in range(intn)]", "intn", "intn", "def input():\n return sys.stdin.readline().rstrip()", "input", "return sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip()", "sys.stdin.readline().rstrip", "sys.stdin.readline()", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "rstrip", "from collections import defaultdict, deque, Counter", "from sys import exit", "import heapq", "heapq", "import math", "math", "import fractions", "fractions", "import copy", "copy", "from itertools import permutations", "from operator import mul", "from functools import reduce", "from bisect import bisect_left, bisect_right", "import sys", "sys", "sys.setrecursionlimit(1000000000)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "1000000000", "mod = 10 ** 9 + 7", "mod", "10 ** 9 + 7", "10 ** 9", "10", "9", "7", "N = getN()", "N", "getN()", "getN", "A = getList()", "A", "getList()", "getList", "ans = float('inf')", "ans", "float('inf')", "float", "'inf'", "for i in range(-100, 101):\n opt = 0\n for k in range(N):\n opt += (A[k] - i) ** 2\n ans = min(ans, opt)", "i", "range(-100, 101)", "range", "-100", "101", "opt = 0", "opt", "0", "for k in range(N):\n opt += (A[k] - i) ** 2\n ", "k", "range(N)", "range", "N", "opt += (A[k] - i) ** 2", "opt", "(A[k] - i) ** 2", "A[k] - i", "A[k]", "A", "k", "i", "2", "ans = min(ans, opt)", "ans", "min(ans, opt)", "min", "ans", "opt", "print(ans)", "print", "ans", "def getArray(intn):\n return [int(input()) for i in range(intn)]", "def getArray(intn):\n return [int(input()) for i in range(intn)]", "getArray", "ans = min(ans, opt)", "min(ans, opt)", "ans", "mod = 10 ** 9 + 7", "10 ** 9 + 7", "mod", "opt += (A[k] - i) ** 2", "(A[k] - i) ** 2", "opt", "def getList():\n return list(map(int, input().split()))", "def getList():\n return list(map(int, input().split()))", "getList", "N = getN()", "getN()", "N", "def getNM():\n return map(int, input().split())", "def getNM():\n return map(int, input().split())", "getNM", "opt = 0", "0", "opt", "A = getList()", "getList()", "A", "def getN():\n return int(input())", "def getN():\n return int(input())", "getN", "def input():\n return sys.stdin.readline().rstrip()", "def input():\n return sys.stdin.readline().rstrip()", "input", "ans = float('inf')", "float('inf')", "ans" ]
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 from sys import exit import heapq import math import fractions import copy from itertools import permutations from operator import mul from functools import reduce from bisect import bisect_left, bisect_right import sys sys.setrecursionlimit(1000000000) mod = 10 ** 9 + 7 N = getN() A = getList() ans = float('inf') for i in range(-100, 101): opt = 0 for k in range(N): opt += (A[k] - i) ** 2 ans = min(ans, opt) 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, 4, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13 ]
[ [ 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 ], [ 69, 48 ], [ 63, 48 ], [ 66, 51 ], [ 57, 51 ], [ 53, 54 ], [ 56, 57 ], [ 59, 60 ], [ 62, 63 ], [ 65, 66 ], [ 68, 69 ] ]
[ "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().split()))", "an", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = float('inf')", "ans", "float('inf')", "float", "'inf'", "for i in range(-100, 101):\n check = 0\n for a in an:\n check += (a-i)**2\n ans = min(ans, check)", "i", "range(-100, 101)", "range", "-100", "101", "check = 0", "check", "0", "for a in an:\n check += (a-i)**2\n ", "a", "an", "check += (a-i)**2", "check", "(a-i)**2", "a-i", "a", "i", "2", "ans = min(ans, check)", "ans", "min(ans, check)", "min", "ans", "check", "print(ans)", "print", "ans", "an = list(map(int, input().split()))", "list(map(int, input().split()))", "an", "ans = float('inf')", "float('inf')", "ans", "n = int(input())", "int(input())", "n", "check = 0", "0", "check", "ans = min(ans, check)", "min(ans, check)", "ans", "check += (a-i)**2", "(a-i)**2", "check" ]
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, 2, 18, 13, 13, 13, 17, 0, 13, 2, 13, 2, 2, 18, 13, 13, 13, 17, 4, 13, 4, 13, 13, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13, 10, 17, 13, 10, 2, 13 ]
[ [ 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 ], [ 44, 59 ], [ 87, 60 ], [ 89, 63 ], [ 93, 65 ], [ 90, 65 ], [ 81, 69 ], [ 44, 70 ], [ 84, 71 ], [ 99, 77 ], [ 96, 77 ], [ 90, 78 ], [ 93, 78 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 92, 93 ], [ 95, 96 ], [ 98, 99 ] ]
[ "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 math", "math", "int(input())", "int", "input()", "input", "s = list(map(int, input().split()))", "s", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "md = math.floor(st.mean(s))", "md", "math.floor(st.mean(s))", "math.floor", "math", "floor", "st.mean(s)", "st.mean", "st", "mean", "s", "mu = md + 1", "mu", "md + 1", "md", "1", "sd = 0", "sd", "0", "su = 0", "su", "0", "for i in range(0, len(s)):\n sd = sd + (s[i] - md) ** 2\n su = su + (s[i] - mu) ** 2", "i", "range(0, len(s))", "range", "0", "len(s)", "len", "s", "sd = sd + (s[i] - md) ** 2", "sd", "sd + (s[i] - md) ** 2", "sd", "(s[i] - md) ** 2", "s[i] - md", "s[i]", "s", "i", "md", "2", "su = su + (s[i] - mu) ** 2", "su", "su + (s[i] - mu) ** 2", "su", "(s[i] - mu) ** 2", "s[i] - mu", "s[i]", "s", "i", "mu", "2", "print(min(sd, su))", "print", "min(sd, su)", "min", "sd", "su", "s = list(map(int, input().split()))", "list(map(int, input().split()))", "s", "mu = md + 1", "md + 1", "mu", "md = math.floor(st.mean(s))", "math.floor(st.mean(s))", "md", "su = su + (s[i] - mu) ** 2", "su + (s[i] - mu) ** 2", "su", "su = 0", "0", "su", "sd = 0", "0", "sd", "sd = sd + (s[i] - md) ** 2", "sd + (s[i] - md) ** 2", "sd" ]
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, 4, 13, 13, 14, 2, 13, 17, 4, 13, 10, 12, 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 ], [ 22, 52 ], [ 54, 52 ], [ 55, 54 ], [ 41, 55 ], [ 33, 55 ], [ 54, 58 ], [ 22, 58 ], [ 67, 64 ] ]
[ "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__ == \"__main__\":\n main()", "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)", "main", "n = int(input())", "n", "int(input())", "int", "input()", "input", "inlis = list(map(int, input().split()))", "inlis", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ans = 10 ** 10", "ans", "10 ** 10", "10", "10", "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 ", "kouho1", "range(-100,101)", "range", "-100", "101", "tmp1 = 0", "tmp1", "0", "for i in range(n):\n tmp1 += (inlis[i]- kouho1) ** 2\n ", "i", "range(n)", "range", "n", "tmp1 += (inlis[i]- kouho1) ** 2", "tmp1", "(inlis[i]- kouho1) ** 2", "inlis[i]- kouho1", "inlis[i]", "inlis", "i", "kouho1", "2", "if tmp1 < ans:\n ans = tmp1\n ", "tmp1 < ans", "tmp1", "ans", "ans = tmp1", "ans", "tmp1", "print(ans)", "print", "ans", "if __name__ == \"__main__\":\n main()", "__name__ == \"__main__\"", "__name__", "\"__main__\"", "main()", "main", "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)", "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)", "main" ]
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, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 10, 13, 13, 10, 2, 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 ], [ 74, 52 ], [ 65, 52 ], [ 68, 53 ], [ 62, 53 ], [ 65, 56 ], [ 74, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ], [ 67, 68 ], [ 70, 71 ], [ 73, 74 ] ]
[ "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 in input().split()", "i", "input().split()", "().split", "()", "input", "split", "for i in input().split()", "int(i)", "int", "i", "A = [int(i) for i in input().split()]", "A", "[int(i) for i in input().split()]", "ans = 200**2 * 100", "ans", "200**2 * 100", "200**2", "200", "2", "100", "for y in range(-100, 101):\n a = 0\n for x in A:\n a += (x-y)**2\n ans = min(ans, a)", "y", "range(-100, 101)", "range", "-100", "101", "a = 0", "a", "0", "for x in A:\n a += (x-y)**2\n ", "x", "A", "a += (x-y)**2", "a", "(x-y)**2", "x-y", "x", "y", "2", "ans = min(ans, a)", "ans", "min(ans, a)", "min", "ans", "a", "print(ans)", "print", "ans", "N = int(input())", "int(input())", "N", "a = 0", "0", "a", "ans = min(ans, a)", "min(ans, a)", "ans", "a += (x-y)**2", "(x-y)**2", "a", "A = [int(i) for i in input().split()]", "[int(i) for i in input().split()]", "A", "ans = 200**2 * 100", "200**2 * 100", "ans" ]
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, 13, 0, 13, 2, 2, 13, 13, 17, 4, 13, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13, 10, 2, 13, 10, 17, 13, 10, 4, 13, 10, 13, 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 ], [ 93, 40 ], [ 81, 40 ], [ 75, 40 ], [ 68, 43 ], [ 93, 47 ], [ 81, 47 ], [ 75, 47 ], [ 71, 50 ], [ 93, 53 ], [ 81, 53 ], [ 75, 53 ], [ 56, 55 ], [ 78, 55 ], [ 83, 58 ], [ 55, 61 ], [ 72, 62 ], [ 69, 62 ], [ 93, 62 ], [ 81, 62 ], [ 75, 62 ], [ 84, 66 ], [ 87, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 26, 80 ], [ 80, 81 ], [ 83, 84 ], [ 86, 87 ], [ 89, 90 ], [ 90, 92 ], [ 92, 93 ] ]
[ "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().split()))", "lis", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ave=0", "ave", "0", "ans=0", "ans", "0", "for i in lis:\n ave+=i", "i", "lis", "ave+=i", "ave", "i", "ave/=n", "ave", "n", "if ave>=int(ave)+0.5:\n ave=int(ave)+1\nelse:\n ave=int(ave)", "ave>=int(ave)+0.5", "ave", "int(ave)+0.5", "int(ave)", "int", "ave", "0.5", "ave=int(ave)+1", "ave", "int(ave)+1", "int(ave)", "int", "ave", "1", "ave=int(ave)", "ave", "int(ave)", "int", "ave", "for i in lis:\n ans+=(i-ave)**2", "i", "lis", "ans+=(i-ave)**2", "ans", "(i-ave)**2", "i-ave", "i", "ave", "2", "print(ans)", "print", "ans", "ave=int(ave)+1", "int(ave)+1", "ave", "ave=int(ave)", "int(ave)", "ave", "ave=0", "0", "ave", "lis=list(map(int,input().split()))", "list(map(int,input().split()))", "lis", "ave+=i", "i", "ave", "ans+=(i-ave)**2", "(i-ave)**2", "ans", "ans=0", "0", "ans", "n=int(input())", "int(input())", "n", "ave/=n", "n", "ave" ]
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, 2, 13, 13, 17, 4, 18, 13, 13, 13, 0, 13, 4, 18, 13, 13, 13, 4, 13, 13, 10, 2, 13, 10, 4, 13, 10, 39, 13, 10, 17, 13, 10, 13, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13 ]
[ [ 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 ], [ 52, 51 ], [ 89, 51 ], [ 76, 54 ], [ 51, 57 ], [ 40, 58 ], [ 83, 62 ], [ 77, 64 ], [ 86, 64 ], [ 94, 66 ], [ 83, 71 ], [ 95, 74 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ], [ 88, 89 ], [ 91, 92 ], [ 94, 95 ], [ 97, 98 ] ]
[ "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", "numpy", "n=input()", "n", "input()", "input", "int(x) for x in input().split()", "for x in input().split()", "x", "input().split()", "().split", "()", "input", "split", "for x in input().split()", "int(x)", "int", "x", "a=[int(x) for x in input().split()]", "a", "[int(x) for x in input().split()]", "a_min=np.min(a)", "a_min", "np.min(a)", "np.min", "np", "min", "a", "a_max=np.max(a)", "a_max", "np.max(a)", "np.max", "np", "max", "a", "cost_list=[]", "cost_list", "[]", "for 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 ", "i", "range(a_min, a_max+1)", "range", "a_min", "a_max+1", "a_max", "1", "cost=0", "cost", "0", "for val in a:\n cost+=(val-i)**2\n \n ", "val", "a", "cost+=(val-i)**2", "cost", "(val-i)**2", "val-i", "val", "i", "2", "cost_list.append(cost)", "cost_list.append", "cost_list", "append", "cost", "min_cost=np.min(cost_list)", "min_cost", "np.min(cost_list)", "np.min", "np", "min", "cost_list", "print(min_cost)", "print", "min_cost", "cost+=(val-i)**2", "(val-i)**2", "cost", "n=input()", "input()", "n", "cost_list=[]", "[]", "cost_list", "cost=0", "0", "cost", "a=[int(x) for x in input().split()]", "[int(x) for x in input().split()]", "a", "a_min=np.min(a)", "np.min(a)", "a_min", "min_cost=np.min(cost_list)", "np.min(cost_list)", "min_cost", "a_max=np.max(a)", "np.max(a)", "a_max" ]
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", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "print(min(sum(map(lambda x: (x - i) * (x - i), a)) for i in range(-100, 101)))", "print", "min(sum(map(lambda x: (x - i) * (x - i), a)) for i in range(-100, 101))", "min", "sum(map(lambda x: (x - i) * (x - i), a))", "sum", "map(lambda x: (x - i) * (x - i), a)", "map", "lambda x: (x - i) * (x - i)", "(x - i) * (x - i)", "x - i", "x", "i", "x - i", "x", "i", "x", "a", "n = int(input())", "int(input())", "n", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a" ]
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, 18, 13, 13, 13, 17, 4, 18, 13, 13, 13, 4, 13, 4, 13, 13, 10, 39, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13, 10, 17, 13 ]
[ [ 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 ], [ 79, 53 ], [ 82, 57 ], [ 44, 58 ], [ 27, 59 ], [ 73, 63 ], [ 79, 65 ], [ 85, 65 ], [ 73, 70 ], [ 72, 73 ], [ 75, 76 ], [ 78, 79 ], [ 81, 82 ], [ 84, 85 ] ]
[ "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, input().split()))", "a", "list(map(int, input().split()))", "list", "map(int, input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "a.sort()", "a.sort", "a", "sort", "b = []", "b", "[]", "for 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)", "i", "range(a[0], a[n-1]+1)", "range", "a[0]", "a", "0", "a[n-1]+1", "a[n-1]", "a", "n-1", "n", "1", "1", "ans = 0", "ans", "0", "for j in range(len(a)) :\n\t\tans = ans + (a[j]-i)**2\n\t", "j", "range(len(a))", "range", "len(a)", "len", "a", "ans = ans + (a[j]-i)**2", "ans", "ans + (a[j]-i)**2", "ans", "(a[j]-i)**2", "a[j]-i", "a[j]", "a", "j", "i", "2", "b.append(ans)", "b.append", "b", "append", "ans", "print(min(b))", "print", "min(b)", "min", "b", "b = []", "[]", "b", "n = int(input())", "int(input())", "n", "ans = ans + (a[j]-i)**2", "ans + (a[j]-i)**2", "ans", "a = list(map(int, input().split()))", "list(map(int, input().split()))", "a", "ans = 0", "0", "ans" ]
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, 13, 13, 17, 4, 13, 4, 13, 13, 10, 4, 13, 10, 17, 13, 10, 4, 13, 10, 2, 13, 10, 2, 13, 10, 17, 13, 10, 4, 13 ]
[ [ 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 ], [ 48, 56 ], [ 81, 57 ], [ 84, 57 ], [ 75, 57 ], [ 78, 63 ], [ 69, 63 ], [ 65, 66 ], [ 68, 69 ], [ 71, 72 ], [ 74, 75 ], [ 77, 78 ], [ 80, 81 ], [ 83, 84 ] ]
[ "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().split()))", "lst", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "ave=sum(lst)/n", "ave", "sum(lst)/n", "sum(lst)", "sum", "lst", "n", "if ave%1>=0.5:\n import math\n ave=math.ceil(ave)\nelse:\n ave//=1", "ave%1>=0.5", "ave%1", "ave", "1", "0.5", "import math", "math", "ave=math.ceil(ave)", "ave", "math.ceil(ave)", "math.ceil", "math", "ceil", "ave", "ave//=1", "ave", "1", "ans=0", "ans", "0", "for i in lst:\n ans+=(abs(i-ave))**2", "i", "lst", "ans+=(abs(i-ave))**2", "ans", "(abs(i-ave))**2", "abs(i-ave)", "abs", "i-ave", "i", "ave", "2", "print(int(ans))", "print", "int(ans)", "int", "ans", "n=int(input())", "int(input())", "n", "ans=0", "0", "ans", "lst=list(map(int,input().split()))", "list(map(int,input().split()))", "lst", "ave=sum(lst)/n", "sum(lst)/n", "ave", "ans+=(abs(i-ave))**2", "(abs(i-ave))**2", "ans", "ave//=1", "1", "ave", "ave=math.ceil(ave)", "math.ceil(ave)", "ave" ]
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, 13, 4, 13, 2, 13, 17, 13, 0, 13, 4, 13, 13, 13, 4, 13, 13, 10, 4, 13, 10, 12, 13, 10, 4, 13, 10, 4, 13, 10, 4, 13, 10, 2, 13, 10, 4, 13 ]
[ [ 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 ], [ 46, 46 ], [ 48, 48 ], [ 91, 50 ], [ 77, 52 ], [ 89, 53 ], [ 83, 54 ], [ 85, 56 ], [ 77, 58 ], [ 89, 60 ], [ 83, 62 ], [ 79, 64 ], [ 92, 67 ], [ 86, 68 ], [ 80, 71 ], [ 73, 74 ], [ 79, 80 ], [ 82, 83 ], [ 85, 86 ], [ 88, 89 ], [ 91, 92 ] ]
[ "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(input())", "int", "input()", "input", "A = list(map(int,input().split()))", "A", "list(map(int,input().split()))", "list", "map(int,input().split())", "map", "int", "input().split()", "().split", "()", "input", "split", "mean = sum(A)//len(A)", "mean", "sum(A)//len(A)", "sum(A)", "sum", "A", "len(A)", "len", "A", "def std_div(mean, A):\n total = 0\n for x in A:\n total += (mean-x)**2\n return total", "std_div", "total = 0", "total", "0", "for x in A:\n total += (mean-x)**2\n ", "x", "A", "total += (mean-x)**2", "total", "(mean-x)**2", "mean-x", "mean", "x", "2", "return total", "total", "mean", "mean", "A", "A", "min1 = std_div(mean,A)", "min1", "std_div(mean,A)", "std_div", "mean", "A", "min2 = std_div(mean+1,A)", "min2", "std_div(mean+1,A)", "std_div", "mean+1", "mean", "1", "A", "ans = min(min1,min2)", "ans", "min(min1,min2)", "min", "min1", "min2", "print(ans)", "print", "ans", "N = int(input())", "int(input())", "N", "def std_div(mean, A):\n total = 0\n for x in A:\n total += (mean-x)**2\n return total", "def std_div(mean, A):\n total = 0\n for x in A:\n total += (mean-x)**2\n return total", "std_div", "ans = min(min1,min2)", "min(min1,min2)", "ans", "A = list(map(int,input().split()))", "list(map(int,input().split()))", "A", "min2 = std_div(mean+1,A)", "std_div(mean+1,A)", "min2", "mean = sum(A)//len(A)", "sum(A)//len(A)", "mean", "min1 = std_div(mean,A)", "std_div(mean,A)", "min1" ]
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, 13, 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, 4, 13, 13, 29, 14, 2, 13, 17, 4, 13, 10, 12, 13, 10, 17, 13, 10, 18, 13, 10, 18, 13, 10, 2, 13, 10, 18, 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 ], [ 70, 69 ], [ 57, 72 ], [ 66, 73 ], [ 54, 77 ], [ 80, 77 ], [ 69, 78 ], [ 63, 78 ], [ 81, 80 ], [ 69, 81 ], [ 63, 81 ], [ 80, 84 ], [ 54, 84 ], [ 94, 91 ], [ 96, 97 ], [ 99, 100 ], [ 102, 103 ], [ 105, 106 ], [ 108, 109 ] ]
[ "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 tmp += (x - a) ** 2\n if ans > tmp:\n ans = tmp\n\n print(ans)\n return\n\n\nif __name__ == '__main__':\n main()", "import sys", "sys", "read = sys.stdin.read", "read", "sys.stdin.read", "sys.stdin", "sys", "stdin", "read", "readline = sys.stdin.readline", "readline", "sys.stdin.readline", "sys.stdin", "sys", "stdin", "readline", "readlines = sys.stdin.readlines", "readlines", "sys.stdin.readlines", "sys.stdin", "sys", "stdin", "readlines", "sys.setrecursionlimit(10 ** 9)", "sys.setrecursionlimit", "sys", "setrecursionlimit", "10 ** 9", "10", "9", "INF = 1 << 60", "INF", "1 << 60", "1", "60", "MOD = 1000000007", "MOD", "1000000007", "def 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 tmp += (x - a) ** 2\n if ans > tmp:\n ans = tmp\n\n print(ans)\n return", "main", "N, *A = map(int, read().split())", "N", "map(int, read().split())", "map", "int", "read().split()", "().split", "()", "read", "split", "*A", "A", "ans = INF", "ans", "INF", "for x in range(-100, 101):\n tmp = 0\n for a in A:\n tmp += (x - a) ** 2\n if ans > tmp:\n ans = tmp\n\n ", "x", "range(-100, 101)", "range", "-100", "101", "tmp = 0", "tmp", "0", "for a in A:\n tmp += (x - a) ** 2\n ", "a", "A", "tmp += (x - a) ** 2", "tmp", "(x - a) ** 2", "x - a", "x", "a", "2", "if ans > tmp:\n ans = tmp\n\n ", "ans > tmp", "ans", "tmp", "ans = tmp", "ans", "tmp", "print(ans)", "print", "ans", "return", "if __name__ == '__main__':\n main()", "__name__ == '__main__'", "__name__", "'__main__'", "main()", "main", "def 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 tmp += (x - a) ** 2\n if ans > tmp:\n ans = tmp\n\n print(ans)\n return", "def 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 tmp += (x - a) ** 2\n if ans > tmp:\n ans = tmp\n\n print(ans)\n return", "main", "MOD = 1000000007", "1000000007", "MOD", "readline = sys.stdin.readline", "sys.stdin.readline", "readline", "readlines = sys.stdin.readlines", "sys.stdin.readlines", "readlines", "INF = 1 << 60", "1 << 60", "INF", "read = sys.stdin.read", "sys.stdin.read", "read" ]
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) ** 2 if ans > tmp: ans = tmp print(ans) return 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, 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, 13, 10, 4, 13, 10, 4, 13, 10, 13, 13 ]
[ [ 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 ], [ 59, 53 ], [ 62, 53 ], [ 55, 56 ], [ 58, 59 ], [ 61, 62 ], [ 64, 65 ] ]
[ "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()", "i", "input().split()", "().split", "()", "input", "split", "for i in input().split()", "int(i)", "int", "i", "a = [int(i) for i in input().split()]", "a", "[int(i) for i in input().split()]", "ans = float(\"inf\")", "ans", "float(\"inf\")", "float", "\"inf\"", "for i in range(-100, 101):\n ans = min(sum([(n - i)** 2 for n in a]), ans)", "i", "range(-100, 101)", "range", "-100", "101", "(n - i)** 2 for n in a", "for n in a", "n", "a", "for n in a", "(n - i)** 2", "n - i", "n", "i", "2", "ans = min(sum([(n - i)** 2 for n in a]), ans)", "ans", "min(sum([(n - i)** 2 for n in a]), ans)", "min", "sum([(n - i)** 2 for n in a])", "sum", "[(n - i)** 2 for n in a]", "ans", "print(ans)", "print", "ans", "N = int(input())", "int(input())", "N", "ans = min(sum([(n - i)** 2 for n in a]), ans)", "min(sum([(n - i)** 2 for n in a]), ans)", "ans", "ans = float(\"inf\")", "float(\"inf\")", "ans", "a = [int(i) for i in input().split()]", "[int(i) for i in input().split()]", "a" ]
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, 13, 4, 13, 13, 10, 17, 13, 10, 4, 13, 10, 13, 13, 10, 13, 13, 10, 2, 13, 10, 4, 13, 10, 2, 13, 10, 17, 13 ]
[ [ 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 ], [ 83, 42 ], [ 47, 46 ], [ 65, 46 ], [ 73, 49 ], [ 46, 52 ], [ 80, 53 ], [ 71, 53 ], [ 68, 53 ], [ 83, 53 ], [ 74, 59 ], [ 62, 59 ], [ 61, 62 ], [ 64, 65 ], [ 30, 67 ], [ 67, 68 ], [ 77, 70 ], [ 70, 71 ], [ 73, 74 ], [ 76, 77 ], [ 79, 80 ], [ 82, 83 ] ]
[ "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().rstrip().split(\" \")))", "A", "list(map(int,input().rstrip().split(\" \")))", "list", "map(int,input().rstrip().split(\" \"))", "map", "int", "input().rstrip().split(\" \")", "().rstrip().split", "().rstrip()", "().rstrip", "()", "input", "rstrip", "split", "\" \"", "ave = 0", "ave", "0", "ans = 0", "ans", "0", "for i in A:\n ave += i", "i", "A", "ave += i", "ave", "i", "ave /= N", "ave", "N", "ave = (ave + 0.5) // 1", "ave", "(ave + 0.5) // 1", "ave + 0.5", "ave", "0.5", "1", "for i in A:\n ans += (i - ave) ** 2", "i", "A", "ans += (i - ave) ** 2", "ans", "(i - ave) ** 2", "i - ave", "i", "ave", "2", "print(int(ans))", "print", "int(ans)", "int", "ans", "ans = 0", "0", "ans", "A = list(map(int,input().rstrip().split(\" \")))", "list(map(int,input().rstrip().split(\" \")))", "A", "ave += i", "i", "ave", "ave /= N", "N", "ave", "ans += (i - ave) ** 2", "(i - ave) ** 2", "ans", "N = int(input())", "int(input())", "N", "ave = (ave + 0.5) // 1", "(ave + 0.5) // 1", "ave", "ave = 0", "0", "ave" ]
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))