Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
8 values
p02767
n = int(input()) x = [int(i) for i in input().split()] lst = [] for P in range(1,max(x)): n = 0 for j in x: n += (j-P)**2 lst.append(n) print(min(lst))
n = int(input()) x = [int(i) for i in input().split()] lst = [] for P in range(1,max(x)+1): n = 0 for j in x: n += (j-P)**2 lst.append(n) print(min(lst))
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
561,473
561,474
u611352758
python
p02767
N = int(input()) X = list(map(int, input().split())) minX = min(X) maxX = max(X) if minX==maxX: print(X[0]) quit() HP = [] for p in range(minX, maxX): hp = 0 for x in X: hp += (x-p)**2 HP.append(hp) print(min(HP))
N = int(input()) X = list(map(int, input().split())) minX = min(X) maxX = max(X) if minX==maxX: print(0) quit() HP = [] for p in range(minX, maxX): hp = 0 for x in X: hp += (x-p)**2 HP.append(hp) print(min(HP))
[ "call.arguments.change" ]
561,475
561,476
u896941378
python
p02767
N = int(input()) X = list(map(int, input().split())) minX = min(X) maxX = max(X) if minX==maxX: print(minX) quit() HP = [] for p in range(minX, maxX): hp = 0 for x in X: hp += (x-p)**2 HP.append(hp) print(min(HP))
N = int(input()) X = list(map(int, input().split())) minX = min(X) maxX = max(X) if minX==maxX: print(0) quit() HP = [] for p in range(minX, maxX): hp = 0 for x in X: hp += (x-p)**2 HP.append(hp) print(min(HP))
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "io.output.change" ]
561,477
561,476
u896941378
python
p02767
N = int(input()) X = list(map(int, input().split())) ans = 10**18 for i in range(1, 101): temp=0 for num in X: temp += (i-num)**2 ans = min(ans, tmp) print(ans)
n=int(input()) arr=list(map(int,input().split())) ans=10**18 #最小値を求めるので初期化しておく for i in range(1,101): #1<=P<=100の範囲について消費する体力の総和を計算 tmp=0 for num in arr: tmp+=(i-num)**2 ans=min(ans,tmp) #消費する体力の総和の最小値が答えとなる print(ans)
[ "assignment.variable.change", "identifier.change" ]
561,479
561,480
u345336405
python
p02767
n = int(input()) x = list(map(int, input().split())) x.sort() mean = sum(x)/n med = int(n / 2) print(med) if mean - int(mean) < 0.5: mean = int(mean) elif mean - int(mean) > 0.5: mean = int(mean) + 1 else: if n % 2 == 0: if (x[med-1] + x[med])/2 <= mean: mean = int(mean) else: mean = int(mean) + 1 else: if x[med] <= mean: mean = int(mean) else: mean = int(mean) + 1 sum = 0 for i in range(n): sum += (x[i]-mean)**2 print(sum)
n = int(input()) x = list(map(int, input().split())) x.sort() mean = sum(x)/n med = int(n / 2) if mean - int(mean) < 0.5: mean = int(mean) elif mean - int(mean) > 0.5: mean = int(mean) + 1 else: if n % 2 == 0: if (x[med-1] + x[med])/2 <= mean: mean = int(mean) else: mean = int(mean) + 1 else: if x[med] <= mean: mean = int(mean) else: mean = int(mean) + 1 sum = 0 for i in range(n): sum += (x[i]-mean)**2 print(sum)
[ "call.remove" ]
561,483
561,484
u518891382
python
p02767
n = int(input()) x = list(map(int,input().split())) c = sum(x)//n ans = 0 for i in x: ans +=(i-c)**2 print(ans)
n = int(input()) x = list(map(int,input().split())) c = round(sum(x)/n) ans = 0 for i in x: ans +=(i-c)**2 print(ans)
[ "call.add", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change", "call.arguments.change" ]
561,487
561,488
u175590965
python
p02767
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))
[ "call.remove" ]
561,489
561,490
u694233896
python
p02767
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)))
[ "call.arguments.add", "call.arguments.change" ]
561,493
561,492
u759076129
python
p02767
import math N = int(input()) xs = [int(i) for i in input().split()] p = int(sum(xs) / len(xs)) print(int(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(int(sum(math.pow(x-p, 2) for x in xs)))
[ "call.remove", "call.arguments.change", "assignment.value.change", "identifier.change", "call.function.change" ]
561,494
561,492
u759076129
python
p02767
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))
[ "assignment.value.change", "identifier.change", "call.function.change", "expression.operation.binary.change" ]
561,502
561,503
u809963697
python
p02767
n = int(input()) x = list(map(int, input().split())) xmin = min(x) xmax = max(x) hp = 10e10 for p in range(xmin, xmax+1): temp = 0 for xi in x: temp += (xi-p)*(xi-p) hp = min(temp,) print(hp)
n = int(input()) x = list(map(int, input().split())) xmin = min(x) xmax = max(x) hp = 10e10 for p in range(xmin, xmax+1): temp = 0 for xi in x: temp += (xi-p)*(xi-p) hp = min(temp, hp) print(hp)
[ "call.arguments.change" ]
561,504
561,505
u239725287
python
p02767
N = int(input()) X = List(map(int, input().split())) def D(x, a): ans = 0 for i in range(len(a)): ans += (x - a[i])**2 return ans for i in range(0, 101): if D(x, X) < D(i+1, X): print(D(i, X)) break
N=int(input()) X=list(map(int,input().split())) def D(x,a): ans=0 for i in range(len(a)): ans+=(x-a[i])**2 return ans for i in range(0,101): if D(i,X)<D(i+1,X): print(D(i,X)) break
[ "assignment.value.change", "identifier.change", "call.function.change", "control_flow.branch.if.condition.change" ]
561,506
561,507
u526131148
python
p02767
N = int(input()) X = list(map(int, input().split())) def D(X,a): ans = 0 for i in range(len(a)): ans += (x - a[i])**2 return ans for i in range(0,101): if D(i,X) < D(i+1,X): print(D(i,X)) break
N=int(input()) X=list(map(int,input().split())) def D(x,a): ans=0 for i in range(len(a)): ans+=(x-a[i])**2 return ans for i in range(0,101): if D(i,X)<D(i+1,X): print(D(i,X)) break
[ "identifier.change" ]
561,508
561,507
u526131148
python
p02767
n = int(input()) x = list(map(int, input().split())) best = 10**10 for i in range(51): num = 0 for xx in x: num += (xx-i)**2 if num < best: best = num print(best)
n = int(input()) x = list(map(int, input().split())) best = 10**10 for i in range(1, 101): num = 0 for xx in x: num += (xx-i)**2 if num < best: best = num print(best)
[ "literal.number.integer.change", "call.arguments.change", "control_flow.loop.range.bounds.upper.change", "call.arguments.add" ]
561,527
561,528
u316733945
python
p02767
N = int(input()) X = list(map(int, input().split())) print(min(lambda p: sum((x-p)**2 for x in X) for i in range(max(X)+1)))
N = int(input()) X = list(map(int, input().split())) print(min(sum((x-p)**2 for x in X) for p in range(max(X)+1)))
[ "identifier.change", "call.arguments.change", "io.output.change" ]
561,529
561,530
u142415823
python
p02767
# template by 3xC and starkizard. # contributors: ##################################################################################### from __future__ import division, print_function import sys import os from collections import Counter, deque, defaultdict import itertools import math import io """Uncomment modules according to your need""" # from bisect import bisect_left, bisect_right, insort # from heapq import heappop, heapify, heappush # from random import randint as rn # from Queue import Queue as Q # from copy import deepcopy # from decimal import * # import re # import operator ##################################################################################### # this enables you to write python3 code with PyPy2 (Python 2) if sys.version_info[0] < 3: input = raw_input range = xrange filter = itertools.ifilter map = itertools.imap zip = itertools.izip ##################################################################################### """value of mod""" MOD = 998244353 mod = 10**9 + 7 """Uncomment next 4 lines if doing huge recursion""" # import threading # threading.stack_size(1<<27) # sys.setrecursionlimit(10000 def prepare_factorial(mod=mod): """ returns two lists, factorial and inverse factorial modulo argument by default 10**9 +7 """ # Comment code out when you don't need inverse factorial or vice versa fact = [1] for i in range(1, 200005): fact.append((fact[-1] * i) % mod) ifact = [0] * 200005 ifact[200004] = pow(fact[200004], mod - 2, mod) for i in range(200004, 0, -1): ifact[i - 1] = (i * ifact[i]) % mod return fact, ifact def modinv(n, p): """ returns N inverse modulo p """ return pow(n, p - 2, p) def ncr(n, r, fact, ifact): """ takes 4 arguments: n , r and factorial and inverse factorial lists""" t = (fact[n] * (ifact[r]*ifact[n-r]) % MOD)% MOD return t def get_n(Sum): """this function returns the maximum n for which Summation(n) <= Sum""" ans = (-1 + sqrt(1 + 8*Sum))//2 return ans def sieve(n): """ returns a list of prime numbers till n """ if n < 2: return list() prime = [True for _ in range(n + 1)] p = 3 while p * p <= n: if prime[p]: for i in range(p * 2, n + 1, p): prime[i] = False p += 2 r = [2] for p in range(3, n + 1, 2): if prime[p]: r.append(p) return r def divs(n, start=1): """ returns a list of all divisors till n """ divisors = [] for i in range(start, int(math.sqrt(n) + 1)): if n % i == 0: if n / i == i: divisors.append(i) else: divisors.extend([i, n // i]) return divisors def divn(n, primes): """ returns the number of divisors, two arguments n and the sieve till n """ divs_number = 1 for i in primes: if n == 1: return divs_number t = 1 while n % i == 0: t += 1 n //= i divs_number *= t def lrfind(d, x, default=-1): """ Takes 2 arguments an iterable and an element. returns a tuple (firstoccurence,lastoccurence) -1 if not found """ left = right = -1 for i in range(len(d)): if d[i] == x: if left == -1: left = i right = i if left == -1: return default, default else: return left, right def gcd(x, y): # math.gcd is slower """ returns greatest common divisor of x and y """ while y: x, y = y, x % y return x def ceil(n, k=1): return n // k + (n % k != 0) #returns math.ceil but protecting against floating inconsistencies def input(): return sys.stdin.readline().strip() def ii(): return int(input()) #inputs integer def mi(): return map(int, input().split()) # inputting space seperated variables for example x,y,z def li(): return list(map(int, input().split())) #inputting a space seperated list of integers def lw(): return input().split() #inputting a space seperated list of strings def lcm(a, b): return abs(a * b) // gcd(a, b) #returns LCM of two arguments def prr(a, sep=' ', end='\n'): print(sep.join(map(str, a)), end=end) #For printing an iterable with seperator sep as optional second argument (default : " "), ending character (default: "\n") as optional third def dd(): return defaultdict(int) #returns a dictionary with values defaulted to 0 def ddl(): return defaultdict(list) #returns a dictionary with values defaulted to [] def write(s): return sys.stdout.write(s) ################################################################### def main(): #CODE GOES HERE: n=ii() x=li() l,r=min(x),max(x) answer0=float("inf") for s in range(l,r): answer0=min(answer0,sum([(i-s)*(i-s) for i in x])) print(answer0) """ -------- Python 2 and 3 footer by Pajenegod and c1729 ---------""" py2 = round(0.5) if py2: from future_builtins import ascii, filter, hex, map, oct, zip range = xrange import os, sys from io import IOBase, BytesIO BUFSIZE = 8192 class FastIO(BytesIO): newlines = 0 def __init__(self, file): self._file = file self._fd = file.fileno() self.writable = "x" in file.mode or "w" in file.mode self.write = super(FastIO, self).write if self.writable else None def _fill(self): s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0]) return s def read(self): while self._fill(): pass return super(FastIO, self).read() def readline(self): while self.newlines == 0: s = self._fill(); self.newlines = s.count(b"\n") + (not s) self.newlines -= 1 return super(FastIO, self).readline() def flush(self): if self.writable: os.write(self._fd, self.getvalue()) self.truncate(0), self.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable if py2: self.write = self.buffer.write self.read = self.buffer.read self.readline = self.buffer.readline else: self.write = lambda s: self.buffer.write(s.encode('ascii')) self.read = lambda: self.buffer.read().decode('ascii') self.readline = lambda: self.buffer.readline().decode('ascii') sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip('\r\n') # sys.stdin = open('input.txt', 'r') # sys.stdout = open('output.txt', 'w') """ main function""" if __name__ == '__main__': main() # threading.Thread(target=main).start()
# template by 3xC and starkizard. # contributors: ##################################################################################### from __future__ import division, print_function import sys import os from collections import Counter, deque, defaultdict import itertools import math import io """Uncomment modules according to your need""" # from bisect import bisect_left, bisect_right, insort # from heapq import heappop, heapify, heappush # from random import randint as rn # from Queue import Queue as Q # from copy import deepcopy # from decimal import * # import re # import operator ##################################################################################### # this enables you to write python3 code with PyPy2 (Python 2) if sys.version_info[0] < 3: input = raw_input range = xrange filter = itertools.ifilter map = itertools.imap zip = itertools.izip ##################################################################################### """value of mod""" MOD = 998244353 mod = 10**9 + 7 """Uncomment next 4 lines if doing huge recursion""" # import threading # threading.stack_size(1<<27) # sys.setrecursionlimit(10000 def prepare_factorial(mod=mod): """ returns two lists, factorial and inverse factorial modulo argument by default 10**9 +7 """ # Comment code out when you don't need inverse factorial or vice versa fact = [1] for i in range(1, 200005): fact.append((fact[-1] * i) % mod) ifact = [0] * 200005 ifact[200004] = pow(fact[200004], mod - 2, mod) for i in range(200004, 0, -1): ifact[i - 1] = (i * ifact[i]) % mod return fact, ifact def modinv(n, p): """ returns N inverse modulo p """ return pow(n, p - 2, p) def ncr(n, r, fact, ifact): """ takes 4 arguments: n , r and factorial and inverse factorial lists""" t = (fact[n] * (ifact[r]*ifact[n-r]) % MOD)% MOD return t def get_n(Sum): """this function returns the maximum n for which Summation(n) <= Sum""" ans = (-1 + sqrt(1 + 8*Sum))//2 return ans def sieve(n): """ returns a list of prime numbers till n """ if n < 2: return list() prime = [True for _ in range(n + 1)] p = 3 while p * p <= n: if prime[p]: for i in range(p * 2, n + 1, p): prime[i] = False p += 2 r = [2] for p in range(3, n + 1, 2): if prime[p]: r.append(p) return r def divs(n, start=1): """ returns a list of all divisors till n """ divisors = [] for i in range(start, int(math.sqrt(n) + 1)): if n % i == 0: if n / i == i: divisors.append(i) else: divisors.extend([i, n // i]) return divisors def divn(n, primes): """ returns the number of divisors, two arguments n and the sieve till n """ divs_number = 1 for i in primes: if n == 1: return divs_number t = 1 while n % i == 0: t += 1 n //= i divs_number *= t def lrfind(d, x, default=-1): """ Takes 2 arguments an iterable and an element. returns a tuple (firstoccurence,lastoccurence) -1 if not found """ left = right = -1 for i in range(len(d)): if d[i] == x: if left == -1: left = i right = i if left == -1: return default, default else: return left, right def gcd(x, y): # math.gcd is slower """ returns greatest common divisor of x and y """ while y: x, y = y, x % y return x def ceil(n, k=1): return n // k + (n % k != 0) #returns math.ceil but protecting against floating inconsistencies def input(): return sys.stdin.readline().strip() def ii(): return int(input()) #inputs integer def mi(): return map(int, input().split()) # inputting space seperated variables for example x,y,z def li(): return list(map(int, input().split())) #inputting a space seperated list of integers def lw(): return input().split() #inputting a space seperated list of strings def lcm(a, b): return abs(a * b) // gcd(a, b) #returns LCM of two arguments def prr(a, sep=' ', end='\n'): print(sep.join(map(str, a)), end=end) #For printing an iterable with seperator sep as optional second argument (default : " "), ending character (default: "\n") as optional third def dd(): return defaultdict(int) #returns a dictionary with values defaulted to 0 def ddl(): return defaultdict(list) #returns a dictionary with values defaulted to [] def write(s): return sys.stdout.write(s) ################################################################### def main(): #CODE GOES HERE: n=ii() x=li() l,r=min(x),max(x) answer0=float("inf") for s in range(l,r+1): answer0=min(answer0,sum([(i-s)*(i-s) for i in x])) print(answer0) """ -------- Python 2 and 3 footer by Pajenegod and c1729 ---------""" py2 = round(0.5) if py2: from future_builtins import ascii, filter, hex, map, oct, zip range = xrange import os, sys from io import IOBase, BytesIO BUFSIZE = 8192 class FastIO(BytesIO): newlines = 0 def __init__(self, file): self._file = file self._fd = file.fileno() self.writable = "x" in file.mode or "w" in file.mode self.write = super(FastIO, self).write if self.writable else None def _fill(self): s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0]) return s def read(self): while self._fill(): pass return super(FastIO, self).read() def readline(self): while self.newlines == 0: s = self._fill(); self.newlines = s.count(b"\n") + (not s) self.newlines -= 1 return super(FastIO, self).readline() def flush(self): if self.writable: os.write(self._fd, self.getvalue()) self.truncate(0), self.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable if py2: self.write = self.buffer.write self.read = self.buffer.read self.readline = self.buffer.readline else: self.write = lambda s: self.buffer.write(s.encode('ascii')) self.read = lambda: self.buffer.read().decode('ascii') self.readline = lambda: self.buffer.readline().decode('ascii') sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip('\r\n') # sys.stdin = open('input.txt', 'r') # sys.stdout = open('output.txt', 'w') """ main function""" if __name__ == '__main__': main() # threading.Thread(target=main).start()
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
561,531
561,532
u436697953
python
p02767
N = int(input()) X = list(map(int, input().split())) x_max = 100 ans_min = 10000 for p in range(x_max): sum_ = 0 for x in X: sum_ += (x - p) ** 2 ans_min = min(sum_, ans_min) print(ans_min)
N = int(input()) X = list(map(int, input().split())) p_max = 100 ans_min = 1000000 # 最大でも(100 - 1) ** 2 * 100だからそれを超えればいい for p in range(1, p_max): sum_ = 0 for x in X: sum_ += (x - p) ** 2 ans_min = min(sum_, ans_min) print(ans_min)
[ "assignment.variable.change", "identifier.change", "literal.number.integer.change", "assignment.value.change", "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "control_flow.loop.range.bounds.upper.change", "call.arguments.add" ]
561,540
561,541
u572122511
python
p02767
N = int(input()) X = list(map(int, input().split())) x_max = 100 ans_min = 10000 for p in range(x_max): sum_ = 0 for x in X: sum_ += (x - p) ** 2 ans_min = min(sum_, ans_min) print(ans_min)
N = int(input()) X = list(map(int, input().split())) x_max = 100 ans_min = 1000000 for p in range(x_max): sum_ = 0 for x in X: sum_ += (x - p) ** 2 ans_min = min(sum_, ans_min) print(ans_min)
[ "literal.number.integer.change", "assignment.value.change" ]
561,540
561,542
u572122511
python
p02767
N = int(input()) X=list(map(int, input().split())) #print(N,X) L=min(X) H=max(X) smallest = 10**4 for p in range(L,H+1): sum=0 #print(p) for j in range(N): sum=sum+(X[j]-p)**2 #print(sum) if sum<=smallest: smallest=sum print(smallest)
N = int(input()) X=list(map(int, input().split())) #print(N,X) L=min(X) H=max(X) smallest = 10**18 for p in range(L,H+1): sum=0 #print(p) for j in range(N): sum=sum+(X[j]-p)**2 #print(sum) if sum<=smallest: smallest=sum print(smallest)
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
561,547
561,548
u914797917
python
p02767
N = int(input()) X=list(map(int, input().split())) #print(N,X) L=min(X) H=max(X) smallest = 10**4 for p in range(L,H): sum=0 #print(p) for j in range(N): sum=sum+(X[j]-p)**2 #print(sum) if sum<smallest: smallest=sum print(smallest)
N = int(input()) X=list(map(int, input().split())) #print(N,X) L=min(X) H=max(X) smallest = 10**18 for p in range(L,H+1): sum=0 #print(p) for j in range(N): sum=sum+(X[j]-p)**2 #print(sum) if sum<=smallest: smallest=sum print(smallest)
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change", "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
561,549
561,548
u914797917
python
p02767
N = int(input()) X=list(map(int, input().split())) MaxX = max(X) ans = 10 ** 7 for i in range(1,MaxX): cost = 0 for j in range(len(X)): cost += abs(X[j] - i) ** 2 ans = min(ans, cost) print(ans)
N = int(input()) X=list(map(int, input().split())) MaxX = max(X) ans = 10 ** 7 for i in range(1,MaxX+1): cost = 0 for j in range(len(X)): cost += abs(X[j] - i) ** 2 ans = min(ans, cost) print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
561,556
561,557
u695261159
python
p02767
n =int(input()) xi = list(map(int,input().split())) min_kyo = 0 for house in xi: min_kyo += (1 -house)**2 for i in range(2,max(xi)): kyori = 0 for house in xi: kyori += (i - house)**2 if kyori < min_kyo: min_kyo = kyori print(min_kyo)
n =int(input()) xi = list(map(int,input().split())) min_kyo = 0 for house in xi: min_kyo += (1 - house)**2 for i in range(2,max(xi)+1): kyori = 0 for house in xi: kyori += (i - house)**2 if kyori < min_kyo: min_kyo = kyori print(min_kyo)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
561,558
561,559
u045628053
python
p02767
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)))
[ "call.arguments.add" ]
561,573
561,574
u878654696
python
p02767
N=int(input()) X=list(map(int,input().split())) minhp=10001 for i in range(1,101): hp=0 for hu in X: hp+=(hu-i)**2 minhp=min(minhp,hp) print(minhp)
N=int(input()) X=list(map(int,input().split())) minhp=10000001 for i in range(1,101): hp=0 for hu in X: hp+=(hu-i)**2 minhp=min(minhp,hp) print(minhp)
[ "literal.number.integer.change", "assignment.value.change" ]
561,575
561,576
u847923740
python
p02767
N=int(input()) X=list(map(int,input().split())) minhp=10001 for i in range(1,101): hp=0 for hu in X: hp+=(hu-i)**2 minhp=min(minhp,hp) print(minhp)
N=int(input()) X=list(map(int,input().split())) minhp=10000001 for i in range(1,101): hp=0 for hu in X: hp+=(hu-i)**2 minhp=min(minhp,hp) print(minhp)
[ "literal.number.integer.change", "assignment.value.change" ]
561,577
561,576
u847923740
python
p02767
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())) v_min = 10 ** 18 m = min( X ) M = max( X ) for i in range( m, M + 1): v = 0 for x in X: v += ( i - x ) ** 2 v_min = min( v, v_min ) print( v_min )
[ "identifier.change" ]
561,598
561,599
u699008198
python
p02767
#C N = int(input()) X = list(map(int, input().split())) ans = 10 ** 12 for i in range(max(X)): tmp_ans = 0 for xi in X: tmp_ans += (xi - i) ** 2 ans = min(ans, tmp_ans) print(ans)
#C N = int(input()) X = list(map(int, input().split())) ans = 10 ** 12 for i in range(1, max(X)+1): tmp_ans = 0 for xi in X: tmp_ans += (xi - i) ** 2 ans = min(ans, tmp_ans) print(ans)
[ "call.arguments.add" ]
561,602
561,603
u982591663
python
p02767
N = int(input()) X = list(map(int, input().split())) X.sort() Y = [0] * max(X) for _x in X: for y_idx in range(len(Y)): Y[y_idx] += (_x - y_idx)**2 print(min(Y))
N = int(input()) X = list(map(int, input().split())) X.sort() Y = [0] * (max(X) + 1) for _x in X: for y_idx in range(len(Y)): Y[y_idx] += (_x - y_idx)**2 print(min(Y))
[]
561,604
561,605
u528376608
python
p02767
#整数の入力 N = int(input()) #スペース区切りの整数の入力リスト X_list = list(map(int, input().split())) ans_list = [] for i in range(N): ans = 0 for j in range(N): ans = ans + (X_list[j]-(i+1))**2 #print(j,"座標:",X_list[j],i+1,"番目 →",ans) ans_list.append(ans) print(min(ans_list))
#整数の入力 N = int(input()) #スペース区切りの整数の入力リスト X_list = list(map(int, input().split())) ans_list = [] for i in range(100): ans = 0 for j in range(N): ans += (X_list[j]-(i+1))**2 ans_list.append(ans) print(min(ans_list))
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "control_flow.loop.range.bounds.upper.change", "assignment.value.change", "expression.operation.binary.remove" ]
561,611
561,612
u964521959
python
p02767
N = int(input()) X = list(map(int, input().split())) start = min(X) stop = max(X) count = 0 ans = 10**9 for i in range(start, stop): count = 0 for x in X: count += (x-i)**2 ans = min(count, ans) print(ans)
N = int(input()) X = list(map(int, input().split())) start = min(X) stop = max(X) count = 0 ans = 10**10 for i in range(start, stop+1): count = 0 for x in X: count += (x-i)**2 ans = min(count, ans) print(ans)
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
561,615
561,614
u597622207
python
p02767
N=int(input()) X=list(map(int,input().split())) x=[] maxx=max(X) sum=0 for p in range(maxx): for j in X: sum+=(j-p)**2 x.append(sum) sum=0 ans=min(x) print(ans)
N=int(input()) X=list(map(int,input().split())) x=[] maxx=max(X) sum=0 for p in range(maxx+10): for j in X: sum+=(j-p)**2 x.append(sum) sum=0 ans=min(x) print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
561,616
561,617
u225020286
python
p02767
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)
[ "call.remove" ]
561,621
561,622
u851469594
python
p02767
n = int(input()) x = list(map(int, input().split())) sum_list = [] start = min(x) stop = max(x) for i in range(start, stop): sum = 0 for j in x: sum += (i - j) ** 2 sum_list.append(sum) print(min(sum_list))
n = int(input()) x = list(map(int, input().split())) sum_list = [] start = min(x) stop = max(x) for i in range(1, 100): sum = 0 for j in x: sum += (i - j) ** 2 sum_list.append(sum) print(min(sum_list))
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "control_flow.loop.range.bounds.lower.change", "control_flow.loop.range.bounds.upper.change" ]
561,623
561,624
u581403769
python
p02767
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)
[ "call.arguments.change" ]
561,627
561,628
u629350026
python
p02767
N = int(input()) X = list(map(int, input().split())) ans = 1000000 for i in range(max(X)): n = 0 for j in range(N): n += (X[j]-i)**2 if n < ans: ans = n print(ans)
N = int(input()) X = list(map(int, input().split())) ans = 1000000 for i in range(1,max(X)+1): n = 0 for j in range(N): n += (X[j]-i)**2 if n < ans: ans = n print(ans)
[ "call.arguments.add" ]
561,634
561,635
u531599639
python
p02766
import sys N,K = map(int,input().split()) for i in range (1,1000): if K ** i >= N: print(i) sys.exit()
import sys N,K = map(int,input().split()) for i in range (1,1000): if K ** i > N: print(i) sys.exit()
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
561,636
561,637
u990824124
python
p02766
N,K=map(int,input().split()) cnt=1 while N > K**cnt: cnt += 1 print(int(cnt))
N,K=map(int,input().split()) cnt=1 while N >= K**cnt: cnt += 1 print(int(cnt))
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
561,638
561,639
u329407311
python
p02766
N,K=map(int,input().split()) cnt=1 while N > K**cnt: cnt += 1 print(cnt)
N,K=map(int,input().split()) cnt=1 while N >= K**cnt: cnt += 1 print(int(cnt))
[ "expression.operator.compare.change", "control_flow.loop.condition.change", "call.add", "call.arguments.change" ]
561,640
561,639
u329407311
python
p02766
n,k = map(int,input().split()) ans = 1 c = k while n > c: c *= k ans += 1 print(ans)
n,k = map(int,input().split()) ans = 1 c = k while n >= c: c *= k ans += 1 print(ans)
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
561,643
561,644
u918935103
python
p02766
N, K = map(int, input().split()) ans = 0 now = 1 while now < N: now *= K ans += 1 print(ans)
N, K = map(int, input().split()) ans = 0 now = 1 while now <= N: now *= K ans += 1 print(ans)
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
561,649
561,650
u102305348
python
p02766
N, K = map(int, input().split()) ans = 1 now = K while now < N: now *= K ans += 1 print(ans)
N, K = map(int, input().split()) ans = 0 now = 1 while now <= N: now *= K ans += 1 print(ans)
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
561,651
561,650
u102305348
python
p02766
# coding:utf-8 N, K = map(int, input().split(' ')) digit = K cnt = 1 while digit < N: digit *= K cnt += 1 print(cnt)
# coding:utf-8 N, K = map(int, input().split(' ')) digit = K cnt = 1 while digit <= N: digit *= K cnt += 1 print(cnt)
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
561,652
561,653
u292849987
python
p02766
n, k = map(int, input().split()) i = 0 while True: s = k ** i if n / s > 1: i += 1 continue else: break print(i)
n, k = map(int, input().split()) i = 0 while True: s = k ** i if n / s >= 1: i += 1 continue else: break print(i)
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
561,661
561,662
u652057333
python
p02766
N, K = map(int, input().split()) ans = 0 while K ** ans < N: ans += 1 print(ans)
N, K = map(int, input().split()) ans = 0 while K ** ans <= N: ans += 1 print(ans)
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
561,669
561,670
u716529032
python
p02766
import sys sys.setrecursionlimit(10 ** 6) input = sys.stdin.readline N, K = [int(x) for x in input().strip().split()] cnt = 1 c = K while c < N: c *= K cnt += 1 print(cnt)
import sys sys.setrecursionlimit(10 ** 6) input = sys.stdin.readline N, K = [int(x) for x in input().strip().split()] cnt = 1 c = K while c <= N: c *= K cnt += 1 print(cnt)
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
561,673
561,674
u408620326
python
p02766
n,p=map(int,input().split()) for i in range(10000): if p**i<=n<p**(i+1): print(i-1) exit()
n,p=map(int,input().split()) for i in range(10000): if p**i<=n<p**(i+1): print(i+1) exit()
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
561,675
561,676
u023229441
python
p02766
N,K = map(int,input().split()) result = 0 while True: if N / K > 1: result +=1 N = N / K else: break print(result+1)
N,K = map(int,input().split()) result = 0 while True: if N / K >= 1: result += 1 N = N / K else: break print(result+1)
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
561,684
561,685
u503111914
python
p02766
N, K = map(int, input().split()) s = 0 while N > K**s: s = s+1 print (s)
N, K = map(int, input().split()) s = 0 while N >= K**s: s = s+1 print (s)
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
561,688
561,689
u375477204
python
p02766
# coding: utf-8 N,k=map(int,input().split()) for i in range(N): if k**i>N: idx=i break print(idx)
# coding: utf-8 N,k=map(int,input().split()) idx=1 for i in range(N): if k**i>N: idx=i break print(idx)
[ "assignment.add" ]
561,690
561,691
u681444474
python
p02766
import math N, K = map(int, input().split()) count = 0 now = 1 while True: if N <= now: break else: count += 1 now *= K print(count)
import math N, K = map(int, input().split()) count = 0 now = 1 while True: if N < now: break else: count += 1 now *= K print(count)
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
561,696
561,697
u749359783
python
p02766
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float('inf') def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) n,k = LI() cnt = 0 tmp = 1 while tmp < n: tmp *= k cnt += 1 print(cnt)
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float('inf') def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) n,k = LI() cnt = 0 tmp = 1 while tmp <= n: tmp *= k cnt += 1 print(cnt)
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
561,704
561,705
u191874006
python
p02767
N=int(input()) X=list(map(int,input().split())) l=len(X) s=10**10 for i in range(min(X),max(X)): x=[] for j in range(l): x.append((X[j]-i)**2) if s>sum(x): s=sum(x) print(s)
N=int(input()) X=list(map(int,input().split())) l=len(X) s=10**10 for i in range(min(X),max(X)+1): x=[] for j in range(l): x.append((X[j]-i)**2) if s>sum(x): s=sum(x) print(s)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
561,712
561,713
u827261928
python
p02767
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)
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
561,716
561,717
u762523240
python
p02767
n = int(input()) line = list(map(int, input().split())) min_dist = 10**9 for i in range(max(line)): sum_dist = 0 for j in range(n): sum_dist += (line[j] - i)**2 if sum_dist < min_dist: min_dist = sum_dist print(min_dist)
n = int(input()) line = list(map(int, input().split())) min_dist = 10**9 for i in range(max(line)+1): sum_dist = 0 for j in range(n): sum_dist += (line[j] - i)**2 if sum_dist < min_dist: min_dist = sum_dist print(min_dist)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
561,722
561,723
u571999153
python
p02767
N = int(input()) X = [int(x) for x in input().split()] ans = 100 ** 2 for i in range(1, max(X)+1): a = 0 for j in range(N): a += (X[j] - i) ** 2 if ans > a: ans = a print(ans)
N = int(input()) X = [int(x) for x in input().split()] ans = 100 ** 2 * N for i in range(min(X), max(X)+1): a = 0 for j in range(N): a += (X[j] - i) ** 2 if ans > a: ans = a print(ans)
[ "identifier.replace.add", "literal.replace.remove", "call.arguments.change", "control_flow.loop.range.bounds.lower.change", "call.arguments.add" ]
561,737
561,738
u241159583
python
p02767
N = int(input()) X = list(map(int, input().split())) ans = 10**18 ans_ = 0 for P in range(-N, N + 1): ans_ = 0 for x in X: ans_ += (x - P) ** 2 ans = min(ans, ans_) print(ans)
N = int(input()) X = list(map(int, input().split())) ans = 10**18 ans_ = 0 for P in range(1, max(X) + 1): ans_ = 0 for x in X: ans_ += (x - P) ** 2 ans = min(ans, ans_) print(ans)
[ "call.arguments.change", "control_flow.loop.range.bounds.upper.change", "expression.operation.unary.remove", "expression.operation.binary.change", "call.arguments.add" ]
561,744
561,745
u344888046
python
p02767
"""Boot-camp-for-Beginners_002_C_Rally_19-August-2020.py""" import numpy as np import sys N=int(input()) X = list(map(int,input().split())) print(X) s=0 for i in range(len(X)): s+=X[i] P=int(s/N) Sum_round_down=0 Sum_round_up=0 for i in range(len(X)): Sum_round_down+=(P-X[i])**2 Sum_round_up+=(P+1-X[i])**2 if(Sum_round_down>=Sum_round_up): Sum=Sum_round_up else: Sum=Sum=Sum_round_down print(int(Sum))
"""Boot-camp-for-Beginners_002_C_Rally_19-August-2020.py""" import numpy as np import sys N=int(input()) X = list(map(int,input().split())) s=0 for i in range(len(X)): s+=X[i] P=int(s/N) Sum_round_down=0 Sum_round_up=0 for i in range(len(X)): Sum_round_down+=(P-X[i])**2 Sum_round_up+=(P+1-X[i])**2 if(Sum_round_down>=Sum_round_up): Sum=Sum_round_up else: Sum=Sum=Sum_round_down print(int(Sum))
[ "call.remove" ]
561,746
561,747
u208120643
python
p02767
N = int(input()) X = list(map(int, input().split())) cnt = 0 mini = float('inf') P = max(X) for i in range(1, P): for j in range(len(X)): cnt += (X[j] - i)**2 if cnt < mini: mini = cnt cnt = 0 print(mini)
N = int(input()) X = list(map(int, input().split())) cnt = 0 mini = float('inf') P = max(X) + 1 for i in range(P): for j in range(len(X)): cnt += (X[j] - i)**2 if cnt < mini: mini = cnt cnt = 0 print(mini)
[ "call.arguments.change" ]
561,754
561,753
u776311944
python
p02767
N = int(input()) X = list(map(int, input().split())) costs = [] for i in range(max(X)): costs.append(sum(map(lambda x: (x - i)**2, X))) print(min(costs))
N = int(input()) X = list(map(int, input().split())) costs = [] for p in range(100): costs.append(sum(map(lambda x: (x - p)**2, X))) print(min(costs))
[ "identifier.change", "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.change" ]
561,755
561,756
u991542950
python
p02767
N = int(input()) cc = list(map(int,input().split())) count = 0 min_sum = float('inf') for i in range(1,101): for j in cc: count += (i-j)**2 min_sum = min(min_sum,count) print(min_sum)
N = int(input()) cc = list(map(int,input().split())) min_sum = float('inf') for i in range(1,101): count = 0 for j in cc: count += (i-j)**2 min_sum = min(min_sum,count) print(min_sum)
[ "assignment.remove", "assignment.add" ]
561,757
561,758
u089925107
python
p02767
n = input() s = map(int,input().split()) m = 10000000 for p in range(0,101): t = 0 for x in s: t+=(x-p)**2 m = min(t,m) print(m)
n = input() s = list(map(int,input().split())) m = 10000000 for p in range(0,101): t = 0 for x in s: t+=(x-p)**2 m = min(t,m) print(m)
[ "call.add", "call.arguments.change" ]
561,780
561,781
u946969297
python
p02767
n = int(input()) x = list(map(int, input().split())) x.sort() res = 10**7 for i in range(x[0],x[-1]): tmp = 0 for j in x: tmp += (j-i)**2 res = min(tmp,res) print(res)
n = int(input()) x = list(map(int, input().split())) x.sort() res = 10**7 for i in range(x[0],x[-1]+1): tmp = 0 for j in x: tmp += (j-i)**2 res = min(tmp,res) print(res)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
561,786
561,787
u935642171
python
p02767
N=int(input()) X=list(map(int, input().split())) ans =100000000000 tmp=0 cnt=0 for i in range(X[0],X[-1]+1): for j in range(len(X)): tmp += (X[j]-i)**2 if ans > tmp: ans =tmp tmp=0 print(ans)
N=int(input()) X=sorted(list(map(int, input().split()))) ans =100000000000 tmp=0 cnt=0 for i in range(X[0],X[-1]+1): for j in range(len(X)): tmp += (X[j]-i)**2 if ans > tmp: ans =tmp tmp=0 print(ans)
[ "call.add", "call.arguments.change" ]
561,788
561,789
u247211039
python
p02767
N=int(input()) X=list(map(int, input().split())) ans =100000000000 tmp=0 cnt=0 for i in range(X[0],X[-1]+1): for j in range(len(X)): tmp += (X[j]-i)**2 if ans > tmp: ans =tmp tmp=0 print(ans)
N=int(input()) X=sorted(list(map(int, input().split()))) ans =100000000000 tmp=0 cnt=0 for i in range(X[0],X[-1]+1): for j in range(len(X)): tmp += (X[j]-i)**2 if ans > tmp: ans =tmp tmp=0 print(ans)
[ "call.add", "call.arguments.change" ]
561,790
561,789
u247211039
python
p02767
def dist(x, p): return (x - p)**2 n = int(input()) x = [int(i) for i in input().split()] index = len(x) // 2 new_x = sorted(x) p1 = - (- sum(x) // len(x)) p2 = sum(x) // len(x) ans = [0, 0] for i in new_x: ans[0] += dist(i, p1) ans[1] += dist(i, p2) print(ans)
def dist(x, p): return (x - p)**2 n = int(input()) x = [int(i) for i in input().split()] index = len(x) // 2 new_x = sorted(x) p1 = - (- sum(x) // len(x)) p2 = sum(x) // len(x) ans = [0, 0] for i in new_x: ans[0] += dist(i, p1) ans[1] += dist(i, p2) print(min(ans))
[ "call.arguments.add", "call.arguments.change" ]
561,799
561,800
u511449169
python
p02767
input() *X,=sorted(map(int,input().split())) a=10**4 for p in range(X[0], X[-1]+1): a=min(a, sum((n-p)**2 for n in X)) print(a)
N=int(input()) *X,=sorted(map(int,input().split())) a=10**9 for p in range(X[0], X[-1]+1): a=min(a, sum((n-p)**2 for n in X)) print(a)
[ "call.arguments.change", "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
561,801
561,802
u623814058
python
p02767
N = int(input()) X = list(map(int, input().split())) ans = 10e9 for i in range(1,max(X)): tmp = 0 for j in range(N): tmp += (X[j]-i)**2 if tmp < ans: ans = tmp # print(tmp) print(ans)
N = int(input()) X = list(map(int, input().split())) ans = 10e9 for i in range(0,max(X)+1): tmp = 0 for j in range(N): tmp += (X[j]-i)**2 if tmp < ans: ans = tmp # print(tmp) print(ans)
[ "literal.number.integer.change", "call.arguments.change", "control_flow.loop.range.bounds.lower.change" ]
561,810
561,811
u304593245
python
p02767
N = int(input()) x = list(map(int,input().split())) l=[] for p in range(1,N+1): sum=0 for i in range(N): sum += (x[i]-p)**2 l.append(sum) print(sorted(l)[0])
N = int(input()) x = list(map(int,input().split())) l=[] for p in range(1,101): sum=0 for i in range(N): sum += (x[i]-p)**2 l.append(sum) print(sorted(l)[0])
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.remove" ]
561,818
561,819
u425762225
python
p02767
N = int(input()) X = list(map(int,input().split())) minimum = 10000000 for n in range(1,N+1): kyori = 0 for i in range(N): kyori += (X[i]-n)**2 #print(kyori) 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)
[ "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.range.bounds.upper.change", "call.arguments.add" ]
561,820
561,821
u720558413
python
p02767
N = int(input()) regis = list(map(int, input().split())) ans = 999999999 for i in range(max(regis)): hp_sum = 0 for regi in regis: hp_sum += (regi - i)**2 ans = min(ans , hp_sum) print(ans)
N = int(input()) regis = list(map(int, input().split())) ans = 999999999 for i in range(200): hp_sum = 0 for regi in regis: hp_sum += (regi - i)**2 ans = min(ans , hp_sum) print(ans)
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "control_flow.loop.range.bounds.upper.change" ]
561,824
561,825
u459215900
python
p02767
N = int(input()) X = list(map(int,input().split())) ans = 10**9 for i in range(max(X)): s = 0 for j in X: s += (i-j)**2 ans = min(ans,s) print(ans)
N = int(input()) X = list(map(int,input().split())) ans = 10**9 for i in range(1,max(X)+1): s = 0 for j in X: s += (i-j)**2 ans = min(ans,s) print(ans)
[ "call.arguments.add" ]
561,830
561,831
u679520304
python
p02767
N = int(input()) X = list(map(int, input().split())) mn = 10**9 for p in range(min(X), max(X)): c = 0 for x in X: c += (p-x)**2 mn = min(c, mn) print(mn)
N = int(input()) X = list(map(int, input().split())) mn = 10**9 for p in range(min(X), max(X)+1): c = 0 for x in X: c += (p-x)**2 mn = min(c, mn) print(mn)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
561,834
561,835
u333190709
python
p02767
N = int(input()) X = list(map(int,input().split())) ans = 1000000000000000 for i in range(1,101): hp=0 for j in range(N): B = (X[j]-i) ** 2 hp+=B print(hp) if ans > hp: ans=hp print(ans)
N = int(input()) X = list(map(int,input().split())) ans = 1000000000000000 for i in range(1,101): hp=0 for j in range(N): B = (X[j]-i) ** 2 hp+=B if ans > hp: ans=hp print(ans)
[ "call.remove" ]
561,840
561,841
u554784585
python
p02767
n = int(input()) x = list(map(int, input().split())) ans = 10 ** 9 for p in range(0, n+1): cnt = 0 for i in x: cnt += (i-p)**2 ans = min(ans, cnt) print(ans)
n = int(input()) x = list(map(int, input().split())) ans = 10 ** 9 for p in range(0, 101): cnt = 0 for i in x: cnt += (i-p)**2 ans = min(ans, cnt) print(ans)
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.remove" ]
561,852
561,853
u057415180
python
p02767
n = int(input()) x = list(map(int, input().split())) ans = 10 ** 9 for p in range(1, n+1): cnt = 0 for i in x: cnt += (i-p)**2 ans = min(ans, cnt) print(ans)
n = int(input()) x = list(map(int, input().split())) ans = 10 ** 9 for p in range(0, 101): cnt = 0 for i in x: cnt += (i-p)**2 ans = min(ans, cnt) print(ans)
[ "literal.number.integer.change", "call.arguments.change", "control_flow.loop.range.bounds.lower.change", "identifier.replace.remove", "literal.replace.add", "expression.operation.binary.change", "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.remove" ]
561,854
561,853
u057415180
python
p02767
n = int(input()) li = list(map(int,input().split())) o1 = (sum(li))//n o2 = o1 + 1 li1 = [] li2 = [] for i in range(n): li1.append((int(li[i]-o1))**2) for j in range(n): li2.append((int(li[j]-o2))**2) if sum(li1) >= sum(li2): print(sum(li2)) else: print(sum(li2))
n = int(input()) li = list(map(int,input().split())) o1 = (sum(li))//n o2 = o1 + 1 li1 = [] li2 = [] for i in range(n): li1.append((int(li[i]-o1))**2) for j in range(n): li2.append((int(li[j]-o2))**2) if sum(li1) >= sum(li2): print(sum(li2)) else: print(sum(li1))
[ "identifier.change", "call.arguments.change", "io.output.change" ]
561,855
561,856
u209275335
python
p02767
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)
[ "call.remove" ]
561,857
561,858
u680503348
python
p02767
n=int(input()) l=list(map(int,input().split())) ans=10e8 for j in range(l[0],l[-1]+1): hp=0 for i in l: hp+=(i-j)**2 if ans>hp: ans=hp print(ans)
n=int(input()) l=list(map(int,input().split())) l.sort() ans=10e8 for j in range(l[0],l[-1]+1): hp=0 for i in l: hp+=(i-j)**2 if ans>hp: ans=hp print(ans)
[ "call.add" ]
561,861
561,862
u901598613
python
p02767
import sys import math from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN from collections import deque from bisect import bisect_left from itertools import product def I(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] #文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる def LSI(): return list(map(int, list(sys.stdin.readline().rstrip()))) def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)] #文字列として取得 def ST(): return sys.stdin.readline().rstrip() def LST(): return sys.stdin.readline().rstrip().split() def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)] def FILL(i,h): return [i for j in range(h)] def FILL2(i,h,w): return [FILL(i,w) for j in range(h)] def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)] def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)] def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP) #'0.01'や'1E1'などで指定、整数に戻すならintをかます MOD = 1000000007 INF = float("inf") sys.setrecursionlimit(10**6+10) N = I() X = LI() max_x = max(X) ans = INF for i in range(1,max_x): temp = 0 for j in X: temp += (j-i)**2 ans = min(ans,temp) print(ans)
import sys import math from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN from collections import deque from bisect import bisect_left from itertools import product def I(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)] #文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる def LSI(): return list(map(int, list(sys.stdin.readline().rstrip()))) def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)] #文字列として取得 def ST(): return sys.stdin.readline().rstrip() def LST(): return sys.stdin.readline().rstrip().split() def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)] def FILL(i,h): return [i for j in range(h)] def FILL2(i,h,w): return [FILL(i,w) for j in range(h)] def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)] def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)] def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP) #'0.01'や'1E1'などで指定、整数に戻すならintをかます MOD = 1000000007 INF = float("inf") sys.setrecursionlimit(10**6+10) N = I() X = LI() max_x = max(X) ans = INF for i in range(1,max_x+1): temp = 0 for j in X: temp += (j-i)**2 ans = min(ans,temp) print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
561,873
561,874
u380995377
python
p02767
def f(n, x): mean = np.mean(x) s1 = sum((x-np.floor(mean))**2) s2 = sum((x-np.ceil(mean))**2) print(int(min(s1, s2))) n = int(input()) x = list(map(int, input().split())) f(n, x)
# ABC156C import numpy as np def f(n, x): mean = np.mean(x) s1 = sum((x-np.floor(mean))**2) s2 = sum((x-np.ceil(mean))**2) print(int(min(s1, s2))) n = int(input()) x = list(map(int, input().split())) f(n, x)
[]
561,898
561,899
u437215432
python
p02767
def f(n, x): mean = np.mean(x) s1 = sum((x-np.floor(mean))**2) s2 = sum((x-np.ceil(mean))**2) print(int(min(s1, s2))) n = int(input()) x = list(map(int, input().split())) f(n, x)
import numpy as np def f(n, x): mean = np.mean(x) s1 = sum((x-np.floor(mean))**2) s2 = sum((x-np.ceil(mean))**2) print(int(min(s1, s2))) n = int(input()) x = list(map(int, input().split())) f(n, x)
[]
561,898
561,900
u437215432
python
p02767
N = int(input()) X = [int(x) for x in input().split()] Xmax = max(X) Xmin = min(X) Pmin = 1000000 for i in range(Xmin, Xmax): p = 0 for x in X: p += (x - i) ** 2 Pmin = min(Pmin, p) print(Pmin)
N = int(input()) X = [int(x) for x in input().split()] Xmax = max(X) Xmin = min(X) Pmin = 1000000 for i in range(Xmin, Xmax + 1): p = 0 for x in X: p += (x - i) ** 2 Pmin = min(Pmin, p) print(Pmin)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
561,903
561,904
u842797390
python
p02767
n = int(input()) x = list(map(int,input().split())) S = sum(x) Ave = sum(x) // n m = 10**6 score = 0 count = 0 for p in range(Ave-100,Ave+101): for i in range(n): score += (x[i]-p)**2 if score < m: m = score score = 0 print(m)
n = int(input()) x = list(map(int,input().split())) S = sum(x) Ave = sum(x) // n m = 10**6 score = 0 for p in range(Ave,Ave+1001): for i in range(n): score += (x[i]-p)**2 if score < m: m = score score = 0 print(m)
[ "expression.operation.binary.remove", "literal.number.integer.change", "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.range.bounds.upper.change" ]
561,911
561,912
u045953894
python
p02767
n = int(input()) X = list(map(int, input().split())) sum = 0 for x in X: sum += x avg = sum // n ans = 0 for x in X: ans += pow((x-avg), 2) print(ans)
n = int(input()) X = list(map(int, input().split())) sum = 0 for x in X: sum += x avg = round(sum / n) ans = 0 for x in X: ans += pow((x-avg), 2) print(ans)
[ "call.add", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change", "call.arguments.change" ]
561,915
561,916
u548976218
python
p02767
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))
[ "call.remove" ]
561,921
561,922
u635252313
python
p02767
N = int(input()) X = list(map(int, input().split())) ans = float("inf") for i in range(N): conf_site = X[i] total = sum([(x - conf_site)**2 for x in X]) ans = min(ans, total) print(ans)
N = int(input()) X = list(map(int, input().split())) ans = float("inf") for i in range(1,101): conf_site = i total = sum([(x - conf_site)**2 for x in X]) ans = min(ans, total) print(ans)
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "control_flow.loop.range.bounds.upper.change", "call.arguments.add" ]
561,925
561,926
u548545174
python
p02767
N = int(input()) x = list(map(int,input().split())) l =[] dis = 0 for i in range(max(x)) : for a in x: dis += (i-a)**2 l.append(dis) dis = 0 print(min(l))
N = int(input()) x = list(map(int,input().split())) l =[] dis = 0 for i in range(1,max(x)+1) : for a in x: dis += (i-a)**2 l.append(dis) dis = 0 print(min(l))
[ "call.arguments.add" ]
561,929
561,930
u924717835
python
p02767
N = int(input()) X = list(map(int, input().split())) L = min(X) R = max(X) def ene(p): cost = 0 for x in X: cost += (x - p) * (x - p) return cost energy = float('inf') while (L < R): energy = min([energy, ene(L)]) L += 1 print(energy)
N = int(input()) X = list(map(int, input().split())) L = min(X) R = max(X) def ene(p): cost = 0 for x in X: cost += (x - p) * (x - p) return cost energy = float('inf') while (L <= R): energy = min([energy, ene(L)]) L += 1 print(energy)
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
561,931
561,932
u819860987
python
p02767
N = int(input()) X = list(map(int,input().split())) d = [0]*(max(X)+1-min(X)) for i in range(min(X),max(X)+1): for x in X: d[i-min(X)] += (x-i-min(X))**2 if i > min(X) and d[i-min(X)] >= d[i-1-min(X)]: print(d[i-1-min(X)]) exit(0) print(min(d))
N = int(input()) X = list(map(int,input().split())) d = [0]*(max(X)+1-min(X)) for i in range(min(X),max(X)+1): for x in X: d[i-min(X)] += (x-i)**2 if i > min(X) and d[i-min(X)] >= d[i-1-min(X)]: print(d[i-1-min(X)]) exit(0) print(min(d))
[ "expression.operation.binary.remove" ]
561,933
561,934
u876536031
python
p02767
N = int(input()) X = list(map(int, input().split())) A = [] for x in range(min(X)+1,max(X)): S = 0 for i in range(N): S = S + (X[i] - x)**2 A.append(S) print(min(A))
N = int(input()) X = list(map(int, input().split())) A = [] for x in range(min(X),max(X)+1): S = 0 for i in range(N): S = S + (X[i] - x)**2 A.append(S) print(min(A))
[ "expression.operation.binary.remove" ]
561,939
561,940
u248221744
python
p02767
n=int(input()) x=list(map(int,input().split())) ans=1145141919 for p in range(max(x)): tmp_ans=0 for i in range(n): tmp_ans+=(x[i]-p)**2 ans=min(ans,tmp_ans) print(ans)
n=int(input()) x=list(map(int,input().split())) ans=1145141919 for p in range(max(x)+1): tmp_ans=0 for i in range(n): tmp_ans+=(x[i]-p)**2 ans=min(ans,tmp_ans) print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
561,941
561,942
u405660020
python
p02767
n = int(input()) point_list = list(map(int, input().split())) hp_list = [] for p in range(max(point_list)): hp = 0 for i in range(len(point_list)): hp += (point_list[i] - p) ** 2 hp_list.append(hp) print(min(hp_list))
n = int(input()) point_list = list(map(int, input().split())) hp_list = [] for p in range(1, max(point_list) + 1): hp = 0 for i in range(len(point_list)): hp += (point_list[i] - p) ** 2 hp_list.append(hp) print(min(hp_list))
[ "call.arguments.add" ]
561,943
561,944
u134019875
python
p02767
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))
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))
[ "assignment.add" ]
561,945
561,946
u857673087
python
p02767
N = int(input()) *X, = map(int, input().split()) mn = min(X) mx = max(X) ans = [] hps = [] for i in range(X[-1]): for x in X: hps.append((x - i) ** 2) ans.append(sum(hps)) hps = [] print(min(ans))
N = int(input()) *X, = map(int, input().split()) mn = min(X) mx = max(X) ans = [] hps = [] for i in range(mx + 1): for x in X: hps.append((x - i) ** 2) ans.append(sum(hps)) hps = [] print(min(ans))
[ "expression.operation.unary.arithmetic.remove", "call.arguments.change" ]
561,947
561,948
u764401543
python
p02767
N = int(input()) X = list(map(int, input().split())) cnt_min = 9999 for P in range(1, 101): cnt = 0 for x in X: cnt += (P-x)**2 if cnt < cnt_min: cnt_min = cnt print(cnt_min)
N = int(input()) X = list(map(int, input().split())) cnt_min = 10000000000000000 for P in range(0, 101): cnt = 0 for x in X: cnt += (P-x)**2 if cnt < cnt_min: cnt_min = cnt print(cnt_min)
[ "literal.number.integer.change", "assignment.value.change", "call.arguments.change", "control_flow.loop.range.bounds.lower.change" ]
561,953
561,954
u259265086
python
p02767
N = int(input()) X = list(map(int, input().split())) cnt_min = 9999 for P in range(0, 101): cnt = 0 for x in X: cnt += (P-x)**2 if cnt < cnt_min: cnt_min = cnt print(cnt_min)
N = int(input()) X = list(map(int, input().split())) cnt_min = 10000000000000000 for P in range(0, 101): cnt = 0 for x in X: cnt += (P-x)**2 if cnt < cnt_min: cnt_min = cnt print(cnt_min)
[ "literal.number.integer.change", "assignment.value.change" ]
561,955
561,954
u259265086
python
p02767
n = int(input()) X = list(map(int, input().split())) for p in range(max(X)): sum = 0 for x in X: sum += ((x - p)**2) if p == 0: ans = sum if ans > sum: ans = sum print(ans)
n = int(input()) X = list(map(int, input().split())) for p in range(101): sum = 0 for x in X: sum += ((x - p)**2) if p == 0: ans = sum if ans > sum: ans = sum print(ans)
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "control_flow.loop.range.bounds.upper.change" ]
561,956
561,957
u673173160
python
p02767
n = int(input()) X = list(map(int, input().split())) for p in range(max(X)): sum = 0 for x in X: sum += ((x - p)**2) if p == 0: ans = sum if ans > sum: ans = sum print(ans)
n = int(input()) X = list(map(int, input().split())) for p in range(max(X)+1): sum = 0 for x in X: sum += ((x - p)**2) if p == 0: ans = sum if ans > sum: ans = sum print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
561,956
561,958
u673173160
python
p02767
n = int(input()) X = list(map(int, input().split())) for p in range(max(X)): sum = 0 for x in X: sum += ((x - p)**2) if p == 0: ans = sum if ans > sum: ans = sum print(ans)
n = int(input()) X = list(map(int, input().split())) for p in range(max(X)+100): sum = 0 for x in X: sum += ((x - p)**2) if p == 0: ans = sum if ans > sum: ans = sum print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
561,956
561,959
u673173160
python
p02767
import math N = int(input()) X = list(map(int,input().split())) A = math.ceil(sum(X)/N) B = math.floor(sum(X)/N) a = 0 b = 0 for i in X: a += (i-A)**2 for _ in X: b += (i-B)**2 print(min(a,b))
import math N = int(input()) X = list(map(int,input().split())) A = math.ceil(sum(X)/N) B = math.floor(sum(X)/N) a = 0 b = 0 for i in X: a += (i-A)**2 for _ in X: b += (_-B)**2 print(min(a,b))
[ "identifier.change", "expression.operation.binary.change" ]
561,962
561,963
u733132703
python