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

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]

b = sorted(a)

for i in a:
    if i == b[-1]:
        print(b[-2])
    else:
        print(b[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]

b = sorted(a)

for i in a:
    if i = b[-1]:
        print(b[-2])
    else:
        print(b[-1])
Problem p02983 (python)

Fixed submission:
l,r = map(int, input().split())

t = []

if r-l >= 2019:
    print(0)
else:
    for i in range(l,r):
        for j in range(l+1,r+1):
            t.append((i*j)%2019)
    print(min(t))

Buggy submission (verdict: Runtime Error):
l,r = map(int, input().split())

t = []

if r-l >= 2019:
    print(0)
else:
    for i in range(l,r):
        for j in range(l+1,r+1):
            t.append((i*j)%2019)

print(min(t))

Buggy submission (verdict: Runtime Error):
l,r = map(int, input().split())

t = []

if r-l >= 2019:
    print(0)
else:
    for i in range(l,r):
        for j in range(l+1,r+1):
            t.append((i*j)%2019)

print(min(t))
Problem p02681 (python)

Fixed submission:
s = input()
t = input()

if t.startswith(s) and str.isalpha(t):
    if len(t) == (len(s) + 1):
        print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())
result = 0

if A >= K:
    print(A)
elif (A + B) >= K:
    print(A)
elif (A + B + C) > K:
    print(A - (K - (A + B)))
else:
    print(A - C)

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())
result = 0

if A >= K:
    print(K)
elif (A + B) >= K:
    print(K)
else:
    for i in range(K):
        if A > (i + 1):
            result += 1
            continue
        elif A == (i + 1):
            result += 1
            continue

        if B > (i + 1 - A):
            result += 0
            continue
        elif B == (i + 1 - A):
            result += 0
            continue

        if C > (i + 1 - A - B):
            result -= 1
            continue
        elif C == (i + 1 - A - B):
            result -= 1
            break
        else:
            break
    print(result)

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())
result = 0

if A >= K:
    print(K)
else:
    for i in range(K):
        if A > (i + 1):
            result += 1
            continue
        elif A == (i + 1):
            result += 1
            continue

        if B > (i + 1 - A):
            result += 0
            continue
        elif B == (i + 1 - A):
            result += 0
            continue

        if C > (i + 1 - A - B):
            result -= 1
            continue
        elif C == (i + 1 - A - B):
            result -= 1
            break
        else:
            break
    print(result)

Buggy submission (verdict: Runtime Error):
A, B, C, K = map(int, input().split())
result = 0

if A > K:
    print(K)
    exit

for i in range(K):
    if A > (i + 1):
        result += 1
        continue
    elif A == (i + 1):
        result += 1
        continue

    if B > (i + 1 - A):
        result += 0
        continue
    elif B == (i + 1 - A):
        result += 0
        continue

    if C > (i + 1 - A - B):
        result -= 1
        continue
    elif C == (i + 1 - A - B):
        result -= 1
        break
    else:
        break

print(result)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

if T.startswith(S):
    if len(T) == (len(S) + 1):
        print('YES')
else:
    print('No')1
Problem p02687 (python)

Fixed submission:
s = input()

if s == 'ABC':
    print('ARC')
else:
    print('ABC')

Buggy submission (verdict: Runtime Error):
x = int(input())

for a in range(100):
    for b in range(100):
        if a**5 + b**5 == x:
            print(a, b)
            exit()
Problem p02696 (python)

Fixed submission:
a,b,n = map(int, input().split())
com = 0
if n < b:
    x = n
else:
    x = b-1
val = (a*x)//b
print(val)

Buggy submission (verdict: Runtime Error):
a,b,n = map(int, input().split())
if n < b:
    x = n
else:
    x = b-1
while x >= 0:
    val = (a*x)//b-a*(x//b)
    if val < com:
        pass
    else:
        com = val
    x -= 1
print(com)
Problem p02681 (python)

Fixed submission:
S = input()
T = input()
if S == T[:-1]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
if (len(S) + 1 ==  len(T)) and (T.index(S) == 0):
    print('yes')
else:
    print('no')
Problem p02887 (python)

Fixed submission:
N = int(input())
S = input()

count = 1
for i in range(N - 1):
    if S[i] != S[i + 1]:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
def fusion(xs):
    if len(xs) < 2:
        yield from xs
    elif xs[0] == xs[1]:
        yield from fusion(xs[1:])
    else:
        yield xs[0]
        yield from fusion(xs[1:])


N = input()
S = input()
print(sum(1 for _ in fusion(S)))
Problem p02681 (python)

Fixed submission:
S = str(input())
T = str(input())
t = int(len(T)) - 1
U = T[:t]

if S == U:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = str(input())
T = str(input())
t = int(len(T)) - 2

if S == T[:t]
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = str(input())
T = str(input())
t = int(len(T)) - 2

if S == T[:t]
  print(Yes)
else:
  No

Buggy submission (verdict: Runtime Error):
S = str(input())
T = str(input())

if S == T[0:len(T)-2]:
  print(Yes)
else:
  No

Buggy submission (verdict: Runtime Error):
S = str(input())
T = str(input())

if S + .  == T:
  print(Yes)
else:
  No

Buggy submission (verdict: Runtime Error):
S = str(input())
T = str(input())

if .S == T:
  print(Yes)
else:
  No
Problem p02681 (python)

Fixed submission:
s = [input() for i in range(2)]
if s[0] == s[1][:-1]:
  print('Yes')
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = [input() for i in range(2)]
if s[0] = s[1][:-1]:
  print('Yes')
else:
  print("No")
Problem p02681 (python)

Fixed submission:
S = input()
T = input()
 
if T[:-1] == S:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
#include <stdio.h>
int main (void){
    int i;
    char S[20], T[20];
    scanf("%s%s", S, T);
    for(i=0;S[i]!='\0';i++){
        if(S[i]==T[i]){
            printf("Yes\n");
            
        }else printf("No\n");
    return 0;
    }
Problem p02747 (python)

Fixed submission:
s = input()

if len(s.replace('hi', '')) == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = input()

if 'hi' in s:
  print('Yes')
else:
  print('No)
Problem p02801 (python)

Fixed submission:
s = str(input())

print(chr(ord(s) + 1))

Buggy submission (verdict: Runtime Error):
num = lambda c: chr(c+64)
s = str(input())

for i in range(1,26):
	if s == num(i).lower:
      print(num(i+1))
Problem p02841 (python)

Fixed submission:
l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))

if l2[1] == 1:
  print('1')
else:
  print('0')

Buggy submission (verdict: Runtime Error):
l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))

if l[1] == 1:
  print('1')
else:
  print('0')
Problem p03844 (python)

Fixed submission:
a, o, b = input().split()

if o == "+":
  print(int(a) + int(b))
elif o == "-":
  print(int(a) - int(b))

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

if op == '+':
  print(a + b)
else:
  print(a - b)

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

if op == '+':
  print(a + b)
else:
  print(a - b)
Problem p03059 (python)

Fixed submission:
[a,b,t] = map(int,input().split(" "))
print((t//a)*b)

Buggy submission (verdict: Runtime Error):
[a,b,t] = (input().split(" "))
print((t//a)*b)
Problem p02899 (python)

Fixed submission:
import numpy as np
n = int(input())
a = list(map(int,input().split()))

a = np.array(a)



print(*np.argsort(a)+1)

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

a = np.array(a)



print(*np.argsort(a)+1)

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

a = np.array(a)

'''
for i in range(1,n+1):
    result.append(a.index(i)+1)
'''


print(*np.argsort(a)+1)
Problem p02946 (python)

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

start = x - k+1
end = x + k-1

ans = ''
for i in range(start,end+1):
    ans += '{} '.format(i)
ans = ans[:-1]

print(ans)

Buggy submission (verdict: Runtime Error):
k,x =list(map(int,input().split()))

start = x - k+1
end = x + k-1

ans = ''
for i in range(start,end+1):
    ans += f'{i} '
ans = ans[:-1]

print(ans)
Problem p02953 (python)

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

tem =0

for i in range(n):

    if(i==0):
        pass
    elif( int(h[-(i+1)]) > 1 + int(h[-i]) - tem ):
        answer = "No"
        break
    elif(int(h[-(i+1)]) == 1 + int(h[-i]) - tem  ):
        tem = 1
    else:
        tem = 0

    answer = "Yes"


print(answer)

Buggy submission (verdict: Runtime Error):

a = input().split()
N = int(a[0])
H = a[1:]
len(H)



for i in range(len(H)):

    if(i==0):
        pass
    elif( int(H[-(i+1)]) >= 1 + int(H[-i]) ):
        answer = "No"
        break
    elif(int(H[-(i+1)]) == 1 + int(H[-i])):
        tem = 1
    else:
        tem = 0

    answer = "Yes"


print(answer)
Problem p03288 (python)

Fixed submission:
import sys
r = int(sys.stdin.readline())
if r < 1200: print("ABC")
elif r < 2800: print("ARC")
else: print("AGC")

Buggy submission (verdict: Runtime Error):
import sys
r = int(sys.stdin.readline())
if r < 1200: print("ABC")
elif r < 2800: print("ARC")
else print("AGC")
Problem p03297 (python)

Fixed submission:
import sys

def gcd(x, y):
    x, y = sorted([x, y])
    while y % x:
        y, x = x, y % x
    return x

t = int(sys.stdin.readline())
for _ in range(t):
    a, b, c, d = map(int, sys.stdin.readline().split())
    if a < b:
        print("No")
    elif d < b:
        print("No")
    elif c >= b:
        print("Yes")
    else:
        g = gcd(b, d)
        if b - g + (a % g) > c:
            print("No")
        else:
            print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
import math

t = int(sys.stdin.readline())
for _ in range(t):
    a, b, c, d = map(int, sys.stdin.readline().split())
    if a < b:
        print("No")
    elif d < b:
        print("No")
    elif c >= b:
        print("Yes")
    else:
        g = math.gcd(b, d)
        if b - g + (a % g) > c:
            print("No")
        else:
            print("Yes")
Problem p02724 (python)

Fixed submission:
X=int(input())
N=0
n=0
if X==0:
    print(0)
else:
    N=X//500
    n=(X-N*500)//5
    print(N*1000+5*n)

Buggy submission (verdict: Runtime Error):
X=int(input())
N=0
n=0
N=X//500
n=(X-N*500)//5
input(N*1000+5*n)
Problem p02796 (python)

Fixed submission:
from operator import itemgetter
n=int(input())
xl=[list(map(int,input().split()))for i in range(n)]
R=[(xl[i][0]-xl[i][1],xl[i][0]+xl[i][1]) for i in range(n)]
r=sorted([(R[i][0],R[i][1]) for i in range(n)],key=itemgetter(1))
s=r[0][1]
ans=1
for i in range(n-1):
    if r[i+1][0]>=s:
        s=r[i+1][1]
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter
n=int(input())
xl=[list(map(int,input().split()))for i in range(n)]
R=[list(xl[i][0]-xl[i][1],xl[i][0]+xl[i][1]) for i in range(n)]
r=sorted([(R[i][0],R[i][1]) for i in range(n)],key=itemgetter(1))
s=r[0][1]
ans=1
for i in range(n-1):
    if r[i+1][0]>=s:
        s=r[i+1][1]
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter
n=int(input())
xl=[list(map(int,input().split()))for i in range(N)]
R=[list(xl[i][0]-xl[i][1],xl[i][0]+xl[i][1]) for i in range(n)]
r=sorted([(R[i][0],R[i][1]) for i in range(n)],key=itemgetter(1))
s=r[0][1]
ans=1
for i in range(n-1):
    if r[i+1][0]>=s:
        s=r[i+1][1]
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter
n=int(input())
xl=[list(map(int,input().split()))for i in range(N)]
R=[list(xl[i][0]-xl[i][1],xl[i][0]+xl[i][1]) for i in range(n)]
r=sorted([(R[i][0],R[i][1]) for i in range(n)],key=itemgetter(1))
s=r[0][1]
ans=1
for i in range(n-1):
    if r[i+1][0]>s:
        s=r[i+1][1]
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter
n=int(input())
xl=[list(map(int,input().split()))for i in range(N)]
R=[list(xl[i][0]-xl[i][1],xl[i][0]+xl[i][1]) for i in range(n)]
r=sorted([(R[i][0],R[i][1]) for i in range(n)],key=itemgetter(1))
s=r[0][1]
ans=1
for i in range(1,n):
    if r[i][0]>s:
        s=r[i][1]
        ans+=1
print(ans)
Problem p02922 (python)

Fixed submission:
A,B=map(int,input().split())
import math
print(math.ceil((B-1)/(A-1)))

Buggy submission (verdict: Runtime Error):
あ
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=int(input())
print(max(A+B,A-B,A*B))
Problem p02994 (python)

Fixed submission:
N,L=map(int,input().split())
souwa=(L-1)*N+N*(N+1)//2
print(souwa-L if L>=0 else souwa if -N+1<=L<0 else souwa-(L+N-1) )

Buggy submission (verdict: Runtime Error):
N,L=map(int,input().split())
souwa=(L-1)*N+N*(N+1)//2
print(souwa-L if L>=0 else souwa if -N+1<=L<0 else souwa-(L+i-1) )
Problem p02681 (python)

Fixed submission:
S = input()
T = input()
l = len(S)
if S == T[:-1] and l<=10 and l>=1 and S.islower():
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
S = list(S)
T = list(T)
l = len(S)
if S == T[:-1] and l<=10 and l>=1 and S.islower():
    print(True)
else:
    print(False)
Problem p02681 (python)

Fixed submission:
moji = [input() for i in range(2)]
if len(moji[0]) >= 1 and len(moji[0]) <= 10 and len(moji[0])+1 == len(moji[1]) and moji[0] == moji[1][:len(moji[0])]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
moji = [input() for i in range(2)]
if len(moji[0]) >= 1 and len(moji[0]) <= 10 and len(moji[0])+1 = len(moji[1]):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
moji = [input() for i in range(2)]
if len(moji(0)) >= 1 and len(moji(0)) <= 10 and len(moji(0))+1 = len(moji(1)):
  print("Yes")
else:
  print("No")
Problem p02681 (python)

Fixed submission:
s=input()
t=input()
if s==t[:-1]:
	print("Yes")
else:
  	print("No")

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
if s==t[:-1]
	print("Yes")
else:
  	print("No")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
if s==t[:-1]
	print("Yes")
else:
  	print("No")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
if s==t[:-1]
	print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s,t=map(int,input().split())
print("No" if t>=s else "Yes")

Buggy submission (verdict: Runtime Error):
s,t=map(int,input().split())
print("Yes" if t>=s else "No")

Buggy submission (verdict: Runtime Error):
s,t=map(int,input().split())
print("Yes" if t>s else "No")
Problem p02772 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
for i in A:
    if i % 2 == 0:
        if not(i % 3 == 0 or i % 5 == 0):
            print("DENIED")
            break
else:
    print("APPROVED")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(int, input().split())
for i in A:
    if not(i % 3 == 0 or i % 5 == 0):
        print("DENIED")
        break
else:
    print("APPROVED")
Problem p02812 (python)

Fixed submission:
N = int(input())
S = input()
ans = 0
for i in range(N - 2):
    if S[i] == "A" :
        if S[i + 1] == "B":
            if S[i + 2] == "C":
                ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0
for i in range(N):
    if S[i] == "A" and i <= N - 2:
        if S[i + 1] == "B":
            if S[i + 2] == "C":
                ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0
for i in range(N):
    if S[i] == "A":
        if S[i + 1] == "B":
            if S[i + 2] == "C":
                ans += 1
print(ans)
Problem p02981 (python)

Fixed submission:
get = input().split()
N = int(get[0])
A = int(get[1])
B = int(get[2])
train = A * N
if train <= B:
    print(train)
else:
    print(B)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())
train = A * N
if train <= B:
    print(train)
else:
    print(B)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())
train = A * N
if train <= B:
    print(train)
else:
    print(B)

Buggy submission (verdict: Runtime Error):
N, A, B= int(input()), int(input()), int(input())
train = A * N
if train <= B:
    print(train)
else:
    print(B)
Problem p03128 (python)

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

setnum = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6} 
rset = {}
for i in a:
    if i in rset:
        if rset[setnum[i]] > i:
            rset[i] = setnum[i]
    else:
        rset[i] = setnum[i]

rset = sorted(rset.items(), reverse=True)
dp = [0] * (n + 1)
for i in rset:
    if n < i[1]:
        continue
    dp[i[1]] = max(dp[i[1]] , i[0])
    for j in range(i[1], n + 1 - i[1]):
        if dp[j] != 0:
            dp[j + i[1]] = max(dp[j + i[1]], dp[j] * 10 + i[0])
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))

setnum = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6} 
rset = {}
for i in a:
    if i in rset:
        if rset[setnum[i]] > i:
            rset[i] = setnum[i]
    else:
        rset[i] = setnum[i]

rset = sorted(rset.items(), reverse=True)
dp = [0] * (n + 1)
for i in rset:
    dp[i[1]] = i[0]
    for j in range(1, n + 1 - i[1]):
        if dp[j] != 0:
            dp[j + i[1]] = max(dp[j + i[1]], dp[j] * 10 + i[0])
print(dp[-1])
Problem p03138 (python)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = a.copy()
count = 1
d = 1
while k >= d:
    count += 1
    d *= 2
else:
    count -= 1
    d //= 2
anst = 0
for i in range(count):
    level = 0
    for j in range(n):
        tmpb = b[j] // d
        if tmpb >= 1 and tmpb % 2 == 1:
            level += 1
        b[j] %= d
    if k >= anst + d and n > level * 2:
        anst += d
    d //= 2

ans = 0
for i in range(n):
    ans += a[i] ^ anst
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = a.copy()
count = 1
d = 1
while k >= d:
    count += 1
    d *= 2
else:
    count 1= 1
    d //= 2
anst = 0
for i in range(count):
    level = 0
    for j in range(n):
        tmpb = b[j] // d
        if tmpb >= 1 and tmpb % 2 == 1:
            level += 1
        b[j] %= d
    if k >= anst + d and n > level * 2:
        anst += d
    d //= 2

ans = 0
for i in range(n):
    ans += a[i] ^ anst
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = a.copy()
count = 1
d = 1
while k >= d:
    count += 1
    d *= 2
else:
    d //= 2
anst = 0
for i in range(count):
    level = 0
    for j in range(n):
        tmpb = b[j] // d
        if tmpb >= 1 and tmpb % 2 == 1:
            level += 1
        b[j] %= d
    if k >= anst + d and n > level * 2:
        anst += d
    d //= 2

ans = 0
for i in range(n):
    ans += a[i] ^ anst
print(ans)
Problem p03148 (python)

Fixed submission:
n, k = map(int, input().split())
td = [list(map(int, input().split())) for _ in range(n)]

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

dict_td = set()
q = []
ans = 0
for i in range(k):
    if td[i][0] in dict_td:
        q.append(td[i])
    ans += td[i][1]
    dict_td.add(td[i][0])

ans += len(dict_td) ** 2

tmp_ans = ans
for i in range(k, n):
    if len(q) == 0:
        break
    if td[i][0] not in dict_td :
        minus = q.pop()
        tmp_ans += td[i][1] - minus[1]
        dict_len = len(dict_td)
        tmp_ans += (dict_len + 1) ** 2 - dict_len ** 2
        dict_td.add(td[i][0])
    ans = max(tmp_ans, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter as ct
n, k = map(int, input().split())

td = [list(map(int, input().split())) for i in range(n)]

kind = len(ct(list(map(lambda x: x[0], td))))
std = sorted(td, key=lambda x: x[1], reverse=True)
dup = []
eat_k = set()
ans = 0
for i in range(k):
    ans += std[i][1]
    if std[i][0] in eat_k:
        dup.append(std[i])
    eat_k.add(std[i][0])
ans += len(eat_k)** 2
tmpa = ans
for i in range(k, n):
    if std[i][0] not in eat_k:
        t = dup.pop()
        tmpa -= t[1]
        tmpa += std[i][1]
        tmpa -= len(eat_k)** 2
        eat_k.add(std[i][0])
        tmpa += len(eat_k)** 2
        ans = max(tmpa, ans)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter as ct
n, k = map(int, input().split())

td = [list(map(int, input().split())) for i in range(n)]

kind = len(ct(list(map(lambda x: x[0], td))))
std = sorted(td, key=lambda x: x[1], reverse=True)
dup = []
eat_k = set()
ans = 0
for i in range(k):
    ans += std[i][1]
    if std[i][0] in eat_k:
        dup.append(std[i])
    eat_k.add(std[i][0])
ans += len(eat_k)** 2
tmpa = ans
for i in range(n - k, n):
    if std[i][0] not in eat_k:
        t = dup.pop()
        tmpa -= t[1]
        tmpa += std[i][1]
        tmpa -= len(eat_k)** 2
        eat_k.add(std[i][0])
        tmpa += len(eat_k)** 2
        ans = max(tmpa, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
td = [list(map(int, input().split())) for _ in range(n)]

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

dict_td = set()
q = []
ans = 0
for i in range(k):
    if td[i][0] in dict_td:
        q.append(td[i])
    ans += td[i][1]
    dict_td.add(td[i][0])

ans += len(dict_td) ** 2

tmp_ans = ans
for i in range(k, n):
    if td[i][0] not in dict_td:
        minus = q.pop()
        tmp_ans += td[i][1] - minus[1]
        dict_len = len(dict_td)
        tmp_ans += (dict_len + 1) ** 2 - dict_len ** 2
        dict_td.add(td[i][0])
    ans = max(tmp_ans, ans)

print(ans)
Problem p03238 (python)

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

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

Fixed submission:
(n, t) = map(int, input().split())
cts = []
for i in range(n):
    ct = list(map(int, input().split()))
    if ct[1] <= t:
        cts.append(ct)
if len(cts) == 0:
    print("TLE")
else:
    cts.sort()
    print(cts[0][0])

Buggy submission (verdict: Runtime Error):
(n, t) = map(int, input().split())
cts = []
for i in range(n):
    ct = list(map(int, input().split()))
    if ct[1] <= t:
        cts.append(ct)
cts.sort()
print(cts[0][0])
Problem p03241 (python)

Fixed submission:
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {m:1}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if n > m / i:
        break
    maxans = i
print(maxans)

Buggy submission (verdict: Runtime Error):
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
params = {}
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
ans = 0
for param in params:
    if n > m / iparam:
        break
    ans = param
print(ans)

Buggy submission (verdict: Runtime Error):
import math
(n, m) = map(int, input().split())
sm = int(math.sqrt(m)) + 1
for i in range(1, sm + 1):
    if m % i == 0 :
        params[i] = 1
        params[m // i] = 1
params = sorted(params)
mdn = m // n
maxans = 0
for i in params:
    if n > m / i:
        break
    maxans = i
print(maxans)