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


# while i <= max(x):
for i in range(min(x),max(x)+1,1):
    tmp = sum(map(lambda p: (p-i)**2,x))
    if ans > tmp:
        ans = tmp
    
print(ans)

import sys

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


# while i <= max(x):
for i in range(min(x),max(x)+1,1):
    tmp = sum(map(lambda p: (p-i)**2,x))
    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):
x = list(map(int,input().split()))
ans = []
if len(set(x)) == 1:
    print(0)
else: 
    for p in range(min(x), max(x)):
        meter = 0
        for xi in x:
            meter += pow((xi-p),2)
        ans.append(meter)
    print(min(ans))

n = int(input())
x = list(map(int,input().split()))
ans = []
if len(set(x)) == 1:
    print(0)
else: 
    for p in range(min(x), max(x)):
        meter = 0
        for xi in x:
            meter += pow((xi-p),2)
        ans.append(meter)
    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):
# input
N = int(input())
X = list(map(int, input().split()))

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

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

print(ans)


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

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

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

# output
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().split()))
ans = 0

for i in range(1,101):
  tmp = 0
  for x in X:
    if i == 1:
      ans += (i - x)**2
    else:
      tmp += (i - x)**2
      if tmp < ans:
        ans = tmp
    
print(ans)

n = int(input())
xl = list(map(int, input().split()))
ans = 0
for x in xl:
  ans += (x-1)**2

for i in range(2, 101):
  tmp = 0
  for x in xl:
    tmp += (x-i)**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):
n=int(input())
l=list(map(int,input().split()))
lmax=0
for i in range(n):
    if lmax<l[i]:
        lmax=l[i]
sumlist=[]

for i in range(lmax):
    sumlist.append(0)
total=0
for i in range(lmax):
    for j in range(n):
        t=(l[j]-i)*(l[j]-i)
        total+=t
    sumlist[i]=total
    total=0
print(sumlist)
min=99999999999999999999999999999999999
for i in range(lmax):
    if min>sumlist[i]:
        min=sumlist[i]
print(min)

n=int(input())
l=list(map(int,input().split()))
lmax=0
for i in range(n):
    if lmax<l[i]:
        lmax=l[i]
sumlist=[]
for i in range(lmax):
    sumlist.append(0)
total=0
for i in range(lmax):
    for j in range(n):
        t=(l[j]-(i+1))*(l[j]-(i+1))
        total+=t
    sumlist[i]=total
    total=0
min=10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
for i in range(lmax):
    if min>sumlist[i]:
        min=sumlist[i]
print(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):
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()




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(100):
        c = 0
        for i in xlist:
            c += (i - p) ** 2
        if min_sum_value > c:
            min_sum_value = c
    print(min_sum_value)

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

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

a = []
for pp in 100:
    sum = 0
    for xx in x:
        sum += abs((xx-pp) ** 2)
    a.append(sum)

print(min(a))



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

a = []
for pp in range(1,101):
    sum = 0
    for xx in x:
        sum += abs((xx-pp) ** 2)
    a.append(sum)

print(min(a))


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

sum_list = []
for i in range(min(x), max(x)):
    sum = 0
    for j in x:
        sum += (x[i] - x[j]) ** 2
    sum_list.append(sum)
    
print(min(sum_list))
    

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

sum_list = []
for i in range(1, 100):
    sum = 0
    for j in x:
        sum += (i - j) ** 2
    sum_list.append(sum)

print(min(sum_list))


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= list(input().split())
ans=[]
for i in range(1,100):
    tairyoku = 0
    for j in N[1:]:
        tairyoku += (int(j) - int(i))**2
    ans.append(tairyoku)
print(min(ans))

#!/usr/bin/env python3
# %%
stdin = open(0)
import numpy as np
 
# %%
data = np.fromstring(stdin.read(), np.int64, sep=' ')
 
# %%
X = data[1:]
costs = []
for p in range(101):
    costs.append(np.sum((X-p)**2))
 
# %%
answer = min(costs)
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 mean(x):
    sum=0
    for _ in x:
        sum+=_
    return sum/len(x)

def rss(x,xbar):
    sum=0
    for _ in x:
        sum+=(_-xbar)**2
    return sum

def main(n,x):
    ans=0
    xbar=mean(x)
    xbar_int=xbar//1
    if(xbar-xbar_int >0.5):
        xbar_int+=1
    ans=rss(x,xbar_int)
    return int(ans)

def main2(n,x):
    xmin=min(x)
    xmax=max(x)
    minsum=1000000

    for p in range(xmin,xmax+1):
        sum=0
        for xx in x:
            sum+=(xx-p)**2
        if(sum<minsum):
            minsum=sum

    return minsum

if __name__=='__main__':
    n,x=readinput()
    ans=main(n,x)
    print(ans)

def readinput():
    n=int(input())
    x=list(map(int,input().split()))
    return n,x

def mean(x):
    sum=0
    for _ in x:
        sum+=_
    return sum/len(x)

def rss(x,xbar):
    sum=0
    for _ in x:
        sum+=(_-xbar)**2
    return sum

def main(n,x):
    ans=0
    xbar=mean(x)
    xbar_int=xbar//1
    if(xbar-xbar_int >0.5):
        xbar_int+=1
    ans=rss(x,xbar_int)
    return int(ans)

def main2(n,x):
    xmin=min(x)
    xmax=max(x)
    minsum=1000000

    for p in range(xmin,xmax+1):
        sum=0
        for xx in x:
            sum+=(xx-p)**2
        if(sum<minsum):
            minsum=sum

    return minsum

if __name__=='__main__':
    n,x=readinput()
    ans=main(n,x)
    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())
C=list(map(int,input().split()))
Cmin,Cmax = min(C),max(C)
Sums=[]
for i in range(Cmin,Cmax+1):
  for j in range(len(C)):
    Sums.append((C[j]-i)^2)
print(min(Sums))
    

import math
N=int(input())
C=list(map(int,input().split()))
ave = sum(C) / len(C)
X=math.floor(ave)
Y=X+1
Xsum,Ysum=0,0
for i in range(len(C)):
  Xsum += (C[i]-X)**2
  Ysum += (C[i]-Y)**2
print(min([Xsum,Ysum]))

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 
read = sys.stdin.buffer.read
N,*X = map(int,read().split())
s = sum(X)
res = [(x-s)**2 for x in X]
print(sum(res))

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def main():
    N, *X = map(int, read().split())
    s = round(sum(X)/len(X))
    res = [(x - s) ** 2 for x in X]
    print(sum(res))
    
    return

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

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)

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

t=1000000007

def mod(k):
    return k%t

def comb(n,k,p):
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

base=power_func(2,n,t)
    
print(mod(2*t+base-1-comb(n,a,t)-comb(n,b,t)))

N=int(input())
A=list(map(int,input().split()))
sum=0
for i in range(N):
    sum = sum+A[i]
ans = 0
if sum%N <= N//2:
    for i in range(N):
        ans = ans+ (A[i]-(sum//N))**2
    print(ans)
else:
    for i in range(N):
        ans = ans+ (A[i]-1-(sum//N))**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()))
x.sort()
ans=float("Inf")
for i in range(x[0],x[n-1]+1):
  print(i)
  cal=0
  for j in range(0,n):
    cal=cal+(x[j]-temp)**2
  ans=min(ans,cal)
print(ans)

n=int(input())
x=list(map(int,input().split()))
x.sort()
ans=float("Inf")
for i in range(x[0],x[n-1]+1):
  temp=i
  cal=0
  for j in range(0,n):
    cal=cal+(x[j]-temp)**2
  ans=min(ans,cal)
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
n=int(input())
x=list(map(int, input().split()))

s = sum(x)
N = len(x)
mean = s / N
mean = math.ceil(mean)
r = 0

print(mean)

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

print(r)

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

s = sum(x)
N = len(x)
mean = s / N
a = math.floor(mean)
b = math.ceil(mean)
ra = 0
rb = 0

for i in range(n):
    ra = ra + (x[i] - a) * (x[i] - a)

for i in range(n):
    rb = rb + (x[i] - b) * (x[i] - b)

if ra < rb:
    print(ra)
else:
    print(rb)

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 math

N = int(input())
XXX = input().split()

xList = []
for i in XXX:
  xList.append(int(i))

dList = []
P = 0
while P < xList[-1]:
  D = 0
  for xi in xList:
    D += (xi - P)*(xi - P)
  dList.append(D)
  P +=1

result = dList.index(min(dList))

print(result)




N = int(input())
XXX = input().split()

xList = []
for i in XXX:
  xList.append(int(i))

dList = []
for P in range(0,max(xList)+1):
  D = 0
  for xi in xList:
    D += (xi - P)*(xi - P)
  dList.append(D)

result = min(dList)

print(result)

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()))
s=0
sum=0
for i in X:
    sum+=i

sum=round(sum/len(X),0)
for i in X:
    tmp=(i-sum)**2
    s=s+tmp
print(s)


N=int(input())
X=list(map(int,input().split()))
s=0
sum=0
for i in X:
    sum+=i

sum=round(sum/len(X),0)
print(sum)
for i in X:
    tmp=(i-sum)**2
    s=s+tmp
print(s)


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

print(sum)


N=int(input())
X=list(map(int,input().split()))
s=0
sum=0
for i in X:
    sum+=i

sum=round(sum/len(X))

for i in X:
    tmp=(i-sum)**2
    s+=tmp
print(s)


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())
xs=list(map(int,input().split()))
p=sum(xs)//n
print(p)
hp,hq=0,0
for i in xs:
    hp+=(i-p)**2
    hq+=(i-p-1)**2
print(min(hp,hq))

n=int(input())
xs=list(map(int,input().split()))
p=sum(xs)//n
hp,hq=0,0
for i in xs:
    hp+=(i-p)**2
    hq+=(i-p-1)**2
print(min(hp,hq))

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
n = int(input())
x = input().split()
x = np.array(x,dtype='int')
m = x.sum()
v = (x**2).sum()
pm = int(np.round(m/n))
n * pm**2 - 2*pm*m + v

import numpy as np
n = int(input())
x = input().split()
x = np.array(x,dtype='int')
m = x.sum()
v = (x**2).sum()
pm = int(np.round(m/n))
print(n * pm**2 - 2*pm*m + v)

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 = []

for i in range(min(X),max(X)+1):
    ans.append(cnt)
    cnt = 0
    for j in X:
        cnt += (j-i)**2
    #ans.append(cnt)
        
print(min(ans))            
        

N = int(input())
X = list(map(int,input().split()))
ans = []
for i in range(min(X),max(X)+1):
    cnt = 0
    for j in X:
        cnt += (j-i)**2
    ans.append(cnt)
        
print(min(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 = input().split()
x = [int(_x) for _x in x]

_p = sum(x) // n

_p_value = sum([(_x - _p) ** 2 for _x in x]) / n
__p_value = sum([(_x - _p + 1) ** 2 for _x in x]) / n

if _p_value > __p_value:
  print(__p_value)
else:
  print(_p_value)

n = int(input())
 
x = input().split()
x = [int(_x) for _x in x]
 
_p = sum(x) // n
 
_p_value = sum([(_x - _p) ** 2 for _x in x])
__p_value = sum([(_x - _p + 1) ** 2 for _x in x])
___p_value = sum([(_x - _p - 1) ** 2 for _x in x])
 
print(min(_p_value, min(__p_value, ___p_value)))


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**100
for i in range(1,101):
  count = 0
  for j in X:
    count += (i-j)*2
  ans = min(ans,count)
print(ans)


n = int(input())
X = list(map(int,input().split)())
ans = 10**100
for i in range(1,101):
  count = 0
  for j in X:
    count += (i-j)*2
  ans = min(ans,count)
print(ans)

n = int(input())
X = list(map(int,input().split()))
ans = 10**100
for i in range(1,101):
  count = 0
  for j in X:
    count += (i-j)**2
  ans = min(ans,count)
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):
import sys

def main():

    input = sys.stdin.buffer.readline
    n = int(input())
    x = list(map(int, input().split()))
    x.sort()
    mt = 10**10
    print(x)
    for ii in range(x[0],x[-1]+1):
        ans = 0
        for i in x:
            ans += (i-ii)**2
        mt = min(mt,ans)
    print(mt)    
    
if __name__ == "__main__":
    main()
    


import sys

def main():

    input = sys.stdin.buffer.readline
    n = int(input())
    x = list(map(int, input().split()))
    x.sort()
    mt = 10**10
    for ii in range(x[0],x[-1]+1):
        ans = 0
        for i in x:
            ans += (i-ii)**2
        mt = min(mt,ans)
    print(mt)    
    
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):
import numpy as np
import collections
from sys import stdin


def get_result(data):
    N, X = data[0][0], data[1:][0]
    X = np.array(X)
    max_X = max(X)
    tmp = np.zeros(max_X)
    for i in range(max_X):
        tmp[i] = np.sum((X - i) ** 2)
    return min(tmp)

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


import numpy as np
import collections
from sys import stdin


def get_result(data):
    N, X = data[0][0], data[1:][0]
    X = np.array(X)
    max_X = max(X)
    tmp = np.zeros(max_X + 1)
    for i in range(max_X + 1):
        tmp[i] = np.sum((X - i) ** 2)
    return int(min(tmp))

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


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(x) for x in input().split()]
print(x)
center = sum(x)//len(x)
center2 = center+1
ans, ans2 =0, 0
for i in x:
    ans += (i-center)**2
    ans2 += (i-center2)**2

print(ans) if ans<ans2 else print(ans2)


n = int(input())
x = [int(x) for x in input().split()]
center = sum(x)//len(x)
center2 = center+1
ans, ans2 =0, 0
for i in x:
    ans += (i-center)**2
    ans2 += (i-center2)**2

print(ans) if ans<ans2 else print(ans2)

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 math

n, a, b=map(int, input().split())
mod = 10**9+7

L=[math.factorial(n) % mod // (math.factorial(n - i) % mod * math.factorial(i) % mod) for i in range(1,n+1) if i != a if i != b]
print(sum(L) % mod)

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

num=sum(X)/N
num1=math.floor(num)
num2=math.ceil(num)

R1=[(X[i]-num1)**2 for i in range(N)]
R2=[(X[i]-num2)**2 for i in range(N)]
print(min(sum(R1),sum(R2)))

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 = float('inf')

for i in range(min(X, 1), max(X, 100) + 1):
    tmp = 0
    for x in X:
        tmp += (i - x) ** 2

    res = min(tmp, res)

print(res)

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

res = float('inf')

for i in range(min(X), max(X)+1):
    tmp = 0
    for x in X:
        tmp += (i - x) ** 2

    res = min(tmp, res)

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()))
mean = X.sum()/N
ans = 0 
for i in range(N):
  ans += (X[i] - mean)**2
  
print(ans)




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

print(ans)

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




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

Verdicts: Runtime Error

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):
def resolve():
    n = int(input())
    x_list = list(map(int, input().split()))
    mn =　10**9
    for i in range(1, max(x_list)+1):
        sm = 0
        for x in x_list:
            sm += (x-i)**2
        if mn > sm:
            mn = sm  
    print(mn)
resolve()

def resolve():
    n = int(input())
    x_list = list(map(int, input().split()))
    mn =　10**6
    for i in range(1, max(x_list)+1):
        sm = 0
        for x in x_list:
            sm += (x-i)**2
        if mn > sm:
            mn = sm  
    print(mn)
resolve()

def resolve():
    n = int(input())
    x_list = list(map(int, input().split()))
    mn = 10**9
    for i in range(1, max(x_list)+1):
        sm = 0
        for x in x_list:
            sm += (x-i)**2
        if mn > sm:
            mn = sm  
    print(mn)
resolve()


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):
import numpy as np
def IsDistributionBiased_Smaller (sortedarr,P):
    _ndarr=np.array(sortedarr)
    smallarr=np.where(_ndarr<=P)
    if len(smallarr) > len (sortedarr)//2:
        return True
    else:
        return False

def WorkloadCalculation(arr,P):
    D=0
    for a in range(len(arr)):
        d=abs(arr[a]-P)
        D += d**2
    return D

N=int(input())
Xlist=[]
X=input().split()
for x in X:
    _x=int(x)
    Xlist.append(_x)

Xlist.sort()
P=(Xlist[0]+Xlist[-1])//2

workload=10000000
STOPflg=False
    
if IsDistributionBiased_Smaller(Xlist,P) ==True:
    while STOPflg==False:
        print(P)
        _wl=WorkloadCalculation(Xlist,P)
        if _wl < workload:
            workload=_wl
            P+=1
        else:
            STOPflg=True
            exit()
else:
    while STOPflg==False:
        print(P)
        _wl=WorkloadCalculation(Xlist,P)
        if _wl < workload:
            workload=_wl
            P-=1
        else:
            STOPflg=True
            exit()
print(workload)

def WorkloadCalculation(arr,P):
    D=0
    for a in range(len(arr)):
        d=abs(arr[a]-P)
        D += d**2
    return D

N=int(input())
Xlist=[]
X=input().split()
for x in X:
    _x=int(x)
    Xlist.append(_x)

Xlist.sort()
P=Xlist[0]

workload=10000000
STOPflg=False
    
while STOPflg==False:
    _wl=WorkloadCalculation(Xlist,P)
    if _wl < workload:
        workload=_wl
        P+=1
    else:
        print(workload)
        STOPflg=True
        exit()
        
print(workload)

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

if N%2==0:
    av = sum(X)/N
else:
    av = (sum(X)/N)+1
    
total = 0

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

print(total)

N = int(input())
X = list(map(int, input().split()))
total = 0
p = []
for i in range(min(X),max(X)+1):
    for j in X:
        total += (i-j)**2
    p.append(total)
    total = 0

print(min(p))

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):
#2
N = int(input())
an = list(map(int,input().split()))
Min = 10**10

for i in range(1,102):
    k = 0
    for j in an:
        k += (j-i)**2
    print(k)
    if Min >k:
        Min = k
        
print(Min)
        

#2
N = int(input())
an = list(map(int,input().split()))
Min = 10**10

for i in range(1,102):
    k = 0
    for j in an:
        k += (j-i)**2
    if Min >k:
        Min = k
        
print(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):
import math


def inp():
    return(int(input()))


def invr():
    return(map(int, input().split()))


n = inp()
arr = invr()
arr = sorted(arr)
max = arr[n-1]
min = arr[0]

cost = 100000000000
print(cost)
for p in range(min, max+1):
    temp_cost = 0
    for xi in arr:
        temp_cost += (xi-p)**2
    if temp_cost < cost:
        cost = temp_cost
print(cost)


import math


def inp():
    return(int(input()))


def invr():
    return(map(int, input().split()))


n = inp()
arr = invr()
arr = sorted(arr)
max = arr[n-1]
min = arr[0]

cost = 100000000000
for p in range(min, max+1):
    temp_cost = 0
    for xi in arr:
        temp_cost += (xi-p)**2
    if temp_cost < cost:
        cost = temp_cost
print(cost)


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

l = min(x)
r = max(x)
ans = 100 ** 3
for i in range(l, r + 1):
    vit = sum(abs(xi - i) ** 2 for xi in x)
    print(i, vit)
    ans = min(ans, vit)
print(ans)


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

l = min(x)
r = max(x)
ans = 100 ** 3
for i in range(l, r + 1):
    vit = sum(abs(xi - i) ** 2 for xi in x)
    ans = min(ans, vit)
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 calc(X, p):
  ans = 0
  for x in X:
    ans += (x-p)**2   
  print(ans)
  
n = int(input())
X = list(map(int, input().split()))

p = np.mean(X)
p1 = np.floor(p)
p2 = np.ceil(p)

if p <= p1 + 0.5:
  calc(X, p1)
else:
  calc(X, p2)

import numpy as np

def calc(X, p):
  ans = 0
  for x in X:
    ans += (x-p)**2   
  print(int(ans))
  
n = int(input())
X = list(map(int, input().split()))

p = np.mean(X)
p1 = np.floor(p)
p2 = np.ceil(p)

if p <= p1 + 0.5:
  calc(X, p1)
else:
  calc(X, p2)

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)
m=[]
for i in x:
  m.append((x-m)**2)
print(sum(m))

n=int(input())
x=list(map(int,input().split()))
p=round(sum(x)/n)
m=[]
for i in x:
  m.append((i-m)**2)
print(sum(m))

n=int(input())
x=list(map(int,input().split()))
p=round(sum(x)/n)
m=[]
for i in x:
  m.append((i-p)**2)
print(sum(m))

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

hp = [0 for i in range(101)]
for i in range(101):
    for j, x in enumerate(X):
        hp[i] = hp[i] + (x-(i+1))**2

print(hp)
print(min(hp))



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

hp = [0 for i in range(101)]
for i in range(101):
    for j, x in enumerate(X):
        hp[i] = hp[i] + (x-(i+1))**2

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

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):
N=int(input())
X=list(map(int,input().split()))
E=[]
e=0
for i in range(min(X),max(X)+1):
    for j in range(len(X)):
        e+=(X[j]-i)**2
    E.append(e)
    e=0
print(E)
print(min(E))
        

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

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):
in = input().split(' ')
in = list(map(int, in))
in.pop(0)

P = round(sum(in)/len(in))

sum = 0
for i in range(len(in)):
  sum += (in[i] - P)**2
  
print(sum)

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

P = round(sum(in)/N)

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

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

P = round(sum(numbers)/N)

sum = 0
for i in range(N):
  sum += (numbers[i] - P)**2

print(sum)

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

v_min = 10 ** 18
m = min( X )
M = max( X )
for i in range( m, M + 1):
  v = 0
  for x in X:
    x += ( i - x ) ** 2
  v_min = min( v, v_min )
print( v_min )
  



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

m = min( X )
M = max( X )

v_min = 10 ** 18
for i in range( m , M + 1 ):
  v = 0
  for x in X:
    v += ( x - i ) **2
  v_min = min( v, v_min )
print( v_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()))

for i in range(N):
  for j in range(1,101):
    print(min(sum(j-x[i])**2))


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

s = sum(X)
l = len(X)
ave = s/l

if ave - float(int(ave)) <= 0.5:
  avei = int(s/l)
else:
  avei = int(s/l) + 1

ans = 0
for i in range(N):
  ans += (X[i] - avei)**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):
b = input()
a = input().split()
for i in range(len(a)):
    a[i] = int(a[i])

best = None

for i in range(len(a)):
    a[i] = a[i] + 1

for i in range(100):
    for j in range(len(a)):
        a[j] = a[j] - 1
    s = sum(a)**2
    if best is None or s < best:
        best = s

print(best)

b = input()
a = input().split()
for i in range(len(a)):
    a[i] = int(a[i])

best = 10000000
besti = None

for i in range(len(a)):
    a[i] = a[i] + 1

for i in range(100):
    for j in range(len(a)):
        a[j] = a[j] - 1
    s = sum(a)**2
    print(s)
    if s < best:
        best = s
        besti = i

print(besti)

b = input()
a = input().split()
for i in range(len(a)):
    a[i] = int(a[i])

best = None
besti = None

for i in range(len(a)):
    a[i] = a[i] + 1

for i in range(100):
    for j in range(len(a)):
        a[j] = a[j] - 1
    s = sum(a)**2
    if best is None or s < best:
        best = s
        besti = i

print(besti)

b = int(input())
a = input().split()
for i in range(len(a)):
    a[i] = int(a[i])

a2 = a.copy()

best = None

for i in range(len(a)):
    a[i] = a[i] + 1

for i in range(100):
    x = [0] * b
    for j in range(len(a)):
        a[j] = a[j] - 1
        x[j] = a[j]**2
    s = sum(x)
    if best is None or s < best:
        best = s

print(best)

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):
import numpy as np
n=int(input())
x=np.fromstring(input(),int,sep=' ')
print(x)
p=0
hoge=np.inf
for i in range(1,np.max(x)+1):
    sux=sum((x-i)**2)
    if sux<hoge:
        p=i
        hoge=sux
print(hoge)

import numpy as np
n=int(input())
x=np.fromstring(input(),int,sep=' ')
p=0
hoge=np.inf
for i in range(1,np.max(x)+1):
    sux=sum((x-i)**2)
    if sux<hoge:
        p=i
        hoge=sux
print(hoge)

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

s=min(l)
g=max(l)
ans=0
for k in range (n):
  ans+=(l[k]-s)**2

for i in range(s+1,g+1):
  hyp=0
  for j in range (n):
    hyp+=(l[j]-i)**2
  if hyp<ans:
    ans=hyp
    
print (ans)

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

s=min(l)
g=max(l)
ans=0
for k in range (n):
  ans+=(l[k]-s)**2

for i in range(s+1,g+1):
  hyp=0
  for j in range (n):
    hyp+=(l[j]-i)**2
  if hyp<ans:
    ans=hyp
    
print (ans)

Verdicts: Runtime Error

Accepted