Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s  = list(str(input()))
t  = list(str(input()))

sd = {}
td = {}

for k in range(ord('a'),ord('z')+1):   
    sd[chr(k)] = 0
    td[chr(k)] = 0

for i in range(len(s)) :
    if s[i] in sd :
        sd[s[i]] = sd[s[i]] + 1

    if t[i] in td :
        td[t[i]] = td[t[i]] + 1
""" 
for k in range(ord('a'),ord('z')+1):   
    print(str(chr(k)) + ":",end="")
    if chr(k) in sd :
        print(str(sd[chr(k)]) + " ",end="")
    else:
        print("0 ",end="")
print()
for k in range(ord('a'),ord('z')+1):   
    print(str(chr(k)) + ":",end="")
    if chr(k) in td :
        print(str(td[chr(k)]) + " ",end="")
    else:
        print("0 ",end="")
print() """

ta = []
sa = []
for k in range(ord('a'),ord('z')+1):
    if td[chr(k)] != sd[chr(k)] : 
        if td[chr(k)] > 0 :
            ta.append(td[chr(k)])
        if sd[chr(k)] > 0 :    
            sa.append(sd[chr(k)])
#print(ta)
#print(sa)

ta.sort()
sa.sort()

if ta == sa :
    print("Yes")
else :
    print("No")

Fixed submission:
l = list(map(int,input().split()))
l.sort(reverse=True)
print(l[0]*10+l[1]+l[2])

Buggy python submission (verdict: Runtime Error):
s  = list(str(input()))
t  = list(str(input()))
s.sort()
t.sort()

for i in range(len(s)):
 
    if s[i] != t[i]:
 
        c1 = s[i]
        c2 = t[i]
 
        for j in range(len(s)):
            if s[j] == c1:
                s[j] = c2
            elif s[j] == c2:
                s[j] = c1

if "".join(s) == "".join(t) :
    print("Yes")        
else :
    print("No")

Fixed submission:
l = list(map(int,input().split()))
l.sort(reverse=True)
print(l[0]*10+l[1]+l[2])
Buggy python submission (verdict: Runtime Error):
ss = str(input())
t  = str(input())

for i in range(len(ss)):

    if ss == t :
        print("Yes")
        exit(0)

    s  = list(ss)

    if s[i] != t[i]:
        c1 = s[i]
        c2 = t[i]
       
        ss = ss.replace(c1 ,"-")
        ss = ss.replace(c2 ,c1 )
        ss = ss.replace("-",c2 )
        print(ss)

print("No")

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

sd = {}
td = {}

for k in range(ord('a'),ord('z')+1):   
    sd[chr(k)] = 0
    td[chr(k)] = 0

for i in range(len(s)) :
    if s[i] in sd :
        sd[s[i]] = sd[s[i]] + 1

    if t[i] in td :
        td[t[i]] = td[t[i]] + 1
""" 
for k in range(ord('a'),ord('z')+1):   
    print(str(chr(k)) + ":",end="")
    if chr(k) in sd :
        print(str(sd[chr(k)]) + " ",end="")
    else:
        print("0 ",end="")
print()
for k in range(ord('a'),ord('z')+1):   
    print(str(chr(k)) + ":",end="")
    if chr(k) in td :
        print(str(td[chr(k)]) + " ",end="")
    else:
        print("0 ",end="")
print() """

ta = []
sa = []
for k in range(ord('a'),ord('z')+1):
    if td[chr(k)] != sd[chr(k)] : 
        if td[chr(k)] > 0 :
            ta.append(td[chr(k)])
        if sd[chr(k)] > 0 :    
            sa.append(sd[chr(k)])
#print(ta)
#print(sa)

ta.sort()
sa.sort()

if ta == sa :
    print("Yes")
else :
    print("No")
Buggy python submission (verdict: Runtime Error):
import math

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

max = abs(t[0]-x)
for i in range(1,len(t)):
    t[i] = abs(t[i]-x)
    max = math.gcd(t[i],max)

print(max)




Fixed submission:
import math

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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

ans = abs(t[0]-x)
for i in range(1,len(t)):
    t[i] = abs(t[i]-x)
    ans = gcd(ans,t[i])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m,q = map(int,input().split())

lr = [[0 for i in range(n)] for j in range(n)]

for i in range(m) :
    l,r = map(int,input().split())    
    lr[l-1][r-1] = lr[l-1][r-1] + 1

pq = []
for i in range(q) :
    pq.append(list(map(int,input().split())))

for i in range(q) :
    p = pq[i][0]
    q = pq[i][1]
    
    count = 0
    for j in range(p-1,q):
        for k in range(p-1,q):
            count += lr[j][k] 
    print(count)

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

lr = [[0 for i in range(n)] for j in range(n)]
for i in range(m) :
    l,r = map(int,input().split())    
    lr[l-1][r-1] = lr[l-1][r-1] + 1

#for l in lr :        
#    print(l)
#print()

# 二次元累積和
for i in range(n) :
    for j in range(n) :
        left = 0
        btm  = 0
        mid  = 0

        if i > 0 :
            left = lr[j][i-1]
        if j > 0 :
            btm  = lr[j-1][i]
        if i > 0 and j > 0 :
            mid  = lr[j-1][i-1]
       
        lr[j][i] = lr[j][i] + left + btm - mid

#for l in lr :        
#    print(l)

ans=[] 
for i in range(q) :
    l,r = map(int,input().split())

    l = l - 1
    r = r - 1
    pre = 0
    if l > 0:    
        #print(lr[r][r],lr[l-1][r],lr[r][l-1],lr[l-1][l-1])
        pre = lr[l-1][r] + lr[r][l-1] - lr[l-1][l-1]     

    count = lr[r][r] - pre
    ans.append(count)

for a in ans:
    print(a)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
print(abs(n//k - (n-(n//k)*k))

Fixed submission:
n,k = map(int,input().split())
if n < k:
    print(1)
else:
    if n%k == 0:
        print(0)
    else:
        if k >= n%k:
            print(1)
        else : 
            print(k - n%k)
Buggy python submission (verdict: Runtime Error):
import sys

args = sys.argv

if(args[1]>8 or args[2]>8):
    print(":(")
else:
    print("Yay!")

Fixed submission:
args = (input())
a = int( args.split(" ")[0])
b = int(args.split(" ")[1])

if(a>8 or b>8):
    print(":(")
else:
    print("Yay!")

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

printf(sys.argv[1])

Fixed submission:
args = (input())
a = int( args.split(" ")[0])
b = int(args.split(" ")[1])

if(a>8 or b>8):
    print(":(")
else:
    print("Yay!")
Buggy python submission (verdict: Runtime Error):
N = input()
Li = map(int, input().split(" "))
Li.sort()
total = 0
for i in Li[0::2]
    total += i
print(total)


Fixed submission:
N = input()
Li = list(map(int, input().split(" ")))
Li.sort()
total = 0
for i in Li[0::2]:
    total += i
print(total)
Buggy python submission (verdict: Runtime Error):
line = raw_input()
lines = line.split()
a = int(lines[0])
b = int(lines[1])
res = 0
if a > b:
  res = a + a - 1
elif b > a:
  res = b + b - 1
else:
  res = a + b

print(res)

Fixed submission:
line = input()
lines = line.split()
a = int(lines[0])
b = int(lines[1])
res = 0
if a > b:
  res = a + a - 1
elif b > a:
  res = b + b - 1
else:
  res = a + b

print(res)

Buggy python submission (verdict: Runtime Error):
line = raw_input()
lines = line.split()
a = int(lines[0])
b = int(lines[1])
res = 0
if a > b:
  res = a + a - 1
elif b > a:
  res = b + b - 1
else:
  res = a + b

print(res)

Fixed submission:
line = input()
lines = line.split()
a = int(lines[0])
b = int(lines[1])
res = 0
if a > b:
  res = a + a - 1
elif b > a:
  res = b + b - 1
else:
  res = a + b

print(res)
Buggy python submission (verdict: Runtime Error):
in1 = input().split()
in2 = input().split()

H = in1[0]
W = in1[1]

h = in2[0]
w = in2[1]

print((H - h) * (W - w))


Fixed submission:
in1 = input().split()
in2 = input().split()

H = int(in1[0])
W = int(in1[1])

h = int(in2[0])
w = int(in2[1])

print((H - h) * (W - w))
Buggy python submission (verdict: Runtime Error):
in = input().split()

a = int(in[0])
b = int(in[1])
c = int(in[2])

if b / a < c:
  print(b/ a)
else:
  print(c)


Fixed submission:
in1 = input().split()

a = int(in1[0])
b = int(in1[1])
c = int(in1[2])

if b / a < c:
  print(int(b / a))
else:
  print(c)
Buggy python submission (verdict: Runtime Error):
import math

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

p = 0.0

if K>N:
    tp = 0.0
    for i in range(1,N+1):#1~N
        #deme i
        tp += 0.5**math.ceil(math.log2(K/i))
    tp = tp / N
    print(tp)
else:
    p = (N-K+1.0)/N#No coin
    tp = 0.0
    for i in range(1,K):#1~K-1
        #deme i
        tp += 0.5**math.ceil(math.log2(K/i))
    tp = tp / (K-1.0)
    print(p+(1.0-p)*tp)



Fixed submission:
import math

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

p = 0.0

if K>N:
    tp = 0.0
    for i in range(1,N+1):#1~N
        #deme i
        tp += 0.5**math.ceil(math.log2(K/i))
    tp = tp / N
    print(tp)
elif K == 1:
    print(1.0)
else:
    p = (N-K+1.0)/N#No coin
    tp = 0.0
    for i in range(1,K):#1~K-1
        #deme i
        tp += 0.5**math.ceil(math.log2(K/i))
    tp = tp / (K-1.0)
    print(p+(1.0-p)*tp)

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

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

p = 0

if K>N:
    tp = 0
    for i in range(1,N+1):
        #deme i
        tp += 0.5**math.ceil(math.log2(K/i))
    tp = tp / N
    print(tp)
else:
    p = (N-K+1)/N#No coin
    tp = 0
    for i in range(1,K):
        #deme i
        tp += 0.5**math.ceil(math.log2(K/i))
    tp = tp / (K-1)
    print(p+(1-p)*tp)



Fixed submission:
import math

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

p = 0.0

if K>N:
    tp = 0.0
    for i in range(1,N+1):#1~N
        #deme i
        tp += 0.5**math.ceil(math.log2(K/i))
    tp = tp / N
    print(tp)
elif K == 1:
    print(1.0)
else:
    p = (N-K+1.0)/N#No coin
    tp = 0.0
    for i in range(1,K):#1~K-1
        #deme i
        tp += 0.5**math.ceil(math.log2(K/i))
    tp = tp / (K-1.0)
    print(p+(1.0-p)*tp)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N = map(int, input().split())
co = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        tmp = N - r*R - g*G
        if (tmp >= 0) and (tmp%B == 0): 
            co += 1
print(co)

Fixed submission:
R,G,B,N = map(int, input().split())
co = 0
for r in range(N//R+1):
    for g in range((N-r*R)//G+1):
        tmp = N - r*R - g*G
        if tmp%B == 0: 
            co += 1
print(co)
Buggy python submission (verdict: Runtime Error):
A,B,T = map(int, input().split())
Ans = ((T+0.5)//A)*B
print(int(Ans)

Fixed submission:
A,B,T = map(int, input().split())
Ans = ((T+0.5)//A)*B
print(int(Ans))
Buggy python submission (verdict: Time Limit Exceeded):

import numpy as np
N = int(input())
As=input().split()
A = np.array([int(s) for s in As])
del(As)

min2A = A[A.argsort()[1]]
minA = np.amin(A)
if np.sum((A%min2A)==0)>=N-1:
    print(min2A)
elif np.sum((A%minA)==0)>=N-1:
    print(minA)
else:
    for i in range((min2A//2)+1)[::-1]:
        if np.sum((A%i)==0)>=N-1:
            print(i)
            break



Fixed submission:

import numpy as np
N = int(input())
As=input().split()
A = np.array([int(s) for s in As])
del(As)

min2A = A[A.argsort()[1]]
minA = np.amin(A)
if np.sum((A%min2A)==0)>=N-1:
    print(min2A)
elif np.sum((A%minA)==0)>=N-1:
    print(minA)
else:
    for i in range(2,min2A+1):
        if (min2A%i == 0) or (minA%i == 0):
            if(min2A%i == 0):
                j = int(min2A/i)
            elif(minA%i == 0):
                j=int(minA/i)
            if np.sum((A%j)==0)>=N-1:
                print(j)
                break

Buggy python submission (verdict: Time Limit Exceeded):

import numpy as np
N = int(input())
As=input().split()
A = np.array([int(s) for s in As])
del(As)
#minA = np.amin(A)
min2A = A[A.argsort()[1]]
for i in range(min2A+1)[::-1]:
    if np.sum((A%i)==0)>=N-1:
        print(i)
        break


Fixed submission:

import numpy as np
N = int(input())
As=input().split()
A = np.array([int(s) for s in As])
del(As)

min2A = A[A.argsort()[1]]
minA = np.amin(A)
if np.sum((A%min2A)==0)>=N-1:
    print(min2A)
elif np.sum((A%minA)==0)>=N-1:
    print(minA)
else:
    for i in range(2,min2A+1):
        if (min2A%i == 0) or (minA%i == 0):
            if(min2A%i == 0):
                j = int(min2A/i)
            elif(minA%i == 0):
                j=int(minA/i)
            if np.sum((A%j)==0)>=N-1:
                print(j)
                break
Buggy python submission (verdict: Runtime Error):
cook = []
amari = []
t = 0
for i in range(5):
    cook.append(int(input()))

for i in range(5):
    if cook[i] % 10 != 0:
        t += cook[i] + (10 - cook[i] % 10)
    else:
        t += cook[i]

for i in range(5):
    if cook[i] % 10 != 0:
        amari.append(10 - cook[i] % 10)

print(t - max(amari))


Fixed submission:
cook = []
amari = [0]
t = 0
for i in range(5):
    cook.append(int(input()))

for i in range(5):
    if cook[i] % 10 != 0:
        t += cook[i] + (10 - cook[i] % 10)
    else:
        t += cook[i]

for i in range(5):
    if cook[i] % 10 != 0:
        amari.append(10 - cook[i] % 10)

print(t - max(amari))

Buggy python submission (verdict: Runtime Error):
cook = []
t = 0
for i in range(5):
    cook.append(int(input()))

for i in range(5):
    if cook[i] % 10 != 0:
        t += cook[i] + (10 - cook[i] % 10)
    else:
        t += cook[i]

amari = []
for i in range(5):
    if cook[i] % 10 != 0:
        amari.append((10 - cook[i] % 10))

print(t - max(amari))


Fixed submission:
cook = []
amari = [0]
t = 0
for i in range(5):
    cook.append(int(input()))

for i in range(5):
    if cook[i] % 10 != 0:
        t += cook[i] + (10 - cook[i] % 10)
    else:
        t += cook[i]

for i in range(5):
    if cook[i] % 10 != 0:
        amari.append(10 - cook[i] % 10)

print(t - max(amari))
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
m = 0
ans = []

if a < b:
    m = b
    n = a
else:
    m = a
    n = b

for i in range(1, m):
    if n % i == 0 and m % i == 0:
        ans.append(i)

if ans:
    print(ans[-k])
else:
    print("1")


Fixed submission:
a, b, k = map(int, input().split())
m = 0
ans = []

if a < b:
    m = b
    n = a
else:
    m = a
    n = b

for i in range(1, n+1):
    if m % i == 0 and n % i == 0:
        ans.append(i)

if ans:
    print(ans[-k])
else:
    print("1")

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
m = 0
ans = []

if a < b:
    m = b
    n = a
else:
    m = a
    n = b

for i in range(1, m):
    if n % i == 0:
        ans.append(i)

#print(ans)
if ans:
    print(ans[k-1])
else:
    print("1")


Fixed submission:
a, b, k = map(int, input().split())
m = 0
ans = []

if a < b:
    m = b
    n = a
else:
    m = a
    n = b

for i in range(1, n+1):
    if m % i == 0 and n % i == 0:
        ans.append(i)

if ans:
    print(ans[-k])
else:
    print("1")
Buggy python submission (verdict: Runtime Error):
n = int(input())

if n % 111 == 0:
	print(n)
else:
	amari = ceil(n / 111) + 1
	print(111*amari)

Fixed submission:
import math

n = int(input())

if n % 111 == 0:
	print(n)
else:
	amari = math.ceil(n / 111)
	print(111*amari)
Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().split())

if if A-B <=1 or B-A <=1:
	print("Yay!")
else:
	print(":(")


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

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

if N == 100:
	print(101 * (100 ** d))
else:
	print(N * (100 ** d))

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

if N == 100:
	print(101 * (100 ** D))
else:
	print(N * (100 ** D))

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

if N == 100:
	print(101 * (100 ** d))
else:
	print(n * (100 ** d))

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

if N == 100:
	print(101 * (100 ** D))
else:
	print(N * (100 ** D))
Buggy python submission (verdict: Runtime Error):
def main():
    """http://drken1215.hatenablog.com/entry/2019/03/03/224600
    """
    N, M=map(int, input().split())
    A, B =[],[]
    for i in  range(M):
        a,b=map(int, input().split())
        A.append(a-1)
        B.append(b-1)
        
    uf=UnionFind(N)
    cur = N * (N-1) // 2
    res =[]
    for a,b in zip(A[::-1],B[::-1]):
        res.append(cur)

        if uf.issame(a, b):
            continue
        
        sa = uf.size(a) * uf.size(b)
        cur -= sa * sb
        uf.merge(a, b)

    print(*res, sep="¥n")


class UnionFind:
    def __init__(self, n):
        self.par = [-1] * n
    # void init(int n) { par.assign(n, -1); }

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]
    
    def issame(self, x, y):
        return self.root(x) == self.root(y)
    
    def merge(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y: return False
        if self.par[x] > self.par[y]:
            x, y = y, x # merge technique
        self.par[x] += self.par[y]
        self.par[y] = x
        return True
    
    def size(self, x):
        return -self.par[self.root(x)]

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    """http://drken1215.hatenablog.com/entry/2019/03/03/224600
    """
    N, M=map(int, input().split())
    A, B =[],[]
    for i in  range(M):
        a,b=map(int, input().split())
        A.append(a-1)
        B.append(b-1)
        
    uf=UnionFind(N)
    cur = N * (N-1) // 2
    res =[]
    for a,b in zip(A[::-1],B[::-1]):
        res.append(cur)

        if uf.issame(a, b):
            continue
        
        sa, sb = uf.size(a),  uf.size(b)
        cur -= sa * sb
        uf.merge(a, b)

    print(*res[::-1], sep="\n")


class UnionFind:
    def __init__(self, n):
        self.par = [-1] * n
    # void init(int n) { par.assign(n, -1); }

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]
    
    def issame(self, x, y):
        return self.root(x) == self.root(y)
    
    def merge(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y: return False
        if self.par[x] > self.par[y]:
            x, y = y, x # merge technique
        self.par[x] += self.par[y]
        self.par[y] = x
        return True
    
    def size(self, x):
        return -self.par[self.root(x)]

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N, A, B, C = map(int, input().split())
    ls = [int(input()) for _ in range(N)]

    tmp = []
    from itertools import permutations
    for a, b, c in permutations([A, B, C]):
        x = f(N, a, b, c, ls)
        tmp.append(x)

    ans = min(tmp)
    print(ans)


def f(N, A, B, C, ls):
    """
    A,B,Cそれぞれが存在していたら終了
    存在しない場合
    diff をとる
        diffと合成するしないでの最善
    ABCの順に依存するが、3つしかないので 3P3=6通り
    N_max=8 よりゴリ押し
    """
    ls = ls[:]
    abc = [A, B, C]

    ans = 0
    for x in abc[:]:
        if x in ls:
            abc.remove(x)
            ls.remove(x)

    while abc:
        x = abc[0]
        diffs = [l - x for l in ls]
        # print(abc, ans, ls, diffs)
        # 完全一致
        if x in ls:
            ls.remove(x)
            abc.remove(x)
            continue

        # 合成コスト以下, sortedで試してたけどmin のkey指定でよかった
        i, diff = min(enumerate(diffs), key=lambda a: abs(a[0]))
        min_cost = abs(diff)
        if min_cost <= 10:
            ans += min_cost
            del ls[i]
            del abc[0]
            continue

        # 合成できない
        if len(ls) < 2:
            ans += abs(ls[0] - x)
            abc.remove(x)
            del ls[0]
            continue

        # 合成
        comb = []
        n_ls = len(ls)
        for i in range(n_ls):
            for j in range(i+1, n_ls):
                comb.append((i, j, ls[i] + ls[j]))

        # 合成前後のコスト比較
        i, j, new_l = min(comb, key=lambda b: abs(b[2] - x))
        # print("\t", [c[2] for c in comb])
        # print("\t", i, j, new_l, min_cost)
        cost = abs(x - new_l)
        if cost >= min_cost:
            del_idx = min(i, j, key=lambda idx: abs(ls[idx]) - x)
            ans += min_cost
            del ls[del_idx]
            del abc[0]
        else:
            ls[i] = new_l
            del ls[j]
            ans += 10

    return ans


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N, A, B, C = map(int, input().split())
    ls = [int(input()) for _ in range(N)]

    ans = editorial(N, A, B, C, ls)
    print(ans)


def editorial(N, A, B, C, ls):
    def dfs(cur, a, b, c):
        if cur == N:
            if min([a, b, c]) > 0:
                # 使わなくて足りない/使いすぎて超過している分は差引すればいい
                tmp = abs(a - A) + abs(b - B) + abs(c - C) - 30
            else:
                tmp = float("inf")
            # print(tmp, a, b, c, sep="\t")
            return tmp

        # 使うか使わないか,合成パターンを試す
        d = ls[cur]
        ret0 = dfs(cur + 1, a, b, c)
        ret1 = dfs(cur + 1, a + d, b, c) + 10
        ret2 = dfs(cur + 1, a, b + d, c) + 10
        ret3 = dfs(cur + 1, a, b, c + d) + 10

        return min([ret0, ret1, ret2, ret3])

    ans = dfs(0, 0, 0, 0)
    return ans


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, K = map(int, input().split())
    *h, = map(int, input().split())

    ans = f(N, K, h)
    print(ans)


def f(N, K, h):
    dp = [None] * (N + 1)
    dp[0] = 0
    dp[1] = 0

    for i in range(2, N + 1):
        hi = i - 1
        cost = float("inf")
        for k in range(1, K + 1):
            if i - k < 1:
                continue

            tmp = dp[i-k] + abs(h[hi] - h[hi-k])
            cost = min(cost, tmp)

        dp[i] = cost

    ans = dp[N]
    return ans


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N, K = map(int, input().split())
    *h, = map(int, input().split())

    ans = f(N, K, h)
    print(ans)


def f(N, K, h):
    dp = [None] * (N + 1)
    dp[0] = 0
    dp[1] = 0

    for i in range(2, N + 1):
        hi = i - 1
        cost = float("inf")
        for k in range(1, K + 1):
            if i - k < 1:
                continue

            tmp = dp[i-k] + abs(h[hi] - h[hi-k])
            cost = min(cost, tmp)

        dp[i] = cost

    ans = dp[N]
    return ans


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())

    ans1 = AC1(N)
    ans2 = AC2(N)
    assert ans1 == ans2

    print(ans1)


def AC1(N):
    for i in range(N, 999+1):
        if len(set(list(str(i)))) == 1:
            return i


def AC2(N):
    for i in range(1, 9+1):
        if N >= 111 * i:
            return 111 * i


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    N = int(input())

    for i in range(N, 999+1):
        if len(set(list(str(i)))) == 1:
            print(i)
            return


if __name__ == '__main__':
    main()