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):
N = int(input())
l = map(int, input().split())

mean = int(sum(l)/N)

stamina = 0

for p in l:
	stamina += (p - mean)**2
    
print(stamina)

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

mean = round(sum(l)/N)
stamina = 0

for p in l:
    stamina += (p - mean)**2

print(stamina)

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_ls = list(map(int, input().split(' ')))
rst = -1
for i in range(min(X_ls), max(X_ls) + 1):
    val = 0
    for j in X_ls:
        val += (i - j) ** 2
    if rst == -1:
        rst = val
    else:
        rst = min(rst, val)
print(val)

N = int(input())
X_ls = list(map(int, input().split(' ')))
rst = -1
for i in range(min(X_ls), max(X_ls) + 1):
    val = 0
    for j in X_ls:
        val += (i - j) ** 2
    if rst == -1:
        rst = val
    else:
        rst = min(rst, val)
print(rst)

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 = int(input())
    A = sorted(map(int, input().split()))
    mean = np.mean(A)
    x = np.array(A) - mean
    print(int(np.dot(x, x)))

main()

import numpy as np
 
def main():
    N = int(input())
    A = sorted(map(int, input().split()))
    mean = int(round(np.mean(A)))
    x = np.array(A) - mean
    print(np.dot(x, x))
 
main()

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):
X = list(map(int, input().split()))
X.sort()
ans = 10**10
for p in range(X[0], X[-1]+1):
    tmp = 0
    for x in X:
        tmp += pow(x-p, 2)
    ans = min(ans, tmp)
print(ans)


n = int(input())
X = list(map(int, input().split()))
ans = 10**10
for p in range(min(X), max(X)+1):
    tmp = 0
    for x in X:
        tmp += pow(x-p, 2)
    ans = min(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):
n = int(input())
x = [int(i) for i in input().split()]
ans = 100100100
for i in range(1,101) :
    s = 0
    for o in x :
        s+=(i-x)*(i-x)
    ans = min(ans,s)
print(ans)

n = int(input())
x = [int(i) for i in input().split()]
ans = 100100100
for i in range(1,101) :
    s = 0
    for o in x :
        s+=(i-o)*(i-o)
    ans = min(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):
import math
import numpy as np
n= int(input())
l = list(map(int,input().split()))

ans = 0
me = int(round(np.mean(l)))
print(me)
for i in range(n):
  ans += (l[i]-me)**2
print(ans)

import math
import numpy as np
n= int(input())
l = list(map(int,input().split()))

ans = 0
me = int(round(np.mean(l)))
#print(me)
for i in range(n):
  ans += (l[i]-me)**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(101):
  for j in range(0,len(a)):
    m=0
    m+=(a[j]-i)**2
    s.append(m)
print(min(s))    

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


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()))
M = round(sum(X)/N)
ans = 0
for i in X:
    ans+=(i-M)*2
print(ans)

N = int(input())
X = list(map(int, input().split()))
M = round(sum(X)/N)
answer = 0
for i in X:
    answer+=(i-M)**2
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):
def f(n, x):
    mean =  np.mean(x)
    s1 = sum((x-np.floor(mean))**2)
    s2 = sum((x-np.ceil(mean))**2)
    print(int(min(s1, s2)))

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


def f(n, x):
    mean =  np.mean(x)
    s1 = sum((x-np.floor(mean))**2)
    s2 = sum((x-np.ceil(mean))**2)
    print(min(s1, s2))

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


def f(n, x):
    mean =  np.mean(x)
    s1 = sum((x-np.floor(mean))**2)
    s2 = sum((x-np.ceil(mean))**2)
    print(int(min(s1, s2)))

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


# ABC156C

import numpy as np
def f(n, x):
    mean =  np.mean(x)
    s1 = sum((x-np.floor(mean))**2)
    s2 = sum((x-np.ceil(mean))**2)
    print(int(min(s1, s2)))

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


Verdicts: 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):
N=int(input())
X=list(map(int,input().split()))
A=sum(X)
y=N*((round(A/N)-A/N)**2)-(A**2)/N
B=sum([i**2 for i in X])
print(y+B)

N=int(input())
X=list(map(int,input().split()))
A=sum(X)
y=N*((round(A/N)-A/N)**2)-(A**2)/N
B=sum([i**2 for i in X])
print(y+B)

N=int(input())
X=list(map(int,input().split()))
A=sum(X)
y=N*((round(A/N)-A/N)**2)-(A**2)/N
B=sum([i**2 for i in X])
print(int(y+B))

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, k = map(int, input().split())
ans = 0

for i in range(n):
    if k ** (i - 1) <= n < k ** i:
        ans = i
        break
if ans == 0:
    ans += 1
print(ans)


n = int(input())
x = list(map(int, input().split()))
x.sort()
ans = float("inf")

for i in range(x[0], x[-1]+1):
    t = 0
    for q in range(n):
        t += (i - x[q]) ** 2
    else:
        if ans > t:
            ans = t

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):
import numpy as np
import math
N=int(input())
X=list(map(float,input().split()))
Xmin=int(math.floor(np.min(X)));Xmax=int(math.ceil(np.max(X)))
P=np.array([i for i in range (Xmin,Xmax+1)])
Sum=np.zeros(len(P),dtype=float)
for i in range(len(P)):
    Sum[i]=np.sum((np.array(X)-P[i])*(np.array(X)-P[i]))
print(np.min(Sum))


import numpy as np
import math
N=int(input())
X=list(map(float,input().split()))
Xmin=int(math.floor(np.min(X)));Xmax=int(math.ceil(np.max(X)))
P=np.array([i for i in range (Xmin,Xmax+1)])
Sum=np.zeros(len(P),dtype=float)
for i in range(len(P)):
    Sum[i]=np.sum((np.array(X)-P[i])*(np.array(X)-P[i]))
print(int(np.min(Sum)))

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()))
import math
P = sum(X)/len(X)
count = 0
for i in range(N):
  count += (X[i] - P)**2
print(math.ceil(count))

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

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 _ in range(n)]
ans = list()
for p in x:
  v_sum = 0
  for i in x:
    v_sum += (p - i)**2
  	ans.append(v_sum)
print(min(ans))


n = int(input())
x = list(map(int,input().split()))
ans = list()
for p in x:
  v_sum = 0
  for i in x:
    v_sum += (p - i)**2
  ans.append(v_sum)
print(min(ans))

n = int(input())
x = [int(input()) for _ in range(n)]
ans = list()
for p in x:
  v_sum = 0
  for i in x:
    v_sum += (p - x)**2
  	ans.append(v_sum)
print(min(ans))


n = int(input())
x = [int(input()) for _ in range(n)]
ans = list()
for p in x:
  v_sum = 0
  for i in x:
    v_sum += (p - i)**2
  ans.append(v_sum)
print(ans.min())


n = int(input())
x = [int(input()) for _ in range(n)]
ans = list()
for p in x:
  v_sum = 0
  for i in x:
    v_sum += (p - x)**2
  	ans.append(v_sum)
print(ans.min())

n = int(input())
x = list(map(int,input().split()))
ans = list()
for p in range(1,101):
  v_sum = 0
  for i in x:
    v_sum += (p - i)**2
  ans.append(v_sum)
print(min(ans))

Verdicts: Runtime Error

Wrong Answer

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):
import math

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

mi_stamina = math.inf
for i in range(-1000, 1000):
    print(x_list)
    double_list = list(map(lambda x: (x-i)**2, x_list))
    print(double_list)
    stamina = sum(double_list)
    if mi_stamina > stamina:
        mi_stamina = stamina

print(mi_stamina)

import math


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


mi_stamina = 1000000000
for i in range(-1000, 1000):
    def _distance(x):
        return (x-i)**2
    double_list = list(map(_distance, x_list))
    stamina = sum(double_list)
    if mi_stamina > stamina:
        mi_stamina = stamina

print(mi_stamina)

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()))

n = len(X)

for xi in x:
  sum_a += xi * xi
  sum_b += xi
  
ans = sum_a - (sum_b*sum_b)/n
print(ans)

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

sum_a = 0
sum_b = 0

for xi in x:
  sum_a += xi * xi
  sum_b += xi
  
ans = sum_a - (sum_b*sum_b)/n
min_ans = 10**9
if ans < min_ans
    ans = min_ans

print(int(ans+0.5))

N = int(input())
x = list(map(int, input().split()))
 
n = len(x)
 
sum_a = 0
sum_b = 0
 
for xi in x:
  sum_a += (xi*xi)
  sum_b += xi

p = int(sum_b/n+0.5)
ans = sum_a - 2*sum_b*p+n*p*p

min_ans = 10**9
if ans > min_ans:
    ans = min_ans
print(int(ans))

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):
def atcoder2():
    a = [list(map(int,input().split())) for l in range(2)]

    n= a[0][0]
    x_l = a[1]

    P = sum(x_l)/n

    print(a,n)
    print(P)
    if P - int(P) >= 0.5:
        add= 1
    else:
        add = 0

    P = int(P)+add
    
    print(P)

    result = 0
    for Xi in x_l:
        result = result + (Xi-P)**2 

    print(result)
    return 


atcoder2()


def atcoder2():
    a = [list(map(int,input().split())) for l in range(2)]

    n= a[0][0]
    x_l = a[1]

    P = sum(x_l)/n

    # print(a,n)
    # print(P)
    if P - int(P) >= 0.5:
        add= 1
    else:
        add = 0

    P = int(P)+add
    
    # print(P)

    result = 0
    for Xi in x_l:
        result = result + (Xi-P)**2 

    print(result)
    return 


atcoder2()

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()))
print(x)
min_ans = 1e9
for i in range(100):
    ans = sum([(i + 1 - j) ** 2 for j in x])
    min_ans = min(ans, min_ans)

print((min_ans))

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

min_ans = 1e9
for i in range(100):
    ans = sum([(i + 1 - j) ** 2 for j in x])
    min_ans = min(ans, min_ans)

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):
def sqerr(x, t):
  return (x - t)**2

N = input()
X = list(map(int, input()))
ans=0
for P in range(1, N+1):
  sum = 0
  for x in X:
    sum += (x-P)**2
    
  if sum > ans:
    ans = sum
    
print(ans)

import numpy as np
 
N = input()
X = list(map(int, input()))
ans=0
for P in range(max(X)):
  sum = np.sum(list(map(lambda x: (x-P)**2, X)))
    
  if sum >= ans:
    ans = sum
    
print(ans)

import numpy as np

N = input()
X = list(map(int, input()))
ans=0
for P in range(max(X)):
  sum = np.sum(map(lambda:x (x-P)**2, X))
    
  if sum >= ans:
    ans = sum
    
print(ans)

import numpy as np
 
N = input()
X = list(map(int, input()))
ans=0
for P in range(max(X)):
  sum = np.sum(map(lambda x: (x-P)**2, X))
    
  if sum >= ans:
    ans = sum
    
print(ans)

import numpy as np
 
N = input()
X = list(map(int, input().split()))
ans=9999999
for P in range(0, 101):
  sum = np.sum(list(map(lambda x: (x-P)**2, X)))
  ans = min(ans, sum)
    
print(ans)

Verdicts: 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):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sys import stdin

n = int(input())
x_list_str = stdin.readline().rstrip().split()
x_list = [int(i) for i in x_list_str]


sum_hp_list = []

min_x = min(x_list)
max_x = max(x_list)

if min_x == max_x:
    print(0)
    exit()
for i in range(min_x, max_x):
    print(i)
    sum_hp = 0
    for x in x_list:
        sum_hp += (x-i)**2
    sum_hp_list.append(sum_hp)

print(min(sum_hp_list))


#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sys import stdin

n = int(input())
x_list_str = stdin.readline().rstrip().split()
x_list = [int(i) for i in x_list_str]


sum_hp_list = []

min_x = min(x_list)
max_x = max(x_list)

if min_x == max_x:
    print(0)
    exit()

for i in range(min_x, max_x):
    sum_hp = 0
    for x in x_list:
        sum_hp += (x-i)**2
    sum_hp_list.append(sum_hp)

print(min(sum_hp_list))


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 sys

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


def cal(number):
    ans = 0
    for X in Xn:
        ans += (X - number)**2
    return ans

ans = sys.maxsize
for i in range(Xn[1], Xn[-1], 1):
    ans = min(ans, cal(i))

print(ans)


import sys

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


def cal(number):
    an = 0
    for X in Xn:
        an += (X - number)**2
    return an

ans = sys.maxsize
for i in range(min(Xn), max(Xn)+1, 1):
    ans = min(ans, cal(i))

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())

res = 0
r = round(sum(x)/len(x))
for i in x:
    res +=(i-p)**2
print(res)

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

res = 0

r = round(sum(x)/len(x))
for i in x:
    res += (i-r)**2
print(res)

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= mean(x)
g= int(m)
if m-g<g+1-m:
  print(g)
else:
  print(g+1)
  

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

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())
arr = list(map(int, input().spli()))
s = sum(arr)
p = s//n
r = 0
for i in arr:
  r += (p-i)**2
print(r)

n = int(input())
arr = list(map(int, input().split()))
m = 1000000000000000
for p in range (1, max(arr)+1):
  r = 0
  for i in arr:
    r += (p-i)**2
  m = min(m, r)
print(m)


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 = [float(x) for x in input().split()]

P = round(sum(X)/N)
print(sum([(x-P)**2 for x in X]))

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

P = round(sum(X)/N)
print(int(sum([(x-P)**2 for x in X])))

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())
l = input()
data = []
for i in range(min(l), max(l)+1):
    sum_l = 0
    for j in range(len(l)):
        sum_l = sum_l + (l[j]-i)**2
    data.append(sum_l)

print(min(data))

n = input()
l = input().split()
data = []
for i in range(int(min(l)), int(max(l))+1):
    sum_l = 0
    for j in range(len(l)):
        sum_l = sum_l + (int(l[j])-i)**2
    data.append(sum_l)

print(min(data))

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()))
avex = round(sum(X)/N)
print(avex)
sumX = 0
for x in X:
    print(x)
    sumX = sumX + (x - 20) ** 2
    
print(sumX)

N = int(input())
X = list(map(int,input().split()))
avex = round(sum(X)/N)
print(avex)
sumX = 0
for x in X:
    sumX = sumX + (x - 20) ** 2    
print(sumX)

N = int(input())
X = list(map(int,input().split()))
avex = round(sum(X)/N)
sumX = 0
for x in X:
    sumX = sumX + (x - 20) ** 2    
print(sumX)

N = int(input())
X = list(map(int,input().split()))
avex = round(sum(X)/N)
sumX = 0

for x in X:
    sumX = sumX + (x - avex) ** 2    
print(sumX)



Verdicts: Wrong Answer

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())
xi = list(map(int, input().split()))

p = round(sum(xi) / n)
print(p)
hp = 0
for x in xi:
    hp += (x - p) ** 2

print(hp)

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

p = round(sum(xi) / n)
hp = 0
for x in xi:
    hp += (x - p) ** 2

print(hp)

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=10**10
for i in range(N):
  for x in X:
    tmp += (i - x)**2
  
  if ans>=tmp:
    ans=tmp

print(ans)

N = int(input())
X = list(map(int,input().split()))
 
ans=10**10
for i in range(0,101):
  tmp=0
  for x in X:
    tmp += (i - x)**2
  
  if ans>=tmp:
    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):
def main():
    N = int(input())
    X = list(map(int, input().split(" ")))
    calc = [0]*max(X)
    for i in range(max(X)):
        for j in range(N):
            calc[i] += (X[j] - (i+1))**2

        print(calc)
    print(min(calc))

if __name__ == '__main__':
    main()

def main():
    N = int(input())
    X = list(map(int, input().split(" ")))
    calc = [0]*max(X)
    for i in range(max(X)):
        for j in range(N):
            calc[i] += (X[j] - (i+1))**2

        #print(calc)
    print(min(calc))

if __name__ == '__main__':
    main()

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_data = list(map(int,input().split()))
mini = min(input_data[1:])
length=max(input_data[1:])-mini
zahyo = [n-mini for n in input_data[1:]]
energy=[0 for i in range(length+1)]
for i in range(length+1):
    for j in range(input_data[0]):
        energy[i]=energy[i]+(i-zahyo[j])**2
print(min(energy))

input_data = list(map(int,input().split()))
mini = min(input_data[1:])
length=max(input_data[1:])-mini
zahyo = [n-mini for n in input_data[1:]]
energy=[0 for i in range(length+1)]
for i in range(length+1):
    for j in range(input_data[0]):
        energy[i]=energy[i]+(i-zahyo[j])**2
print(min(energy))

input_data = list(map(int,input().split()))
mini = min(input_data[1:])
length=max(input_data[1:])-mini
zahyo = [n-mini for n in input_data[1:]]
energy=[0 for i in range(length+1)]
for i in range(length+1):
    for j in range(input_data[0]):
        energy[i]=energy[i]+(i-zahyo[j])**2
print(min(energy))

N= int(input())
input_data = [int(x) for x in input().split()]
mini = min(input_data)
length=max(input_data)-mini
zahyo = [n-mini for n in input_data]
energy=[0 for i in range(length+1)]
for i in range(length+1):
    for j in range(N):
        energy[i]=energy[i]+(i-zahyo[j])**2
print(min(energy))

Verdicts: 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):
import sys
input = sys.stdin.readline

N = int(input())
X = [int(x) for x in input().split()]
MAX = max(X)
res = []
if MAX == 1:
  print(1)
  sys.exit()
for a in range(1, MAX+1):
  total = 0
  for x in X:
    kyori = (x - a) * (x - a)
    total += kyori
  res.append(total)
print(min(res))
print(res)


import sys
input = sys.stdin.readline

N = int(input())
X = [int(x) for x in input().split()]
MAX = max(X)
res = []
if MAX == 1:
  print(1)
  sys.exit()
for a in range(1, MAX+1):
  total = 0
  for x in X:
    kyori = (x - a) * (x - a)
    total += kyori
  res.append(total)
print(min(res))
print(res)

import sys
input = sys.stdin.readline

N = int(input())
X = [int(x) for x in input().split()]
P = int(sum(X) / N) + 1
print(sum(X))
print(sum(X) / N)
total = 0
for x in X:
  kyori = (x - P) * (x - P)
  total += kyori
print(total)

import sys
input = sys.stdin.readline

N = int(input())
X = [int(x) for x in input().split()]
P = int(sum(X) / N + 0.5)
total = 0
for x in X:
  kyori = (x - P) * (x - P)
  total += kyori
print(total)

Verdicts: Wrong Answer

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):
def dist(x, p):
    return (x - p)**2


n = int(input())
x = [int(i) for i in input().split()]
index = len(x) // 2
new_x = sorted(x)
p1 = - (- sum(x) // len(x))
p2 = sum(x) // len(x)
ans = [0, 0]
for i in new_x:
    ans[0] += dist(i, p1)
    ans[1] += dist(i, p2)
print(ans)

def dist(x, p):
    return (x - p)**2


n = int(input())
x = [int(i) for i in input().split()]
index = len(x) // 2
new_x = sorted(x)
p1 = - (- sum(x) // len(x))
p2 = sum(x) // len(x)
ans = [0, 0]
for i in new_x:
    ans[0] += dist(i, p1)
    ans[1] += dist(i, p2)
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())
List = list(map(int, input().split()))
s = 0
t = 0

for i in range(N):
  s += List[i]

ave = s/N

for i in range(N):
  t += (List[i]-ave)**2

print(t)


N = int(input())
List = list(map(int, input().split()))
s = 0
t = 0

for i in range(100):
  for j in range(N):
    t += (List[j]-i-1)**2

  if s>t:
    s = t

print(t)


N = int(input())
List = list(map(int, input().split()))
s = 1000000000000000000000
t = 0

for i in range(100):
  for j in range(N):
    t += (List[j]-i-1)**2

  if s>t:
    s = t
    t = 0
  else:
    t = 0

print(s)


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 = list(map(int, input().split()))

x.sort()

mean = sum(x)/n

if isinstance(mean,float):
    mean = int(mean) + 1

print(mean)

sum = 0

for i in range(n):
    sum += (x[i]-mean)**2

print(sum)


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

x.sort()

mean = sum(x)/n
med = int(n / 2)
print(med)

if mean - int(mean) < 0.5:
    mean = int(mean)
elif mean - int(mean) > 0.5:
    mean = int(mean) + 1
else:
    if n % 2 == 0:
        if (x[med-1] + x[med])/2 <= mean:
            mean = int(mean)
        else:
            mean = int(mean) + 1
    else:
        if x[med] <= mean:
            mean = int(mean)
        else:
            mean = int(mean) + 1
sum = 0

for i in range(n):
    sum += (x[i]-mean)**2

print(sum)

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

x.sort()

mean = sum(x)/n
med = int(n / 2)

if mean - int(mean) < 0.5:
    mean = int(mean)
elif mean - int(mean) > 0.5:
    mean = int(mean) + 1
else:
    if n % 2 == 0:
        if (x[med-1] + x[med])/2 <= mean:
            mean = int(mean)
        else:
            mean = int(mean) + 1
    else:
        if x[med] <= mean:
            mean = int(mean)
        else:
            mean = int(mean) + 1
sum = 0

for i in range(n):
    sum += (x[i]-mean)**2

print(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()
List = [input().split()]


ans = 10**18
def rally(p):
    n = 0
    for a in range(N):
        n += (p-List[a])**2
    return n

for i in range(1,101):
    ans = min(rally(i),ans)

print(ans)


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

N = 7
List = [14,14,2,13,56,2,37]

ans = 10**18
def rally(p):
    n = 0
    for a in range(N):
        n += (p-List[a])**2
    return n

for i in range(1,101):
    ans = min(rally(i),ans)

print(ans)


N = input()
List = [int(i) for i in input().split()]



ans = 10**18
def rally(p):
    n = 0
    for a in range(N):
        n += (p-List[a])**2
    return n

for i in range(1,101):
    ans = min(rally(i),ans)

print(ans)


N = int(input())
List = [int(i) for i in input().split()]


ans = 10**18
def rally(p):
    n = 0
    for a in range(N):
        n += (int(p)-List[a])**2
    return n

for i in range(1,101):
    ans = min(rally(i),ans)

print(ans)


Verdicts: 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 = list(map(int, input().split()))

def D(X,a):
	ans = 0
	for i in range(len(a)):
		ans += (x - a[i])**2
	return ans

for i in range(0,101):
	if D(i,X) < D(i+1,X):
		print(D(i,X))
		break

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

def D(X,a):
	ans = 0
	for i in range(len(a)):
		ans += (x - a[i])**2
	return ans

for i in range(0,101):
	if D(i,X) < D(i+1,X):
		print(D(i,X))
		break

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

def D(x, a):
    ans = 0
    for i in range(len(a)):
        ans += (x - a[i])**2
    return ans

for i in range(0, 101):
    if D(x, X) < D(i+1, X):
        print(D(i, X))
        break



N=int(input())
X=list(map(int,input().split()))
def D(x,a):
	ans=0
	for i in range(len(a)):
		ans+=(x-a[i])**2
	return ans
for i in range(0,101):
	if D(i,X)<D(i+1,X):
		print(D(i,X))
		break


Verdicts: 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())
A = list(map(int, input().split()))
B = []
CCC = 0
j = 1
max_A = max(A)
for j in range(101):
    if j == 0:
        continue
    CCC = 0
    if N == 1:
        B.append(A[0])
        break
    for k in range(N):
        CCC += (A[k] - j) ** 2
    B.append(CCC)
x = min(B)
print(len(B))
print(x)

N = int(input())
A = list(map(int, input().split()))
B = []
CCC = 0
j = 1
max_A = max(A)
for j in range(101):
    if j == 0:
        continue
    CCC = 0
    for k in range(N):
        CCC += (A[k] - j) ** 2
    B.append(CCC)
x = min(B)
print(x)

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()))
sum = 1000000 ** 10000000
for i in range(1, 101):
  tmp = 0
  for x in X:
    tmp += (x - i) ** 2
  if tmp < sum:
    sum = tmp
    ans = i
print(ans)

N = int(input())
X = list(map(int, input().split()))
sum = 1000000
for i in range(1, 101):
  tmp = 0
  for x in X:
    tmp += (x - i) ** 2
  sum = min(sum, tmp)
print(sum)

Verdicts: Time Limit Exceeded

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):
# coding: utf-8


def main():
    n = int(input())
    point = list(map(int, input().split(' ')))    

    max_point = max(point)
    min_point = min(point)
    min_sums = []
    for p in range(min_point, max_point + 1):
        sum_ = 0
        for x in numbers:
            sum_ += (x - p) ** 2
        min_sums.append(sum_)

    print(min(min_sums))

    return 0


if __name__ == '__main__':
    main()

# coding: utf-8


def main():
    n = int(input())
    numbers = list(map(int, input().split(' ')))    

    max_number = max(numbers)
    min_number = min(numbers)
    min_sums = []
    for p in range(min_number, max_number + 1):
        sum_ = 0
        for x in numbers:
            sum_ += (x - p) ** 2
        min_sums.append(sum_)

    print(min(min_sums))

    return 0


if __name__ == '__main__':
    main()

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 = round((sum(X) / N), 3)
integer = int(a)
f = a - i

if f < 0.5:
    P = integer
else:
    P = integer + 1

total = 0
for i in X:
    total += (i - P) ** 2

print(total)

N = int(input())

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

a = sum(X) / N
integer = int(a)
f = a - i

if f < 0.5:
    P = integer
else:
    P = integer + 1

total = 0
for i in X:
    total += (i - P) ** 2

print(total)

N = int(input())
 
X = list(map(int, input().split()))
 
a = round((sum(X) / N), 3)
integer = int(a)
f = a - integer
 
if f < 0.5:
    P = integer
else:
    P = integer + 1
 
total = 0
for i in X:
    total += (i - P) ** 2
 
print(total)

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 = 100000

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

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


for i in 100:
  result = 0
  for j in x:
    result += (i - j)**2
  print(min(result))
    

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

ans = 100000

for i in range(100):
    result = 0
    for j in x:
        result += (j - i )**2
    ans = min(result, ans)
        
print(ans)


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

ans = 10000000

for i in range(100):
    result = 0
    for j in x:
        result += (j - i )**2
    ans = min(result, ans)
        
print(ans)


Verdicts: 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 = list(map(int, input().split()))


ans = float("inf")
for i in range(N):
    conf_site = X[i]
    total = sum([(x - conf_site)**2 for x in X])
    ans = min(ans, total)

print(ans)

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


ans = float("inf")
for i in range(1,101):
    conf_site = i
    total = sum([(x - conf_site)**2 for x in X])
    ans = min(ans, total)

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):
loss = 0
ans = 0
minimum = min(zahyou)
maximum = max(zahyou)
for i in range(minimum, maximum+1):
    loss = 0
    for j in zahyou:
        loss += (j-i)**2
        
    if i == minimum:
        ans = loss
    if loss < ans:
        ans = loss
print(ans)

n = int(input())
zahyou = list(map(int,input().split()))
loss = 0
ans = 0
minimum = min(zahyou)
maximum = max(zahyou)
for i in range(minimum, maximum+1):
    loss = 0
    for j in zahyou:
        loss += (j-i)**2
        
    if i == minimum:
        ans = loss
    if loss < ans:
        ans = loss
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())
xs = list(map(int, input().split(" "))) + list(range(100 - n))

for i in range(1, 100):
    print(sum([(xs[j] - i)**2 for j in range(n)]))

n = int(input())
xs = list(map(int, input().split(" "))) + list(range(100 - n))

ans = 9999999999999999
for i in range(1, 100):
    ans = min(ans, sum([(xs[j] - i)**2 for j in range(n)]))

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()))
ans = 1000000000000000
for i in range(1,101):
    hp=0
    for j in range(N):
        B = (X[j]-i) ** 2
        hp+=B
    print(hp)
    if ans > hp:
        ans=hp

print(ans)
        


N = int(input())
X = list(map(int,input().split()))
ans = 1000000000000000
for i in range(1,101):
    hp=0
    for j in range(N):
        B = (X[j]-i) ** 2
        hp+=B
    if ans > hp:
        ans=hp

print(ans)
        


Verdicts: Wrong Answer

Accepted