Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S=input()
S1=int(S[:2])
S2=int(S[2:])

if S1 == 0 AND S2 == 0:
    print('NA')
if S1 == 0 AND S2 >12:
    print('NA')
if S1 > 12 AND S2 == 0:
    print('NA')
elif S1 > 12 and S2 > 12:
    print('NA')
elif S1 > 12 and S2 <= 12:
    print('YYMM')
elif S1 <= 12 and S2 > 12:
    print('MMYY')
else:
    print('AMBIGUOUS')


Fixed submission:
S=input()
S1=int(S[:2])
S2=int(S[2:])

if (S1 == 0 and S2 == 0) or (S1 >12 and S2 > 12):
    print('NA')
elif S1 == 0 or S1 > 12:
  if S2 >=1 and S2 <=12:
    print('YYMM')
  else:
    print('NA')
elif S2 == 0 or S2 > 12:
  if S1 >=1 and S1 <=12:
    print('MMYY')
  else:
    print('NA')
else:
    print('AMBIGUOUS')
Buggy python submission (verdict: Runtime Error):
i=input()
if((i[0]==i[1]&&i[1]==i[2])||(i[1]==i[2]&&i[2]==i[3])):
	print('Yes')
else:
  	print('No')

Fixed submission:
a,b,c,d=input()
print('Yes' if a==b==c or b==c==d else 'No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(n)]
c=0
d=[]
for i in range(n-1,-1,-1):
  j=2
  c=b[i]
  while((i+1)*j<=n):
    c=c^b[(i+1)*j-1]
    j+=1
  if (c!=a[i]):
    b[i]=1
  c=0
  j=2
print('{0}'.format(sum(b)))
e=list(map(str,b))
for i in range(n):
  if(b[i]==1):
    d.append(i+1)
f=' '.join(d)
print('{0}'.format(f))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(n)]
c=0
d=[]
for i in range(n-1,-1,-1):
  j=2
  c=b[i]
  while((i+1)*j<=n):
    c=c^b[(i+1)*j-1]
    j+=1
  if (c!=a[i]):
    b[i]=1
  c=0
  j=2
print('{0}'.format(sum(b)))
for i in range(n):
  if(b[i]==1):
    d.append(i+1)
e=list(map(str,d))
f=' '.join(e)
print('{0}'.format(f))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=int(n/3)
if(a[0]==a[n-1] and a[0]==0):
    print('Yes')
elif(n%3!=0):
    print('No')
elif(a[0]==a[b-1] and a[b-1]!=a[b] and a[b]==a[n-1]):
    if(a[0]^a[n-1]^a[n-1]==0):
        print('Yes')
    else:
        print('No')
elif(a[0]==a[2*b-1] and a[2*b-1]!=a[2*b] and a[2*b]==a[n-1]):
    if(a[0]^a[0]^a[n-1]==0):
        print('Yes'):
    else:
        print('No')
else:
    if(a[0] == a[b-1] and a[b-1] != a[b]):
        if(a[b]==a[2*b-1] and a[2*b-1]!=a[2*b]):
            if(a[2*b]==a[n-1]):
                if(a[0]^a[b]^a[n-1]==0):
                    print('Yes')
                else:
                    print('No')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
    

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=int(n/3)
if(a[0]==a[n-1] and a[0]==0):
    print('Yes')
elif(n%3!=0):
    print('No')
elif(a[0]==a[b-1] and a[b-1]!=a[b] and a[b]==a[n-1]):
    if(a[0]^a[n-1]^a[n-1]==0):
        print('Yes')
    else:
        print('No')
elif(a[0]==a[2*b-1] and a[2*b-1]!=a[2*b] and a[2*b]==a[n-1]):
    if(a[0]^a[0]^a[n-1]==0):
        print('Yes')
    else:
        print('No')
else:
    if(a[0] == a[b-1] and a[b-1] != a[b]):
        if(a[b]==a[2*b-1] and a[2*b-1]!=a[2*b]):
            if(a[2*b]==a[n-1]):
                if(a[0]^a[b]^a[n-1]==0):
                    print('Yes')
                else:
                    print('No')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
n,d=map(int,input().split())
x=[]
for i in range(n):
    a=list(map(int,input().split()))
    x.append(a)
import math
c=0
d=0
e=0
for j in range (n-1):
    for k in range(j+1,n):
        for m in range(d):
            d+=float((x[j][m]-x[k][m])*(x[j][m]-x[k][m]))
        c=float(math.sqrt(d))
        if(c.is_integer()=1):
            e+=1
        d=0
print('{0}'.format(e))
        
        

Fixed submission:
n,a,b=map(int,input().split())
print('{0}'.format(min(b,n*a)))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
b=[]
gap=0
e=0
f=0
m=0
for i in range(n):
    c,d=map(int,input().split())
    a.append(c)
    b.append(d)
while (gap<=n/9):
    gap=gap*3+1
while (gap>0):
    for i in range(gap,n):
        key=b[i]
        l=a[i]
        if(key<b[i-gap]):
            j=i
            while True:
                b[j]=b[j-gap]
                a[j]=a[j-gap]
                j-=gap
                if(j<gap or key>=b[j-gap]):
                    break
            b[j]=key
            a[j]=l
        gap=int((gap-1)/3)
for i in range(n):
    e+=a[i]
    if(e>b[i]):
        m=1
if(m==1):
    print('No')
else:
    print('Yes')


Fixed submission:
s=str(input())
c=0
for i in range(3):
  if(s[i]==s[i+1]):
    c=1
    break
if(c==0):
  print('Good')
else:
  print('Bad')
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
b=0
c=0
d=1
e=0
for i in range(m):
    a.append(int(input()))
for j in range(m-1):
    if(a[j]+1==a[j+1]):
        print('0')
        break    
z=list(set(a))
z=sorted(z)
z.append(0)     
for i in range(n):
    if(z[b]==i+1):
        b+=1    
        continue    
    else:
        c=d+e
        e=d
        d=c
print({0}.format(c%100000007)

Fixed submission:
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
flag=0
c=[0 for i in range(n+1)]
b=0
a.append(-2)
c[0]=1
if(a[b]==1):
    c[1]=0
    b+=1
else:
    c[1]=1
for i in range(2,n+1):
    if (i==a[b]):
        c[i]=0
        b+=1
    else:
        c[i]=c[i-1]+c[i-2]
        c[i]=c[i] %1000000007
print('{0}'.format(c[n]))
Buggy python submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
s=str(input())
s=s.replace('.','0')
s=s.replace('#','1')
x=0
y=0
f=0
g=0
for i in range(c-a-2):
    x=int(s[i+a+1])
    y=int(s[i+a+2])
    if(x*y==1):
        f=-1
for j in range(d-b-2):
    x=int(s[j+b+1])
    y=int(s[j+b+2])
    if(x*y==1):
        g=-1
if(d<c):
    if(s[b+1:d].find('000')==-1 and ):
        f=-1
if(f==0 and g==0):
    print('Yes')
else:
    print('No')


Fixed submission:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=s.replace('.','0')
s=s.replace('#','1')
x=0
y=0
f=0
g=0
for i in range(c-a-1):
    x=int(s[i+a])
    y=int(s[i+a+1])
    if(x*y==1):
        f=-1
for j in range(d-b-1):
    x=int(s[j+b])
    y=int(s[j+b+1])
    if(x*y==1):
        g=-1
if(d<c):
    if(s[b-2:d+1].find('000')==-1):
        f=-1
if(f==0 and g==0):
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
s=str(input())
s=s.replace('.','0')
s=s.replace('#','1')
x=0
y=0
f=0
g=0
for i in range(c-a-2):
    x=int(s[i+a+1])
    y=int(s[i+a+2])
    if(x*y==1):
        f=-1
for j in range(d-b-2):
    x=int(s[j+b+1])
    y=int(s[j+b+2])
    if(x*y==1):
        g=-1
x=s.replace('11','7')
x=x.replace('000','8')
x=x.replace('0','')
x=x.replace('1','')
if(d<c):
    if(s[b+1:d].find('000')==-1 and ):
        f=-1
if(f==0 and g==0):
    print('Yes')
else:
    print('No')




Fixed submission:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=s.replace('.','0')
s=s.replace('#','1')
x=0
y=0
f=0
g=0
for i in range(c-a-1):
    x=int(s[i+a])
    y=int(s[i+a+1])
    if(x*y==1):
        f=-1
for j in range(d-b-1):
    x=int(s[j+b])
    y=int(s[j+b+1])
    if(x*y==1):
        g=-1
if(d<c):
    if(s[b-2:d+1].find('000')==-1):
        f=-1
if(f==0 and g==0):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
frag = 0
max=a
min=a
if (max<b):
    max=b
if (max<c):
    max=c
if (max<d):
    max=d
if (max<e):
    max=e
if (min>b):
    min=b
if (min>c):
    min=c
if (min>d):
    min=d
if (min>e):
    min=e
z= max-min
if (z>k):
    print(':(')
    else :
        print('Yay!')

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
max=a
min=a
if (max<b):
    max=b
if (max<c):
    max=c
if (max<d):
    max=d
if (max<e):
    max=e
if (min>b):
    min=b
if (min>c):
    min=c
if (min>d):
    min=d
if (min>e):
    min=e
z= max-min
if (z>k):
    print(':(')
else :
    print('Yay!')
Buggy python submission (verdict: Runtime Error):
M=input(int())
print(24+(24-M))

Fixed submission:
M=int(input())
print(24+(24-M))

Buggy python submission (verdict: Runtime Error):
n=input()
print(48-n)

Fixed submission:
M=int(input())
print(24+(24-M))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
print(sum(range(N)))

Fixed submission:
N = int(input())
print((N * (N - 1)) // 2)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
a_list = list(map(int, input().split()))
MOD = 10 ** 9 + 7

inversion = 0
for i, a1 in enumerate(a_list):
    for a2 in a_list[(i + 1):]:
        if a1 > a2:
            inversion += 1

lower_count = [0] * (N + 1)
for a in a_list:
    lower_count[a] = len([x for x in a_list if x < a])
total_lower = sum(lower_count)


total_k = (K * (K - 1)) // 2
total = (total_lower * total_k) % MOD + (inversion * K) % MOD
print(total)


Fixed submission:
N, K = map(int, input().split())
a_list = list(map(int, input().split()))
MOD = 10 ** 9 + 7

inversion = 0
for i in range(len(a_list)):
    for j in range(len(a_list) - 1, i, -1):
        if a_list[j] < a_list[j - 1]:
            a_list[j], a_list[j - 1] = a_list[j - 1], a_list[j]
            inversion += 1

total_lower = 0
for i in range(len(a_list)):
    total_lower += len([x for x in a_list if x < a_list[i]])


total_k = (K * (K - 1)) // 2
total = (total_lower * total_k+ inversion * K) % MOD
print(total)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

def search(tree, target):
    subs = [target]
    for node in tree[target]:
        subs += search(tree, node)
    return subs
N, Q = map(int, input().split())

tree = defaultdict(list)
parent = [None] * N
for i in range(N - 1):
    a, b = map(int, input().split())
    tree[a] += [b]

subs =[None] * (N + 1)
for i in range(1, N + 1):
    subs[i] = search(tree, i)

values = [0] * (N + 1)
for i in range(Q):
    p, q = map(int, input().split())
    for j in subs[p]:
        values[j] += q

values = map(str, values[1:])
print(" ".join(values))

Fixed submission:
from collections import defaultdict

N, Q = map(int, input().split())

parent = defaultdict(list)
for i in range(N - 1):
    a, b = map(int, input().split())
    parent[b] = a

values = [0] * (N + 1)
for i in range(Q):
    p, x = map(int, input().split())
    values[p] += x


for i in range(2, N + 1):
    values[i] += values[parent[i]]
values = map(str, values[1:])
print(" ".join(values))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = map(int, input().split())

rewards = [None] * N
for i in range(N):
    a, b = map(int, input().split())
    rewards[i] = (b, a)

heap = []
total = 0
for day in range(1, M + 1):
    target_rewards = list(filter(lambda x: (day - 1) < x[1] <= day, rewards))

    for reward in target_rewards:
        heapq.heappush(heap, (-reward[0], reward[1]))

    if len(heap) > 0:
        max_reward = heapq.heappop(heap)
        total += -max_reward[0]

print(total)


Fixed submission:
import heapq
N, M = map(int, input().split())

rewards = [[] for _ in range(M + 1)]
for i in range(N):
    a, b = map(int, input().split())
    if a <= M:
        rewards[a].append(b)

heap = []
total = 0
for day in range(1, M + 1):
    for reward in rewards[day]:
        heapq.heappush(heap, -reward)

    if len(heap) > 0:
        max_reward = heapq.heappop(heap)
        total += -max_reward

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = map(int, input().split())

rewards = [None] * N
for i in range(N):
    a, b = map(int, input().split())
    rewards[i] = (b, a)

heap = []
total = 0
for day in range(1, M + 1):
    target_rewards = list(filter(lambda x: (day - 1) < x[1] <= day, rewards))

    for reward in target_rewards:
        heapq.heappush(heap, (-reward[0], reward[1]))

    if len(heap) > 0:
        max_reward = heapq.heappop(heap)
        total += -max_reward[0]

print(total)


Fixed submission:
import heapq
N, M = map(int, input().split())

rewards = [[] for _ in range(M + 1)]
for i in range(N):
    a, b = map(int, input().split())
    if a <= M:
        rewards[a].append(b)

heap = []
total = 0
for day in range(1, M + 1):
    for reward in rewards[day]:
        heapq.heappush(heap, -reward)

    if len(heap) > 0:
        max_reward = heapq.heappop(heap)
        total += -max_reward

print(total)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
a_list = list(map(int, input().split()))

total_a = sum(a_list)
#約数の列挙
candidates = set()
for i in [a for a in range(1, total_a) if a * a <= total_a]:
    if total_a % i == 0:
        candidates.add(i)
        candidates.add(total_a // i)

ans = 1
for x in candidates:
    remainders = sorted(map(lambda a: a % x, a_list))
    total_r = sum(remainders)
    border = total_r // x
    need = sum(remainders[:(N - border)])
    if need <= K:
        ans = max(ans, x)
print(ans)


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

total_a = sum(a_list)
#約数の列挙
candidates = set()
for i in range(1, total_a):
    if i * i > total_a:
        break
    if total_a % i == 0:
        candidates.add(i)
        candidates.add(total_a // i)

ans = 1
for x in candidates:
    remainders = sorted(map(lambda a: a % x, a_list))
    total_r = sum(remainders)
    border = total_r // x
    need = sum(remainders[:(N - border)])
    if need <= K:
        ans = max(ans, x)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
a_list = list(map(int, input().split()))

total_a = sum(a_list)
#約数の列挙
candidates = set()
for i in [a for a in range(1, total_a) if a * a <= total_a]:
    if total_a % i == 0:
        candidates.add(i)
        candidates.add(total_a // i)

ans = 1
for x in candidates:
    remainders = sorted(map(lambda a: a % x, a_list))
    total_r = sum(remainders)
    border = total_r // x
    need = sum(remainders[:(N - border)])
    if need <= K:
        ans = max(ans, x)
print(ans)


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

total_a = sum(a_list)
#約数の列挙
candidates = set()
for i in range(1, total_a):
    if i * i > total_a:
        break
    if total_a % i == 0:
        candidates.add(i)
        candidates.add(total_a // i)

ans = 1
for x in candidates:
    remainders = sorted(map(lambda a: a % x, a_list))
    total_r = sum(remainders)
    border = total_r // x
    need = sum(remainders[:(N - border)])
    if need <= K:
        ans = max(ans, x)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a_list = [None] * N
for i in range(N):
    a_list[i] = int(input())

#remove duplicate
sorted_a = sorted(a_list, reverse = True)
max_a = sorted_a[0]

result = []
for a in a_list:
    if a == max_a:
        print(max(sorted_a[1:]))
    else:
        print(max_a)


Fixed submission:
N = int(input())
a_list = [None] * N
for i in range(N):
    a_list[i] = int(input())

#remove duplicate
sorted_a = sorted(a_list, reverse = True)
max_a = sorted_a[0]

result = []
for a in a_list:
    if a == max_a:
        print(sorted_a[1])
    else:
        print(max_a)
Buggy python submission (verdict: Runtime Error):
orders = [int(input()) for _ in range(5)]

rest = []
time = 0
for order in orders:
    if order % 10 == 0:
        time += order
    else:
        rest.append(order)

rest_mods = list(map(lambda x: x % 10, rest))
min_mods_index = rest_mods.index(min(rest_mods))
for i in range(len(rest)):
    time += rest[i]
    if i != min_mods_index:
        time += 10 - rest[i] % 10
print(time)


Fixed submission:
orders = [int(input()) for _ in range(5)]

rest = []
time = 0
for order in orders:
    if order % 10 == 0:
        time += order
    else:
        rest.append(order)

rest_mods = list(map(lambda x: x % 10, rest))

if len(rest_mods) > 0:
    min_mods_index = rest_mods.index(min(rest_mods))
    for i in range(len(rest)):
        time += rest[i]
        if i != min_mods_index:
            time += 10 - rest[i] % 10
else:
    time += sum(rest)
print(time)
Buggy python submission (verdict: Runtime Error):
# O(log(B))で求める場合

import math

# f(x) = 0からxまでのxor
def f(x):
    x += 1
    digit = math.ceil(math.log2(x)) + 1

    ret = 0
    for d in range(digit):
        loop = 1 << (d + 1)
        count = (x // loop) * (loop // 2)
        count += max(0, x % loop - loop // 2)

        if count % 2 == 1:
            ret += 1 << d
    return ret



A, B = map(int, input().split())
print(f(A - 1) ^ f(B))


Fixed submission:
import math

# f(x) = 0からxまでのxor
def f(x):
    div = (x // 2) % 2
    if x % 2 == 0:
        return div ^ x
    else:
        return div ^ 1

A, B = map(int, input().split())
print(f(A - 1) ^ f(B))

Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
bi_list = [n for n in range(math.ceil(math.log2(B)) + 1)]

if A == B:
    print(A)
    exit()

odd_num = 0
count_list = [0] * (len(bi_list) + 1)
for i in range(A, B + 1):
    if i % 2 != 0:
        odd_num +=1
    for b in bi_list:
        if i >= b and i % (2 ** b) == 0:
            count_list[b] += 1

result_list = [0] * (len(bi_list) + 1)
for i, elem in enumerate(reversed(count_list)):
    if elem % 2 == 0:
        result_list[i] = "0"
    else:
        result_list[i] = "1"

if odd_num % 2 != 0:
    result_list[-1] = "1"
print(int("".join(result_list), 2))


Fixed submission:
import math

# f(x) = 0からxまでのxor
def f(x):
    div = (x // 2) % 2
    if x % 2 == 0:
        return div ^ x
    else:
        return div ^ 1

A, B = map(int, input().split())
print(f(A - 1) ^ f(B))
Buggy python submission (verdict: Runtime Error):
N, M= map(int, input().split())
a_list = sorted(map(int, input().split()), reverse = True)

# インデックスを分かりやすくするために先頭に0を追加
match_num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [- 10 ** 5] * (N + 1)
dp[0] = 0

# 桁数を調べる
for i in range(1, N+1):
    dp[i] = max([dp[i - match_num[a]] + 1 for a in a_list])

# 各桁に使う数字を調べる
ans = [""] * dp[N]
rest_match = N
for i in range(dp[N]):
    for a in a_list:
        index = rest_match - match_num[a]
        if index >= 0 and dp[index] == dp[N] - i - 1:
            rest_match -= match_num[a]
            ans[i] = str(a)
            break
print("".join(ans))


Fixed submission:
N, M= map(int, input().split())
a_list = sorted(map(int, input().split()), reverse = True)

# インデックスを分かりやすくするために先頭に0を追加
match_num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

inf = 10 ** 5
dp = [-inf] * (N + 1)
dp[0] = 0

# 桁数を調べる
for i in range(1, N+1):
    dp[i] = max([dp[i - match_num[a]] + 1 for a in a_list if i - match_num[a] >= 0] + [-inf])

# 各桁に使う数字を調べる
ans = [""] * dp[N]
rest_match = N
for i in range(dp[N]):
    for a in a_list:
        index = rest_match - match_num[a]
        if index >= 0 and dp[index] == dp[N] - i - 1:
            rest_match -= match_num[a]
            ans[i] = str(a)
            break
print("".join(ans))

Buggy python submission (verdict: Runtime Error):
N, M= map(int, input().split())
a_list = sorted(map(int, input().split()), reverse = True)

# インデックスを分かりやすくするために先頭に0を追加
match_num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dp = [- 10 ** 5] * (N + 1)
dp[0] = 0

# 桁数を調べる
for i in range(1, N+1):
    dp[i] = max([dp[i - match_num[a]] + 1 for a in a_list])

# 各桁に使う数字を調べる
ans = [""] * dp[N]
rest_match = N
for i in range(dp[N]):
    for a in a_list:
        if dp[rest_match - match_num[a]] == dp[N] - i - 1:
            rest_match -= match_num[a]
            ans[i] = str(a)
            break
print("".join(ans))


Fixed submission:
N, M= map(int, input().split())
a_list = sorted(map(int, input().split()), reverse = True)

# インデックスを分かりやすくするために先頭に0を追加
match_num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

inf = 10 ** 5
dp = [-inf] * (N + 1)
dp[0] = 0

# 桁数を調べる
for i in range(1, N+1):
    dp[i] = max([dp[i - match_num[a]] + 1 for a in a_list if i - match_num[a] >= 0] + [-inf])

# 各桁に使う数字を調べる
ans = [""] * dp[N]
rest_match = N
for i in range(dp[N]):
    for a in a_list:
        index = rest_match - match_num[a]
        if index >= 0 and dp[index] == dp[N] - i - 1:
            rest_match -= match_num[a]
            ans[i] = str(a)
            break
print("".join(ans))
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N, K = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(N)]

sushi = sorted(sushi, key = lambda x: x[1], reverse = True)
types = set()
max_vals = [0]
other_vals = [0]

for typ, val in sushi:
    if typ not in types:
        max_vals.append(max_vals[-1] + val)
        types.add(typ)
    else:
        other_vals.append(other_vals[-1] + val)

max_score = 0
for k in range(1, K + 1):
    if K - k < len(other_vals):
        score = max_vals[k] + other_vals[K - k] + k ** 2
        max_score = max(max_score, score)

print(max_score)


Fixed submission:
from collections import defaultdict

N, K = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(N)]

sushi = sorted(sushi, key = lambda x: x[1], reverse = True)
types = set()
max_vals = [0]
other_vals = [0]

for typ, val in sushi:
    if typ not in types:
        max_vals.append(max_vals[-1] + val)
        types.add(typ)
    else:
        other_vals.append(other_vals[-1] + val)

max_score = 0
for k in range(1, K + 1):
    if K - k < len(other_vals) and k < len(max_vals):
        score = max_vals[k] + other_vals[K - k] + k ** 2
        max_score = max(max_score, score)

print(max_score)
Buggy python submission (verdict: Runtime Error):
S = input()

keyence = list("keyence")

for char in S:
    if char == keyence[0]:
        del keyence[0]

if len(keyence) == 0:
    print("YES")
else:
    print("NO")

Fixed submission:
S = input()

keyence = "keyence"

isKey = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            isKey = True
            break
    if isKey:
        break

if isKey:
    print("YES")
else:
    print("NO")