Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
h = [int(input()) for i in range(n)]
h.sort()
print(min(h[k + ki - 1] - h[ki] for ki in range(k)))

Fixed submission:
n, k = [int(i) for i in input().split()]
h = [int(input()) for i in range(n)]
h.sort()
print(min(h[k + ki - 1] - h[ki] for ki in range(n - k + 1)))

Buggy python submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
h = [int(input()) for i in range(n)]
INF = 10 ** 9 + 1

h.sort()
ans = INF
for ki in range(k):
    d = h[k + ki - 1] - h[ki]
    if ans > d:
        ans = d

print(ans)

Fixed submission:
n, k = [int(i) for i in input().split()]
h = [int(input()) for i in range(n)]
h.sort()
print(min(h[k + ki - 1] - h[ki] for ki in range(n - k + 1)))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = [int(i) for i in input().split()]

a = {}
py = []
for mi in range(m):
    pi, yi = [int(i) for i in input().split()]
    if pi in a:
        a[pi].append(yi)
    else:
        a[pi] = [yi]
    py.append((pi, yi))

for av in a.values():
    av.sort()

for pyi in py:
    sp = str(pyi[0]).zfill(6)
    sy = str(a[pyi[0]].index(pyi[1]) + 1).zfill(6)
    print(sp + sy)

Fixed submission:
n, m = [int(i) for i in input().split()]
ipyo = [[i] + [int(_) for _ in input().split()] + [0] for i in range(m)]

ipyo.sort(key=lambda x: x[2])

cnt = [0] * n
for v in ipyo:
    p = v[1]
    cnt[p - 1] += 1
    v[3] = cnt[p - 1]

ipyo.sort(key=lambda x: x[0])

for v in ipyo:
    print('{0:06d}'.format(v[1]) + '{0:06d}'.format(v[3]))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = [int(i) for i in input().split()]

a = {}
y = []
for mi in range(m):
    pi, yi = [int(i) for i in input().split()]
    if pi in a:
        a[pi].append(yi)
    else:
        a[pi] = [yi]
    y.append(yi)

for av in a.values():
    av.sort()

for yi in y:
    for ak, av in a.items():
        if yi in av:
            print(str(ak).zfill(6) + str(av.index(yi) + 1).zfill(6))
            break

Fixed submission:
n, m = [int(i) for i in input().split()]
ipyo = [[i] + [int(_) for _ in input().split()] + [0] for i in range(m)]

ipyo.sort(key=lambda x: x[2])

cnt = [0] * n
for v in ipyo:
    p = v[1]
    cnt[p - 1] += 1
    v[3] = cnt[p - 1]

ipyo.sort(key=lambda x: x[0])

for v in ipyo:
    print('{0:06d}'.format(v[1]) + '{0:06d}'.format(v[3]))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
h = [sum(range(i)) for i in range(1, 1000)]
print(h[b - a] - b)

Fixed submission:
a, b = map(int, input().split())
h = [sum(range(i + 1)) for i in range(1, 1000)]
print(h[b - a - 2] - a)
Buggy python submission (verdict: Time Limit Exceeded):
n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0] * 2501 for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1

for i in range(n):
    for j in range(i + 1):
        for k in range(2451):
            dp[i + 1][j][k] += dp[i][j][k]
            dp[i + 1][j + 1][k + x[i]] += dp[i][j][k]

ans = 0
for j in range(1, n + 1):
    ans += dp[n][j][j * a]

print(ans)

Fixed submission:
n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0] * 2501 for _ in range(n + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1

for i in range(n):
    for j in range(i + 1):
        for k in range(2451):
            dp[i + 1][j][k] += dp[i][j][k]
            dp[i + 1][j + 1][k + x[i]] += dp[i][j][k]

ans = 0
for j in range(1, n + 1):
    ans += dp[n][j][j * a]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]


N = int(input())
seq = list(map(int, input().split()))
ans = 0
for i in range(N -1):
    for j in range(i+1, N):
        tmp = (seq[i] * seq[j])
        ans += tmp
print(ans%(10**9+7))



Fixed submission:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]


N = int(input())
seq = list(map(int, input().split()))

s = 0
for i in range(N):
    s += seq[i]

s2 =0
for i in range(N):
    s2 += seq[i]**2


s0 = (s**2 -s2)//2

print(s0%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]


import itertools

n = int(input())
seq = list(map(int, input().split()))

ans = 0
a = list(itertools.combinations(seq,2))

for i in range(len(a)):
    #print(a[i][0], a[i][1])
    ans += a[i][0] * a[i][1]
    ans %= 10**9+7


print(ans)



Fixed submission:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]


N = int(input())
seq = list(map(int, input().split()))

s = 0
for i in range(N):
    s += seq[i]

s2 =0
for i in range(N):
    s2 += seq[i]**2


s0 = (s**2 -s2)//2

print(s0%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]


import itertools

n = int(input())
seq = list(map(int, input().split()))

ans = 0
a = list(itertools.combinations(seq,2))

for i in range(len(a)):
    #print(a[i][0], a[i][1])
    ans += a[i][0] * a[i][1]

ans %= 10**9+7

print(ans)



Fixed submission:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]


N = int(input())
seq = list(map(int, input().split()))

s = 0
for i in range(N):
    s += seq[i]

s2 =0
for i in range(N):
    s2 += seq[i]**2


s0 = (s**2 -s2)//2

print(s0%(10**9+7))
Buggy python submission (verdict: Runtime Error):
#n = int(input())
x, y = map(int, input().split())
#l = list(map(int, input().split()))
#s = input()
ans = "Yes"
for i in range(x+1):
    if 2*i+4*x == y:
        ans = "No"

print(ans)


Fixed submission:
#n = int(input())
#n, k = map(int, input().split())
l = list(map(int, input().split()))
#s = input()

for i in range(len(l)):
    if l[i] == 0:
        print (i+1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
#a, b = map(int, input().split())
l = list(map(int, input().split()))
#s = input()
ans = 1
for i in range(n):
    ans = ans * l[i]
if (ans > 10**18):
    ans = -1

print (ans)


Fixed submission:
n = int(input())
#a, b = map(int, input().split())
l = list(map(int, input().split()))
#s = input()
ans = 1

if 0 in l:
    print (0)
    exit()

for i in range(n):
    ans = ans * l[i]
    if (ans > 10**18):
        ans = -1
        break

print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

# N = 200 x 200 x 200 = 8000000でO(N)で計算できることから間に合うはず
import math
ans = 0
K = int(input())
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += math.gcd(i,math.gcd(j,k))
print(ans)






Fixed submission:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

# N = 200 x 200 x 200 = 8000000でO(N)で計算できることから間に合うはず
import math
ans = 0
K = int(input())
for i in range(1,K+1):
    for j in range(1,K+1):
        tmp = math.gcd(i,j)
        for k in range(1,K+1):
            ans += math.gcd(k,tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
#l=list(map(int, input().split()))
a,b=map(int, input().split())
#l=list(map(int, input().split()))
#n = int(input())
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def cf(x1,x2):
    cf =[]
    cf.append(1)
    for i in range(2, min(x1,x2)+1):
        if x1 %i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

ans = 1
temp1 = divisor(a)
temp2 = divisor(b)
hoge = []
if len(temp1) < len(temp2):
    hoge = temp1
    hoge2 = temp2
else:
    hoge = temp2
    hoge2 = temp1

temp = []
for i in hoge:
    if i in hoge2:
        temp.append(i)

#print (temp)
for i in temp:
    if is_prime(i):
        ans += 1

print (ans)



Fixed submission:
#l=list(map(int, input().split()))
#n,k=map(int, input().split())
#l=list(map(int, input().split()))
n = int(input())

if (n%2==0):
    ans = n//2/n
else:
    ans = (n//2+1)/n

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#l=list(map(int, input().split()))
a,b=map(int, input().split())
#l=list(map(int, input().split()))
#n = int(input())

def cf(x1,x2):
    cf =[]
    cf.append(1)
    for i in range(2, min(x1,x2)+1):
        if x1 %i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

ans = 1
temp = cf(a,b)
for i in temp:
    if is_prime(i):
        ans += 1

print (ans)



Fixed submission:
#l=list(map(int, input().split()))
a,b=map(int, input().split())
#l=list(map(int, input().split()))
#n = int(input())
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1



ans = 1
temp1 = divisor(a)
temp2 = divisor(b)
hoge = []
if len(temp1) < len(temp2):
    hoge = temp1
    hoge2 = temp2
else:
    hoge = temp2
    hoge2 = temp1

temp = []
for i in hoge:
    if i in hoge2:
        temp.append(i)

#print (temp)
for i in temp:
    if is_prime(i):
        ans += 1

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

l = []
for i in range(n):
    l.append(k)

for a in range(q):
    j = int(input())
    for i in range(len(l)):
        if (j-1 != i):
            l[i] -=1

for i in l:
    if (i > 0):
        print("Yes")
    else:
        print("No")



Fixed submission:
#l=list(map(int, input().split()))
n,k,q=map(int, input().split())

l = []
for i in range(n):
    l.append(k)

for a in range(q):
    j = int(input())
    l[j-1] += 1

for i in l:
    if (i - q > 0):
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
n,k = map(int,(input().split()))
s = input()

l = []

i = 0
last = "H"
cnt = 1
while 1:
    if (i>=len(s)):
        break
    if (last == s[i]):
        cnt +=1
    else:
        l.append(cnt)
        cnt = 1
        last = s[i]
    i+=1

t = sorted(l, reverse=True)
ans = 0
for i in range(k+1):
    ans+=t[i]

print(ans)





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

l = []

i = 0
last = "H"
cnt = 0
for i in range(len(s)-1):
    if (s[i] == s[i+1]):
        cnt+=1


print(min(n-1, cnt+2*k))
Buggy python submission (verdict: Runtime Error):
a = int(input())
Lists = list(map(int, input().split()))

ma = []

for j in range(a):
    test = Lists.pop(0)
    for i in Lists:
        ma.append((i+test)/2)

ma2 = []
for j in ma:
    test = ma.pop(0)
    for i in ma:
        ma2.append((i+test)/2)

print (max(ma2))


Fixed submission:
a = int(input())
Lists = sorted(list(map(int, input().split())))

ans = Lists[0]

for i in range(1,a):
    ans += Lists[i]
    ans /= 2

print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
 
res1 = A + B
res2 = A - B
res3 = A * B
 
if res1 > res2:
  if (res1 > res3):
    print res1
  else:
  	print res3
else:
  if (res2 > res3):
    print res2
  else:
    print res3

Fixed submission:
A, B = map(int, input().split())
 
res1 = A + B
res2 = A - B
res3 = A * B
 
if res1 > res2:
  if (res1 > res3):
    print (res1)
  else:
  	print (res3)
else:
  if (res2 > res3):
    print (res2)
  else:
    print (res3)

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

res1 = A + B
res2 = A - B
res3 = A * B

if res1 > res2:
  if (res1 > res3):
    return res1
  else:
  	return res3
else:
  if (res2 > res3):
    return res2
  else:
    return res3
    


Fixed submission:
A, B = map(int, input().split())
 
res1 = A + B
res2 = A - B
res3 = A * B
 
if res1 > res2:
  if (res1 > res3):
    print (res1)
  else:
  	print (res3)
else:
  if (res2 > res3):
    print (res2)
  else:
    print (res3)

Buggy python submission (verdict: Runtime Error):

A, B = map(int, input().split())

res1 = A + B
res2 = A - B
res3 = A * B

print(max[res1,res2,res3])

Fixed submission:
A, B = map(int, input().split())
 
res1 = A + B
res2 = A - B
res3 = A * B
 
if res1 > res2:
  if (res1 > res3):
    print (res1)
  else:
  	print (res3)
else:
  if (res2 > res3):
    print (res2)
  else:
    print (res3)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
List =[]
for i in range(N):
    List.append(int(input()))

for i in range(N):
    temp = List[:]
    temp.pop(i)
    print(max(temp))



Fixed submission:
N = int(input())
List =[]
for i in range(N):
    List.append(int(input()))

temp = sorted(List)

ma = temp[N-1]
se = temp[N-2]

for i in range(N):
    if (List[i] == ma):
        print(se)
    else:
        print(ma)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int, input().split())

array = []
n = b - a + 1
for i in range(n):
    array.append(i+a)

ans = 0

for i in array:
    if (i % c != 0) and (i % d != 0):
        ans+=1
        
print (ans)


Fixed submission:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

a,b,c,d = map(int, input().split())

#b-a分を回してみるのは10**18なので間に合わない

#A以上B以下の整数でXで割り切れない個数を言い換えると
#Bが整数Xで割り切れない個数 - (A-1)が整数Xで割り切れない個数となる

#次にBが整数Xで割り切れない個数を考える。
#Bが整数Xで割り切れる個数は、B//Xなので、割り切れない個数は B-B//Xとなる

#次にBが整数XとYで割り切れない個数を考える
#B -B//X -B//Y + 2B//(X*Y)としたいところだが
#XとYでも割り切れるものは、B//(X*Y)ではなく、B//LCM(X,Y)となる
# X = 4, Y = 6だと 24で割り切れる個数となるが
# 12は、4と6でも割り切れるが24では割り切れない
#よってXとYの最小公倍数となる

import math

def lcm(x, y):
    return x // math.gcd(x, y) * y

def func(val, x, y):
    return val-val//x-val//y+val//lcm(x,y)

ans = (func(b,c,d)-func(a-1,c,d))
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int, input())

if a>=13:
    print(b)
elif a<=5:
    print(0)
else:
    print(b//2)


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

if a>=13:
    print(b)
elif a<=5:
    print(0)
else:
    print(b//2)
Buggy python submission (verdict: Time Limit Exceeded):
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

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

# n,mが10^5なのでO(n)は間に合わない
ans = 0
for i in range(1,n+1):
    flg = True
    for j in range(m):
        if i < l[j][0] or i > l[j][1]:
            flg = False
    if (flg):
        ans+=1
print(ans)




Fixed submission:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

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

# n,mが10^5なのでO(n^2)は間に合わない
"""
ans = 0
for i in range(1,n+1):
    flg = True
    for j in range(m):
        if i < l[j][0] or i > l[j][1]:
            flg = False
    if (flg):
        ans+=1
print(ans)
"""

#lをO(m)で走査して上限、下限をあらかじめ確定しておく
up = 10**5+1
lo = 0

for i in range(m):
    if lo < l[i][0]:
        lo = l[i][0]
    if  up > l[i][1]:
        up = l[i][1]

ans = 0
for i in range(1,n+1):
    if i >= lo and i <= up:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

n = int(input())
a = []
for i in range(n):
    s, p = map(str, input().split())
    p = int(p)
    a.append((s,p,i+1))
# 要素[1]を逆ソート
a.sort(key=lambda x:x[1], reverse=True)
# 要素[0]を順ソート
a.sort(key=lambda x:x[0])

for i in range(n):
    print(a[i][2])


Fixed submission:
s = input()

aa = int(s[0]+s[1])
bb = int(s[2]+s[3])

if bb <= 12 and bb >=1:
    if aa <= 12 and aa >=1:
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    if aa <=12 and aa >=1:
        print("MMYY")
    else:
        print("NA")
Buggy python submission (verdict: Runtime Error):
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]

h,w = map(int, input().split())
a = [input() for _ in range(h)]

y = [False] * h
x = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            y[i] = True
            x[j] = True

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





Fixed submission:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]

h,w = map(int, input().split())
a = [input() for _ in range(h)]

y = [False] * h
x = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            y[i] = True
            x[j] = True

for i in range(h):
    if y[i]:
        for j in range(w):
            if x[j]:
                print(a[i][j],end="")
        print("")
Buggy python submission (verdict: Time Limit Exceeded):
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n,k = map(int, input().split())
a = list(map(int, input().split()))

d = [0] * (n+1)

for i in range(n):
    d[a[i]] += 1

d.sort()
cnt = 0
for i in range(len(d)):
    if d[i] == 0:
        cnt+=1
for i in range(cnt):
    del d[0]

if (len(d) -k > 0):
    num = len(d) - k
    print(sum(d[0:num]))
else:
    print(0)



Fixed submission:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n,k = map(int, input().split())
a = list(map(int, input().split()))

d = [0]*(n+1)

for i in range(n):
    d[a[i]] += 1

d.sort()

print(sum(d[:n-k+1]))
Buggy python submission (verdict: Runtime Error):
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]
import math

n = int(input())

ans = []

nj = int(math.sqrt(n))
for i in range(1,nj):
    a = i
    if n % a == 0:
        b = n // a
        tmp = max(len(str(a)), len(str(b)))
        #print(a,b)
        ans.append(tmp)
print(min(ans))







Fixed submission:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n = int(input())

i = 1
ans = 1000000000000
while i * i <= n:
    if (n % i == 0):
        a = i
        b = n//a
        a_keta = len(str(a))
        b_keta = len(str(b))
        m_keta = max(a_keta, b_keta)
        ans = min(ans, m_keta)
    i += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

ans = [0 for i in range(len(S)-len(T))]
for i in range(len(S)-len(T)):
    cnt = len(T)
    for j in range(len(T)):
        if S[i+j] == T[j]:
            cnt -= 1
    ans[i] = cnt
print(min(ans))


Fixed submission:
S = input()
T = input()

ans = [0 for i in range(len(S)-len(T)+1)]
for i in range(len(S)-len(T)+1):
    cnt = len(T)
    for j in range(len(T)):
        if S[i+j] == T[j]:
            cnt -= 1
    ans[i] = cnt
print(min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
tmp = [1 for i in range(N-K+1)]

for i in range(K, N+1):
    for j in range(K):
        tmp[i-K] *= A[i-K+j]

for i in range(1, N-K+1):
    if tmp[i-1] < tmp[i]:
        print('Yes')
    else:
        print('No')


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

for i in range(K, N):
    if A[i-K] < A[i]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, K = map(int, input().split())
p = list(map(int, input().split()))
ans = 10e6

for i in itertools.combinations(p, K):
    tmp = sum(list(i))
    if tmp < ans:
        ans = tmp

print(ans)


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

ans = sum(sorted(p)[:K])
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

count = [0 for i in range(10**5)]

for a_i in A:
    count[a_i] += 1

bef_ans = 0
for i in range(Q):
    B, C = map(int, input().split())
    tmp = count[B]
    count[B] = 0
    count[C] += tmp
    ans = 0
    if i == 0:
        for j in range(10**5):
            ans += j*count[j]
    else:
        ans = bef_ans - B*tmp + C*tmp
    print(ans)
    bef_ans = ans


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

count = [0 for i in range(10**5+1)]

for a_i in A:
    count[a_i] += 1

bef_ans = 0
for i in range(Q):
    B, C = map(int, input().split())
    tmp = count[B]
    count[B] = 0
    count[C] += tmp
    ans = 0
    if i == 0:
        for j in range(10**5+1):
            ans += j*count[j]
    else:
        ans = bef_ans - B*tmp + C*tmp
    print(ans)
    bef_ans = ans

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

count = [0 for i in range(10**5)]

for a_i in A:
    count[a_i] += 1

for i in range(Q):
    B, C = map(int, input().split())
    tmp = count[B]
    count[B] = 0
    count[C] += tmp
    ans = 0
    for j in range(10**5):
        ans += j*count[j]
    print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

count = [0 for i in range(10**5+1)]

for a_i in A:
    count[a_i] += 1

bef_ans = 0
for i in range(Q):
    B, C = map(int, input().split())
    tmp = count[B]
    count[B] = 0
    count[C] += tmp
    ans = 0
    if i == 0:
        for j in range(10**5+1):
            ans += j*count[j]
    else:
        ans = bef_ans - B*tmp + C*tmp
    print(ans)
    bef_ans = ans