Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
X=[int(i) for i in input().split()]
X.sort()

if N==1:
  print(X[M-1]-X[0])
elif N>=M:
  print(0)
elif N+1=M:
  print(X[0])
else:
  Y=list()
  [Y.append(X[i]-X[i-1]) for i in range(M)[1:]]
  Y.sort()
  print(sum(Y[:-(N-1)]))


Fixed submission:
N,M = map(int,input().split())
X=sorted([int(i) for i in input().split()])

Y=list()
for i in range(M)[1:]:
  diff = X[i]-X[i-1]
  Y.append(diff)

Y=sorted(Y)

if N==1:
  print(sum(Y))
else:
  print(sum(Y[:-(N-1)]))

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
X=[int(i) for i in input().split()]
X.sort()

Y=list()
for i in range(M)[1:]
  Y.append(X[i]-X[i-1])

Y.sort()

if N==1:
  print(sum(Y))
else:
  print(sum(Y[:-(N-1)]))


Fixed submission:
N,M = map(int,input().split())
X=sorted([int(i) for i in input().split()])

Y=list()
for i in range(M)[1:]:
  diff = X[i]-X[i-1]
  Y.append(diff)

Y=sorted(Y)

if N==1:
  print(sum(Y))
else:
  print(sum(Y[:-(N-1)]))

Buggy python submission (verdict: Runtime Error):
N=int(input())
M=int(input())

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

Y=list()
before=X[0]
for i in X:
  diff = i - before
  if diff == 0:
    continue
  Y.append(diff)
  before = i

Y=sorted(Y)

print(sum(Y[:-(N-1)]))



Fixed submission:
N,M = map(int,input().split())
X=sorted([int(i) for i in input().split()])

Y=list()
for i in range(M)[1:]:
  diff = X[i]-X[i-1]
  Y.append(diff)

Y=sorted(Y)

if N==1:
  print(sum(Y))
else:
  print(sum(Y[:-(N-1)]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(input().split())

a.sort(reverse=True)

alice = 0
bob = 0

for i in range(len(n)):
    if i % 2 == 0:
        alice = alice + int(a[i])
    else:
        bob = bob + int(a[i])

print (alice-bob)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))

a.sort(reverse=True)

print(sum(a[0::2])-sum(a[1::2]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(n) for n in input().split()]
maxA = max(A)
if maxA < sum(A) - maxA:
	print("yes")
else:
	print("no")

Fixed submission:
import sys
T,X = [int(n) for n in input().split()]

print(T/X)

Buggy python submission (verdict: Runtime Error):
T = input('Tの入力')
X = input('Xの入力')
t = int(T) / int(X)
print(t)

Fixed submission:
import sys
T,X = [int(n) for n in input().split()]

print(T/X)

Buggy python submission (verdict: Runtime Error):
'''T, Xの入力'''
T = input('Tの入力')
X = input('Xの入力')
t = T / X
print(t):

Fixed submission:
import sys
T,X = [int(n) for n in input().split()]

print(T/X)
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = [int(n) for n in input().split()]
maxL = max(L)
if maxL < sum(L) - maxL
	print("yes")
else:
	print("no")

Fixed submission:
N=int(input())
l=list(map(int,input().split()))
max=max(l)
if max<sum(l)-max:
 print("Yes")
else:
 print("No")
Buggy python submission (verdict: Runtime Error):
# M: the number of KOMA
# N: the number of Xs
M, N = map(int, input().split())
# each length of edges
Xs= list(map(int, input().split()))

# searching largest one
largestX = -10**5

# searching smallest one
smallestX = 10**5

# straightforward searching way
for i in range(N):
  if Xs[i] > largestX:
    largestX = Xs[i]
  if Xs[i] < smallestX:
    smallestX = Xs[i]


if M > N:
    print(0)
elif (largestX - smallestX) % M == 0:
    print( int((largestX - smallestX) / M) )
else:
    print( int((largestX - smallestX) / M )+ 1)


Fixed submission:
T, X = map(int, input().split())
print(float(T/X))

Buggy python submission (verdict: Runtime Error):
T, X = map(int(), input().split)
print(float(T/X))

Fixed submission:
T, X = map(int, input().split())
print(float(T/X))
Buggy python submission (verdict: Runtime Error):
# the number of inputs
N = int(input())
# each length of edges
Ls= map(int(), input().split())
largestL = 0
largestIndex = 0
 
# straightforward way
for i in range(N):
  if Ls[i] > largestL:
    largestL = Ls[i]
    largestIndex = i
 
sumOfSmallLs = 0
for i in range(N):
  if i != largestIndex:
    sumOfSmallLs += Ls[i]
 
if sumOfSmallLs < largestL:
  print('Yes')
else:
  print('No')

Fixed submission:
# the number of inputs
N = int(input())
# each length of edges
Ls= list(map(int, input().split()))

# searching largest one
largestL = 0
largestIndex = 0

# straightforward way
for i in range(N):
  if Ls[i] > largestL:
    largestL = Ls[i]
    largestIndex = i

sumOfSmallLs = 0
for i in range(N):
  if i != largestIndex:
    sumOfSmallLs += Ls[i]

if sumOfSmallLs > largestL:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
# the number of inputs
N = int(input())
# each length of edges
Ls= map(int, input().split())
largestL = 0
largestIndex = 0

# straightforward way
for i in range(N):
  if Ls[i] > largestL:
    largestL = Ls[i]
    largestIndex = i

sumOfSmallLs = 0
for i in range(N):
  if i != largestIndex:
    sumOfSmallLs += Ls[i]

if sumOfSmallLs < largestL:
  print('Yes')
else:
  print('No')

Fixed submission:
# the number of inputs
N = int(input())
# each length of edges
Ls= list(map(int, input().split()))

# searching largest one
largestL = 0
largestIndex = 0

# straightforward way
for i in range(N):
  if Ls[i] > largestL:
    largestL = Ls[i]
    largestIndex = i

sumOfSmallLs = 0
for i in range(N):
  if i != largestIndex:
    sumOfSmallLs += Ls[i]

if sumOfSmallLs > largestL:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N = input()
if N == "1":
    print(""Hello Wolrd")
elif N == "2":
    a = int(input())
    b =int(input())
    print(a+b)

Fixed submission:
N = input()
if N == "1":
    print("Hello World")
elif N == "2":
    a = int(input())
    b =int(input())
    print(a+b)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [input() for i in range(N)]

if len(set(a)) != N:
    print("No")
    exit()

for i in range(1,N):
    if  a[i-1][-1] != a[i][0]:
        print("No")
        exit()
pront("Yes")


Fixed submission:
N = int(input())
a = [input() for i in range(N)]

if len(set(a)) != N:
    print("No")
    exit()

for i in range(1,N):
    if  a[i-1][-1] != a[i][0]:
        print("No")
        exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
N = int(input())
for i in range(N):
    t,x,y=map(int,input()split())
    if x+y>t or (t+x+y)%2 != 0:
        print("No")
        break
 print("Yes")

Fixed submission:
N = int(input())
for i in range(N):
    t,x,y=map(int,input().split())
    if x+y>t or (t+x+y)%2 != 0:
        print("No")
        exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
a,b = int(input())
print("%.10f"%(a/b))

Fixed submission:
a,b = map(int,input().split())
print("%.10f"%(a/b))
Buggy python submission (verdict: Runtime Error):
n = int(input())
table = list(map(int,input().split()))
table.sort()
count = 0
for i in range(n):
    if i%2 = 0:
        count += table[i]
    else:
        pass
print(count)

Fixed submission:
n = int(input())
table = list(map(int,input().split()))
table.sort()
count = 0
for i in range(2*n):
    if i%2 == 0:
        count += table[i]
    else:
        pass
print(count)

Buggy python submission (verdict: Runtime Error):
n = int(input())
table = list(map(int,input().split()))
table.sort()
count = 0
for i in range(1,n+1):
    if i%2 = 1:
        count += table[i]
    else:
        pass
print(count)

Fixed submission:
n = int(input())
table = list(map(int,input().split()))
table.sort()
count = 0
for i in range(2*n):
    if i%2 == 0:
        count += table[i]
    else:
        pass
print(count)
Buggy python submission (verdict: Runtime Error):
G, B = map(int,input().split())

if G>0 and B>0:
    print('Positive')

elif G<=0 and B>=0:
    print('Zero')

elif a < 0 and b < 0:
    if (b - a) % 2 == 0:
        print("Negative")
    else:
        print("Positive")

Fixed submission:
G, B = map(int,input().split())

if G>0 and B>0:
    print('Positive')

elif G<=0 and B>=0:
    print('Zero')

elif G < 0 and B < 0:
    if (B - G) % 2 == 0:
        print("Negative")
    else:
        print("Positive")

Buggy python submission (verdict: Runtime Error):
G, B = map(int,input().split())

if G*B <= 0:
  print('Zero')

elif G > 0:
  print('Positive')

elif (b - a) % 2 == 0:
  print('Negative')

Fixed submission:
G, B = map(int,input().split())

if G>0 and B>0:
    print('Positive')

elif G<=0 and B>=0:
    print('Zero')

elif G < 0 and B < 0:
    if (B - G) % 2 == 0:
        print("Negative")
    else:
        print("Positive")
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = [int(input()) for _ in range(N)]

if max(L) < sum(L)-max(L):
    print("Yes")
else:
    print("No")


Fixed submission:
N = int(input())
L = list(map(int, input().split()))

if max(L) < sum(L)-max(L):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
A,B = map(int,input())
if A<9 and B<9:
    print("Yay!")
else:
    print(":(")


Fixed submission:
A,B = map(int,input().split())
if A<9 and B<9:
    print("Yay!")
else:
    print(":(")

Buggy python submission (verdict: Runtime Error):

A = int(input())
B = int(input())

if A+B <= 16 and A < 9 and B < 9:
    print("Yay!")
else :
    print(":(")


Fixed submission:
A,B = map(int,input().split())
if A<9 and B<9:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Runtime Error):
D, N = map(int,input())

print(N * (100**D))


Fixed submission:
D, N = map(int,input().split())
if N == 100:
    N += 1
print(N * (100**D))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
min = S[1:N].count("E")

for i in range (1,N):
    if S[i] == "W":
        continue
    count = S[0:i].count("W") + S[i+1:N].count("E")
    if min > count:
        min = count
print(min)


Fixed submission:
N = int(input())
S = input()
min = S[1:N].count("E")
now = S[1:N].count("E")

for i in range (1,N):
    if S[i-1] == "E" and S[i] == "E":
        now -= 1
    if S[i-1] == "W" and S[i] == "W":
        now += 1
    if now < min:
        min = now
print(min)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
min = S[0:1].count("W") + S[2:N].count("E")

for i in range (N):
    count = S[0:i].count("W") + S[i+1:N].count("E")
    if min > count:
        min = count
print(min)


Fixed submission:
N = int(input())
S = input()
min = S[1:N].count("E")
now = S[1:N].count("E")

for i in range (1,N):
    if S[i-1] == "E" and S[i] == "E":
        now -= 1
    if S[i-1] == "W" and S[i] == "W":
        now += 1
    if now < min:
        min = now
print(min)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
list = ["zzz" for i in range(K)]
for i in range(len(s)):
    for j in range(len(s)-i):
        if len(list) < K or s[i : i+j+1] < list[K-1]:
            # sSet.add(s[i : i+j+1]
            if all([k != s[i : i+j+1] for k in list]):
                list[K-1] = s[i : i+j+1]
                list.sort()
print(list[K - 1])


Fixed submission:
s = input()
K = int(input())
list = ["zzz" for i in range(K)]
for i in range(len(s)):
    for j in range(len(s)-i):
        if j > 5:
            continue
        if len(list) < K or s[i : i+j+1] < list[K-1]:
            if not s[i : i+j+1] in list:
                list[K-1] = s[i : i+j+1]
                list.sort()
print(list[K - 1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
sSet = set()
for i in range(len(s)):
    for j in range(len(s)-i):
        sSet.add(s[i : i+j+1])
list = list(sSet)
list.sort()
print(list[K - 1])


Fixed submission:
s = input()
K = int(input())
list = ["zzz" for i in range(K)]
for i in range(len(s)):
    for j in range(len(s)-i):
        if j > 5:
            continue
        if len(list) < K or s[i : i+j+1] < list[K-1]:
            if not s[i : i+j+1] in list:
                list[K-1] = s[i : i+j+1]
                list.sort()
print(list[K - 1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
sSet = set()
for i in range(len(s)):
    for j in range(len(s)):
        sSet.add(s[i : j+1])
list = list(sSet)
list.sort()
try:
    list.remove("")
except:
    pass
print(list[K - 1])


Fixed submission:
s = input()
K = int(input())
list = ["zzz" for i in range(K)]
for i in range(len(s)):
    for j in range(len(s)-i):
        if j > 5:
            continue
        if len(list) < K or s[i : i+j+1] < list[K-1]:
            if not s[i : i+j+1] in list:
                list[K-1] = s[i : i+j+1]
                list.sort()
print(list[K - 1])
Buggy python submission (verdict: Runtime Error):
N=int(input())
NUM_list = [0]*1000000000
X=0

for i in range(N):
   NUM_list[int(input())]+=1

for i in range(1000000000):
   X += NUM_list[i]%2

print(X)

Fixed submission:
X=0
hoge=1
N=int(input())
NUM_list = list(int(input()) for i in range(N))
NUM_list.sort()
for i in range(N-1):
   if NUM_list[i]==NUM_list[i+1]:
      hoge+=1
   else:
      X += hoge%2
      hoge=1
X+=hoge%2

print(X)
Buggy python submission (verdict: Runtime Error):
s=input().split()
a=s[0]/s[1]
print(a)

Fixed submission:
s=input().split()
a=float(s[0])/float(s[1])
print(a)
Buggy python submission (verdict: Runtime Error):
s1=input()
s2=input().split()
a=sorted(s2,reverse=True)

max=int(a[0])
cnt=a[1:]
all=sum(int(i) for i in cnt)

if(max<all):
  print('Yes')
else
  print('No')



Fixed submission:
s1=input()
s2=input().split()
n2=[int(i) for i in s2]
a=sorted(n2,reverse=True)

max=a[0]
cnt=a[1:]
all=sum(cnt)

if(max<all):
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
s1=input()
s2=input().split()
a=sorted(s2,reverse=True)

max=a[0]
cnt=a[1:]
all=sum(int(i) for i in cnt)

if(max<all){
  print('Yes')
}else{
  print('No')
}


Fixed submission:
s1=input()
s2=input().split()
n2=[int(i) for i in s2]
a=sorted(n2,reverse=True)

max=a[0]
cnt=a[1:]
all=sum(cnt)

if(max<all):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
if k%2 == 0:
    for _ in range(int(k/2)):
        a = int(a/2)
        b += a
        b = int(b/2)
        a += b
    print(a ,b)
    
else:
    for _ in range((k-1/2)):
        a = int(a/2)
        b += a
        b = int(b/2)
        a += b
    a = int(a/2)
    b += a
    print(int(a),int(b))

Fixed submission:
a, b, k = map(int, input().split())
if k%2 == 0:
    for _ in range(int(k/2)):
        a = int(a/2)
        b += a
        b = int(b/2)
        a += b
    print(a ,b)
    
else:
    for _ in range(int(k/2)):
        a = int(a/2)
        b += a
        b = int(b/2)
        a += b
    a = int(a/2)
    b += a
    print(int(a),int(b))
Buggy python submission (verdict: Runtime Error):
t, x = map(input())
a = t / x
print (a)

Fixed submission:
x, y = map (int, input().split())
a = x / y
print (a)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = list(map(int, input().split()))

x.sort()

sub_array = []
for i in range(len(x) - 1):
    sub_array.append(x[i+1] - x[i])

sub_array.sort()

for i in range(n-1):
    sub_array.pop(-1)

print (sum(sub_array))


Fixed submission:
n, m = map(int, input().split())
x = list(map(int, input().split()))

x.sort()

sub_array = []
for i in range(len(x) - 1):
    sub_array.append(x[i+1] - x[i])

sub_array.sort()

for i in range(n-1):
    if (len(sub_array) == 0):
        break
    sub_array.pop(-1)

print (sum(sub_array))
Buggy python submission (verdict: Runtime Error):
N = int(input())
Llist = list(map(int, input().split()))
 
sum = 0
for i in Llist:
  if i != max(Llist):
    sum += i
 
if max(Llist) <= sum:
  print("Yes")
else:
  print("No")

Fixed submission:
x,t = map(int, input().split())
print("{}".format(float(x)/t))

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
x,t = map(int, input().split())
print({}.format(float(x)/t))

Fixed submission:
x,t = map(int, input().split())
print("{}".format(float(x)/t))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
a,b = stdin.readline().rstrip().split()
if a*b % 2 == 0:
  print("Even")
else:
  print("Odd")


Fixed submission:
from sys import stdin

a,b = [int(x) for x in stdin.readline().rstrip().split()]

if a*b % 2 == 0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Runtime Error):
from sys import stdin
s1, s2, s3 = [x for x in list(stdin.readline())]


Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
s1, s2, s3 = [x for x in list(stdin.readline())]
print(int(s1)+int(s2)+int(s3))

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
[int(x) for x in list(stdin.readline())]

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
[for x in list(stdin.readline())]

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
from sys import stdin

[int(x) for x in list(stdin.readline())]

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
from sys import stdin
[int(x) for x in list(stdin.readline())]

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
from sys import stdin

s1, s2, s3 = [int(x) for x in list(stdin.readline())]

print(str(s1+s2+s3))

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
from sys import stdin

s1, s2, s3 = [int(x) for x in list(stdin.readline())]

print(str(s1+s2+s3))

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
from sys import stdin

s1, s2, s3 = [int(x) for x in list(stdin.readline())]

print(s1+s2+s3)

Fixed submission:
print(input().count("1"))

Buggy python submission (verdict: Runtime Error):
from sys import stdin

s1, s2, s3 = [int(x) for x in list(stdin.readline())]

print(s1+s2+s3)

Fixed submission:
print(input().count("1"))
Buggy python submission (verdict: Runtime Error):
T,X=map(int,inputs.split())
print(T/X)

Fixed submission:
T,X=map(int,input().split())
print(format(T/X,'0.4f'))
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
td=[[int(a) for a in input().split()]for i in range(N)]

td=sorted(td,key=lambda x:-x[1])

ans=0
eat=[]
noteat=[]
for t,d in td[:K]:
  ans+=d
  if t not in eat:
    eat.append(t)
  else:
    noteat.append(d)
temp_result=ans+len(eat)**2
max_result=temp_result

for t,d in td[K:]:
  if not noteat:
    break
  if t not in eat:
    temp_result+=2*len(eat)+1
    temp_result+=d-noteat.pop()
    eat.add(t)
    max_result=max(max_result,temp_result)
print(max_result)
 



Fixed submission:
a,b,c=map(int,input().split())
arr=sorted([a,b,c])
print(int(arr[0]*arr[1]/2))

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
td=[[int(a) for a in input().split()]for i in range(N)]

td=sorted(td,key=lambda x:-x[1])

ans=0
eat=[]
noteat=[]
for t,d in td[:K]:
  ans+=d
  if t not in eat:
    eat.append(t)
  else:
    noteat.append(d)
temp_result=ans+sum(eat)**2
max_result=temp_result

for t,d in td[K:]:
  if not noteat:
    break
  if t not in eat:
    temp_result+=2*len(eat)+1
    temp_result+=d-noteat.pop()
    eat.add(t)
    max_result=max(max_result,temp_result)
print(max_result)
 


Fixed submission:
a,b,c=map(int,input().split())
arr=sorted([a,b,c])
print(int(arr[0]*arr[1]/2))

Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()
arr=sorted([a,b,c])
print(arr[0]*arr[1])
return arr[0]*arr[1]



Fixed submission:
a,b,c=map(int,input().split())
arr=sorted([a,b,c])
print(int(arr[0]*arr[1]/2))
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
td=[[int(a) for a in input().split()]for i in range(N)]

td=sorted(td,key=lambda x:-x[1])

ans=0
eat=[]
noteat=[]
for t,d in td[:K]:
  ans+=d
  if t not in eat:
    eat.append(t)
  else:
    noteat.append(d)
temp_result=ans+len(eat)**2
max_result=temp_result

for t,d in td[K:]:
  if not noteat:
    break
  if t not in eat:
    temp_result+=2*len(eat)+1
    temp_result+=d-noteat.pop()
    eat.append(t)
    max_result=max(max_result,temp_result)
print(max_result)
 

Fixed submission:
N,K=map(int,input().split())
td=[[int(a) for a in input().split()]for i in range(N)]

td=sorted(td,key=lambda x:-x[1])

ans=0
eat=set([])
noteat=[]
for t,d in td[:K]:
  ans+=d
  if t not in eat:
    eat.add(t)
  else:
    noteat.append(d)
temp_result=ans+len(eat)**2
max_result=temp_result

for t,d in td[K:]:
  if not noteat:
    break
  if t not in eat:
    temp_result+=2*len(eat)+1
    temp_result+=d-noteat.pop()
    eat.add(t)
    max_result=max(max_result,temp_result)
print(max_result)

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
td=[[int(a) for a in input().split()]for i in range(N)]

td=sorted(td,key=lambda x:-x[1])

ans=0
eat=[]
noteat=[]
for t,d in td[:K]:
  ans+=d
  if t not in eat:
    eat.append(t)
  else:
    noteat.append(d)
temp_result=ans+len(eat)**2
max_result=temp_result

for t,d in td[K:]:
  if not noteat:
    break
  if t not in eat:
    temp_result+=2*len(eat)+1
    temp_result+=d-noteat.pop()
    eat.add(t)
    max_result=max(max_result,temp_result)
print(max_result)
 



Fixed submission:
N,K=map(int,input().split())
td=[[int(a) for a in input().split()]for i in range(N)]

td=sorted(td,key=lambda x:-x[1])

ans=0
eat=set([])
noteat=[]
for t,d in td[:K]:
  ans+=d
  if t not in eat:
    eat.add(t)
  else:
    noteat.append(d)
temp_result=ans+len(eat)**2
max_result=temp_result

for t,d in td[K:]:
  if not noteat:
    break
  if t not in eat:
    temp_result+=2*len(eat)+1
    temp_result+=d-noteat.pop()
    eat.add(t)
    max_result=max(max_result,temp_result)
print(max_result)

Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
td=[[int a for a in input().split()]for i in range(N)]

td=sorted(td,key=lambda x:-x[1])

ans=0
eat=[]
noteat=[]
for t,d in td[:K]:
  ans+=d
  if t not in eat:
    eat.append(t)
  else:
    noteat.append(d)
temp_result=ans+sum(eat)**2
max_result=temp_result

for t,d in td[K:]:
  if not noteat:
    break
  if t not in eat:
    temp_result+=2*len(eat)+1
    temp_result+=d-noteat.pop()
    eat.add(t)
    max_result=max(max_result,temp_result)
print(max_result)
 

Fixed submission:
N,K=map(int,input().split())
td=[[int(a) for a in input().split()]for i in range(N)]

td=sorted(td,key=lambda x:-x[1])

ans=0
eat=set([])
noteat=[]
for t,d in td[:K]:
  ans+=d
  if t not in eat:
    eat.add(t)
  else:
    noteat.append(d)
temp_result=ans+len(eat)**2
max_result=temp_result

for t,d in td[K:]:
  if not noteat:
    break
  if t not in eat:
    temp_result+=2*len(eat)+1
    temp_result+=d-noteat.pop()
    eat.add(t)
    max_result=max(max_result,temp_result)
print(max_result)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
def dfs(level,req,seq):
  if len(seq)==req:
    return
  if level==0:
    seq.append("P")
    return
  elif level>=1:
    seq.append("B")
    level-=1
    dfs(level,req,seq)
    seq.append("P")
    dfs(level,req,seq)
    seq.append("B")
    return seq
seq=[] 
if N==K==1:
  print("0")
else:
  seq=dfs(N,K,seq)
  #ans=seq[:K]
  ans=[i for i in seq if i=='P']
  print(len(ans))
  
  



Fixed submission:
N,K=map(int,input().split())
a=[1]
p=[1]
for i in range(N):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)
def find(N,K):
  if N==0:
    return 0 if K<=0 else 1
  elif K<=a[N-1]+1:
    return find(N-1,K-1)
  else:
    return p[N-1]+1+find(N-1,K-2-a[N-1])
print(find(N,K))
Buggy python submission (verdict: Runtime Error):
if int(kaku) != len(s_list):
    print('No')
else:
    hen_list = [int(x) for x in s_list]

    m = max(hen_list)
    total = sum(hen_list)
    print(m, total)

    if m < total - m:
            print('Yes')
    else:
        print('No')



Fixed submission:
kaku = input()
s_list = input().split(' ')
if not int(kaku) == len(s_list):
    print('No')
else:
    hen_list = [int(x) for x in s_list]
    m = max(hen_list)
    total = sum(hen_list)
    if m < total - m:
            print('Yes')
    else:
        print('No')