TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
import math
from statistics import mean, median,variance,stdev
N = int(input())
X = list(map(int,input().split()))
a = sum(X)
ave = round(a/N)
b = 0
for i in range(N):
    b +=(X[i]-20)**2
print(b)

import numpy as np

N = int(input())
X = list(map(int,input().split()))

a = mean(X)
print(a)
b = 0
for i in range(N):
    b +=(X[i]-a)**2
print(b)

N = int(input())
X = list(map(int,input().split()))
ans = 10**8
c = int()
for i in range(1,100):
    c = 0
    for j in range(len(X)):
        c += (X[j]-i)**2
    if c < ans:
        ans = c
print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n = int(input())
list = list(map(int, input().split()))

sum = 0
for i in list:
  sum += i
average = sum // len(list)
print(average)

ans = 0
for i in list:
  ans += (i-average-1)*(i-average-1)
print(ans)

n = int(input())
list = list(map(int, input().split()))

sum = 0
for i in list:
  sum += i
average = sum // len(list)


ans1 = 0
ans2 = 0
ans3 = 0
ans4 = 0
ans5 = 0
for i in list:
  ans1 += (i-average+1)*(i-average+2)
  ans2 += (i-average+1)*(i-average+1)
  ans3 += (i-average)*(i-average)
  ans4 += (i-average-1)*(i-average-1)
  ans5 += (i-average-2)*(i-average-2)
answer = min(ans1,min(ans2,min(ans3,min(ans4,ans5))))
print(answer)

Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):

n = int(input())
x = list(map(int,input().split()))
x.sort()
cnt = 0
min = 0

for i in range(x[0], x[-1] + 1):
    for j in range(n):
        cnt += (x[j] - i) ** 2

    if i == x[0]:
        minimum = cnt

    minimum = min([minimum, cnt])
    cnt = 0

print(minimum)


n = int(input())
x = list(map(int, input().split()))

x.sort()
cnt = 0
minimum = 0
for i in range(x[0], x[-1] + 1):
    for j in range(n):
        cnt += (x[j] - i) ** 2

    if i == x[0]:
        minimum = cnt

    minimum = min([minimum, cnt])
    cnt = 0

print(minimum)

Verdicts: Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n=int(input())
x=list(map(int,input().split()))
a=sum(x)//n
ans=0
anss=0
for i in x:
  ans=ans+(i-a)**2
a=a+1
for i in x:
  anss=anss+(i-a)**2
if anss < ans:
  ans=anss
print(ans,a)

n=int(input())
x=list(map(int,input().split()))
a=sum(x)//n
ans=0
anss=0
for i in x:
  ans=ans+(i-a)**2
a=a+1
for i in x:
  anss=anss+(i-a)**2
if anss < ans:
  ans=anss
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
minHP = float('inf')
for i in range(n):
    HP = 0
    for j in range(100):
        HP += (a[j] - (i + 1)) ** 2
    if minHP > HP:
        minHP = HP
print(minHP)

n = int(input())
a = list(map(int,input().split()))
minHP = float('inf')
for i in range(n):
    HP = 0
    for j in range(max(a)):
        HP += (a[j] - (i + 1)) ** 2
    if minHP > HP:
        minHP = HP
print(minHP)

n = int(input())
a = list(map(int,input().split()))
minHP = float('inf')
for i in range(max(a)):
    HP = 0
    for j in range(n):
        HP += (a[j] - (i + 1)) ** 2
    if minHP > HP:
        minHP = HP
print(minHP)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n = int(input())
x = [int(i) for i in input().split()]
l, r = 0, 0
for i in x:
    l = min(l, i)
    r = max(l, i)
ans = 10e9
for i in range(l, r + 1):
    cost = 0
    for j in range(n):
        cost += (x[j] - i) * (x[j] - i)
        print(i, j)
    ans = min(ans, cost)
print(ans)


n = int(input())
x = [int(i) for i in input().split()]
l, r = x[0], x[0]
for i in x:
    l = min(l, i)
    r = max(r, i)
ans = 10e9
for i in range(l, r + 1):
    cost = 0
    for j in range(n):
        cost += (x[j] - i) ** 2
    ans = min(ans, cost)
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N=int(input())
X=list(map(int,input().split()))
P=round(sum(X)/N) 
print(sum((x-P)**2 for x in X))　


N=int(input())
X=list(map(int,input().split()))
P=round(sum(X)/N)

print(sum((x-P)**2 for x in X))



Verdicts: Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
import math

N = int(input())
Xi = list(map(int, input().split(" ")))

Xi_min = min(Xi)
Xi_max = max(Xi)

ans = math.inf
print("-----")
for i in range(Xi_min, Xi_max+1):
    tmp = 0
    for j in range(N):
        tmp += pow(Xi[j] - i, 2)
    if tmp < ans:
        ans = tmp

print(ans)

import math

N = int(input())
Xi = list(map(int, input().split(" ")))

Xi_min = min(Xi)
Xi_max = max(Xi)

ans = 999999999
for i in range(Xi_min, Xi_max+1):
    tmp = 0
    for j in range(N):
        tmp += pow(Xi[j] - i, 2)
    if tmp < ans:
        ans = tmp

print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N = int(input())
X = sorted(list(map(int, readline().split())))
ans = 10**9+7
for p in range(0, 102):
    res = 0
    for x in X:
        res += (p-x)**2 
    ans = min(ans, res)
print(ans)

n = int(input())
(*x,) = map(int, input().split())
a = round(sum(x) / n)
print(sum(((i - a) ** 2) for i in x))

Verdicts: Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n = int(input())
ls = list(map(int,input().split()))

ls = sorted(ls)

ans = 10000000000000
x = 0
for i in range(ls[0],ls[-1]+1):
  tmp = 0
  for a in ls:
    tmp += (a-i)**2
  if ans > tmp:
    x = i
    ans = tmp
print(x)


n = int(input())
ls = list(map(int,input().split()))

ls = sorted(ls)

ans = 10000000000000
x = 0
for i in range(ls[0],ls[-1]+1):
  tmp = 0
  for a in ls:
    tmp += (a-i)**2
  if ans > tmp:
    x = i
    ans = tmp
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
a=int(input())
b=list(map(int,input().split()))
c=(sum(b)//a)**2
print(c)

import math
a=int(input())
b=list(map(int,input().split()))
n=round(sum(b)/a)
ans=0
for i in b:
    ans+=(n-i)**2

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N = int(input())
a = list(map(int,input().split()))
s = []
for i in range(1,101):
    b = sum((a[j]-i-1)**2 for j in range(N))
    s.append(b) 
print(min(b))


N = int(input())
a = list(map(int,input().split()))
s = []
for i in range(1,N+1):
    b = sum((a[j]-i)**2 for j in range(0,N))
    s.append(s)
print(min(s))


N = int(input())
a = list(map(int,input().split()))
s = []
for i in range(1,101):
    b = sum((a[j]-i)**2 for j in range(N))
    s.append(b) 
print(min(s))


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
import numpy as np
MOD = 10**9+7

N,a,b = map(int,input().split())

N = int(input())
A = np.array(list(map(int,input().split())), dtype = 'int64')
a1 = np.min(A)
a2 = np.max(A)

ans = 1000000
for p in range(a1,a2+1):
    B = (A-p)**2
    s = np.sum(B)
    if s < ans:
        ans = s

print(ans)

import numpy as np

N = int(input())
A = np.array(list(map(int,input().split())), dtype = 'int64')
a1 = np.min(A)
a2 = np.max(A)

ans = 1000000
for p in range(a1,a2+1):
    B = (A-p)**2
    s = np.sum(B)
    if s < ans:
        ans = s

print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N = int(input())
X = list(map(int, input().split()))

min = 0
result = 0
for i in range(N):
    for j in X:
        print(j)
        result += (i + 1 - j) ** 2
    if min > result:
        min = result
    if min == 0:
        min = result
    result = 0

print(min)

min = 0
result = 100000000
for i in range(100):
    for j in X:
        result += (i + 1 - j) ** 2
    if min > result:
        min = result
    result = 0

print(min)

N = int(input())
X = list(map(int, input().split()))

min = 1000000
result = 0
for i in range(100):
    for j in X:
        result += (i + 1 - j) ** 2
    if min > result:
        min = result
    result = 0

print(min)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
import sys
lines = sys.stdin.readlines()

N, X = lines.strip("\n")
X = X.strip(" ")

res = float('inf')
for i in Range(1, 101):
  cur_res = 0
  for j in X:
    cur_res = cur_res + (j-i)^2
  if cur_res < res:
    res = cur_res

print(cur_res)

import sys
lines = sys.stdin.readlines()
 
N, X = lines.strip("\n")
X = map(int, X.strip(" "))
 
res = float('inf')
for i in Range(1, 101):
  cur_res = 0
  for j in X:
    cur_res = cur_res + (j-i)^2
  if cur_res < res:
    res = cur_res
 
print(cur_res)

import sys
Row=int(input())
 

X = map(int, input().strip())
 
res = float('inf')
for i in range(1, 101):
  cur_res = 0
  for j in X:
    cur_res = cur_res + (j-i)^2
  if cur_res < res:
    res = cur_res
 
print(res)


import sys
lines = sys.stdin.readlines()
 
N, X = lines.strip("\n")
X = map(int, X.strip())
 
res = float('inf')
for i in range(1, 101):
  cur_res = 0
  for j in X:
    cur_res = cur_res + (j-i)^2
  if cur_res < res:
    res = cur_res
 
print(res)

import sys
lines = sys.stdin.readlines()
 
N, X = lines.strip("\n")
X = map(int, X.strip(" "))
 
res = float('inf')
for i in range(1, 101):
  cur_res = 0
  for j in X:
    cur_res = cur_res + (j-i)^2
  if cur_res < res:
    res = cur_res
 
print(res)

N=int(input())
Xs = list(map(int, input().split()))

res=0
for i in Xs:
    res = res + (i-round(sum(Xs)/N))**2

print(res)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n = int(input())
x_lis = list(map(int, input().split()))
ans = 0
avg = sum(x_lis)/n
if avg - int(avg) >= 0.5:
    avg = int(avg) + 1
else:
    avg = int(avg)
print(avg)
for x in x_lis:
    ans += (x - avg)**2
print(ans)

n = int(input())
x_lis = list(map(int, input().split()))
ans = 0
avg = sum(x_lis)/n
if avg - int(avg) >= 0.5:
    avg = int(avg) + 1
else:
    avg = int(avg)
print(avg)
for x in x_lis:
    ans += (x - avg)**2
print(ans)

n = int(input())
x_lis = list(map(int, input().split()))
ans = 0
avg = sum(x_lis)/n
if avg - int(avg) >= 0.5:
    avg = int(avg) + 1
else:
    avg = int(avg)
for x in x_lis:
    ans += (x - avg)**2
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N = int(input())
X = [int(x) for x in input().split()]
allpoint = []
for j in range(1, X[-1]+1):
    total = 0
    print(j)
    for i in X:
        total += (i - j)**2
    allpoint.append(total)
print(min(allpoint))


N = int(input())
X = [int(x) for x in input().split()]
p = round(sum(X)/N)
total = 0
for i in X:
    total += (i - p)**2
print(total)

Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
input()
print(min(sum((x-p)**2 for x in map(int, input().split())) for p in range(101)))


N = int(input())
X = list(map(int, input().split()))
print(min(lambda p: sum((x-p)**2 for x in X) for i in range(max(X)+1)))


N = int(input())
X = list(map(int, input().split()))
print(min(sum((x-p)**2 for x in X) for p in range(max(X)+1)))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n = int(input())
X = list(map(int, input().split()))

ans = []
for i in range(n+100):
    total = 0
    for j in range(n):
        print(i+1,X[j])
        diff = ((i+1)-X[j])**2
        total += diff
    ans.append(total)
print(min(ans))


n = int(input())
X = list(map(int, input().split()))

ans = []
for i in range(n+100):
    total = 0
    for j in range(n):
        diff = ((i+1)-X[j])**2
        total += diff
    ans.append(total)
print(min(ans))


Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n = int(input())

x = list(map(int,input().split()))

ans = float('inf')

for i in range(1,101):
  ans_temp = 0
  for j in x:
    ans_temp += (x-i)**2
  ans = min(ans,ans_temp)
print(ans)

n = int(input())

x = list(map(int,input().split()))

ans = float('inf')

for i in range(1,101):
  ans_temp = 0
  for j in x:
    ans_temp += (j-i)**2
  ans = min(ans,ans_temp)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n = int(input())
x = [int(input()) for i in range(n)]
e = sum(x)//len(x)
k = 0
for i in range(len(x)):
    k = k + (x[i] - e)*(x[i] - e)
print(k)

n = int(input())
x = [int(x) for x in input().split()]
e = round(sum(x)/len(x))
k = 0
for i in range(len(x)):
    k = k + (x[i] - e)*(x[i] - e)
print(k)

Verdicts: Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N = int(input())
X = list(map(int, input().split()))
X_sum = sum(X)

if X_sum % N == 0:
    div = round(X_sum / N)
    ans = 0
    for i in range(N):
        ans += (X[i] - div) ** 2
    print(ans)


N = int(input())
X = list(map(int, input().split()))
div = round(sum(X) / N)
ans = 0
for i in range(N):
    ans += (X[i] - div) ** 2
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
import numpy as np

def main(n, xs):
    minx = min(xs)
    maxx = max(xs)
    ress = []

    for x in range(minx, maxx+1):
        res = sum((xs - x) ** 2)
        ress.append(res)

    res = min(ress)
    return res

if __name__ == "__main__":
    cin = input()
    n = int(cin.split(" ")[0])
    cin = input()
    xs = np.array([], dtype="int")

    for i in range(n):
        xs = np.append(xs, int(cin.split(" ")[i]))
    print(xs)
    cout = main(n, xs)
    print(cout)

import numpy as np

def main(n, xs):
    minx = min(xs)
    maxx = max(xs)
    ress = []

    for x in range(minx, maxx+1):
        res = sum((xs - x) ** 2)
        ress.append(res)

    res = min(ress)
    return res

if __name__ == "__main__":
    cin = list(iter(input, ""))
    n = int(cin[0].split(" ")[0])
    xs = np.array(cin[1].split(" "))
    xs = xs.astype("int")
    cout = main(n, xs)
    print(cout)

import numpy as np

def main(n, xs):
    minx = min(xs)
    maxx = max(xs)
    ress = []

    for x in range(minx, maxx+1):
        res = sum((xs - x) ** 2)
        ress.append(res)

    res = min(ress)
    return res

if __name__ == "__main__":
    cin = iter(input, "")
    n = int(cin[0].split(" ")[0])
    xs = np.array(cin[1].split(" ")).astype("int")
    cout = main(n, xs)
    print(cout)

import numpy as np
import math as m

def main(**kwargs):
    minx = min(X)
    maxx = max(X)
    r = min([sum((X - x) ** 2) for x in range(minx, maxx+1)])
    return r

if __name__ == "__main__":
    cin = np.array(input().split(" ")).astype("int")
    n = cin[0]

    cin = np.array(input().split(" ")).astype("int")
    X = np.array(cin)
    
    cout = main(n=n, X=X)
    print(cout)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n = int(input())
za = list(map(int,input().split()))
print(za)
za_max = max(za)
za_min = min(za)
kouho = 0
kouho_sum = 0
ans = 9999999999999999999999999999999999999999999999999999999999999999999999999999
for zahyou in range(za_min,za_max+1):
    for i in za:
        kouho = (i - zahyou)*(i - zahyou)
        kouho_sum = kouho_sum + kouho
    if(ans > kouho_sum):
        ans = kouho_sum
        kouho_sum = 0
print(ans)

n = int(input())
za = list(map(int,input().split()))
za_max = max(za)
za_min = min(za)
kouho = 0
kouho_sum = 0
ans = 9999999999999999999999999999999999999999999999999999999999999999999999999999
for zahyou in range(za_min,za_max+1):
    for i in za:
        kouho = (i - zahyou)*(i - zahyou)
        kouho_sum = kouho_sum + kouho
    if(ans > kouho_sum):
        ans = kouho_sum
        kouho_sum = 0
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N = int(input())
X = list(map(int, input().split()))
X.sort()
ans = 999999999
for i in range(1,100):
    tmp = 0
    for j in X:
        tmp += (i-j)**2
    if tmp < ans:
        ans = tmp
        ans = i
print(ans)

N = int(input())
X = list(map(int, input().split()))
X.sort()
ans = 999999999
for i in range(1,100):
    tmp = 0
    for j in X:
        tmp += (i-j)**2
    if tmp < ans:
        ans = tmp
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
n=int(input())
i = list(map(int, input().split()))
ave=sum(i) / n
ans=0
as=Decimal(str(f)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
for k in range(n):
  ans+=(as-i[k])**2
print(ans)  

import numpy as np
n=int(input())
i = list(map(int, input().split()))
ia=np.array(i)
ave=np.mean(ia)
ans=0
for k in range(n):
  ans+=(round(ave, 0)-i[k])**2
print(int(ans))  

Verdicts: Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N=int(input())
X=list(map(int, input().spliet()))
k1=(max(X)+min(X))//2
k2=k1+1
ans1=0
ans2=0
for x in X:
  ans1+=(k1-x)**2
  ans2+=(k2-x)**2

print(min(ans1, ans2))

N=int(input())
X=list(map(int, input().split()))
g=sum(X)/N
if g-int(g)>=0.5:
  g=int(g)+1
else:
  g=int(g)   
ans=0
for x in X:
  ans+=(x-g)**2

print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n=int(input())
ls=input().split(' ')
mp=[]
for i in range(min(ls),max(ls)+1):
    hp=0
    for j in range(n):
        hp+=(i-int(ls[j]))**2
    mp.append(hp)
print(min(mp))

n=int(input())
ls=input().split(' ')
mp=[]
for i in range(int(min(ls)),int(max(ls))+1):
    hp=0
    for j in range(n):
        hp+=(i-int(ls[j]))**2
    mp.append(hp)
print(min(mp))

Verdicts: Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n = int(input())
temp = [int(s) for s in input().split()]
rarry = 0
min = 100000007
min_temp = 0
print(max(temp))
for n_ in range(max(temp) + 1):
    for i in temp:
        min_temp += ((i - n_) ** 2)
    #print(min_temp)
    if(min > min_temp):
        min = min_temp
    min_temp = 0


print("{}".format(str(min)))

n = int(input())
temp = [int(s) for s in input().split()]
rarry = 0
min = 100000007
min_temp = 0
#print(max(temp))
for n_ in range(max(temp) + 1):
    for i in temp:
        min_temp += ((i - n_) ** 2)
    #print(min_temp)
    if(min > min_temp):
        min = min_temp
    min_temp = 0


print("{}".format(str(min)))

Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n = int(input())
x = list(map(int,input().split()))
min_energy = 250000
for i range(100):
  energy = 0
  for k range(n):
    cons = (i+1-x[k])*(i+1-x[k])
    energy += cons
  if energy < min_energy:
    min_energy = energy
print(min_energy)

n = int(input())
p = list(map(int,input().split()))
min_energy = 250000
for i range(100):
  energy = 0
  for k range(n):
    energy += (i+1-p[k])(i+1-p[k])
  if energy < min_energy:
    min_energy = energy
print(min_energy)

n = int(input())
x = list(map(int,input().split()))
m_energy = 250000
for i range(0,101):
  m_energy = 0
  for k range(n):
    m_energy += (x[k]-1)**2
  if energy < m_energy:
    m_energy = energy
print(minenergy)

n = int(input())
x = list(map(int,input().split()))
min_energy = 250000
for i range(100):
  energy = 0
  for k range(n):
    energy += (i+1-x[k])*(i+1-x[k])
  if energy < min_energy:
    min_energy = energy
print(min_energy)

n = int(input())
x = list(map(int,input().split()))
min_energy = 250000
for i range(0,101):
  energy = 0
  for k range(n):
    energy += (x[k]-1)**2
  if energy < min_energy:
    min_energy = energy
print(min_energy)


n = int(input())
x = list(map(int,input().split()))
min_energy = 250000
for i range(100):
  energy = 0
  for k range(n):
    energy += (i+1-x[k])*(i+1-x[k])
  if energy < min_energy:
    min_energy = energy
print(min_energy)

n = int(input())
x = list(map(int,input().split()))
m_energy = 250000
for i in range(1,101):
  energy = 0
  for k in range(n):
    m_energy += (x[k]-1)**2
  if energy < m_energy:
    m_energy = energy
print(m_energy)

n = int(input())
x = list(map(int,input().split()))
m_energy = 250000
for i in range(1,101):
  energy = 0
  for k in range(n):
    m_energy += (x[k]-i)**2
  if energy < m_energy:
    m_energy = energy
print(m_energy)

n = int(input())
x = list(map(int,input().split()))
m_energy = 250000
for i in range(1,101):
  energy = 0
  for k in range(n):
    energy += (x[k]-i)**2
  if energy < m_energy:
    m_energy = energy
print(m_energy)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
"""Boot-camp-for-Beginners_002_C_Rally_19-August-2020.py"""
import numpy as np
import sys

N=int(input())
X = list(map(int,input().split()))
print(X)
s=0
for i in range(len(X)):
    s+=X[i]
P=s/N

Sum=0
for i in range(len(X)):
    Sum+=(P-X[i])**2
print(int(Sum)+1)

"""Boot-camp-for-Beginners_002_C_Rally_19-August-2020.py"""
import numpy as np
import sys

N=int(input())
X = list(map(int,input().split()))
print(X)
s=0
for i in range(len(X)):
    s+=X[i]
P=int(s/N)

Sum_round_down=0
Sum_round_up=0
for i in range(len(X)):
    Sum_round_down+=(P-X[i])**2
    Sum_round_up+=(P+1-X[i])**2
if(Sum_round_down>=Sum_round_up):
    Sum=Sum_round_up
else:
    Sum=Sum=Sum_round_down
print(int(Sum))

"""Boot-camp-for-Beginners_002_C_Rally_19-August-2020.py"""
import numpy as np
import sys

N=int(input())
X = list(map(int,input().split()))
s=0
for i in range(len(X)):
    s+=X[i]
P=int(s/N)

Sum_round_down=0
Sum_round_up=0
for i in range(len(X)):
    Sum_round_down+=(P-X[i])**2
    Sum_round_up+=(P+1-X[i])**2
if(Sum_round_down>=Sum_round_up):
    Sum=Sum_round_up
else:
    Sum=Sum=Sum_round_down
print(int(Sum))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N = input()
People = list(map(int, input().split()))
for P in range(1, max(People)):
    Distance = list(map(lambda x: (x-P)**2), People)
    Total_Distance = sum(Distance)
Total_Distance_List = list(Total_Distance)
print(min(Total_Distance_List))

N = int(input())
X = list(map(int, input().split()))
for p in range(1, max(X)):
    for x in X:
        x_sum=0
        x_sum+=(x-p)**2
    ans = min(ans, x_sum)
print(ans)

N = int(input())
X = list(map(int, input().split()))
for P in range(1, max(X)):
    Distance = list(map(lambda x: (x-P)**2), X)
    Total_Distance = sum(Distance)
Total_Distance_List = list(Total_Distance)
print(min(Total_Distance_List))

N = int(input())
X = list(map(int, input().split()))
ans = float("inf")
for p in range(1, max(X)+1):
    
    for x in X:
        x_sum=0
        x_sum+=(x-p)**2
    ans = min(ans, x_sum)
print(ans)

N = int(input())
X = list(map(int, input().split()))

for p in range(1, max(X)+1):
    x_sum=0
    for x in X:
        x_sum+=(x-p)**2
    ans = min(ans, x_sum)
print(ans)

N = int(input())
X = list(map(int, input().split()))
for p in range(1, max(X)):
    x_sum=0
    for x in X:
        x_sum+=(x-p)**2
    ans = min(ans, x_sum)
print(ans)

N = input()
X = list(map(int, input().split()))
for p in range(1, max(X)):
    for x in X:
        x_sum=0
        x_sum+=(x-p)**2
    ans = min(ans, x_sum)
print(ans)

N = int(input())
X = list(map(int, input().split()))
ans = float("inf")
for p in range(1, max(X)+1):
   
    for x in X:
        x_sum+=(x-p)**2
    ans = min(ans, x_sum)
print(ans)

N = int(input())
X = list(map(int, input().split()))
ans = float("inf")
for p in range(1, max(X)+1):
    x_sum=0
    for x in X:
        x_sum+=(x-p)**2
    ans = min(ans, x_sum)
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N = int(input())
total = 0 
X = list( input().split())
for i in X: 
    total +=  (X[i] - N) * (X[i] - N)
print(total)
  

N = int(input())
X = list(map(int, input().split()))
M = round(sum(X)/N)
ans = 0
for i in X:
    ans+=(i-M)**2
print(ans)


Verdicts: Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N=int(input())
X=list(map(int,input().split()))

P=sum(X)/N
L=0
for i in range(N):
    L += X[i]**2
print(int(L-2*P*sum(X)+N*P**2))

N=int(input())
X=list(map(int,input().split()))

P=sum(X)/N
if P%1 < 0.5:
    P=P//1
else:
    P=P//1+1
L=0
for i in range(N):
    L += X[i]**2
print(int(L-2*P*sum(X)+N*P**2))

Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N=int(input())

X=list(map(int, input().split()))

X.sort()
P=0
print(X)
min=10000000000
while P <= X[-1]:
    power=0
    for j in range(len(X)):
        power=power+(X[j]-P)**2

    if power<=min:
        min=power

    P=P+1


print(min)

    N=int(input())
     
    X=list(map(int, input().split()))
     
    X.sort()
    i=X[0]
    min=10000000000
    while i <= X[-1]:
        power=0
        for j in range(len(X)):
            power=power+(X[j]-i)**2
     
        if power<=min:
            min=power
     
        i=i+1
     
     
    print(min)

N=int(input())

X=list(map(int, input().split()))

X.sort()
i=X[0]
print(X)
min=10000000000
while i <= X[-1]:
    power=0
    for j in range(len(X)):
        power=power+(X[j]-i)**2

    if power<=min:
        min=power

    i=i+1


print(min)

N=int(input())

X=list(map(int, input().split()))

X.sort()

min=10000000000
for P in range(100):

    power=0
    for j in range(len(X)):
        power=power+(X[j]-P)**2

    if power<=min:
        min=power

    P=P+1


print(min)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n = int(input())
x = [int(i) for i in input().split()]
d = {}

def m(x, p):
  a = (x - p)**2
  return a
#d.setdefault(j, []).append([i, j, m(i,j)])
for i in range(min(x), max(x)):
  b = 0
  for j in x:
    b += m(j,i)
  d[i]=[b]
print(min(d.values())[0]

n = int(input())
x = [int(i) for i in input().split()]
d = []
for i in range(min(x), max(x)+1):
  a = 0
  for j in x:
    a += (j - i)**2
#    print("({}-{})**2={}".format(j,i,(j - i)**2))
  d.append(a)
print(min(d))


Verdicts: Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def calc_sum_of_power(N, coord):
    spot = round(sum(coord)/N)
    return sum([(x - spot)**2 for x in coord])

def main():
    N = int(input())
    coord = map(int, input().split())
    print(calc_sum_of_power(N, coord))

if __name__ == "__main__":
    try:
        assert calc_sum_of_power(2, [1, 4]) == 5
        assert calc_sum_of_power(7, [14, 14, 2, 13, 56, 2, 37]) == 2354
    except:
        import traceback
        traceback.print_exc()
        exit()
    main()


#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def calc_sum_of_power(N, coord):
    spot = round(sum(coord)/N)
    return sum([(x - spot)**2 for x in coord])

def main():
    N = int(input())
    X = map(int, input().split())
    print( (n))

if __name__ == "__main__":
    try:
        assert calc_sum_of_power(2, [1, 4]) == 5
        assert calc_sum_of_power(7, [14, 14, 2, 13, 56, 2, 37]) == 2354
    except:
        import traceback
        traceback.print_exc()
        exit()
    main()


#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def calc_sum_of_power(N, coord):
    spot = round(sum(coord)/N)
    return sum([(x - spot)**2 for x in coord])

def main():
    N = int(input())
    coord = list(map(int, input().split()))
    print(calc_sum_of_power(N, coord))

if __name__ == "__main__":
    try:
        assert calc_sum_of_power(2, [1, 4]) == 5
        assert calc_sum_of_power(7, [14, 14, 2, 13, 56, 2, 37]) == 2354
    except:
        import traceback
        traceback.print_exc()
        exit()
    main()


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n = int(input())
x = list(map(int, input().split()))

ave = sum(x) // n
ans1 = sum((xi - ave)**2 for xi in x)
ans2 = sum((xi - ave - 1)**2 for xi in x)
print(min(ans1, ans2))

if n==2:
    print(n)

import sys
input = sys.stdin.readline


n = int(input())
x = list(map(int, input().split()))

x2 = [i ** 2 for i in x]
ans = float('inf')
sum1 = sum(x)
sum2 = sum(x2)
for p in range(1, 101):
    cnt = sum2 + (sum(x) * (-1) * 2 * p) + (p**2*n)
    ans = min(ans, cnt)
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
n=input()
x=list(map(int, input().split()))
maxn=0
for i in range(n):
    if x[i]>maxn:
        maxn=x[i]
    else:
        maxn=maxn
minp=0
for j in range(n):
    minp=minp+(x[j]-1)**2
for i in range(maxn+1)
    for j in range(n):
        power=power+(x[j]-i)**2
    if power<minp:
        minp=power
    else:
        minp=minp
print(minp)

n=int(input())
x=list(map(int, input().split()))
maxn=0
for i in range(n):
    if x[i]>maxn:
        maxn=x[i]
    else:
        maxn=maxn
minp=0
for j in range(n):
    minp=minp+(x[j]-1)**2
for i in range(maxn+1):
    power=0
    for j in range(n):
        power=power+(x[j]-i)**2
    if power<minp:
        minp=power
    else:
        minp=minp
print(minp)

Verdicts: Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N = int(input()) 
x = list(map(int, input().split())) 

m = 0
for p in range(N):
	s = 0
	for i in range(N):
		s += (x[i] - (p + 1)) ** 2
		print(s)
    
	if p == 0 or s < m:
		m = s

print(m)


N = int(input())
X = list(map(int, input().split()))

ans = float('inf')
for i in range(1, 101):
    ans_i = 0
    for j in range(N):
        ans_i += (X[j] - i) ** 2
    ans = min(ans, ans_i)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N = int(input())
X = input().split()
X = [int(l) for l in X]

s = 0
for x in X:
    s += (x-1)**2

S = s

if N == 1:
    print(0)
else:
    m = max(X)
    n = min(X)
    for P in range(n,m+1):
        s = 0
        for x in X:
            s += (x-P)**2
        if s < S:
            S = s
	print(S)

N = int(input())
X = input().split()
X = [int(l) for l in X]

s = 0
for x in X:
    s += (x-X[0])**2
S = s

if N == 1:
    print(S)
else:
    m = max(X)
    n = min(X)
    for P in range(n,m+1):
        s = 0
        for x in X:
            s += (x-P)**2
        if s < S:
            S = s
    print(S)

Verdicts: Runtime Error

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
import numpy as np
N = input()
X = np.array([i for i in map(int,input().split())])

print(np.sum((X-np.round(sum(X)/len(X)))**2))

import numpy as np
N = int(input())
X = np.array(list(map(int,input().split())))

point = np.rint(np.average(X))
print(int(np.sum((point - X)**2)))


Verdicts: Wrong Answer

Accepted
Problem: There are N people living on a number line.  The i-th person lives at coordinate X_i.  You are going to hold a meeting that all N people have to attend.  The meeting can be held at any **integer coordinate**. If you choose to hold the meeting at coordinate P, the i-th person will spend (X_i - P)^2 points of stamina to attend the meeting.  Find the minimum total points of stamina the N people have to spend.

Submission attempts (in order):
N=int(input())
A=[int(x) for x in input().rstrip().split()]
ave=sum(A)//len(A)
ans=0
print(ave)
if N/2<(sum(A)%len(A)):
  ave+=1

for i in A:
  ans+=(i-ave)**2
print(ans)


N=int(input())
A=[int(x) for x in input().rstrip().split()]
ave=sum(A)//len(A)
ans=0

if N/2<(sum(A)%len(A)):
  ave+=1

for i in A:
  ans+=(i-ave)**2
print(ans)


Verdicts: Wrong Answer

Accepted