Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03136 (python)

Fixed submission:
n=input()
a=list(map(int, input().split()))
if max(a)*2 < sum(a):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
if max(a)*2 >=　sum(a):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
if max(a)*2 >=　sum(a):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
if max(a) >=　sum(a) - max(a):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = input()
N = int(n)
a = [input() for i in range(N)]
a = int(a)
if max(a)　>=　sum(a) - max(a):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
a = int([input() for i in range(N)])
if max(a)　>=　sum(a) - max(a):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [input() for i in range(N)]
if max(a)　>=　sum(a) - max(a):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = input()
a = [input() for i in range(N)]

if max(a)　>=　sum(a) - max(a):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = input()
a = [input() for i in range(N)]

if max(a)　>　sum(a) - max(a):
  print("Yes")
else
  print("No")

Buggy submission (verdict: Runtime Error):
N = input()
a = [input() for i in range(N)]

if max(a)　>　sum(a) - max(a):
  print("Yes")
  else
      print("No")

Buggy submission (verdict: Runtime Error):
N = input()
a = [input() for i in range(N)]

if max(a)　>　sum(a) - max(a):
  print(Yes)
  else
      print(No)
Problem p03220 (python)

Fixed submission:
n=int(input())
t,a=map(int,input().split())
h=[]
tmp=input()
lst=tmp.split(' ')

for i in range(n):
    c=t-int(lst[i])*0.006
    h.append(abs(a-c))

m=0
for i in range(1,n):
    if(h[i]<h[m]):
        m=i
print(m+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().split())
h=[]
for i in range(n):
    tmp=int(input)
    c=t-tmp*0.006
    h.append(abs(a-c))

m=0
for i in range(1,n):
    if(h[i]<h[m]):
        m=i
print(m)

Buggy submission (verdict: Runtime Error):
n=int(input())
t,a=map(int,input().split())
h=[]
for i in rrange(n):
    tmp=int(input)
    c=t-tmp*0.006
    h.append(abs(a-c))

m=0
for i in range(1,n):
    if(h[i]<h[m]):
        m=i
print(m)
Problem p03238 (python)

Fixed submission:
s=input()
if s=="1":
    print("Hello World")
else:
    a=int(input())
    b=int(input())
    print(a+b)

Buggy submission (verdict: Runtime Error):
s=input()
if s=="1":
    print("Hello World")
else:
    a,b=map(int,input().split())
    print(a+b)

Buggy submission (verdict: Runtime Error):
s=input()
if s=="1":
    print("Hello World");
else:
    a,b=map(int,input().split())
    print(a+b)
Problem p03262 (python)

Fixed submission:
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)


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

if n==1:
    a=int(input())
    print(abs(a-x))
    exit()
else:
    str=input()
    lst=str.split(" ")
    a=int(lst[0])
    b=int(lst[1])
    maxim=gcd(abs(a-x),abs(b-x))
    for i in range(2,n):
        c=int(lst[i])
        maxim=gcd(maxim,abs(c-x))
print(maxim)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
    if b==0:
        return a
    else:
        gcd(b,a%b)


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

if n==1:
    a=int(input())
    print(abs(a-x))
    exit()
else:
    str=input()
    lst=str.split(" ")
    a=int(lst[0])
    b=int(lst[1])
    maxim=gcd(abs(a-x),abs(b-x))
    for i in range(2,n):
        c=int(lst[i])
        maxim=gcd(maxim,abs(c-x))
print(maxim)
Problem p03273 (python)

Fixed submission:
h,w=map(int,input().split())
a=['']*h
for i in range(h):
    a[i]=input()

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            row[i]=True
            col[j]=True;

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end="")
        print()

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=['']*h
for i in range(h):
    a[i]=input()

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            raw[i]=True
            col[j]=True;

for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end="")
        print()

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=['']*h
for i in range(h):
    a[i]=input()

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            raw[i]=True
            col[j]=True;

for i in range(h):
    if raw[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end="")
        print()

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=['']*h
for i in range(h):
    a[i]=input()

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            raw[i]=true
            col[j]=true;

for i in range(h):
    if raw[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j],end="")
        print()
Problem p03274 (python)

Fixed submission:
n,k=map(int,input().split())
lst1=input()
lst2=lst1.split(" ")
lst=[]
for i in lst2:
    lst.append(int(i))

minr=[]
minl=[]

for i in range(n-k+1):
    l=i
    r=i+k-1
    minr.append(abs(lst[r])+abs(lst[r]-lst[l]))
    minl.append(abs(lst[l])+abs(lst[r]-lst[l]))

minr.sort()
minl.sort()

m=min(minr[0],minl[0])
print(m)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
lst1=input()
lst2=lst1.split(" ")
lst=[]
for i in lst2:
    lst.append(int(i))

minr=[]
minl=[]

for i in range(n-k+1):
    l=i
    r=i+k-1
    minr.sppend(abs(lst[r])+abs(lst[r]-lst[l]))
    minl.append(abs(lst[l])+abs(lst[r]-lst[l]))

minr.sort()
minl.sort()

m=min(minr[0],minl[0])
print(m)
Problem p03289 (python)

Fixed submission:
str=list(input())
flag=True
if str[0]!='A':
    flag=False
str[0]='a'
cnt=0
for i in range(2,len(str)-1):
    if str[i]=='C':
        cnt+=1
        if cnt==1:
            str[i]='c'
if cnt!=1:
    flag=False

tmp="".join(str)
if not tmp.islower():
    flag=False

if flag==True:
    print("AC")
else:
    print("WA")

Buggy submission (verdict: Runtime Error):
str=list(input())
flag=True
if str[0]!='A':
    flag=False
str[0]='a'
cnt=0
for i in range(2,len(str)-1):
    if str[i]=='C':
        cnt+=1
        if cnt==1:
            str[i]='c'
if cnt!=1:
    flag=False

tmp="".join(str)
print(tmp)
if not tmp.islower():
    flag=False

if flag==True:
    print("AC")
else:
    print("WA

Buggy submission (verdict: Runtime Error):
str=input()
flag=True
if str[0]!='A':
    flag=False
    str[0]='a'
cnt=0
for i in range(2,len(str)-2):
    if str[i]=='C':
        cnt+=1
        if cnt==1:
            str[i]='c'
if cnt!=1:
    flag=False

if str.islower():
    flag=False

if flag==True:
    print("AC")
else:
    print("WA")
Problem p03316 (python)

Fixed submission:
def f(n):
	res=0
	while n>0:
		res+=n%10
		n//=10
	return res

N=int(input())
x=f(N)
if N%x==0:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
def f(n):
	res=0
	while n>0:
		res+=n%10
		n//=10
	return res

N=int(input())
print(x)
if N%x==0:
	print("Yes")
else:
	print("No")
Problem p03633 (python)

Fixed submission:
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

n=int(input())

x=1
for i in range(n):
    c=int(input())
    x=c*x//gcd(c,x)
print(x)

Buggy submission (verdict: Runtime Error):
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

n=int(input())

a=int(input())
b=int(input())
x=a*b//gcd(a,b)
for i in range(n-2):
    c=int(input())
    x=c*x//gcd(c,x)
print(x)

Buggy submission (verdict: Runtime Error):
def gcd(x,y):
    if y==0:
        return x
    while y!=0:
        return gcd(y,x%y)

n=int(input())

a=int(input())
b=int(input())
x=a*b//gcd(a,b)
for i in range(n-2):
    c=int(input())
    x=c*x//gcd(c,x)
print(x)
Problem p04044 (python)

Fixed submission:
n, l = map(int, input().split())
ss = [input() for _ in range(n)]
print(''.join(sorted(ss)))

Buggy submission (verdict: Runtime Error):
n, l = map(int, input().split())
ss = [input() for _ in range(l)]
print(''.join(sorted(ss)))
Problem p02945 (python)

Fixed submission:
a,b = map(int,input().split())
print(max(a+b,a-b,a*b))

Buggy submission (verdict: Runtime Error):
a,b=input().split
print(max(a+b,a-b,a*b))
Problem p03238 (python)

Fixed submission:
a=int(input())
if a==1:
  print("Hello World")
else:
  b=int(input())
  c=int(input())
  print(b+c)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
if a==1:
  print("Hello World")
elif a==2:
  print(b+c)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
if a==1:
  print("Hello World")
else:
  print(b+c)
Problem p03351 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
e=abs(a-b)
f=abs(b-c)
g=abs(a-c)
if g>d and (e>d or f>d):
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
e=abs(a-b)
f=abs(b-c)
g=abs(a-c)
if g>d and e>d or f>d
  print("No")
else:
  print("Yes")
Problem p03377 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a+b>=c>=a:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a+b>=c>=a
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a+b>=c and a<=c
  print("YES")
else:
  print("NO")
Problem p03386 (python)

Fixed submission:
a,b,k=map(int,input().split())
if b-a+1<=k*2:
  for i in range(a,1+b):
    print(i)
else:
  for i in range(a,a+k):
    print(i)
  for y in range(b-k+1,b+1):
    print(y)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
if a-b<=c:
  for i in range(a,b):
    print(i)
else:
  for i in range(a,a+c-1):
    print(i)
  for y in range(b-c+1,b):
    print(y)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
if a-b<=c:
  for i in range[a:b]:
    print(i)
else:
  for i in range[a:a+c-1]:
     for y in range[b-c+1:b]:
        print(i)
        print(y)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
if a-b<=c:
  for i in range[a:b]:
    print(i)
else:
  for i in range[a:a+c-1]:
    print(i)
  for y in range[b-c+1:b]:
    print(y)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
d=c+1
e=b-a
f=0
g=0
if d==e:
  while e>f:
    print(a)
    a+=1
    f+=1
else:
  while c>f:
    print(a)
    a+=1
    f+=1
  while c>g:
    print(b-1)
      b+=1
      g+=1
Problem p03400 (python)

Fixed submission:
a=int(input())
b,c=map(int,input().split())
d=0
while d<a:
  e=((b-1)//int(input()))+1
  c+=e
  d+=1
print(c)

Buggy submission (verdict: Runtime Error):
a=int(input())
b,c=map(int,input().split())
d=0
while d<a:
  e=int(input())
  if e>0: 
    f=b//e+1
  else:
    f=b//e
  c+=f
print(c)

Buggy submission (verdict: Runtime Error):
a=int(input())
b,c=map(int,input().split())
d=0
f=0
while d<a:
  e=(b//int(input()))
  if e==0:
    f+=e
  else:
    f+=(e+1)
    c+=f
    d+=1
    print(c)

Buggy submission (verdict: Runtime Error):
a=int(input())
b,c=map(int,input().split())
d=0
while d<a:
  e=(b//int(input()))
  if e==0:
    f+=e
  else:
    f+=(e+1)
    c+=f
    d+=1
    print(c)

Buggy submission (verdict: Runtime Error):
a=int(input())
b,c=map(int,input().split())
for i in range():
  e=(b//(int(input()))+1
  c+=e
  print(c)

Buggy submission (verdict: Runtime Error):
a=int(input())
b,c=map(int,input().split())
d=0
for i in range():
  e=(b//(int(input()))+1
  d+=e
  print(d+c)

Buggy submission (verdict: Runtime Error):
a=int(input())
b,c=map(int,input().split())
d=0
for i in range():
  e=(b//(int(input()))+1
  d+=e
  print(d+c)
Problem p03456 (python)

Fixed submission:
from math import sqrt
a,b=input().split()
c=sqrt(int(a+b))
if c==int(c):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from math import sprt
a,b=input().split()
c=sqrt(int(a+b))
if c==int(c):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from math import sprt
a,b=map(int,input().split())
c=sqrt(int(a+b))
if c==int(c):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from math import sqrt
a,b=input().split()
c=sqrt.(int(a+b))
if c==int(c):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from marh import sqrt
a,b=input().split()
c=sqrt(int(a+b))
if c==int(c):
  print("Yes")
else:
  print("No")
Problem p03469 (python)

Fixed submission:
a=input()
print("2018"+a[4:])

Buggy submission (verdict: Runtime Error):
a=input()
a[3]="8"
print(a)

Buggy submission (verdict: Runtime Error):
a=input()
if a[3]!="8":
    a[3]="8"
    print(a)
else:
    print(a)

Buggy submission (verdict: Runtime Error):
a=input()
if a[3]!=8:
    a[3]=8
    print(a)
else:
    print(a)

Buggy submission (verdict: Runtime Error):
a=input()
if a[3]!=8:
    a[3]=8
    print(a)
Problem p03477 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
e=a+b
f=c+d
if e>f:
  print("Left")
elif e==f:
  print("Balanced")
else:
  print("Right")

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
e=a+b
f=c+d
if e>f:
  print("Left")
elif e=f:
  print("Balanced")
else:
  print("Right")
Problem p03501 (python)

Fixed submission:
a,b,c=map(int,input().split())
d=a*b
if d<c:
  print(d)
else:
  print(c)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input(),split())
d=a*b
if d<c:
  print(d)
else:
  print(c)
Problem p03543 (python)

Fixed submission:
a=list(input())
if a[0]==a[1]==a[2] or a[1]==a[2]==a[3]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a=list(input())
if a[0]=a[1]=a[2] or a[1]=a[2]=a[3]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a=input()
if a[0]=a[1]=a[2] or a[1]=a[2]=a[3]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a=list(int(input()))
if a[0]=a[1]=a[2] or a[1]=a[2]=a[3]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a=list(input())
if a[0]=a[1]=a[2] or a[1]=a[2]=a[3]:
    print("Yes")
else:
    print("No")
Problem p03547 (python)

Fixed submission:
a,b=input().split()
if (a<b):
  print("<")
elif (a==b):
  print("=")
else :
  print(">")

Buggy submission (verdict: Runtime Error):
a,b=input().split()
if a<b:
  print("<")
elif a==b:
  print("=")
else a>b:
  print(">")

Buggy submission (verdict: Runtime Error):
a,b=input().split()
if a<b
  print("<")
elif a==b:
  print("=")
else a>b:
  print(">")

Buggy submission (verdict: Runtime Error):
a,b=input().split()
if a<b:
  print("<")
elif a==b:
  print("=")
else a>b:
  print(">")

Buggy submission (verdict: Runtime Error):
a,b=input().split()
if c<d:
  print("<")
elif c==d:
  print("=")
else c>d:
  print(">")

Buggy submission (verdict: Runtime Error):
a,b=input().split()
c=ord(input(a))
d=ord(input(b))
if c<d:
  print("<")
elif c==d:
  print("=")
else c>d:
  print(">")

Buggy submission (verdict: Runtime Error):
a,b=input().split()
c=ord(a)
d=ord(b)
if c<d:
  print("<")
elif c==d:
  print("=")
else c>d:
  print(">")
Problem p03605 (python)

Fixed submission:
a=list(input())
if a[0]!="9" and a[1]!="9":
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a=list(input().split())
if a[0]==9 or a[1]==9:
  print("Yes")
else:
  print("No")
Problem p03679 (python)

Fixed submission:
a,b,c=map(int,input().split())
if b>=c:
  print("delicious")
elif abs(b-c)>a:
  print("dangerous")
else:
  print("safe")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if d>c:
  print("delicious")
elif abs(b-c)>a:
  print("dangerous")
else:
  print("safe")
Problem p03729 (python)

Fixed submission:
a,b,c=input().split()
s=[a,b,c]
if a[-1]==b[0] and b[-1]==c[0]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
s=list(input(a))
f=list(input(b))
g=list(input(c))
if s[-0]==f[0] and f[-0]==g[0]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
e=list(input(a))
f=list(input(b))
g=list(input(c))
if e[-0]==f[0] and f[-0]==g[0]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
e=list(input(a))
f=list(input(b))
g=list(input(c))
if e[-0]==f[0] and f[-0]==g[0]
  print("YES")
else:
  print("NO")
Problem p03737 (python)

Fixed submission:
a,b,c=input().split()
print(a[0].upper()+b[0].upper()+c[0].upper())

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
print(a[0].upper()+b[0].upper()+c[0].upper)

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
print(a.upper[0]+b.upper[0]+c.upper[0])
Problem p03826 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
if a*b==c*d:
  print(a*b)
elif a*b>c*d:
  print(a*b)
else:
  print(c*d)

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if a*b=c*d:
  print(a*b)
elif a*b>c*d:
  print(a*b)
else:
  print(c*d)
Problem p03844 (python)

Fixed submission:
print(eval(input()))

Buggy submission (verdict: Runtime Error):
a,b,c=input().split
if b=="-":
  print(int(a)-int(c))
else:
  print(int(a)+int(c))

Buggy submission (verdict: Runtime Error):
a,b,c=input().split
if b=="-":
  print(int(a)-int(b))
else:
  print(int(a)+int(b))

Buggy submission (verdict: Runtime Error):
a,op,b=input().split()
print(int(a)+input(op)+int(b))

Buggy submission (verdict: Runtime Error):
a,op,b=input().split()
print(int(a)+op+int(b))
Problem p03860 (python)

Fixed submission:
a,b,c=input().split()
print(a[0][0]+b[0][0]+c[0][0])

Buggy submission (verdict: Runtime Error):
a,b,c=input()
e=list(input(a))
f=list(input(b))
g=list(input(c))
print(e[0]+f[0]+g[0])

Buggy submission (verdict: Runtime Error):
a,b,c=input()
e=list(input(a))
f=list(input(b))
g=list(input(c))
print(e[0],f[0],g[0])

Buggy submission (verdict: Runtime Error):
a,b,c=list(input())
print(a[0],b[0],c[0])
Problem p04029 (python)

Fixed submission:
a=int(input())
c=0
while a>=0:
  c+=a
  a=a-1
print(int(c))

Buggy submission (verdict: Runtime Error):
a=int(input())
c==0
while a==0:
  c+=a
  a-=1
print(int(c))

Buggy submission (verdict: Runtime Error):
a=int(input())
while a==0:
  c+=a
  a-=1
print(int(c))
Problem p04044 (python)

Fixed submission:
n,l=map(int,input().split())
c=[]
for i in range(n):
  c.append(input())
c.sort()
print("".join(c))

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
c=[]
for i range(n):
  c.append(input())
c.sort()
print(''.join(c))

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
c=[]
for i range(n):
  c.append(input())
c.sort()
print("".join(c))

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
c=[]
for i range(n):
  c.append(input())
c.sort()
print("",join(c))

Buggy submission (verdict: Runtime Error):
n,l=map(int.input().split())
c=[]
for i in range(n):
  c.append(input())
c.sort()
print("".join(c))

Buggy submission (verdict: Runtime Error):
n,l=map(int.input().split())
c=[]
for i in range(n):
  c.append(input())
c.sort
print(c)
Problem p03148 (python)

Fixed submission:
N, K = [int(_) for _ in input().split()]
TD = [[int(_) for _ in input().split()] for i in range(N)]
 
# print(TD)
 
xs = sorted(TD, key=lambda x:-x[1])
 
#print(xs)
 
baset = 0
ts = set()
ds = []
 
for t, d in xs[:K]:
    baset += d
    if not t in ts:
        ts.add(t)
    else:
        ds.append(d)
result = baset + len(ts)**2
r = result

for t, d in xs[K:]:
    if not ds:
        break
    if t not in ts:
        r += 2*len(ts) + 1
        r += d - ds.pop()
        ts.add(t)
        result = max(r,result)

print(result)

Buggy submission (verdict: Runtime Error):
N, K = [int(_) for _ in input().split()]
TD = [[int(_) for _ in input().split()] for i in range(N)]
 
# print(TD)
 
xs = sorted(TD, key=lambda x:-x[1])
 
#print(xs)
 
baset = 0
ts = set()
ds = []
 
for t, d in xs[:K]:
    baset += d
    if not t in ts:
        ts.add(t)
    else:
        ds.append(d)
result = baset + len(ts)**2
r = result

for t, d in xs[K:]:
    if not ts:
        break
    if t not in ts:
        r += 2*len(ts) + 1
        r += d - ds.pop()
        ts.add(t)
        result = max(r,result)

print(result)
Problem p03150 (python)

Fixed submission:
s = list(input())
ss = ['k','e','y','e','n','c','e']
a = 0
b = 0
c = 0
for i in range(len(ss)):
    if s[i] == ss[i]:
        continue
    else:
        a = i
        break
else:
    print('YES')
    exit()


sss = ss[a:]
for i in range(len(sss)):
    if sss[len(sss)-i-1] == s[len(s)-i-1]:
        continue
    else:
        print('NO')
        break
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
a = 0
b = 0
c = 0
for i in range(len(ss)):
    if s[i] == ss[i]:
        continue
    else:
        a = i
        break
else:
    print('YES')
    exit()


sss = ss[a:]
print(sss)
for i in range(len(sss)):
    if sss[len(sss)-i-1] == s[len(s)-i-1]:
        continue
    else:
        print('NO')
        break
else:
    print('YES')
Problem p03151 (python)

Fixed submission:
import numpy as np
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

mi = []
pl = []

for i in range(N):
    s = A[i] - B[i]
    if s < 0:
        mi.append(s)
    elif s > 0:
        pl.append(s)

            
pl.sort(reverse=True)
p = np.sum(mi)



if (len(pl)>0)and(len(mi)>0):
    count = 0
    for i in pl:
        if p + i < 0:
            p += i
            count += 1
            continue
        else:
            count += 1
            break
    else:
        print('-1')
        exit()

    print(count + len(mi))
    
        
elif len(mi) == 0:
    print('0')
    exit()
else:
    print('-1')
    exit()

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

mi = []
pl = []
sum = 0
if (np.sum(B) > np.sum(A)):
    print('-1')
    exit()

else:
    for i in range(N):
        s = A[i] - B[i]
        if s < 0:
            mi.append(-s)
        elif s > 0:
            pl.append(s)

            
pl.sort(reverse=True)
p = np.sum(mi)
if (p != 0) and (len(pl) != 0):
    count = 1
    for i in pl:
        if p-i > 0:
            p -= i
            count += 1
        else:
            break
        
    else:
        print('-1')
        exit()
elif(p == 0) and (len(pl) != 0):
    print('0')
else:
    count = 0

print(len(mi)+count)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

mi = []
pl = []
sum = 0
if (sum(B) > sum(A)):
    print('-1')
    exit()

else:
    for i in range(N):
        s[i] = A[i] - B[i]
        if s[i] < 0:
            mi.append(-s[i])
        elif s[i] > 0:
            pl.append(s[i])

            
pl.sort(reverse=True)
p = sum(mi)
if (p != 0) and (len(pl) != 0):
    count = 1
    for i in pl:
        if p-i > 0:
            p -= i
            count += 1
        else:
            break
        
    else:
        print('-1')
        exit()
elif(p == 0) and (len(pl) != 0):
    print('0')
else:
    count = 0

print(len(mi)+count)