Problem:


Score : 300 points

Problem Statement

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.

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq X_i \leq 100

Input

Input is given from Standard Input in the following format:

N
X_1 X_2 ... X_N

Output

Print the minimum total stamina the N people have to spend.

Sample Input 1

2
1 4

Sample Output 1

5

Assume the meeting is held at coordinate 2. In this case, the first person will spend (1 - 2)^2 points of stamina, and the second person will spend (4 - 2)^2 = 4 points of stamina, for a total of 5 points of stamina. This is the minimum total stamina that the 2 people have to spend.

Note that you can hold the meeting only at an integer coordinate.

Sample Input 2

7
14 14 2 13 56 2 37

Sample Output 2

2354



Sample input:
2
1 4


Sample output:
5

Submission status: Wrong Answer

Solution code:
n = int(input())
list = []
list1 = []
list2 = []
list3 = []
c = 0
a = input().split()
for i in range(0, len(a)):
    list1.append(int(a[i]))
for j in range(1, 30):
    for item in list1:
        c = c+ (item-j)**2
    list2.append(c)
l = len(list2)
for z in range(0, l-1):
    list3.append(list2[z+1]-list2[z])
list3.sort()
print(list3[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
x=list(map(int,input().split()))
ans=10**9
for i in range(1,max(x)):
  s=0
  for j in range(len(x)):
    s=s+(x[j]-i)**2
  ans=min(ans,s)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
list = []
list1 = []
list2 = []
list3 = []
c = 0
a = input().split()
for i in range(0, len(a)):
    list1.append(int(a[i]))
for j in range(1, 30):
    for item in list1:
        c = c+ (item-j)**2
    list2.append(c)
l = len(list2)
for z in range(0, l):
    list3.append(list2[z-1]-list2[z-2])
list3.sort()
print(list3[1])

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
X = iil()
ti = 100*100
for i in range(min(X),max(X)+1):
    cal = 0
    for item in X:
        cal += (item-i)**2
    ti = min(cal,ti)

print(ti)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
ans = 100000000
for p in x:
    hp = 0
    for i in range(n):
        hp += (x[i] - p)**2
    ans = min(ans,hp)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
x = list(map(int,input().split()))
l = []
for i in range(N):
    ans = (x[i] - N) ** 2
    l.append(ans)
print(sum(l))

Submission status: Wrong Answer

Solution code:
N = int(input())
x = list(map(int,input().split()))
l = []
for i in range(N):
    ans = (x[i] - ((sum(x)//N)+1)) ** 2
    l.append(ans)
print(sum(l))

Submission status: Wrong Answer

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

mn=99999
#for p in range(min(X),max(X)+1):
for p in range(1,101):
    sm=0
    for x in X:
        sm+=(x-p)**2
    #print(p,sm)
    mn=min(sm,mn)
print(mn)

Submission status: Wrong Answer

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

mn=99999
for p in range(0,max(X)+1):
    sm=0
    for x in X:
        sm+=(x-p)**2
    #print(p,sm)
    mn=min(sm,mn)
print(mn)

Submission status: Wrong Answer

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

mn=99999
for p in range(min(X),max(X)+1):
    sm=0
    for x in X:
        sm+=(x-p)**2
    #print(p,sm)
    mn=min(sm,mn)
print(mn)

Submission status: Wrong Answer

Solution code:
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):
    ans = min(ans, cal(i))

print(ans)

Submission status: Wrong Answer

Solution code:
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[0], Xn[-1]+1, 1):
    ans = min(ans, cal(i))

print(ans)

Submission status: Wrong Answer

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

min_dis = 1e10
for p in range(min(x),max(x)):
    dis = 0
    for y in x:
        dis += (p-y)*(p-y)
    min_dis = min(dis, min_dis)
print(min_dis)

Submission status: Wrong Answer

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

min_dis = 1e5
for p in range(min(x),max(x)):
    dis = 0
    for y in x:
        dis += (p-y)*(p-y)
    min_dis = min(dis, min_dis)
print(min_dis)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
HP1 = 0
HP2 = 0
P1 = sum(X) // N
P2 = sum(X) // N + 1
for Xi in X:
    HP1 = HP1 + (Xi - P1) ** 2
    HP2 = HP2 + (Xi - P1) ** 2

print(min(HP1, HP2))

Submission status: Wrong Answer

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

L=False
for i in range(100):
    L0=0
    for ii in range(N):
        L0+=(i+1-X[ii])**2
    if L==False:
        L=L0
    else:
        L=min(L,L0)
print(L)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

tmp = np.array(num).mean() 
if tmp-int(tmp)<0.5:
    tmp=int(tmp)
else:
    tmp=int(tmp)+1
tmp

ans = 0
for i in num:
    ans += (i-tmp)**2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
sum = []
for n in range(1,N+1):
    s = 0
    for x in X:
        s = s + ((x-n)*(x-n))
    sum.append(s)

print(min(sum))

Submission status: Wrong Answer

Solution code:
N=int(input())
X=[int(s) for s in input().split()]

sum=0
Ans=0
count=0
Xmax=sorted(X)[N-1]

for i in range(Xmax):
    sum=0
    for j in range(N):
        sum+=(X[j]-i)**2
    count+=1
    if count==1:
        Ans=sum
    Ans=min(Ans,sum)
    

print(Ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=[int(s) for s in input().split()]

sum=0
Ans=10000000000000000000000000000000000000
Xmax=sorted(X)[N-1]

for i in range(Xmax):
    sum=0
    for j in range(N):
        sum+=(X[j]-i)**2
    Ans=min(Ans,sum)

print(Ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=[int(s) for s in input().split()]

sum=0
Ans=10000000000000000
Xmax=sorted(X)[N-1]

for i in range(Xmax):
    sum=0
    for j in range(N):
        sum+=(X[j]-i)**2
    Ans=min(Ans,sum)

print(Ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=[int(s) for s in input().split()]

sum=0
Ans=100000000000
Xmax=sorted(X)[N-1]

for i in range(0,Xmax):
    sum=0
    for j in range(N):
        sum+=(X[j]-i)**2
    Ans=min(Ans,sum)

print(Ans)

Submission status: Wrong Answer

Solution code:
def get_x(arr):
  pass


def main():
  input()
  X = list(map(int,input().split()))
  ans = 10 ** 8
  for i in range(min(X), max(X)):
    nums = [(x-i)**2 for x in X]  
    if sum(nums) < ans:
      ans = sum(nums)
  print(ans)

    
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
a = max(x)
b = min(x)
y = 0
ans = 100000

for i in range (b,a+1): #住民がいる間で
  y = 0 #初期化
  for j in x: #体力の総和を計算
    y = y + (j-i)**2
  if y < ans:
    ans = y

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    X = list(map(int,input().split()))
#    print(sum(X),len(X))
    AVG = int(sum(X)/len(X))
#    print()
    total = 0
    for i in X:
        total += (AVG - i)**2

    print(total)

main()

Submission status: Wrong Answer

Solution code:
def main():
    N = input()
    X = list(map(int,input().split()))
    print(sum(X),len(X))
    AVG = int(sum(X)/len(X))
    print()
    total = 0
    for i in X:
        total += (AVG - i)**2

    print(total)

main()

Submission status: Wrong Answer

Solution code:
N = int(input())
li = list(map(int,input().split()))
ans = 0
for i in range(1,101):
    for x in li:
        ans += (x-i)**2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

ret = sys.maxsize

for i in range(min(X) , max(X)):
    pow = 0
    for x in X:
        pow += (x - i) ** 2
    if pow < ret:
        ret = pow

print(ret)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = sorted([int(i) for i in input().split(" ")])

mind = float("inf")
for i in range(x[0], x[-1], 1):
  sumd = 0
  for p in x:
    sumd += (p - i)**2
  mind = min(mind, sumd)
print(mind)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))

if sum(l) % n == 0:
    k = sum(l) // n
else:
    k = sum(l) // n + 1
    
ans = 0
for i in l:
    ans += (k - i) ** 2

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[int(i) for i in input().split()]

sum=0
for i in range(n):
  sum=sum+x[i]

if (sum/n)%1==0:
  p=(sum/n)
elif (sum/n)%1<0.5:
  p=int((sum/n))
else:
  p=int((sum/n))+1
  
answer=0
for i in range(n):
  answer=answer+(x[i]-p)**2

print(answer)

Submission status: Wrong Answer

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

ans = 0

for i in X:
  ans += (N-i)**2
 

print(ans)

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    X = list(map(int, input().split()))
    r = min((x - p) ** 2 for x in X for p in range(1, 101))
    print(r)


main()

Submission status: Wrong Answer

Solution code:
N = int(input())
x = tuple(map(int, input().split()))
mid = (max(x) + min(x)) // 2
curr_sum = 0
dp = [10**9] * 101
for i in range(min(x), max(x)):
  dp[i] = 0
  for num in x:
    dp[i] += (num - i) ** 2
print(min(dp))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
buff = 0
min = 999999
for i in range(1,n+1):
  buff = 0
  for j in x:
    #print(j,"j",i,"i")
    #print(((j - i)**2))
    buff += ((j - i)**2)
  if(min > buff):
    min = buff
print(min)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=list(map(int,input().split()))
x=[]
maxx=max(X)
sum=0
for p in range(maxx):
  for j in X:
    sum+=(j-p)**2
  x.append(sum)
  sum=0
ans=min(x)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
X=np.array(list(map(int,input().split())))
ans=sum(X**2)
for i in range(min(X),max(X)):
    Z=sum(X**2)-sum(2*X*i)+N*i**2
    ans=min(Z,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
ans = float("inf")
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)

Submission status: Wrong Answer

Solution code:
n=int(input())
X=list(map(int,input().split()))
sum=9999

def f(i,X):
  sumf=0
  for j in X:
    sumf+=(j-i)**2
  return sumf

for i in range(min(X),max(X)):
  sum=min(sum,f(i,X))

print(sum)

Submission status: Wrong Answer

Solution code:
N,*X=map(int,open(0).read().split());print(sum(map(lambda x:(round(sum(X)/N,0)-x)**2,X)))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0]*max(a)
for i in range(0,max(a)):
  sum=0
  for j in range(0,n):
    sum=sum+(i-a[j])**2
  b[i]=sum
print(min(b))

Submission status: Wrong Answer

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

if sum(X) == 0:
    print(0)
else:
    ans = 100 * N
    P = 100
    while P > 0:
        a = 0
        for x in X:
            a += (x - P) ** 2
        ans = min(ans, a)
        P -= 1
    print(ans)

Submission status: Wrong Answer

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

ans = 100 * N
P = 100
while P > 0:
    a = 0
    for x in X:
        a += (x - P) ** 2
    ans = min(ans, a)
    P -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = [int(n) for n in range(N)]

min_ans = +float('inf')

for i in range(N):
    ans = 0
    for x in X:
        ans += (x - i)**2
    min_ans = min([min_ans, ans])

print(min_ans)

Submission status: Wrong Answer

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

ans = 10000
P = 100
while P > 0:
    a = 0
    for x in X:
        a += (x - P) ** 2
    ans = min(ans, a)
    P -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
sum = 0
for xi in range(len(x)):
    sum += (x[xi] - n ) ** 2
print(sum)

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int, input().split()))
res = 1e9
while n > 0:
    r = 0
    for i in li:
        r += (i - n)**2
    res = min(res, r)
    n -= 1
print(res)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    x = LI()
    ans = 0
    if n % 2 == 0:
        p = sum(x)//n
    else:
        p = sum(x)//n + 1
    for i in range(n):
        ans += ((x[i]-p)**2)
    print(ans)
    return


# Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3 ## -*- python -*-
import sys

n = int(input())
x = []
for c in input().split():
  x.append(int(c))
print(x)
a = sys.maxsize
for i in range(min(x), max(x)):
    c = 0
    for j in x:
        c = c + (j-i) * (j-i)
    a = min([a, c])
print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
max_x = max(x)
ans = 100000000
for i in range( max_x ):
  a = 0
  for j in x:
    a += ( j - i ) ** 2
  ans = min( a, ans )
  
print( ans )

Submission status: Wrong Answer

Solution code:
n  = int(input())
x = list(map(int, input().split(" ")))

min_x = min(x)
max_x = max(x)

power = []
for i in range(100):
    power.append(i*i)

result = 999999
for i in range(min_x, max_x):
    count = 0
    for j in range(n):
        count = count + power[abs(i - x[j])]
    if(result > count):
        result = count

print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, X: "List[int]"):
    X.sort()
    m = 10000000
    for p in range(X[0], X[-1]):
        s = 0
        for x in X:
            s += (x - p) ** 2
        if s < m:
            m = s

    print(m)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# input
N = int(input())
X = list(map(int, input().split()))

# process/output
if N == 1:
    print(X[0])

else:
    L = min(X)
    R = max(X)

    ans = 10000
    for i in range(L, R+1):
        cost = 0
        for x in X:
            cost += (x-i)**2
        
        if cost < ans:
            ans = cost

    print(ans)

Submission status: Wrong Answer

Solution code:
# input
N = int(input())
X = list(map(int, input().split()))

# process
L = min(X)
R = max(X)

ans = 10000
for i in range(L, R):
    cost = 0
    for x in X:
        cost += (x-i)**2
    
    if cost < ans:
        ans = cost

# output
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    xlist = list(map(int, input().split()))
    x_min = min(xlist)
    x_max = max(xlist)
    min_sum_value = 10**15
    
    for p in range(x_min, x_max, 1):
        c = 0
        for i in xlist:
            c += (i - p) ** 2
        if min_sum_value > c:
            min_sum_value = c
    print(min_sum_value)

main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    xlist = list(map(int, input().split()))
    x_min = min(xlist)
    x_max = max(xlist)
    min_sum_value = 10000000
    
    for p in range(x_min, x_max, 1):
        c = 0
        for i in xlist:
            c += (i - p) ** 2
        if min_sum_value > c:
            min_sum_value = c
    print(min_sum_value)

main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    xlist = list(map(int, input().split()))
    x_min = min(xlist)
    x_max = max(xlist)
    min_sum_value = 10000000
    
    for p in range(x_max, x_min, 1):
        c = 0
        for i in xlist:
            c += (i - p) ** 2
        if min_sum_value > c:
            min_sum_value = c
    print(min_sum_value)
main()

Submission status: Wrong Answer

Solution code:
# 入力処理
N = int(input())
X_list = [int(x) for x in input().split() ]
ans = 10000
# P を 1から100まで全ケース試す。
for p in range(1,101):
  temp = 0
  for x in X_list:
    temp += (x-p)**2
  ans = min(ans, temp)

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    x = list(map(int, input().split()))
    
    ans_tmp = 10000000000000
    for j in range(n):
        ans = 0
        for i in range(n):
            ans += (x[i]-(j+1))**2

        if ans_tmp >= ans:
            ans_tmp = ans
    
    print(ans_tmp)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

ans = 99999999

for p in range(1, len(x)+1):
    c = 0
    for j in range(len(x)):
        c += (x[j] - p) ** 2
    
    ans = min(ans ,c)
    
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
X = list(map(int, input().split()))
# n, k = map(int, input().split())
p = math.ceil(sum(X)/n)
ans = 0
for i in range(n):
    ans += (p-X[i])**2
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
X = list(map(int, input().split()))
# n, k = 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))

Submission status: Wrong Answer

Solution code:
N=int(input())
X=list(map(int,input().split(" ")))
P=X[0]
L=X[N-1]
sum1=0
for i in range(N):
  sum1+=(X[i]-P)*(X[i]-P)
while P!=L:
  sum2=0
  for i in range(N):
    sum2+=(X[i]-P-1)*(X[i]-P-1)
  if sum2<sum1:
    sum1=sum2
  P+=1
print(sum1)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=list(map(int,input().split(" ")))
P=X[0]
L=X[N-1]
sum1=0
for i in range(N):
  sum1+=(X[i]-P)*(X[i]-P)
sum2=0
for i in range(N):
  sum2+=(X[i]-P-1)*(X[i]-P-1)
while sum1>=sum2:
  P+=1
  sum1=0
  sum2=0
  for i in range(N):
    sum1+=(X[i]-P)*(X[i]-P)
  for i in range(N):
    sum2+=(X[i]-P-1)*(X[i]-P-1)
for i in range(N):
  sum2+=(X[i]-L)*(X[i]-L)
if sum1<sum2:
  print(sum1)
else:
  print(sum2)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=list(map(int,input().split(" ")))
P=X[0]
L=X[N-1]
sum1=0
for i in range(N):
  sum1+=(X[i]-P)*(X[i]-P)
sum2=0
for i in range(N):
  sum2+=(X[i]-P-1)*(X[i]-P-1)
while sum1>=sum2:
  P+=1
  sum1=0
  sum2=0
  for i in range(N):
    sum1+=(X[i]-P)*(X[i]-P)
  for i in range(N):
    sum2+=(X[i]-P-1)*(X[i]-P-1)
print(sum1)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=list(map(int,input().split(" ")))
P=X[0]
L=X[N-1]
sum1=0
for i in range(N):
  sum1+=(X[i]-P)*(X[i]-P)
sum2=0
for i in range(N):
  sum2+=(X[i]-P-1)*(X[i]-P-1)
while sum1>sum2:
  P+=1
  sum1=0
  sum2=0
  for i in range(N):
    sum1+=(X[i]-P)*(X[i]-P)
  for i in range(N):
    sum2+=(X[i]-P-1)*(X[i]-P-1)
print(sum1)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.fromstring(input(), dtype=np.int64, sep=" ")
result = int(np.ceil(a.var()*n))
print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
ylist = list(map(int,input().split()))
p = list(range(0,max(ylist)//2+3))
anslist = []
for i in p:
  ansl = sum((p[i]-ylist[j])**2 for j in range(0,n))
  anslist.append(ansl)
print(min(anslist))

Submission status: Wrong Answer

Solution code:
n = int(input())
ylist = list(map(int,input().split()))
p = sum(ylist)/n
print(int(sum([(ylist[i]-p)**2 for i in range(0,n) ])+1))

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
# 最小二乗法とやってること同じなので平均で最小になると考えて
P = sum(X) // N
ans = 0
for x in X:
    ans += (x - P)**2
print(ans)

Submission status: Wrong Answer

Solution code:
##input##
N = int(input())
num = input().split()
max_num =max(num)
temp = []
##

for i in range(int(max_num)):
  sum = 0
  for a in num:
    out = (i - int(a))** 2
    sum += out
  temp.append(sum)
#print(temp)
min_temp=min(temp)
print(min_temp)

Submission status: Wrong Answer

Solution code:
N = int(input())
num = input().split()
#print(num)
sum = 0

for i in num:
  sum = sum + int(i)

##print(sum)
ave = sum / N
ave_int = sum // N
##print(ave)
##print(ave_int)

if ave_int - ave >= 0.5:
  out = ave_int +1
else:
  out = ave_int

temp = 0
out_sum = 0

for i in num:
  temp = (out - int(i)) **2
  out_sum += temp

print(out_sum)

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
#156_c
n = int(input())
x_lis = [int(x) for x in input().split()]
 

s = []
for pos in range(min(x_lis),max(x_lis)+1):

    tir = []
    for x in x_lis:
        tir.append((x - pos)**2)
    s.append(sum(tir))
print(s)
        

print(min(s))

Submission status: Wrong Answer

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

ans = []
count = 0

for i in range(0,101):
    number = 0
    count = 0
    for j in X:
        number = number + ((j-i)**2)
        count = count + 1
        if N == count:
            ans.append(number)

print(ans)

Submission status: Wrong Answer

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

ans = []
count = 0

for i in range(1,N+1):
    number = 0
    count = 0
    for j in X:
        number = number + ((j-i)**2)
        count = count + 1
        if N == count:
            ans.append(number)

print(min(ans))

Submission status: Wrong Answer

Solution code:
N = 2
X = [1,4]

ans = []
count = 0

for i in range(1,N+1):
    number = 0
    count = 0
    for j in X:
        number = number + ((j-i)**2)
        count = count + 1
        if N == count:
            ans.append(number)

print(min(ans))

Submission status: Wrong Answer

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

ans = []
count = 0

for i in range(1,N+1):
    number = 0
    count = 0
    for j in X:
        number = number + ((j-i)**2)
        count = count + 1
        if N == count:
            ans.append(number)

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, X: "List[int]"):
    X.sort()
    sum=0
    for i in X:
        sum+=i**2
    tempsum=0
    for p in range(X[0],X[N-1]):
        temp=0
        for j in range(N):
            temp+=p**2-2*p*X[j]
        tempsum=min(tempsum,temp)
    print(sum+tempsum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
ans = 10000
x.sort()
for p in range(x[0],x[-1]):
    sum = 0
    for i in range(n):
        sum += (x[i]-p)**2
    ans = min(ans,sum)   
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=list(map(int,input().split()))
m=1000000
for i in range(n):
    su=0
    for j in range(n):
        su+=(x[j]-i-1)**2
    if m>su:
        m=su
print(su)

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    
    ans = 10 ** 9
    for i in range(A[0], A[-1]):
        c = 0
        for a in A:
            c += (abs(a-i)) ** 2
        ans = min(ans, c)
        
    return ans

print(solve())

Submission status: Wrong Answer

Solution code:
a = int(input())
li = input().split()
c = 0
n = 0
while n < a:
	b = (int(li[n]) - a) ** 2
	c += b
	n += 1
print(c)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
m = 10**20
for p in range(x[0],x[n-1]+1):
    power = 0
    for i in range(n):
        power += (x[i]-p)**2
    m = min(m,power)
print(m)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
m = 10**10
for p in range(x[0],x[n-1]+1):
    power = 0
    for i in range(n):
        power += (x[i]-p)**2
    m = min(m,power)
print(m)

Submission status: Wrong Answer

Solution code:
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)]))

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    x_line = list(map(int, input().split(' ')))
    max_x = max(x_line)
    min_x = min(x_line)
    result = 10000
    for i in range(min_x, max_x + 1):
        hash_result = 0
        for x in x_line:
            hash_result += (x - i) ** 2
        if hash_result < result:
            result = hash_result
    print(result)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[i for i in map(int, input().split())]
ans=1000000000000000000000000000000000000000
x.sort()

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

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[i for i in map(int, input().split())]
ans=1000000000000000000000000000000000000000
x.sort()
print(n,x)

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

Submission status: Wrong Answer

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

ans = 100000
for i in range(min(X), max(X) + 1):
    tmp_ans = 0
    for j in range(N):
        tmp_ans += (X[j] - i) ** 2 
    ans = min(ans, tmp_ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [int(a) for a in input().split()]
ans = 0
for i in range(1,101):
    res = 0
    for j in x:
        res += (j-i)**2
    if ans==0:
        ans = res
    elif ans > res:
        ans = res
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [int(a) for a in input().split()]
ans = 0
for i in range(101):
    res = 0
    for j in x:
        res += (j-i)**2
    if ans==0:
        ans = res
    elif ans > res:
        ans = res
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math

n=int(input())
x=[int(k) for k in input().split()]

p=math.ceil(sum(x)/n)

ans=0
 
for i in x:
  ans+=(p-i)**2
  
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math

n=int(input())
x=[int(k) for k in input().split()]

p=sum(x)/n

ans=0
for i in x:
  ans+=(p-i)**2
  
print(math.ceil(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
X= [int(i) for i in input().split()]
X.sort()

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

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [int(i) for i in input().split()]
x.sort()

ans = 10000
for p in range(1,101):
  sum =0
  for i in range(n):
    sum += (x[i]-p)**2
    
  ans = min(ans,sum)
  
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [int(i) for i in input().split()]
x.sort()

ans = 10000
for p in range(1,x[-1]*2):
  sum =0
  for i in range(n):
    sum += (x[i]-p)**2
    
  ans = min(ans,sum)
  
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [int(i) for i in input().split()]
x.sort()

ans = 10000
for p in range(1,x[-1]+1):
  sum =0
  for i in range(n):
    sum += (x[i]-p)**2
    
  ans = min(ans,sum)
  
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [int(i) for i in input().split()]
x.sort()

ans = 10000

for p in range(x[-1]):
  sum =0
  for i in range(n):
    sum += (x[i]-p)**2
    
  ans = min(ans,sum)
  
  
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
p = int((min(x) + (max(x) - min(x)) / 2))
ans = [i - p for i in x]
ans = [i ** 2 for i in ans]
print(sum(ans))

Submission status: Wrong Answer

Solution code:
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()

Submission status: Wrong Answer

Solution code:
N=int(input())
X=list(map(int, input().split()))
sum=sum(X)
ave=int(sum/N)+1
Y=0
for i in X:
	Y+=(i-ave)**2
print(Y)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
min = 10000

for p in range(101):
    sum = 0
    for i in range(n):
        sum = sum + (x[i] - p)**2
    if  sum < min:
        min = sum

print(min)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
min = 10000

for p in range(100):
    sum = 0
    for i in range(n):
        sum = sum + (x[i] - p)**2
    if  sum < min:
        min = sum

print(min)

Submission status: Wrong Answer

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

ans = 100 * 100
for i in range(101):
    power = 0
    for e in x:
        power += (e - i) ** 2

    ans = min(ans, power)

print(ans)