Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):

def resolve():
    n, k = list(map(int, input().split()))
    xxx = list(map(int, input().split()))
    ans = float("inf")
    for i in range(n-k+1):
        lll = xxx[i:i+k]
        max_l = lll[-1]
        min_l = lll[0]
        if not min_l <= 0 <= max_l:
            ans = min(ans, max(abs(min_l), abs(max_l)))
        else:
            ans = min(ans, min(abs(min_l), abs(max_l))+abs(max_l-min_l))
    print(ans)
resolve()

Fixed submission:

def resolve():
    n, k = list(map(int, input().split()))
    xxx = list(map(int, input().split()))
    ans = float("inf")
    for i in range(n-k+1):
        max_l = xxx[i+k-1]
        min_l = xxx[i]
        if not min_l <= 0 <= max_l:
            ans = min(ans, max(abs(min_l), abs(max_l)))
        else:
            ans = min(ans, min(abs(min_l), abs(max_l))+abs(max_l-min_l))
    print(ans)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, k = list(map(int, input().split()))
    xxx = list(map(int, input().split()))
    ans = float("inf")
    for i in range(n-k+1):
        lll = xxx[i:i+k]
        if not lll[0] <= 0 <= lll[-1]:
            ans = min(ans, max(abs(lll[0]), abs(lll[-1])))
        else:
            ans = min(ans, min(abs(lll[0]), abs(lll[-1]))+abs(lll[-1]-lll[0]))
    print(ans)
resolve()

Fixed submission:

def resolve():
    n, k = list(map(int, input().split()))
    xxx = list(map(int, input().split()))
    ans = float("inf")
    for i in range(n-k+1):
        max_l = xxx[i+k-1]
        min_l = xxx[i]
        if not min_l <= 0 <= max_l:
            ans = min(ans, max(abs(min_l), abs(max_l)))
        else:
            ans = min(ans, min(abs(min_l), abs(max_l))+abs(max_l-min_l))
    print(ans)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, k = list(map(int, input().split()))
    xxx = list(map(int, input().split()))
    ans = float("inf")
    for i in range(n-k+1):
        lll = xxx[i:i+k]
        if not lll[0] <= 0 <= lll[-1]:
            ans = min(ans, max(abs(lll[0]), abs(lll[-1])))
        else:
            ans = min(ans, min(abs(lll[0]), abs(lll[-1]))+abs(lll[-1]-lll[0]))
    print(ans)
resolve()

Fixed submission:

def resolve():
    n, k = list(map(int, input().split()))
    xxx = list(map(int, input().split()))
    ans = float("inf")
    for i in range(n-k+1):
        max_l = xxx[i+k-1]
        min_l = xxx[i]
        if not min_l <= 0 <= max_l:
            ans = min(ans, max(abs(min_l), abs(max_l)))
        else:
            ans = min(ans, min(abs(min_l), abs(max_l))+abs(max_l-min_l))
    print(ans)
resolve()
Buggy python submission (verdict: Runtime Error):
def root(x):
    if c[x] == x:
        return x
    else:
        c[x] = root(c[x])
        return c[x]


def uni(x,y):
    rx = root(x)
    ry = root(y)
    c[ry] = rx


n, m = map(int, input().split())
c = [i for i in range(n)]
for i in range(m):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    uni(x,y)

for i in range(n):
    root(i)

print(len(set(c)))


Fixed submission:
import sys
sys.setrecursionlimit(10**6)


def root(x):
    if c[x] == x:
        return x
    else:
        c[x] = root(c[x])
        return c[x]


def uni(x,y):
    rx = root(x)
    ry = root(y)
    c[ry] = rx


n, m = map(int, input().split())
c = [i for i in range(n)]
for i in range(m):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    uni(x,y)

for i in range(n):
    root(i)

print(len(set(c)))
Buggy python submission (verdict: Runtime Error):
#import math
#from functools import reduce

def gcd(a,b):
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r

    return a


n = int(input())
a = [int(i) for i in input().split()]
L = [0] * (n-1)
for i in range(n-1):
    L[i] = gcd(a[i],a[i+1])

if n == 3:
    L.append(gcd(a[0],a[2]))

L.sort(reverse=True)

for l in L:
    c = 0
    for i in a:
        if i % l != 0:
            c += 1
    if c <= 1:
        ans = l
        break

print(ans)


Fixed submission:
def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r
    return a


n = int(input())
A = [int(i) for i in input().split()]

L = [0] * n
L[0] = 0
L[1] = A[0]
for i in range(2,n):
    L[i] = gcd(L[i-1], A[i-1])

R = [0] * n
R[-1] = 0
R[-2] = A[-1]
for i in range(3,n+1):
    R[-i] = gcd(R[-i+1], A[-i+1])

M = [gcd(L[i],R[i]) for i in range(n)]

print(max(M))

Buggy python submission (verdict: Time Limit Exceeded):
#import math
from functools import reduce

def gcd(a,b):
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r

    return a


n = int(input())
a = [int(i) for i in input().split()]
L = [0] * n

for i in range(n):
    aa = a[:]
    aa.pop(i)
    L[i] = reduce(gcd, aa)

print(max(L))


Fixed submission:
def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r
    return a


n = int(input())
A = [int(i) for i in input().split()]

L = [0] * n
L[0] = 0
L[1] = A[0]
for i in range(2,n):
    L[i] = gcd(L[i-1], A[i-1])

R = [0] * n
R[-1] = 0
R[-2] = A[-1]
for i in range(3,n+1):
    R[-i] = gcd(R[-i+1], A[-i+1])

M = [gcd(L[i],R[i]) for i in range(n)]

print(max(M))

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

n = int(input())
a = [int(i) for i in input().split()]
L = [0] * n

for i in range(n):
    aa = a[:]
    aa.pop(i)
    L[i] = reduce(math.gcd, aa)

print(max(L))


Fixed submission:
def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r
    return a


n = int(input())
A = [int(i) for i in input().split()]

L = [0] * n
L[0] = 0
L[1] = A[0]
for i in range(2,n):
    L[i] = gcd(L[i-1], A[i-1])

R = [0] * n
R[-1] = 0
R[-2] = A[-1]
for i in range(3,n+1):
    R[-i] = gcd(R[-i+1], A[-i+1])

M = [gcd(L[i],R[i]) for i in range(n)]

print(max(M))
Buggy python submission (verdict: Runtime Error):
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for a in A:
    for b in B:
        AB.append(a + b)

AB.sort(reverse=True)

ABC = []
for i in range(min(x * y, k)):
    for c in C:
        ABC.append(AB[i] + c)

ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])


Fixed submission:
n = int(input())
c = [int(input()) for i in range(5)]
mc = min(c)
b = n // mc
r =  0 if n % mc == 0 else 1

print(4 + b + r)
Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

ABC = []
for i in range(x):
    for j in range(y):
        if (i + 1) * (j + 1)  <= k:
            for h in range(z):
                if (i + 1) * (j + 1) * (h + 1) <= k:
                    ABC.append(A[i] + B[j] + C[h])

ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])


Fixed submission:
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for a in A:
    for b in B:
        AB.append(a + b)

AB.sort(reverse=True)

ABC = []
for i in range(min(x * y, k)):
    for c in C:
        ABC.append(AB[i] + c)

ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for a in A:
    for b in B:
        AB.append(a + b)

AB.sort(reverse=True)

ABC = []
for i in range(min(x * y, k)):
    for c in C:
        ABC.append(AB[i] + c)

ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])


Fixed submission:
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for a in A:
    for b in B:
        AB.append(a + b)

AB.sort(reverse=True)

ABC = []
for i in range(min(x * y, k)):
    for c in C:
        ABC.append(AB[i] + c)

ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])

Buggy python submission (verdict: Runtime Error):
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for a in A:
    for b in B:
        AB.append(a + b)

AB.sort(reverse=True)

ABC = []
for i in range(min(a * b, k)):
    for c in C:
        ABC.append(AB[i] + c)

ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])


Fixed submission:
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for a in A:
    for b in B:
        AB.append(a + b)

AB.sort(reverse=True)

ABC = []
for i in range(min(x * y, k)):
    for c in C:
        ABC.append(AB[i] + c)

ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
d = dict([list(map(int, input().split()))[::-1] for i in range(N)])
d = sorted(d.items(), key=lambda x: x[1])
c = p = i = 0

while c < M:
    if c + d[i][0] <= M:
        c += d[i][0]
        p += d[i][1] * d[i][0]
        i += 1
    else:
        p += d[i][1] * (M - c)
        print(c)
        break

print(p)


Fixed submission:
N, M = map(int, input().split())
d = [list(map(int, input().split())) for i in range(N)]
d.sort(key=lambda x:(x[0],x[1]))

c = p = i = 0

while c < M:
    if c + d[i][1] <= M:
        c += d[i][1]
        p += d[i][0] * d[i][1]
        i += 1
    else:
        p += d[i][0] * (M - c)
        break

print(p)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
d = dict([list(map(int, input().split())) for i in range(N)])
d = sorted(d.items())

c = p = i = 0

while c < M:
    if c + d[i][1] <= M:
        c += d[i][1]
        p += d[i][0] * d[i][1]
        i += 1
    else:
        p += d[i][0] * (M - c)
        break

print(p)


Fixed submission:
N, M = map(int, input().split())
d = [list(map(int, input().split())) for i in range(N)]
d.sort(key=lambda x:(x[0],x[1]))

c = p = i = 0

while c < M:
    if c + d[i][1] <= M:
        c += d[i][1]
        p += d[i][0] * d[i][1]
        i += 1
    else:
        p += d[i][0] * (M - c)
        break

print(p)
Buggy python submission (verdict: Runtime Error):
n = int(input())
I = float('inf')
H = [int(i) for i in input().split()]
H1 = [abs(H[i]-H[i-1]) for i in range(1,n)] + [I]
H2 = [abs(H[i]-H[i-2]) for i in range(2,n)] + [I]*2

def dfs(c,a):
    if c >= n - 1:
        return a
    else:
        r1 = dfs(c + 1, a + H1[c])
        r2 = dfs(c + 2, a + H2[c])
        return min(r1,r2)


print(dfs(0,0))


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

H1 = [abs(H[i]-H[i-1]) for i in range(1,n)]
H2 = [abs(H[i]-H[i-2]) for i in range(2,n)]

D = [0]*n
D[1] = H1[0]

for i in range(2,n):
    D[i] = min(D[i-1] + H1[i-1], D[i-2] + H2[i-2])

print(D[-1])
Buggy python submission (verdict: Runtime Error):
N, Q = list(map(int, input().split()))
s = input()

lt = []
ld = []

for q in range(Q):
    t, d = input().split()
    lt.append(t)
    ld.append(d)

pl = -1
pr = N

for q in range(Q-1, -1, -1):
    if ld[q] == 'L':
        if s[pl + 1] == lt[q]:
            pl += 1
    else:
        if s[pr - 1] == lt[q]:
            pr -= 1

print(max(pr - pl -1, 0))


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

lt = []
ld = []

for q in range(Q):
    t, d = input().split()
    lt.append(t)
    ld.append(d)

pl = -1
pr = N

for q in range(Q-1, -1, -1):
    if ld[q] == 'L':
        if pl < N - 1 and s[pl + 1] == lt[q]:
            pl += 1
        if pr <= N - 1 and s[pr] == lt[q]:
            pr += 1
    else:
        if pr > 0 and s[pr - 1] == lt[q]:
            pr -= 1
        if pl >= 0 and s[pl] == lt[q]:
            pl -= 1

print(max(pr - pl -1, 0))

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = list(map(int, input().split()))
s = input()

dic = {}
for n in range(len(s)):
    if s[n] in dic:
        dic[s[n]].append(n)
    else:
        dic[s[n]] = [n]

go = [1] * N
Z = N

for q in range(Q):
    t, d = input().split()
    if t in dic:
        loc = dic[t]
        if d == 'L':
            for l in loc:
                if l == 0:
                    Z -= go[l]
                    go[l] = 0
                else:
                    go[l - 1] += go[l]
                    go[l] = 0
        else:
            for l in loc:
                if l == N - 1:
                    Z -= go[l]
                    go[l] = 0
                else:
                    go[l + 1] += go[l]
                    go[l] = 0

print(Z)

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

lt = []
ld = []

for q in range(Q):
    t, d = input().split()
    lt.append(t)
    ld.append(d)

pl = -1
pr = N

for q in range(Q-1, -1, -1):
    if ld[q] == 'L':
        if pl < N - 1 and s[pl + 1] == lt[q]:
            pl += 1
        if pr <= N - 1 and s[pr] == lt[q]:
            pr += 1
    else:
        if pr > 0 and s[pr - 1] == lt[q]:
            pr -= 1
        if pl >= 0 and s[pl] == lt[q]:
            pl -= 1

print(max(pr - pl -1, 0))
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = list(map(int, input().split()))
S = input()
w = []
for a in range(len(S)-1):
    if S[a] == 'A' and S[a+1] == 'C':
        w.append(1)
    else:
        w.append(0)
  
for n in range(Q):
    l, r = list(map(int, input().split()))
    v = w[(l-1):(r-1)]
    print(sum(v))


Fixed submission:
N, Q = list(map(int, input().split()))
S = input()
w = [0]
v = 0
for a in range(len(S)-1):
    if S[a] == 'A' and S[a+1] == 'C':
        v += 1
    w.append(v)
for n in range(Q):
    l, r = list(map(int, input().split()))
    print(w[r-1] - w[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = list(map(int, input().split()))
S = input()
for n in range(Q):
    l, r = list(map(int, input().split()))
    s = S[(l-1):r]
    c = 0
    for a in range(len(s)):
        if s[a] == 'A':
            if a < (len(s) - 1):
                if s[a+1] == 'C':
                    c += 1
                    a += 1
                elif s[a+1] != 'A':
                    a += 1
    print(c)


Fixed submission:
N, Q = list(map(int, input().split()))
S = input()
w = [0]
v = 0
for a in range(len(S)-1):
    if S[a] == 'A' and S[a+1] == 'C':
        v += 1
    w.append(v)
for n in range(Q):
    l, r = list(map(int, input().split()))
    print(w[r-1] - w[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = list(map(int, input().split()))
S = input()
for n in range(Q):
    l, r = list(map(int, input().split()))
    s = S[(l-1):r]
    c = 0
    for a in range(len(s)):
        if s[a] == 'A':
            if a < (len(s) - 1) and s[a+1] == 'C':
                c += 1
                a += 1
    print(c)

Fixed submission:
N, Q = list(map(int, input().split()))
S = input()
w = [0]
v = 0
for a in range(len(S)-1):
    if S[a] == 'A' and S[a+1] == 'C':
        v += 1
    w.append(v)
for n in range(Q):
    l, r = list(map(int, input().split()))
    print(w[r-1] - w[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
inf = float("inf")

N = int(input())
A = [int(i) for i in input().split()]

bmin = inf
bmax = -inf

for b in range(0, N):
    bmin = min(bmin, A[b] - b)
    bmax = max(bmax, A[b] - b)

bb = inf

mn = round(bmin + bmax)
for d in range(mn, bmin -1, -1):
    df = 0
    for b in range(0, N):
        df = df + abs(A[b] - (d + b))
    if df < bb:
        bb = df
    else:
        break

for d in range(mn, bmax + 1):
    df = 0
    for b in range(0, N):
        df = df + abs(A[b] - (d + b))
    if df < bb:
        bb = df
    else:
        break

print(bb)

Fixed submission:
import numpy as np

N = int(input())
A = [int(i) for i in input().split()]

list = []

for b in range(0, N):
    list.append(A[b] - b)

md = int(np.median(list))

bb = 0
for b in range(0, N):
    bb += abs(list[b] - md)

print(bb)

Buggy python submission (verdict: Time Limit Exceeded):
inf = float("inf")

N = int(input())
A = [int(i) for i in input().split()]

bmin = inf
bmax = -inf

for b in range(0, N):
    bmin = min(bmin, A[b] - b)
    bmax = max(bmax, A[b] - b)

bb = inf
for d in range(bmin, bmax + 1):
    df = 0
    for b in range(0, N):
        df = df + abs(A[b] - (d + b))
    bb = min(bb, df)

print(bb)

Fixed submission:
import numpy as np

N = int(input())
A = [int(i) for i in input().split()]

list = []

for b in range(0, N):
    list.append(A[b] - b)

md = int(np.median(list))

bb = 0
for b in range(0, N):
    bb += abs(list[b] - md)

print(bb)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input())
S = input()

c = N
for a in range(0, N):
	left = Counter(S[0:a])
	right = Counter(S[(a+1):N])
	c = min(c, left['W'] + right['E'])
print(c)

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

nE = 0
n = 0
minn = 0
for a in range(1, N):
	wE = (1 if S[a] == 'E' else 0)
	n = n + (1 if S[a-1] == 'W' else 0) - wE
	minn = min(minn, n)
	nE = nE + wE
print(minn + nE)
Buggy python submission (verdict: Runtime Error):
s = input()
K = int(input())

f1 = ""
f2 = ""
f3 = ""
f4 = ""
f5 = ""
for a1 in range(0, len(s)):
	for a2 in range(a1 + 1, len(s) + 1):
		w = s[a1:a2]
		if w != f1 and w != f2 and w != f3 and w != f4 and w != f5:
			if f5 == "" or w < f5:
				f5 = w
			if f4 == "" or f5 < f4:
				t = f4
				f4 = f5
				f5 = t
			if f3 == "" or f4 < f3:
				t = f3
				f3 = f4
				f4 = t
			if f2 == "" or f3 < f2:
				t = f2
				f2 = f3
				f3 = t
			if f1 == "" or f2 < f1:
				t = f1
				f1 = f2
				f2 = t

if K == 1:
	print(f1)
if K == 2:
	print(f2)
if K == 3:
	print(f3)
if K == 4:
	print(f4)
if K == 5:
	print(f5)

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

if (abs(b - a) <= d and abs(c - b) <= d) or abs(a - c) <= d:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
masu = [[0 for y in range(h)] for x in range(w)]
for y in range(0, h):
    z = list(input())
    for x in range(0, w):
        masu[y][x] = z[x]
hantei = "Yes"
for y in range(0, h):
    for x in range(0, w):
        if (masu[y][x] == "#"):
            if (not((y > 0 and masu[y - 1][x] == "#") or (y < h - 1 and masu[y + 1][x] == "#") or (x > 0 and masu[y][x - 1] == "#") or (x < w - 1 and masu[y][x + 1] == "#"))):
                hantei = "No"
print (hantei)

Fixed submission:
h, w = map(int, input().split())
masu = [[0 for x in range(w)] for y in range(h)]
for y in range(0, h):
    z = list(input())
    for x in range(0, w):
        masu[y][x] = z[x]
hantei = "Yes"
for y in range(0, h):
    for x in range(0, w):
        if (masu[y][x] == "#"):
            if (not((y > 0 and masu[y - 1][x] == "#") or (y < h - 1 and masu[y + 1][x] == "#") or (x > 0 and masu[y][x - 1] == "#") or (x < w - 1 and masu[y][x + 1] == "#"))):
                hantei = "No"
print (hantei)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin


def input():
    return stdin.readline()[:-1]


def intput():
    return int(input())


def sinput():
    return input().split()


def intsput():
    return map(int, sinput())


n, k = intsput()

a = list(intsput())
f = list(intsput())

a.sort()
f.sort(reverse=True)
p = [a[i] * f[i] for i in range(n)]
scrap = [0] * n

start = 0
end = max(p)
target = (start + end) // 2
while start != end:
    cnt = 0
    for i in range(n):
        fix = 0
        if p[i] > target:
            fix = (p[i] - target + f[i] - 1) // f[i]
            cnt += fix
        #scrap[i] = a[i] - fix
        if cnt > k:
            start = target + 1
            target = (start + end) // 2
            break
    else:
        end = target
        target = (start + end) // 2

print(start)


Fixed submission:
from sys import stdin


def input():
    return stdin.readline()[:-1]


def intput():
    return int(input())


def sinput():
    return input().split()


def intsput():
    return map(int, sinput())


n, k = intsput()

a = list(intsput())
f = list(intsput())

a.sort()
f.sort(reverse=True)
p = [a[i] * f[i] for i in range(n)]
scrap = [0] * n

start = 0
end = max(p)
target = (start + end) // 2
while start != end:
    cnt = 0
    for i in range(n):
        fix = 0
        if p[i] > target:
            fix = (p[i] - target + f[i] - 1) // f[i]
            cnt += fix
        #scrap[i] = a[i] - fix
        if cnt > k:
            start = target + 1
            target = (start + end) // 2
            break
    else:
        end = target
        target = (start + end) // 2

print(start)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
 
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    A, B, C = list(map(int,input().split()))
    OUT=max(A,B,C)
    print(A+B+C-OUT)
    
if __name__ == "__main__":
    main()

Fixed submission:
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

# import sys, math, random
# import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
 
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    A, B, C = list(map(int,input().split()))
    o=max(A,B,C)
    print(A+B+C-o)
    
if __name__ == "__main__":
    main()