Harryxun/testdata huggingface dataset:
Buggy python 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)


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 python submission (verdict: Time Limit Exceeded):
N,K = list(map(int,input().split()))
s = [list(map(int,input().split())) for l in range(N)]
ans = []
s.sort(key = lambda x:x[1],reverse = True)
cnt = {}
A = 0
for i in range(K):
    if s[i][0] not in cnt:
        cnt[s[i][0]] = 1
    else:
        cnt[s[i][0]] += 1
    ans.append(s[i])
    A += s[i][1]
A += len(cnt)**2

ans.sort(key = lambda x:x[1])
for i in range(K,N):
    if s[i][0] not in cnt:
        for j in range(K):
            if cnt[ans[j][0]] >= 2:
                ans.pop(j)
                ans.insert(0,s[i])
                cnt[s[i][0]] = 1
                temp = 0
                for l in ans:
                    temp += l[1]
                A = max(A,temp+len(cnt)**2)
                    
                break
            
            
    else:
        continue

    if len(cnt) >= K:break
print(A)

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 python 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')
    

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 python 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)
        
    
    
    
    
            
        
            
    
    
        
    
    
    



        
        
    
        
    
            
    



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 python 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)
        
    
    
    
    

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 python submission (verdict: Runtime Error):
H,W = list(map(int,input().split()))
data = [list(input()) for l in range(H)]
visit = [[0 for i in range(W)] for j in range(H)]
sum = 0
def search(i,j,col):
    global H,W,data,visit,sum
    if (i < 0)or(i >= H)or(j < 0)or(j >= W):
        return
    if (i >= 0)and(i <= H-1)and(j >= 0)and(j <= W-1):
        if (visit[i][j]):return
        if (col == '#') and (data[i][j] == '.'):
            sum += 1
            visit[i][j] = 1
        elif (col == '.') and (data[i][j] == '#'):
            visit[i][j] = 1
        elif (col == ''):
            visit[i][j] = 1
        else:return
    
            
    if data[i][j] == '#':
        search(i-1,j,'#')
        search(i,j-1,'#')
        search(i,j+1,'#')
        search(i+1,j,'#')
    if data[i][j] == '.':
        search(i-1,j,'.')
        search(i,j-1,'.')
        search(i,j+1,'.')
        search(i+1,j,'.')
    

for i in range(H):
    for j in range(W):
        if data[i][j] == '#':
            visit = [[0 for i in range(W)] for j in range(H)]
            search(i,j,'')

print(sum)

Fixed submission:
import math
H,W = list(map(int,input().split()))
data = [list(input()) for l in range(H)]
check = [[0 for s in range(W)] for k in range(H)]
sum = 0

def search(i,j,H,W,data,check):
    stack = [[i,j]]
    check[i][j] = 1 
    tempSum = 0
    numW = 0
    numB = 0
    while True:
        if len(stack) != 0:
            s = stack[-1]
            hNow,wNow = s[0],s[1]
            WB = data[hNow][wNow]
            if WB == '.':
                numW += 1
            else:
                numB += 1
        else:
            return (numW*numB),check


        stack.pop()

        if hNow < H-1:
            if (data[hNow+1][wNow] != WB) and (check[hNow+1][wNow] == 0):
                stack.append([hNow+1,wNow])
                check[hNow+1][wNow] = 1
        if wNow < W-1:
            if (data[hNow][wNow+1] != WB) and (check[hNow][wNow+1] == 0):
                stack.append([hNow,wNow+1])
                check[hNow][wNow+1] = 1

        if hNow > 0:
            if (data[hNow-1][wNow] != WB) and (check[hNow-1][wNow] == 0):
                stack.append([hNow-1,wNow])
                check[hNow-1][wNow] = 1

        if wNow > 0:
            if (data[hNow][wNow-1] != WB) and (check[hNow][wNow-1] == 0):
                stack.append([hNow,wNow-1])
                check[hNow][wNow-1] = 1
        
for i in range(H):
    for j in range(W):
        if (check[i][j] == 0):
            temp,check = search(i,j,H,W,data,check)
            sum += temp

print(sum)
Buggy python submission (verdict: Runtime Error):
N = int(input())
data = [[0 for i in range(3)] for j in range(N)]
for i in range(N):
    data[i][0],data[i][1],data[i][2] = [int(s) for s in input().split()]

fl = 0
for Cx in range(0,101):
    for Cy in range(0,101):
        s1 = abs(data[0][0]-Cx)+abs(data[0][1]-Cy)+data[0][2]
        for i in range(1,N):
            s2 = abs(data[i][0]-Cx)+abs(data[i][1]-Cy)+data[i][2]
            if s1 != s2:
                break
        else:
            H = s1
            cx = Cx
            cy = Cy
            fl = 1
        if fl:
            break
    if fl:
        break

print(cx,cy,H)
                
            
        
    
    
      

Fixed submission:
N = int(input())
data = [[0 for i in range(3)] for j in range(N)]
for i in range(N):
    data[i][0],data[i][1],data[i][2] = [int(s) for s in input().split()]


for p in data:
    if p[2] != 0:
        base_x = p[0]
        base_y = p[1]
        base_height = p[2]


for Cx in range(0,101):
    for Cy in range(0,101):
        height = abs(base_x-Cx)+abs(base_y-Cy)+base_height
        for p in data:
            if p[2] != max([height-abs(Cx-p[0])-abs(Cy-p[1]),0]):
                break
        else:
            print(str(Cx)+' '+str(Cy)+' '+str(height))
            exit()
Buggy python submission (verdict: Runtime Error):
#nの約数列挙
def devisor(n):
    ans = []
    if n == 1:return [1]
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            if i != n//i:
                ans.append(i)
                ans.append(n//i)
            else:
                ans.append(i)
            

    return ans       

#n個の正数の積でmになる場合の数
def cnt(n,m):
    ans = 0
    if n == 1:return 1
    s = devisor(m)
    for i in s:
        ans += cnt(n-1,m//i)
    return ans


N,M = list(map(int,input().split()))
print(cnt(N,M))

Fixed submission:
def fctr(n):
    f = []
    c = 0
    for i in range(2,int(n**0.5)+1):
        while n%i==0:
            c+=1
            n = n//i
        if c!=0:
            f.append([i,c])
            c = 0

    if n!=1:
        f.append([n,1])

    return f

def combination(n,r):
    r = min(r,n-r)
    result = 1
    for i in range(n-r+1,n+1):
        result *= i
    for i in range(1,r+1):
        result //= i
    return result

mod = 10**9 + 7
N,M = list(map(int,input().split()))
ans = 0
s = fctr(M)

for i in s:
    if ans == 0:
        ans = combination(N-1+i[1],i[1]) % mod
    else:
        ans = (ans*combination(N-1+i[1],i[1]))%mod

if M != 1:         
    print(ans)
else:
    print('1')
Buggy python submission (verdict: Runtime Error):
N_X = list(map(int,input().split()))
data = list(map(int,input().split()))
k = 0

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

def mulgcd(list):
    if len(list)==2:
        return gcd(list[0],list[1])
    return gcd(mulgcd(list[1:]),list[0])


for i in data:
    data[k] = abs(i - N_X[1])
    k += 1


if N_X[0] == 1:
    print(abs(data[0]))
else:
    print(mulgcd(data))


Fixed submission:
N_X = list(map(int,input().split()))
data = list(map(int,input().split()))
k = 0

for i in data:
    data[k] = abs(i - N_X[1])
    k += 1

m = min(data)
a = []
for i in range(1,m+1):
    if m % i == 0:
        a.append(i)
        a.append(int(m/i))
    if i**2 > m:
        break

a.sort()
a.reverse()

for i in a:
    if all(c%i == 0 for c in data):
        print(i)
        break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = list(input())
ans = [0]*(N)
for i in range(N):
    L = []
    R = []
    if (i >= 1) and (i <= N-2):
        L = s[:i]
        R = s[i+1:]
    elif (i == 0):
        R = s[1:]
    else:
        L = s[:N-1]
    ans[i] = L.count('W') + R.count('E')

print(min(ans))

Fixed submission:
N = int(input())
s = list(input())
sum = [0]*(N+1)

for i in range(1,N+1):
    if s[i-1] == 'W':
        sum[i] = sum[i-1]+1
    else:
        sum[i] = sum[i-1]
    
for i in range(1,N+1):
    temp = sum[i-1] + (N-i - (sum[N]-sum[i]))
    if i == 1:
        ans = temp
    elif temp < ans:
        ans = temp
    

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,C = list(map(int,input().split()))
imos = [[0 for j in range(10**5+1)] for i in range(C)]
for i in range(N):
    l,r,c = list(map(int,input().split()))
    c -= 1
    l -= 1
    imos[c][l] += 1
    imos[c][r] -= 1

for c in range(C):
    for i in range(1,10**5+1):
        imos[c][i] += imos[c][i-1]
for c in range(C):
    for i in range(10**5+1):
        if (imos[c][i] > 0):
            imos[c][i] = 1

ans = 0

for i in range(10**5):
    cnt = 0
    for c in range(C):
        cnt += imos[c][i]

    ans = max(cnt,ans)

print(ans)

Fixed submission:
def merge(s):
    correct_s = []
    s.sort(key = lambda x:(x[2],x[0]))
    min_max = [s[0][0],s[0][1]]
    for i in range(1,len(s)):
        if s[i][2] == s[i-1][2] and s[i][0] == min_max[1]:
            min_max[1] = s[i][1]   
        else:
            correct_s.append([min_max[0],min_max[1],s[i-1][2]])
            min_max[0],min_max[1] = s[i][0],s[i][1]
    else:
        correct_s.append([min_max[0],min_max[1],s[len(s)-1][2]])

    return correct_s
        
        
    
import heapq
N,C = list(map(int,input().split()))
data = []
av = []
for i in range(N):
    data.append(list(map(int,input().split())))
    


s = merge(data)
s.sort()


for i in range(len(s)):
    if i == 0:
        heapq.heappush(av,s[i][1])
    elif s[i][0] <= av[0]:
        heapq.heappush(av,s[i][1])
    else:
        heapq.heappop(av)
        heapq.heappush(av,s[i][1])

print(len(av))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N,K = list(map(int,input().split()))
s = [list(map(int,input().split())) for i in range(N)]

tup = ()
for i in range(N):
    tup += (i,)

data = list(itertools.combinations(tup,2))
ans = []

for x in range(len(data)):
    for y in range(len(data)):
        cnt = 0
        x_side = data[x]
        y_side = data[y]
        x_left = min(s[x_side[0]][0],s[x_side[1]][0])
        x_right = max(s[x_side[0]][0],s[x_side[1]][0])
        y_bottom = min(s[y_side[0]][1],s[y_side[1]][1])
        y_top = max(s[y_side[0]][1],s[y_side[1]][1])
        for i in s:
            if (x_left <= i[0] and i[0] <= x_right)and(y_bottom <= i[1] and i[1] <= y_top):
                cnt += 1
        if cnt >= K:
            ans.append((x_right-x_left)*(y_top-y_bottom))
    
        
print(min(ans))

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

x,y = [],[]
xx,yy = [],[]

for i in range(n):
    X,Y = map(int,input().split())

    x.append(X)
    xx.append(X)
    y.append(Y)
    yy.append(Y)



xx.sort()
yy.sort()
ans = 10**20

for i in range(n):
    for j in range(i):
        lx,rx = xx[j],xx[i]

        num = [0 for _ in range(n+1)]

        for k in range(n):
            if lx <= x[k] <= rx:
                num[yy.index(y[k])+1] += 1

        for k in range(n):
            num[k+1] += num[k]


        for k in range(n):
            for l in range(k):
                by,ty = yy[l],yy[k]

                if num[k+1] - num[l] >= K:
                    ans = min(ans,(rx-lx)*(ty-by))



print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
t = [input() for i in range(a)]
cnt = 0
for i in range(a):
    for j in range(i+1,a):
        if sorted(t[i]) == sorted(t[j]):
            cnt += 1

print(cnt)

Fixed submission:
a = int(input())
t = [input() for i in range(a)]
cnt = 0
dict = {}
for i in range(a):
    src = "".join(sorted(t[i]))
    if src in dict.keys():
        dict[src] += 1
    else:
        dict[src] = 0
ans = 0
for a in dict.values():
    ans += a*(a+1)/2
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
t = [input() for i in range(a)]
cnt = 0
for i in range(a):
    lst1 = list(t[i])
    for j in range(i+1,a):
        lst2 = list(t[j])
        if sorted(lst1) == sorted(lst2):
            cnt += 1

print(cnt)

Fixed submission:
a = int(input())
t = [input() for i in range(a)]
cnt = 0
dict = {}
for i in range(a):
    src = "".join(sorted(t[i]))
    if src in dict.keys():
        dict[src] += 1
    else:
        dict[src] = 0
ans = 0
for a in dict.values():
    ans += a*(a+1)/2
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
Ask = input()
puts = Ask.split()


A = int(puts[0])
B = int(puts[1])

for i in range(max(A,B)):
	C = abs(A-i)
	D = abs(B-i)
	if (C == D):
		print(i)
		Pos = True
		break
	else:
		Pos = False
	
if not Pos:
	print('IMPOSSIBLE')


Fixed submission:
Ask = input()
puts = Ask.split()


A = int(puts[0])
B = int(puts[1])
Ans = 0

Pos = False

if (A == B):
	Pos = True
elif (A**2 - B**2) % (2*(A-B)) == 0:
	Pos= True
	Ans =  (A**2 - B**2) / (2*(A-B))
	
if not Pos:
	print('IMPOSSIBLE')
else:
	print(int(Ans))
Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
new = []

for i in range(num):
    a = list(input())
    a.sort()
    narr = ''.join(a)
    new.append(narr)

k = 0

for i in range(num):
    for j in range(i+1 , num):
        if new[i] == new[j]:
            k += 1

print(k)

Fixed submission:
num = int(input())
arr = []
d = {}

for i in range(num):
    s = sorted(list(input()))
    ss = ''.join(s)
    arr.append(ss)

#print(arr)
ans = 0

for i in range(num):
    if arr[i] in d:
        ans += d[arr[i]] 
        d[arr[i]] += 1
    else:
        d[arr[i]] = 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
new = []

for i in range(num):
    a = list(input())
    a.sort()
    narr = ''.join(a)
    new.append(narr)

k = 0

for i in range(num):
    for j in range(i+1 , num):
        if new[i] == new[j]:
            k += 1

print(k)

Fixed submission:
num = int(input())
arr = []
d = {}

for i in range(num):
    s = sorted(list(input()))
    ss = ''.join(s)
    arr.append(ss)

#print(arr)
ans = 0

for i in range(num):
    if arr[i] in d:
        ans += d[arr[i]] 
        d[arr[i]] += 1
    else:
        d[arr[i]] = 1

print(ans)
Buggy python submission (verdict: Runtime Error):
L = list(map(int(),input().split()))
if sum(L)==17:
  print('YES')
else:
  pritn('NO')
 

Fixed submission:
L = [int(i) for i in input().split()]

S = sum(L)
S2 = S - L[0]
S1 = S2 - L[1]

if S != 17:
    print('NO')
else:
    if S2==10 and S1==5:
        print('YES')
    elif S2==12 and (S1==5 or S1==7):
        print('YES')
    else:
        print('NO')

Buggy python submission (verdict: Runtime Error):
lst = input('3 nums with 2 space(1<=nums<=10):')
i = 0
for n in lst:
  if n>10 or n<1:
    print('NO')
    break
    
  if n==5:
    i += 1
  elif n==7:
    i -= 1
if i == 1:
  print('YES')
else:
  print('NO')

Fixed submission:
L = [int(i) for i in input().split()]

S = sum(L)
S2 = S - L[0]
S1 = S2 - L[1]

if S != 17:
    print('NO')
else:
    if S2==10 and S1==5:
        print('YES')
    elif S2==12 and (S1==5 or S1==7):
        print('YES')
    else:
        print('NO')
Buggy python submission (verdict: Runtime Error):
a = input()
if a = A :
	print('T')
elif a = T :
	print('A')
elif a = C :
	print('G')
else:
	print('C')

Fixed submission:
a = input()
if a is 'A' :
	print('T')
elif a is 'T' :
	print('A')
elif a is 'C' :
	print('G')
else:
	print('C')
Buggy python submission (verdict: Runtime Error):
k, x = map(int, input().split())

tmp = [y for y in range(x-k+1, x+k)]
y = ' '.join(tmp)
print(y)

Fixed submission:
k, x = map(int, input().split())
tmp = [str(y) for y in range(x-k+1, x+k)]
print(' '.join(tmp))
Buggy python submission (verdict: Runtime Error):
A, B = [int(i) for i input().split(' ')]
print(max((A + B), (A - B), (A * B)))

Fixed submission:
A, B = [int(i) for i in input().split(' ')]
print(max((A + B), (A - B), (A * B)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ss = []
for _ in range(N):
    ss.append(''.join(sorted(input())))

result = 0
for i in range(N):
    for j in range(i + 1, N):
        if ss[i] == ss[j]:
            result += 1
print(int(result))

Fixed submission:
N = int(input())
ss = []
for _ in range(N):
    ss.append(''.join(sorted(input())))
d = {}
for s in ss:
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
print(sum(int((v * (v - 1)) / 2) for v in d.values() if v > 1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ss = []
for _ in range(N):
    ss.append(''.join(sorted(input())))

result = 0
for u in set(ss):
    cnt = len([s for s in ss if s == u])
    result += (cnt * (cnt -1)) / 2
print(int(result))


Fixed submission:
N = int(input())
ss = []
for _ in range(N):
    ss.append(''.join(sorted(input())))
d = {}
for s in ss:
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
print(sum(int((v * (v - 1)) / 2) for v in d.values() if v > 1))
Buggy python submission (verdict: Runtime Error):
a, b = input().split()
max(a + b, a - b, a * b)

Fixed submission:
a, b = [int(x) for x in input().split()]
print(max(a + b, a - b, a * b))

Buggy python submission (verdict: Runtime Error):
a, b = input(), input()
max(a + b, a - b, a * b)

Fixed submission:
a, b = [int(x) for x in input().split()]
print(max(a + b, a - b, a * b))
Buggy python submission (verdict: Runtime Error):
k, x = [int(x) for x in input().split()]
print(" ".join(range(x - k + 1, x + k - 1)))

Fixed submission:
k, x = [int(x) for x in input().split()]
print(" ".join(str(i) for i in range(x - k + 1, x + k)))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

# N,Cを取得
n, c = map(int, input().split())

# x1, v1..xN, vNを取得
xs = []
vs = []
for _i in range(n):
    x, v = map(int, input().split())
    xs.append(x)
    vs.append(v)

r1, r2, l1, l2 = [[], [], [], []]
r_sum, l_sum = [0, 0]
for i in range(n):
    r_sum += vs[i]
    r1.append(r_sum - xs[i])
    r2.append(r_sum - 2 * xs[i])

    i_rev = n - i - 1
    l_sum += vs[i_rev]
    l1.append(l_sum - (c - xs[i_rev]))
    l2.append(l_sum - 2 * (c - xs[i_rev]))

r1_l2_max = 0
l1_r2_max = 0
for i in range(n):
    r1_max = max(r1[:i + 1])
    l2_max = max(l2[:n - i - 1] or [0])
    r1_l2_max = max(r1_l2_max, r1_max + l2_max)

    l1_max = max(l1[:i + 1])
    r2_max = max(r2[:n - i - 1] or [0])
    l1_r2_max = max(l1_r2_max, l1_max + r2_max)

total_max = max(r1_l2_max, l1_r2_max)

# 結果を出力
print("{}".format(total_max))


Fixed submission:
# -*- coding: utf-8 -*-

# N,Cを取得
n, c = map(int, input().split())

# x1, v1..xN, vNを取得
xs = []
vs = []
for _i in range(n):
    x, v = map(int, input().split())
    xs.append(x)
    vs.append(v)

r1, r2, l1, l2 = [[], [], [], []]
r_sum, l_sum = [0, 0]
for i in range(n):
    r_sum += vs[i]
    r1.append(r_sum - xs[i])
    r2.append(r_sum - 2 * xs[i])

    i_rev = n - i - 1
    l_sum += vs[i_rev]
    l1.append(l_sum - (c - xs[i_rev]))
    l2.append(l_sum - 2 * (c - xs[i_rev]))

r1_max, r2_max = [0, 0]
l1_max, l2_max = [0, 0]
r1_maxs, r2_maxs = [[0], [0]]
l1_maxs, l2_maxs = [[0], [0]]
for i in range(n):
    r1_max = max(r1_max, r1[i])
    r1_maxs.append(r1_max)
    r2_max = max(r2_max, r2[i])
    r2_maxs.append(r2_max)
    l1_max = max(l1_max, l1[i])
    l1_maxs.append(l1_max)
    l2_max = max(l2_max, l2[i])
    l2_maxs.append(l2_max)

r1_l2_max = 0
l1_r2_max = 0
for i in range(0, n + 1):
    r1_l2_max = max(r1_l2_max, r1_maxs[i] + l2_maxs[n - i])
    l1_r2_max = max(l1_r2_max, l1_maxs[i] + r2_maxs[n - i])

total_max = max(r1_l2_max, l1_r2_max)

# 結果を出力
print("{}".format(total_max))