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

Submission attempts (in order):
import statistics
n=int(input())
x=[int(_) for _ in input().split()]
mid=int(statistics.mean(x))
mmid=mid-1
cnt=0
cntm=0
for i in range(len(x)):
  cnt+= (x[i]-mid)**2
  cntm+=(x[i]-mmid)**2
print(min(cnt,cntm,cntp))
  

import statistics
n=int(input())
x=[int(_) for _ in input().split()]
mid=int(statistics.mean(x))
mmid=mid-1
pmid=mid+1
cnt=0
cntm=0
cntp=0
for i in range(len(x)):
  cnt+= (x[i]-mid)**2
  cntm+=(x[i]-mmid)**2
  cntp+=(x[i]-pmid)**2
print(min(cnt,cntm,cntp))
  


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


def num(N,X):
    number = 0
    for x in X:
        num = x-N

        num2 = num**2

        number += num2

    return number
    
kekka = str(num(N,X))
print(kekka)
    

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

def num(N,X):
    number = 0
    for x in X:
        num = x-N
        #print(str(num))
        num2 = num**2
        print(str(num2))
        number += num2
        #print(str(number))
    return number
    
kekka = str(num(N,X))
print(kekka)

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

def num(P, X):
    number = 0
    for x in X:
        num = x-P
        #print(str(num))
        num2 = num**2
        number += num2
    return number

nList = []
for p in range(min(X), max(X) + 1):
    nList.append(num(p, X))

n = str(min(nList))
print(n)

Verdicts: Runtime Error

Wrong Answer

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

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

minimum = 10000000

for n in range(1,N+1):
  d = 0
  for i in range(N):
    d += (X[i]-n)**2
  print(d)
  if kyori < minimum:
    minimum = kyori
print(minimum)

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

minimum = 10000000

for n in range(1,max(X)+1):
  kyori = 0
  for i in range(N):
    kyori += (X[i]-n)**2
  if kyori < minimum:
    minimum = kyori
print(minimum)

Verdicts: Runtime Error

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

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

hp_sums = []

for i in range(max(X)):
    P = i+1
    distance_list = list(map(lambda x: (x-P)**2, X))
    print(distance_list)
    hp_sum = sum(distance_list)
    hp_sums.append(hp_sum)

print(min(hp_sums))

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

hp_sums = []

for i in range(max(X)):
    P = i+1
    distance_list = list(map(lambda x: (x-P)**2, X))
    hp_sum = sum(distance_list)
    hp_sums.append(hp_sum)

print(min(hp_sums))

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

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
import numpy as np
n = int(input())
X = list(map(int, input().split()))
a = sum(X)
b = sum(X[i]**2 for i in range(n))
m = np.floor(a/n)
if m + 1/2 <= a/n:
  m += 1
else:
  break
s = n*(m**2) - 2*a*m + b
print(int(s))


import math
n = int(input())
X = list(map(int, input().split()))
a = sum(X)
b = sum(X[i]**2 for i in range(n))
m = math.floor(a/n)
if m + 1/2 <= a/n:
  m += 1
else:
  break
s = n*(m**2) - 2*a*m + b
print(s)

import numpy as np
n = int(input())
X = list(map(int, input().split()))
a = sum(X)
b = sum(X[i]**2 for i in range(n))
m = np.floor(a/n)
if m + 1/2 <= a/n:
  m += 1
s = n*(m**2) - 2*a*m + b
print(int(s))


Verdicts: Runtime Error

Runtime Error

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

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

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


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

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


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

ans = 1e10
for p in range(1,101):
  sum =0
  for x in X:
    sum += (p-x)**2
    
  ans = min(ans,sum)
  
print(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):
import math

N = int(input())
xs = [int(i) for i in input().split()]
p = sum(xs) / len(xs)

print(sum([math.pow(x-p, 2) for x in xs]))

import math

N = input()
xs = [int(i) for i in input().split()]
p = round(sum(xs)/len(xs))

print(sum(math.pow(x-p, 2) for x in xs))

import math

N = input()
xs = [int(i) for i in input().split()]
p = round(sum(xs)/len(xs))

print(sum(math.pow(x-p) for x in xs))

import math

N = input()
xs = [int(i) for i in input().split()]
p = round(sum(xs)/len(xs))

print(int(sum(math.pow(x-p, 2) for x in xs)))

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

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

Submission attempts (in order):
N = int(input())
X = list(map(int, input().split()))
P = sum(X) // N
result1 = 0
result2 = 0

for x in X:
  result1 += (x - P)**2
  result2 += (x - P - 1)**2

if result1 < result2:
  result = result1
elif result1 > result2:
  result = result2


print(result)

N = int(input())
X = list(map(int, input().split()))
P = sum(X) // N
result1 = 0
result2 = 0

for x in X:
  result1 += (x - P)**2
  result2 += (x - P - 1)**2

if result1 <= result2:
  result = result1
elif result1 > result2:
  result = result2


print(result)

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=input()
mk=input().split()
m=[]
t=0
s=0
for k in mk:
  pk=int(k)
  t+=pk
  s+=(pk**2)
  m.append(pk)
px=round(t/n)
ans=s+n*(px**2)-2*px*t
print(ans)

n=input()
mk=input().split()
t=0
s=0
ans=0
for k in mk:
  pk=int(k)
  t+=pk
  s+=(pk**2)
px=round(t/n)
ans+=s+n*(px**2)-2*px*t
print(ans)


n=int(input())
mk=input().split()
t=0
s=0
ans=0
for k in mk:
  pk=int(k)
  t+=pk
  s+=(pk**2)
px=round(t/n)
ans+=s+n*(px**2)-2*px*t
print(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):
N =int(input())
X = map(int,input().split())
c = 100000000
for i in range(1,101):
  t=0
  for j in X:
    t += (j-i)**2

  if t=<c:
    t=c
print(c)


N=int(input())
X= list(map(int,input().split()))
cnt = 1000000
for j in range(100):
    t = 0
    for i in li:
        t += (i-(j+1))**2
    if t <= cnt:
        cnt = t
print(cnt)


N =int(input())
X = map(int,input().split())
c = 0
for i in range(1,101):
  t=0
  for j in X:
    t += (j-i)**2

  if t<c:
    t=c
print(c)

N =int(input())
X = list(map(int,input().split()))
c = 100000000
for i in range(1,101):
  t=0
  for j in X:
    t += (j-i)**2

  if t=<c:
    t=c
print(c)


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


Verdicts: Runtime Error

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):
from sys import stdin
import sys
import math
from functools import reduce
import itertools

n = int(stdin.readline().rstrip())
x = [int(x) for x in stdin.readline().rstrip().split()]

p = int(sum(x)/n)
q = p+1

a = sum([(i-p)**2 for i in x])
b = sum([(i-q)**2 for i in x])

print(p,q,a,b)

print(min([a,b]))


from sys import stdin
import sys
import math
from functools import reduce
import itertools

n = int(stdin.readline().rstrip())
x = [int(x) for x in stdin.readline().rstrip().split()]

p = int(sum(x)/n)
q = p+1

a = sum([(i-p)**2 for i in x])
b = sum([(i-q)**2 for i in x])

print(min([a,b]))


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())
lst=list(map(int,input().split()))
P=round(lst/N)
print(sum[(i-P)**2 for i in lst])

N=int(input())
lst=list(map(int,input().split()))
P=round(sum(lst)/N)
print(sum[(i-P)**2 for i in lst])

N=int(input())
lst=list(map(int,input().split()))
P=round(sum(lst)/N)
print(sum([(i-P)**2 for i in lst]))

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

a=sum(x)/len(x)
b=min(sum(x)//len(x)-a,sum(x)//len(x)+1-a)

c=0

for i in x:
    c+=(i-b)**2

print(int(c))

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

if n==1:
    print('0')
    sys.exit()

if x.count(x[0])==n:
    print('0')
    sys.exit()

a=sum(x)/len(x)
d=[]
for i in range(min(x),max(x)):
    c=0
    for j in x:
        c+=(i-j)**2
    d.append(c)

print(min(d))


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
input = sys.stdin.readline
N = int(input())
lists = list(input().split())
ave_sum = 0
for i in lists:
  ave_sum = ave_sum + int(i)
ave = int(ave_sum / N)
nijyo = 0
for i in lists:
  nijyo = nijyo + (int(i) - ave_sum) ** 2
print(str(nijyo))

import sys
input = sys.stdin.readline
N = int(input())
lists = list(input().split())
ave_sum = 0
for i in lists:
  ave_sum = ave_sum + int(i)
ave = round(ave_sum / N)
nijyo = 0
for i in lists:
  nijyo = nijyo + (int(i) - ave) ** 2
print(str(nijyo))

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 = 100000000
for p in x:
    hp = 0
    for i in range(n):
        hp += (x[i] - p)**2
    ans = min(ans,hp)

print(ans)


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

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()))
print(int((sum(X) + 0.5) / N))


import numpy as np
N = int(input())
X = np.array(list(map(int, input().split())))
x = int(np.sum(X) / N + 0.5)
print(np.sum(np.square(X - 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):
import sys
n = int(sys.stdin.readline())
li = list(map(int, sys.stdin.readline().split()))
min = 0
for k in li:
    min += (k-i) ** 2
i = 2
while i <= 100:
  s = 0
  for k in li:
    s += (k-i) ** 2
  if s < min:
    min = s
  i += 1
print(min)
    

import sys
n = int(sys.stdin.readline())
li = list(map(int, sys.stdin.readline().split()))
min = 0
for k in li:
    min += (k-1) ** 2
i = 2
while i <= 100:
  s = 0
  for k in li:
    s += (k-i) ** 2
  if s < min:
    min = s
  i += 1
print(min)
    


Verdicts: Runtime Error

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

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

each = 0
loss = []

for(int i=min(x); i<max(x); i++):
  for j in range(len(x)):
    each = np.power((x[j]-i), 2)
    each += each
  loss.append(each)
  
print(min(each))

import numpy as np
N = int(input())
x = [int(i) for i in input().split() ]

each = 0
loss = 0
ll = []
k = 0

for k in range(min(x), max(x)):
      for j in range(len(x)):
            each = np.power((x[j]-k), 2)
            loss += each
      ll.append(loss)
  
print(min(ll))

import numpy as np
N = int(input())
x = [int(i) for i in input().split() ]

each = 0
loss
ll = []

for(int i=min(x); i<max(x); i++):
  for j in range(len(x)):
    each = np.power((x[j]-i), 2)
    loss += each
  ll.append(loss)
  
print(min(each))

import numpy as np
N = int(input())
x = [int(i) for i in input().split() ]

each = 0
loss = []

for(int i=min(x); i<max(x); i++):
  for j in range(len(x)):
    each = np.power((x[j]-i), 2)
  loss.append(each)
  
print(min(each))

import numpy as np
N = int(input())
x = [int(i) for i in input().split() ]

each = 0
loss = 0
ll = []

for k in range(min(x), max(x)):
      for j in range(len(x)):
            each = np.power((x[j]-k), 2)
            loss += each
      ll.append(loss)
  
print(min(ll))

import numpy as np
N = int(input())
x = [int(i) for i in input().split() ]

each = 0
loss = 0
ll = []

for k in range(min(x), max(x)+1):
      for j in range(len(x)):
            each = np.power((x[j]-k), 2)
            loss += each
      ll.append(loss)
      loss = 0
  
print(min(ll))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
av = round(sum(a)/n)
x=0
for i in a:
    x = x + (av)**2 
print(x)

n = int(input())
a = list(map(int, input().split()))
av = round(sum(a)/n)
x=0
for i in a:
    x = x + (i-av)**2 
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()))
ans=float('inf')
for i in range(min(x),max(x)):
  now=0
  for x in X:
    now+=(i-x)*(i-x)
  ans=min(now,ans)
print(ans)

n=int(input())
X=list(map(int,input().split()))
ans=float('inf')
for i in range(min(X),max(X)+1):
  now=0
  for x in X:
    now+=(i-x)*(i-x)
  ans=min(now,ans)
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):
#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))

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

ans = 0
for x in range(max(X)+1):
  ans_temp = 0
  for i in range(N):
    ans_temp += (X[i]-x)**2
  ans = max(ans, ans_temp)
print(ans)

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

print(min(memo))

N=int(input())
S=list(map(int,input().split()))
memo=[]
for i in range(min(S)-100,max(S)+100):
    summ = 0
    for j in range(0,N):
        summ+=(i-S[j])**2
    memo.append(summ)

print(min(memo))

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 sys

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

mi,mx=li[0],li[-1]
ans=10**9
t=10**9
if mi==mx:
    print(0)
    sys.exit()

for i in range(mi,mx):
    ans=min(ans,t)
    t=0
    for j in (li):
       try:
           t+=(li[j]-i)**2
       except:
           print(j)
       
print(ans)

import sys

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

mi,mx=li[0],li[-1]
ans=10**9
t=10**9
if mi==mx:
    print(0)
    sys.exit()

for i in range(mi,mx):
    ans=min(ans,t)
    t=0
    for j ,item in enumerate(li):
       t+=(li[j]-i)**2
       
print(ans)

Verdicts: Wrong Answer

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

Submission attempts (in order):
from decimal import Decimal, ROUND_HALF_UP
N = int(input())
X = [int(i) for i in input().split()]

ans = 0
X_mean = Decimal(str(sum(X) / N))
X_mean = X_mean.quantize(Decimal('0'), rounding=ROUND_HALF_UP)
print(X_mean)

for i in range(N):
    ans += (X[i] - X_mean) ** 2

print(ans)


from decimal import Decimal, ROUND_HALF_UP

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

ans = 0
X_mean = Decimal(str(sum(X) / N))
X_mean = X_mean.quantize(Decimal('0'), rounding=ROUND_HALF_UP)

for i in range(N):
    ans += (X[i] - X_mean) ** 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())
X = list(map(int,input().split()))
tmp = 0
tmp2 = 0
ans = 10 ** 10
for i in range(1,101):
  for a in range(N):
    tmp = abs(X[a] - i) ** 2
    tmp2 = tmp
  ans = min(ans,tmp2)
print(str(ans))

N = int(input())
X = list(map(int,input().split()))
tmp = 0
ans = 10 ** 10
for i in range(1,101):
  tmp = 0
  for a in range(N):
    tmp = tmp + (abs(X[a] - i)) ** 2
  ans = min(ans,tmp)
print(str(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()))
sum = 0
min_sum = 100000000
P = 1
while P <= 100:
 for n in X:
   sum = sum +(n-P)**2
 if sum <= min_sum:
   min_sum = sum
 P = P + 1
print(min_sum)

N = int(input())
X = list(map(int, input().split()))
Z = []
b = 0

for i in range(max(X) + 1):
    for a in X:
        b = b + pow((a - i),2)
    Z.append(b)
    b = 0

print(min(Z))

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):
# coding: utf-8
 
a = int(input())
b=list(map(int,input().split()))
sum = 0

for i in range(a):
    sum += b[i]


ans_pre = sum/a
ans = round(ans_pre)

print(ans)

# coding: utf-8
 
a = int(input())
b=list(map(int,input().split()))
sum = 0
 
for i in range(a):
    sum += b[i]
  
ans_pre = sum/a
ans = round(ans_pre)

sum = 0 

for i in range(a):
    sum += (b[i]-ans)**2

print(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):
import math
N = int(input())
X = list(map(int,input().split()))
P = math.ceil(sum(X)/N)
P1 = P - 1
hp = 0

for x in X:
  hp_x = (P-x)**2
  hp2_x = (P1 - x)**2
  hp = hp + hp_x
  hp2 = hp2 + hp2_x
print(min(hp,hp2))

N = int(input())
X = list(map(input().split()))
P = ceil(sum(X)/2)

hp = 0

for x in X:
  hp_x = (P-X)**2
  hp = hp + hp_x
print(hp)

import math
N = int(input())
X = list(map(int,input().split()))
P = math.ceil(sum(X)/N)
P1 = P - 1
hp = 0
hp2 = 0

for x in X:
  hp_x = (P-x)**2
  hp2_x = (P1 - x)**2
  hp = hp + hp_x
  hp2 = hp2 + hp2_x
print(min(hp,hp2))


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


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


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 sys
N,M = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(M)]

ans = [0] * N
checkd = [False] * N

for i in range(M):
    if not checkd[sc[i][0]-1]:
        checkd[sc[i][0]-1] = True
        ans[sc[i][0]-1] = sc[i][1]
    else:
        if ans[sc[i][0]-1] != sc[i][1]:
            print('-1')
            sys.exit()

if N >= 2 and checkd[0] and ans[0] == 0:
    print('-1')
    sys.exit()

real = 0
for i in ans:
    real = real * 10 + i
    
print(real)

N=int(input())
X=list(map(int,input().split()))
min = 9999999999
for i in range(1,101):
    sum = 0
    for j in range(N):
        sum += (X[j] - i)**2
        
    if sum < min:
        min = sum

print(min)

Verdicts: Runtime Error

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

Submission attempts (in order):
import numpy as np
n = int(input())
l = np.array(map(int, input().split()))

ans = np.sum((l - round(np.mean(l)))**2)
print(ans)

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

l = np.array(l)
ans = np.sum((l - round(np.mean(l)))**2)
print(int(ans))


Verdicts: Runtime Error

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

Submission attempts (in order):
def resolve():
    n = int(input())
    x = list(map(int, input().split()))
    x.sort()
    xx = [0 for i in range(n)]
    for i,j in enumerate(x):
        xx[i] = j**2
    minp = 100
    p = 0
    for i in range(max(x)):
        k = i*(n*i - 2*sum(x))
        if k < minp:
            minp = k
            p = i
    print(sum(xx)-2*p*sum(x)+n*(p**2))


def resolve():
    n = int(input())
    x = list(map(int, input().split()))
    x.sort()
    xx = [0 for i in range(n)]
    for i,j in enumerate(x):
        xx[i] = j**2
    minp = 100
    for i in range(200):
        k = i*(n*i - 2*sum(x))
        if k < minp:
            minp = k
    print(sum(xx)+ minp)
if __name__ == "__main__":
    resolve()

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 = sum(x) // len(x)+1
l = [] 
for i in x:
  s = (i-m)**2
  if s < 0:
    l.append(-s)
  else:
    l.append(s)
print(sum(l), l, m)

_ = int(input())
x = list(map(int,input().split()))
def p(m):
  l = [] 
  for i in x:
    s = (i-m)**2
    if s < 0:
      l.append(-s)
    else:
      l.append(s)
  return(sum(l))
a = [p(i) for i in range(100)]
print(min(a))

Verdicts: Wrong Answer

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

Submission attempts (in order):
N=input()
list=map(int,input().split())
sum+=0
for i in range(1,N+1)
sum=abs(i-list)
print(min(sum**2))


N=input()
list=map(int,input().split())
sum+=0
for i in range(1,N+1)
sum+=abs(i-list)
print(min(sum**2))


N = int(input())
men=list(map(int,input().split()))
for i in range(1,101):
  suu=0
  if i==1:
    for n in range(N):
      suu+=(1-men[n])**2
      ans=suu
  else:
    for h in range(N): 
      suu+=(i-men[h])**2
  if suu<ans:
      ans=suu
print(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):
N=int,input()
X=list(map(int,input().split()))
def P(n):
    return sum([(X[i]-n)**2 for i in range(0,N)])
l=[P(i) for i in range(1,101)]
print(min(l))


N=int,input()
X=list(map(int,input().split()))
def P(n):
    return sum([(X[i]-n)**2 for i in range(0,N)])
l=[P(i) for i in range(1,101)]
print(min(l))


N=int(input())
X=list(map(int,input().split()))
def P(n):
    return sum([(X[i]-n)**2 for i in range(0,N)])
l=[P(i) for i in range(1,101)]
print(min(l))


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()))
 
cost = 0
 
for i in range(1, 101):
  cand = 0
  for x in X:
    cand += (x-i)**2
  cost = min(cost, cand)
 
print(cost)

N = int(input())
X = list(map(int, input().split()))
 
cost = 0
 
for i in range(-50, 201):
  cand = 0
  for x in X:
    cand += (x-i)**2
  cost = min(cost, cand)
 
print(cost)

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

cost = 0

for i in range(1, 101):
  cand = 0
  for x in X:
    cand += (x[i]-i)**2
  cost = min(cost, cand)

print(cost)

N = int(input())
X = list(map(int, input().split()))
 
cost = 10**10
 
for i in range(1, 101):
  cand = sum([(x-i)**2 for x in X])
  cost = min(cost, cand)

print(cost)

Verdicts: Wrong Answer

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 ans(p, x):
    a = 0
    for i in x:
        a += (i - p)**2
    return a

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

p = sum(x)//n

print(min(ans(p), ans(p+1)))


def ans(p, x):
    a = 0
    for i in x:
        a += (i - p)**2
    return a

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

p = sum(x)//n

print(min(ans(p, x), ans(p+1, x)))


Verdicts: Runtime Error

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

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

ave=int(sum(list)/len()list)

ans=0
for i in list:
  ans+= pow((i-ave),2)

print(ans)


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

ave=int(sum(list)/len()list)

ans=0
[ans+= pow((i-ave),2) for i in list]

print(ans)

n=int(input())
list=list(map(int,input().split()))
min_tairyoku=10000000000000000000
tairyoku=[]
for i in range(min(list),max(list)+1):
    t=0
    for j in list:
        t += (j-i) ** 2
    tairyoku.append(t)
print(min(tairyoku))


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()))
min_=10**9
for i in range(min(x),max(x)+1,1):
  #print(i)
  sum_=0
  for j in range(n):
    sum_+=(x[j]-i)**2
  if sum_<min_: min_=sum_
  print(min_)
print(int(min_))

n=int(input())
x=list(map(int, input().split()))
min_=10**9
for i in range(min(x),max(x)+1,1):
  #print(i)
  sum_=0
  for j in range(n):
    sum_+=(x[j]-i)**2
  if sum_<min_: min_=sum_
  #print(min_)
print(int(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()))
sum_min = 10**8

for i in range(min(X), max(X)+1):
    s = 0
    for j in range(N):
        s += (X[j] - i)**2
    
    if s < sum_min:
        sum_min = s

print(sum_min)

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()))
i=1
XT=list(map(tairyoku,X))
ans=sum(XT)
for i in range(2,101):
    XT=list(map(tairyoku,X))
    ans=min(ans,sum(XT))
print(ans)

N=int(input())
X=list(map(int,input().split()))
def tairyoku(n):
    return (n-i)**2
i=1
XT=list(map(tairyoku,X))
ans=sum(XT)
for i in range(2,101):
    XT=list(map(tairyoku,X))
    ans=min(ans,sum(XT))
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 = 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()

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

    for i in X:
        total1 += (AVG1 - i)**2

    if total >= total1:
        print(total1)
    else:
        print(total)

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

for j in range(N):
    result += (1-coordinate[j])**2

for i in range(1,101):
    for k in range(N):
        resultl += (i-coordinate[k])**2

    if resultl < result:
        result = resultl
    resultl = 0

print(result)

N = int(input())
coordinate = list(map(int, input().split()))
result = 0
resultl = 0
 
for j in range(N):
    result += (1-coordinate[j])**2
    
for i in range(1,101):
    for k in range(N):
        resultl += (i-coordinate[k])**2
 
    if resultl < result:
        result = resultl
    resultl = 0
    
print(result)

Verdicts: Runtime Error

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

Submission attempts (in order):
import numpy as np

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

print(np.mean(X))
print(int(np.mean(X)))
if np.mean(X)-int(np.mean(X))>=0.5:
    count=int(np.mean(X))+1
else:
    count=int(np.mean(X))    

result=0
for i in range(N):
    result+=(X[i]-count)*(X[i]-count)
print(result)

import numpy as np

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

if np.mean(X)-int(np.mean(X))>=0.5:
    count=int(np.mean(X))+1
else:
    count=int(np.mean(X))    

result=0
for i in range(N):
    result+=(X[i]-count)*(X[i]-count)
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 = map(int, input().split())
hp_list = [sum([(xx-p)**2 for xx in x]) for p in range(1, 101)]
print(min(hp_list))    

N = int(input())
x = list(map(int, input().split()))
hp_list = [sum([(xx-p)**2 for xx in x]) for p in range(min(x), max(x)+1)]
print(min(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):
number = input()
coordinates = list(map(int, input().split()))
coordinates.sort()
coordinates.reverse()
#print(coordinates)
list = []
for i in range(coordinates[0]):
    total=0
    for j in range(number):
        total += (coordinates[j]-i)**2
    list.insert(0, total)
list.sort()
print(list[0])

number, base = map(int, input().split())
devision = number
list = []
while(devision>=base):
    surplus = devision % base
    devision = int(devision / base)
    
    list.insert(0,surplus)
    #print(list)
list += [devision]
#print(list)
print(len(list))

number = int(input())
coordinates = list(map(int, input().split()))
coordinates.sort()
coordinates.reverse()
#print(coordinates)
list = []
for i in range(coordinates[0]+1):
    total=0
    for j in range(number):
        total += (coordinates[j]-i)**2
    list.insert(0, total)
list.sort()
print(list[0])

Verdicts: Runtime Error

Runtime Error

Accepted