Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,M,X=list(map(int,input().split()))
lines = []

for i in range(N):
	lines.append(list(map(int,input().split())))
pricemin = 1500000
for i in range(2**N):
	price = 0
	count = 0
	A = [0]*M
	for j in range(N):
		if ((i >> j) & 1):
			for k in range(M):
				A[k] += lines[j][k+1]
			price += lines[j][0]
	for j in range(M):
		if A[j] >= X:
			count += 1
	if count == M and pricemin > price:
		pricemin = price
if pricemin == 1500000:
	print('-1')
else:
	print(pricemin)
			
	



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

Buggy python submission (verdict: Runtime Error):
N,M,X=list(map(int,input().split()))
lines = []

for i in range(N):
	lines.append(list(map(int,input().split())))
pricemin = 1000000
for i in range(2**N):
	price = 0
	count = 0
	A = [0]*M
	for j in range(N):
		if ((i >> j) & 1):
			for k in range(M):
				A[k] += lines[j][k+1]
			price += lines[j][0]
	for j in range(M):
		if A[j] >= X:
			count += 1
	if count == M and pricemin > price:
		pricemin = price
if pricemin == 1000000:
	print('-1')
else:
	print(pricemin)
			
	



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

Buggy python submission (verdict: Runtime Error):
A, B, C, K = list(map(int,input().split()))
count = 0
s = 0
if A > K:
	print(K)
elif A+B > K:
	print(A)
else:
	print(2*A + B - K)


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

Buggy python submission (verdict: Runtime Error):
A, B, C, K = list(map(int,input().split()))
count = 0
s = 0
while K > 0:
	if count < A:
		s += 1
	elif count >= A+B:
		s -= 1
	K -= 1
	count += 1
print(s)


Fixed submission:
S = input()
T = input()
N = len(T)
T2 = T[0:N-1]
if S == T2:
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Runtime Error):
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
p = 1
B = [-1]*N
B[0] = 0
count = 1
while K < count :
	p = A[p-1]
	if B[p-1] != -1:
		break
	B[p-1] = count
	count += 1
if K < count:
	print(p)
	return
K -= count
K = K % (count-B[p-1])
for i in range(K):
	p = A[p-1]
print(p)

	


Fixed submission:
import sys
N,K=list(map(int,input().split()))
A=list(map(int,input().split()))
p = 1
B = [-1]*N
B[0] = 0
count = 1
while K >= count:
	p = A[p-1]
	if B[p-1] != -1:
		break
	B[p-1] = count
	count += 1
if K < count:
	print(p)
	sys.exit()
K -= count
K = K % (count-B[p-1])
for i in range(K):
	p = A[p-1]
print(p)
Buggy python submission (verdict: Time Limit Exceeded):
a = input()

a = int(a)

b = a

b = int(b)

if a % 9 == 0:

    for i in range(a):
        b += b % pow(10, i)

else:
    print("No")
    exit()

if b % 9 == 0:
    print("Yes")
else:
    print("No")


Fixed submission:
a = input()

a = int(a)

if a % 9 == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
S=input()
print(max(i for i in range(4)if S.index("R"*i)))

Fixed submission:
S = input()

if S == "SSS":
    cnt = 0
elif S == "RRR":
    cnt = 3
elif "RR" in S:
    cnt = 2
else:
    cnt = 1
    
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
X, K, D = map(int, input().split())

x = X
done = False
while K:
    K -= 1
    pre = x
    if x >= 0:
        x -= D
    else:
        x += D
    if pre * x <=0:
        if K % 2 == 0:
            ans = abs(x)
        else:
            ans = abs(pre)
        done = True
        break

if not done:
    ans = abs(x)

print(ans)

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

aX = abs(X)
if aX // D >= K:
    ans = aX - K * D
else:
    if (K - (aX // D )) % 2 == 0:
        ans = aX % D
    else:
        ans = (aX % D) - D
    
print(abs(ans))

Buggy python submission (verdict: Time Limit Exceeded):
x, k, d = map(int, input().split())
i = 1
x = abs(x)

if k*d <= x:
    print(x-k*d)
else:
    while(d*i < x):
        i += 1
    #print(i)
    if (k-i)%2 == 0:
        print(abs(x-d*i))
    else:
        print(x-d*i + d)


Fixed submission:
x, k, d = map(int, input().split())
i = 1
x = abs(x)

if k*d <= x:
    print(x-k*d)
else:
    i = x//d + 1
    #print(i)
    if (k-i)%2 == 0:
        print(abs(x-d*i))
    else:
        print(x-d*i + d)
Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
b = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
ans = 0
kazu = 0
c_a = 0
c_b = 0
time = 0
'''
a.append(10**9 + 1)
b.append(10**9 + 1)


while True:
    if time + min(a[c_a],b[c_b])>k:
        break
    if a[c_a]>b[c_b]:
        time += b[c_b]
        c_b += 1
    elif a[c_a]<b[c_b]:
        time += a[c_a]
        c_a += 1

    ans += 1
'''
a = [0]+a
b = [0]+b

for i in range(1,n+1):
    a[i]= a[i-1]+a[i]
for i in range(1,m+1):
    b[i]= b[i-1]+b[i]

for i in range(0,n+1):
    for j in range(min(0,kazu-i+1),m+1):
        time = a[i] + b[j]
        if time > k:
            break
        kazu = i + j

print(kazu)


Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
b = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
kazu = 0
c_a = 0
c_b = 0
time = 0

a = [0]+a
b = [0]+b

for i in range(1,n+1):
    a[i]= a[i-1]+a[i]
for i in range(1,m+1):
    b[i]= b[i-1]+b[i]

for i in range(0,n+1):
    for j in range(max(0,kazu-i+1),m+1):
        time = a[i] + b[j]
        if time > k:
            break
        kazu = i + j

print(kazu)

Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = map(int, input().split())
a = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
b = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
ans = 0
kazu = 0
c_a = 0
c_b = 0
time = 0
'''
a.append(10**9 + 1)
b.append(10**9 + 1)


while True:
    if time + min(a[c_a],b[c_b])>k:
        break
    if a[c_a]>b[c_b]:
        time += b[c_b]
        c_b += 1
    elif a[c_a]<b[c_b]:
        time += a[c_a]
        c_a += 1

    ans += 1
'''
a = [0]+a
b = [0]+b

for i in range(1,n+1):
    a[i]= a[i-1]+a[i]
for i in range(1,m+1):
    b[i]= b[i-1]+b[i]

for i in range(0,n+1):
    for j in range(0,m+1):
        time = a[i] + b[j]
        if time > k:
            break
        kazu = i + j
    ans = max(ans,kazu)

print(ans)


Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
b = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
kazu = 0
c_a = 0
c_b = 0
time = 0

a = [0]+a
b = [0]+b

for i in range(1,n+1):
    a[i]= a[i-1]+a[i]
for i in range(1,m+1):
    b[i]= b[i-1]+b[i]

for i in range(0,n+1):
    for j in range(max(0,kazu-i+1),m+1):
        time = a[i] + b[j]
        if time > k:
            break
        kazu = i + j

print(kazu)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(1,n+1):
    for j in range(i,n+1,i):
        ans += j

print(ans)


Fixed submission:
n = int(input())
ans = 0
for i in range(1,n+1):
    ans += n//i*(i+n//i*i)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
def make_prime_list_2(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]
def search_divisor_num_1(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num

n = int(input())
ans = 0
for k in range(1,n+1):
    ans += k * search_divisor_num_1(k)

print(ans)


Fixed submission:
n = int(input())
ans = 0
for i in range(1,n+1):
    ans += n//i*(i+n//i*i)//2

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
nlis = list(map(int, input().split())) # list()でリスト化、それを変数に代入。

if nlis[-1] == 2 or nlis[-1] == 4 or nlis[-1] == 5 or nlis[-1] == 7 or nlis[-1] == 9:
    print('hon')
elif nlis[-1] == 0 or nlis[-1] == 1 or nlis[-1] == 6 or nlis[-1] == 8:
    print('pon')
else:
    print('bon')


Fixed submission:

str = input()
h = list(str)#文字列をリストに

if(h[-1]=='2' or h[-1]=='4' or h[-1]=='5' or h[-1]=='7' or h[-1]=='9'):
    print('hon')
elif(h[-1]=='0' or h[-1]=='1' or h[-1]=='6' or h[-1]=='8'):
    print('pon')
else:
    print('bon')

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
#一行で入力された数値をリストに

if(h[-1]==2 or h[-1]==4 or h[-1]==5 or h[-1]==7 or h[-1]==9):
    print('hon')
elif(h[-1]==0 or h[-1]==1 or h[-1]==6 or h[-1]==8):
    print('pon')
else:
    print('bon')


Fixed submission:

str = input()
h = list(str)#文字列をリストに

if(h[-1]=='2' or h[-1]=='4' or h[-1]=='5' or h[-1]=='7' or h[-1]=='9'):
    print('hon')
elif(h[-1]=='0' or h[-1]=='1' or h[-1]=='6' or h[-1]=='8'):
    print('pon')
else:
    print('bon')

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
#一行で入力された数値をリストに

if(h[-1]==2 or h[-1]==4 or h[-1]==5 or h[-1]==7 or h[-1]==9):
    print("hon")
elif(h[-1]==0 or h[-1]==1 or h[-1]==6 or h[-1]==8):
    print("pon")
else:
    print("bon")


Fixed submission:

str = input()
h = list(str)#文字列をリストに

if(h[-1]=='2' or h[-1]=='4' or h[-1]=='5' or h[-1]=='7' or h[-1]=='9'):
    print('hon')
elif(h[-1]=='0' or h[-1]=='1' or h[-1]=='6' or h[-1]=='8'):
    print('pon')
else:
    print('bon')

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
#一行で入力された数値をリストに

if(h[-1]==2 or h[-1]==4 or h[-1]==5 or h[-1]==7 or h[-1]==9):
    print("hon")
elif(h[-1]==0 or h[-1]==1 or h[-1]==6 or h[-1]==8):
    print("pon")
else:
    print("bon")


Fixed submission:

str = input()
h = list(str)#文字列をリストに

if(h[-1]=='2' or h[-1]=='4' or h[-1]=='5' or h[-1]=='7' or h[-1]=='9'):
    print('hon')
elif(h[-1]=='0' or h[-1]=='1' or h[-1]=='6' or h[-1]=='8'):
    print('pon')
else:
    print('bon')
Buggy python submission (verdict: Runtime Error):
n = int(input())
array = [input()]
ans = 1

for i in range(1, n-1):
    tmp = input()
    j = i
    while True:
        j -= 1
        if j==0 or tmp >= array[j-1]:
            break
    if tmp != array[j-1]:
        ans += 1
        array.insert(j, tmp)
print(ans)


Fixed submission:
n = int(input())
s = {input() for i in range(n)}#縦に入力されたものをリストに

print(len(s))
Buggy python submission (verdict: Time Limit Exceeded):
import math

k = int(input())
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans += math.gcd(math.gcd(a, b), c)

print(ans)


Fixed submission:
import math

k = int(input())
ans = 0

for a in range(1,k-1):
    for b in range(a+1,k):
        for c in range(b+1,k+1):
            ans += math.gcd(math.gcd(a, b), c)*6

for a in range(1,k):
    for b in range(a+1,k+1):
        ans += math.gcd(a,b)*6

for a in range(1,k+1):
    ans += a

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
goukei = 0
ind = 0
kitai = 0

for i in range(k):
    goukei = goukei + p[i]

list = [goukei]

for j in range(1, n-k+1):
    list.append(list[j-1] - p[j-1] + p[j+k-1])

ind = list.index(max(list))

for j in range(ind, ind+k):
    for i in range(1,p[j]+1):
        kitai = kitai + i/p[j]
'''
print(max(list))
print(p)
print(list)
print(ind)
'''
print(kitai)


Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
goukei = 0
ind = 0
kitai = 0

for i in range(k):
    goukei = goukei + p[i]

list = [goukei]

for j in range(1, n-k+1):
    list.append(list[j-1] - p[j-1] + p[j+k-1])

ind = list.index(max(list))

for j in range(ind, ind+k):
    kitai = kitai + (p[j]+1)/2
'''
print(max(list))
print(p)
print(list)
print(ind)
'''
print(kitai)
Buggy python submission (verdict: Runtime Error):
n, k = (int(x) for x in input().split())
s = input()
happy = 0

if(s[0] == 'R' and s[1] == 'R'):
    happy = happy + 1
if(s[-1] == 'L' and s[-2] == 'L'):
    happy = happy + 1

for i in range(1,n-1):
    if(s[i] == 'R' and s[i+1] == 'R'):
        happy = happy + 1
    if(s[i] == 'L' and s[i-1] == 'L'):
        happy = happy + 1

happy = happy + 2*k
print(min(happy, n-1))


Fixed submission:
n, k = (int(x) for x in input().split())
s = input()
happy = 0

if(s[0] == 'R' and s[1] == 'R'):
    happy = happy + 1
if(s[n-1] == 'L' and s[n-2] == 'L'):
    happy = happy + 1

for i in range(1,n-1):
    if(s[i] == 'R' and s[i+1] == 'R'):
        happy = happy + 1
    if(s[i] == 'L' and s[i-1] == 'L'):
        happy = happy + 1

happy = happy + 2*k
print(min(happy, n-1))

Buggy python submission (verdict: Runtime Error):
n, k = (int(x) for x in input().split())
s = input()
happy = 0

if(s[0] == 'R' and s[1] == 'R'):
    happy = happy + 1
if(s[-1] == 'L' and s[-2] == 'L'):
    happy = happy + 1

for i in range(1,n-1):
    if(s[i] == 'R' and s[i+1] == 'R'):
        happy = happy + 1
    if(s[i] == 'L' and s[i-1] == 'L'):
        happy = happy + 1

happy = happy + 2*k
print(min(happy, n-1))


Fixed submission:
n, k = (int(x) for x in input().split())
s = input()
happy = 0

if(s[0] == 'R' and s[1] == 'R'):
    happy = happy + 1
if(s[n-1] == 'L' and s[n-2] == 'L'):
    happy = happy + 1

for i in range(1,n-1):
    if(s[i] == 'R' and s[i+1] == 'R'):
        happy = happy + 1
    if(s[i] == 'L' and s[i-1] == 'L'):
        happy = happy + 1

happy = happy + 2*k
print(min(happy, n-1))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
num = 0

for i in range(n):
    num = num + i

print(num)


Fixed submission:
n = int(input())

num = 0

num = n*(n-1)//2

print(num)
Buggy python submission (verdict: Runtime Error):
a,b = int(input().split())
print(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):
import math
n = int(input())
lst = list()
num = 0
flag = 1
for i in range(n):

    s = input()
    s = list(s)
    s.sort()
    lst.append(s)

lst.sort()

for i in range(n-1):
    if (lst[i] == lst[i+1]):
        flag = flag + 1
    else:
        num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
        flag = 1
if (flag > 1):
    num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
print(num)


Fixed submission:
import math
n = int(input())
lst = list()
num = 0
flag = 1
for i in range(n):

    s = input()
    s = list(s)
    s.sort()
    lst.append(s)

lst.sort()

for i in range(n-1):
    if (lst[i] == lst[i+1]):
        flag = flag + 1
    else:
        if (flag > 1):
            num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
        flag = 1
if (flag > 1):
    num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = list()
num = 0
for i in range(n):

    s = input()
    s = list(s)
    s.sort()
    lst.append(s)


for i in range(n):
    for j in range(i+1, n):
        if (lst[i] == lst[j]):
            num = num + 1
print(num)


Fixed submission:
import math
n = int(input())
lst = list()
num = 0
flag = 1
for i in range(n):

    s = input()
    s = list(s)
    s.sort()
    lst.append(s)

lst.sort()

for i in range(n-1):
    if (lst[i] == lst[i+1]):
        flag = flag + 1
    else:
        if (flag > 1):
            num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
        flag = 1
if (flag > 1):
    num = num + math.factorial(flag) // (math.factorial(flag - 2) * 2)
print(num)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
h.append(10000000000)
max = 0
flag = 0

for i in range(n):

    if h[i+1]<h[i]:
        h[i]=h[i]-1
    if h[i]>=max and h[i+1]>=h[i]:
        max = h[i]
    else:
        flag = 1
        break
if flag == 1:
    print('No')
else:
    print('Yes')


Fixed submission:
a,b,c = map(int, input().split())
d = c-(a-b)
if(d<0):
    d = 0
print(d)
Buggy python submission (verdict: Runtime Error):
n = int(input())
n
a = list(map(int, input().split(' ')))#モンスター
b = list(map(int, input().split(' ')))#勇者
b.append(0)
beat = 0

for i in range(n):
    mada = b[i]-a[i]
    beat += min(b[i],a[i])
    if mada > 0:
        b[i+1] += mada
beat += min(a[-1],b[-1])

print(beat)


Fixed submission:
a,b = input().split()
a=int(a)
b=int(b)
if (a+b)%2 != 0:
    print('IMPOSSIBLE')
else:
    print(int((a+b)/2))
Buggy python submission (verdict: Time Limit Exceeded):
def returnmax(numbers, i, N):
    nowmax = 0
    for j in range(N):
        if j != i:
            if nowmax < numbers[j]:
                nowmax = numbers[j]
    return nowmax
    
numbers = []
N = int(input())
for i in range(N):
    numbers.append(int(input()))
for i in range(N):
    print(returnmax(numbers, i, N))


Fixed submission:
def returnsecond(numbers, N):
    first = 0
    firc = 0;
    second = 0
    for j in range(N):
        if first < numbers[j]:
            first = numbers[j]
            firc = j
    for j in range(N):
        if(j != firc and second <= numbers[j]):
            second = numbers[j]

    return first, second;


numbers = []
N = int(input())

for i in range(N):
    numbers.append(int(input()))
first, second = returnsecond(numbers, N)

for i in range(N):
    if numbers[i] != first:
        print(first)
    else:
        print(second)

Buggy python submission (verdict: Time Limit Exceeded):
def returnmax(numbers, i, N):
    nowmax = 0
    for j in range(N):
        if j != i:
            if nowmax < numbers[j]:
                nowmax = numbers[j]
    return nowmax
numbers = []
N = int(input())
for i in range(N):
    numbers.append(int(input()))
for i in range(N):
    print(returnmax(numbers, i, N))


Fixed submission:
def returnsecond(numbers, N):
    first = 0
    firc = 0;
    second = 0
    for j in range(N):
        if first < numbers[j]:
            first = numbers[j]
            firc = j
    for j in range(N):
        if(j != firc and second <= numbers[j]):
            second = numbers[j]

    return first, second;


numbers = []
N = int(input())

for i in range(N):
    numbers.append(int(input()))
first, second = returnsecond(numbers, N)

for i in range(N):
    if numbers[i] != first:
        print(first)
    else:
        print(second)
Buggy python submission (verdict: Runtime Error):
import random
S = input()

A = random.randint(0, len(S) - 2)

print(S[A] + S[A + 1] + S[A + 2])


Fixed submission:
import random
S = input()

A = random.randint(0, len(S) - 3)

print(S[A] + S[A + 1] + S[A + 2])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
prod = 1

for a in A:
  if a == 0:
    prod == 0

for a in A:
  prod *= a

if prod > 10**18:
  prod = -1

print(prod) 

Fixed submission:
def main():
  N = int(input())
  A = list(map(int, input().split()))
  prod = 1

  for a in A:
    if a == 0:
      print(0)
      return

  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return

  print(prod) 

main()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
prod = 1

for a in A:
  prod *= a

if prod > 10**18:
  prod = -1

print(prod) 

Fixed submission:
def main():
  N = int(input())
  A = list(map(int, input().split()))
  prod = 1

  for a in A:
    if a == 0:
      print(0)
      return

  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return

  print(prod) 

main()
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, K = map(int ,input().split())
count = 0

if A > K:
  for k in range(K):
    count += 1
elif A + B >= K:
  for a in range(A):
    count += 1
elif A + B < K  and A >= K - A - B:
   for ac in range(A + A + B - K):
    count += 1
else:
  for ca in range(K - A - A - B):
    count -= 1

print(count)

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

Xa = min(K,A)
K2 = K - Xa
Xb = min(K2,B)
Xc = K2 - Xb

print(Xa - Xc)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
R = []

for i in range(N):
  for a in A:
    if a == i + 1:
      R.extend("1") 
  print(len(R))
  R = []
      

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
R = [0] * N

for i in A:
  R[i - 1] += 1

for i in range(N):
  print(R[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
count = 0

for i in range(N):
  for a in A:
    if a == i + 1:
      count += 1
  print(count)
  count = 0
      

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
R = [0] * N

for i in A:
  R[i - 1] += 1

for i in range(N):
  print(R[i])
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N,K = int(s[0]), int(s[1])
    cand1 = abs(N - K*math.ceil(N/float(K)))
    cand2 = abs(N - K*math.floor(N/float(K)))
    print(min(cand1, cand2))


Fixed submission:
import math

if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N,K = int(s[0]), int(s[1])
    if(N>=K):
        #cand1 = int(abs(N - int(K*math.ceil(N/float(K)))))
        #cand2 = int(abs(N - int(K*math.floor(N/float(K)))))
        cand1 = int(N%K)
        cand2 = int(K-(N%K))
        print(min(cand1, cand2))
    else:
        print(min(int(abs(N-K)),N))
Buggy python submission (verdict: Runtime Error):
input_line = int(input())
for i in range(input_line):
	s = input().rstrip().split(' ')
return 7 - ['SUN','MON','TUE','WED','THU','FRI','SAT'].index(s[0])

Fixed submission:
s = input().rstrip().split(' ')
print(7 - ['SUN','MON','TUE','WED','THU','FRI','SAT'].index(s[0]))

Buggy python submission (verdict: Runtime Error):
input_line = int(input())
for i in range(input_line):
  s = input().rstrip().split(' ')
  return 7 - ['SUN','MON','TUE','WED','THU','FRI','SAT'].index(s[0])

Fixed submission:
s = input().rstrip().split(' ')
print(7 - ['SUN','MON','TUE','WED','THU','FRI','SAT'].index(s[0]))
Buggy python submission (verdict: Runtime Error):
N,X = map(int,input().split())
arr = list(map(int,input().split()))
sumarr = np.cumsum(arr)
print(len(sumarr[sumarr<=X])+1)


Fixed submission:
import numpy as np
N,X = map(int,input().split())
arr = list(map(int,input().split()))
sumarr = np.cumsum(arr)
print(len(sumarr[sumarr<=X])+1)
Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N = int(s[0])
    M = int(s[1])
    L = []
    R = []
    for i in range(M):
        s = input().rstrip().split(' ')
        L.append(int(s[0]))
        R.append(int(s[1]))

    res = list(range(1,N+1))

    for i in range(M):
        res = list(range(max(res[0],L[i]), min(R[i],res[-1])+1))

    print(len(res))

Fixed submission:
if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N = int(s[0])
    M = int(s[1])
    L = []
    R = []
    for i in range(M):
        s = input().rstrip().split(' ')
        L.append(int(s[0]))
        R.append(int(s[1]))

    res = list(range(1,N+1))
    res_min = 1
    res_max = N

    for i in range(M):
        res_min = max(res_min,L[i])
        res_max = min(R[i],res_max)

    print(max(res_max-res_min+1,0))
Buggy python submission (verdict: Runtime Error):
N,X,T  = map(int, input().split())
a = N // X
if N % X ==0:
  pritn(a*T)
else:
	print((a+1)*T)

Fixed submission:
N,X,T  = map(int, input().split())
a = N // X
if N % X ==0:
  print(a*T)
else:
	print((a+1)*T)