Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect



def main():
    num, max_num = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num)]

    data.sort(key=lambda x:(-x[1]))
    # for


    visit = [0 for i in range(max_num + 1)]

    ans = 0
    # print(data)
    for i in range(num):
        day, value = data[i]
        ind_lim = day
        try:
            ind_insert = visit[ind_lim:].index(0)
            visit[ind_insert + ind_lim] = 1
            ans += value
        except:
            pass
        # print(visit)

    print(ans)







if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect


visit = []

def aaa(ind_lim, dame_num):
    global visit
    if ind_lim >= dame_num:
        return -1
    elif visit[ind_lim] == -1:
        return -1
    elif visit[ind_lim] == 0:
        return ind_lim
    else:
        visit[ind_lim] = aaa(visit[ind_lim], dame_num)
        return visit[ind_lim]

def main():
    num, max_num = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num)]

    data.sort(key=lambda x:(-x[1]))
    # for

    global visit
    visit = [0 for i in range(max_num + 1)]

    ans = 0

    for i in range(num):
        day, value = data[i]
        ind_lim = day
        # print(i, num, visit)
        ind_insert = aaa(ind_lim, max_num + 1)
        if ind_insert != -1:
            visit[ind_insert] = ind_insert + 1
            ans += value

    # print('uuu')
    print(ans)







if __name__ == '__main__':
    main()
### BUGGY CODE ###

N=int(input())
*P,=map(int,input().split())

print(sum(P[i] <=min(set(P[:i+1])) for i in range(N)))

### FIXED CODE ###

N=int(input())
*P,=map(int,input().split())

mi=P[0]
cnt=0
for i in range(N):
    if P[i]<mi:mi=P[i]
    if P[i]<=mi:cnt+=1
       
print(cnt)
### BUGGY CODE ###

N = int(input())
P = list(map(int, input().split()))
ans = 0

for i in range(N):
  tmp = P[0:i+1]
  if P[i] == min(tmp):
    ans += 1

print(ans)

### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
ans = 0
min_number = 2*10**5+1

for i in range(N):
  min_number = min(min_number, P[i])
  if min_number == P[i]:
    ans += 1
  
print(ans)
### BUGGY CODE ###

def main():
    import sys
    from collections import Counter

    input = sys.stdin.readline

    s = str(input().rstrip())
    num = ""
    li = []
    f = 0
    mi = 0
    li_append = li.append

    for i in range(1, len(s) + 1):
        num = s[-i] + num
        li_append(int(num) % 2019)
        if num[0] == "0":
            f += 1
        else:
            if f > 0:
                mi += ((f + 1) * f) // 2
                f = 0

    co = Counter(li)
    val = co.values()
    ans_1 = 0

    for i in val:
        if i > 1:
            ans_1 += (i * (i - 1)) // 2
        else:
            continue
    ans2 = 0
    if 0 in co:
        zero = co[0]
        ans2 = zero
    print(ans_1 + ans2 - mi)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    import sys
    from collections import defaultdict
    dic = defaultdict(int)

    input = sys.stdin.readline

    s = str(input().rstrip())
    m = 0
    before_m = 0.1

    for i in range(1, len(s) + 1):
        before_m = int(before_m*10)%2019
        m_ad = (int(s[-i]) * before_m) % 2019
        m = (m_ad + m) % 2019
        dic[m] += 1

    ans1 = 0

    for x in dic.values():
        if x > 1:
            ans1 += x * (x - 1) // 2
    ans2 = dic[0]

    print(ans1 + ans2)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

N, C = map(int, input().split())
TV = [[0]*(2*10**5) for i in range(C)]

for i in range(N):
    s, t, c = map(int, input().split())
    TV[c-1][2*s-2] += 1
    TV[c-1][2*t-1] -= 1

for i in range(C):
    for j in range(1, 2*10**5):
        TV[i][j] = TV[i][j]+TV[i][j-1]

for i in range(C):
    for j in range(1, 2*10**5):
        TV[i][j] = min(1, TV[i][j])

import numpy as np
TV = np.array(TV)
print(np.max(TV.sum(axis=0)))


### FIXED CODE ###

import numpy

N, C = map(int, input().split())
STC = [list(map(int, input().split())) for i in range(N)]
Channel = numpy.array([[0]*(2*10**5+1) for i in range(C+1)])

for s, t, c in STC:
    Channel[c][2*s-1] += 1
    Channel[c][2*t] -= 1
    
for i in range(len(Channel)):
    Channel[i] = numpy.cumsum(Channel[i])
bool_Channel = Channel.astype(numpy.bool_)

needs = numpy.sum(bool_Channel, axis=0)
print(needs.max())
### BUGGY CODE ###

def memoize(f):  
    cache = {}  
    def helper(x):  
        if x not in cache:              
            cache[x] = f(x)  
        return cache[x]  
    return helper 

def split_apex(a):
    if len(a) == 2:
        yield (a[0],), (a[1],)
    else:
        for i in range(0, len(a)):
            yield (a[i],), a[:i] + a[i + 1:]

@memoize
def wait(a):
    global g
    if len(a) == 1:
        return 0
    return min(calc_wait(apex, apices) for apex, apices in split_apex(a))

def calc_wait(apex, apices):
    global g
    w = [g[apex[0]][i] for i in apices if g[apex[0]][i] != -1]
    return  wait(apex) + wait(apices) + (min(w) if len(w) else 200000)

n = int(input())
g = [None] + [[None] + list(map(int, input().split())) for _ in range(n)]

a = tuple(i + 1 for i in range(n))
print(wait(a))

### FIXED CODE ###

class Forest:
    def __init__(self, g, id):
        self.forest = set([id])
        self.graph = g
        self.next_wait = self.graph[id]
        self.wait = 0
    def add_tree(self, id):
        self.wait += self.next_wait[id]
        self.forest.update([id])
         
        self.marge_next_wait(id)
    def next_tree(self):
        min_id = min_wait = None
        for id, wait in self.next_wait.items():
            if id not in self.forest:
                if min_wait == None or min_wait > wait:
                    min_wait = wait
                    min_id = id
        return min_id
    def marge_next_wait(self, merge_id):
        for id, wait in self.graph[merge_id].items():
            if id not in self.next_wait or self.next_wait[id] > wait:
                self.next_wait[id] = wait
n = int(input())
g = [{e:i for e, i in enumerate(map(int, input().split())) if i != -1} for _ in range(n)]
forest = Forest(g,0)
for i in range(n - 1):
    id = forest.next_tree()
    forest.add_tree(id)
print(forest.wait)
### BUGGY CODE ###

import bisect

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))

for _ in range(M):
  tmp_a = int(A[-1]/2)
  del A[-1]
  A.insert(bisect.bisect_left(A,tmp_a),tmp_a)
print(sum(A))

### FIXED CODE ###

import heapq

N,M = map(int,input().split())
A = []
for a in map(int,input().split()):
  heapq.heappush(A,-a)

cnt = 0
while cnt < M:
  a = heapq.heappop(A)
  heapq.heappush(A,-((-a)//2))
  cnt += 1
print(-sum(A))
### BUGGY CODE ###

L = input()
mod = 10**9 + 7

x = len(L)
L = int(L, 2)
ans = 0
count = 0
for i in range(x-1, -1, -1):
    if (L >> i) & 1:
        ans += ((3**i) * (2**count)) % mod
        ans %= mod
        count += 1
    else:
        continue

ans += 2**count % mod
ans %= mod
print(ans)

### FIXED CODE ###

L = input()
mod = 10**9 + 7

x = len(L)
L = int(L, 2)
DP1 = [0] * (x+1)  # sure under L
DP2 = [0] * (x+1)  # possible under L
DP1[1] = 1
DP2[1] = 2
for i in range(2, x+1):
    if (L >> (x-i)) & 1:
        DP1[i] = (DP1[i-1] * 3 + DP2[i-1]) % mod
        DP2[i] = DP2[i-1] * 2 % mod

    else:
        DP1[i] = DP1[i-1] * 3 % mod
        DP2[i] = DP2[i-1]
ans = (DP1[x] + DP2[x]) % mod
print(ans)
### BUGGY CODE ###


n =int(input())

sum = 0
for i in range (1,n+1,1):
    k= n//i
    sum += int(i*k*(k+1)/2)

print(sum)



### FIXED CODE ###


n =int(input())

sum = 0
for i in range (1,n+1,1):
    k= n//i
    sum += int(i*k*(k+1)/2)

print(sum)
### BUGGY CODE ###

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


coord = {}
for i in range(h):
    for j in range(w):
        a_ij = a[i][j] - 1
        coord[a_ij] = (i, j)

import math
cost = [[0 for i in range(int(math.ceil(h * w / d)))] for i in range(d)]
for i in range(h * w - d):
    i0 = int(i / d)
    i1 = int(i % d)
    cost[i1][i0] = abs(coord[i + d][0] - coord[i][0]) + abs(coord[i + d][1] - coord[i][1])

cost_sum = [[0 for i in range(int(math.ceil(h * w / d)))] for i in range(d)]
for i in range(d):
    for j in range(int(math.ceil(h * w / d))):
        cost_sum[i][j] = sum(cost[i][:j])

for i in range(q):
    l = lr[i][0] - 1
    r = lr[i][1] - 1

    _cost_sum = cost_sum[int(l % d)]
    print(_cost_sum[int(r / d)] - _cost_sum[int(l / d)])


### FIXED CODE ###

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


coord = {}
for i in range(h):
    for j in range(w):
        a_ij = a[i][j] - 1
        coord[a_ij] = (i, j)

import math
cost = [[0 for i in range(int(math.ceil(h * w / d)))] for i in range(d)]
for i in range(h * w - d):
    i0 = int(i / d)
    i1 = int(i % d)
    cost[i1][i0] = abs(coord[i + d][0] - coord[i][0]) + abs(coord[i + d][1] - coord[i][1])

cost_sum = [[0 for i in range(int(math.ceil(h * w / d)))] for i in range(d)]
for i in range(d):
    for j in range(int(math.ceil(h * w / d))):
        if j != 0:
            cost_sum[i][j] = cost_sum[i][j-1] + cost[i][j-1]
        else:
            cost_sum[i][j] = 0

for i in range(q):
    l = lr[i][0] - 1
    r = lr[i][1] - 1

    _cost_sum = cost_sum[int(l % d)]
    print(_cost_sum[int(r / d)] - _cost_sum[int(l / d)])
### BUGGY CODE ###

import itertools
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
L = [A,B,C]
M = list(itertools.product(*L))
T = []
for i in range(len(M)):
  T.append(sum(M[i]))
T.sort()
for i in range(len(T)-1,len(T)-K-1,-1):
  print(T[i])

### FIXED CODE ###

import itertools
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
L = [A,B,C]
if X*Y*Z <= 3000:
  M = list(itertools.product(*L))
  T = []
  for i in range(len(M)):
    T.append(sum(M[i]))
  T.sort()
  for i in range(len(T)-1,len(T)-K-1,-1):
    print(T[i])
else:
  T = []
  for i in range(X):
    for j in range(Y):
      T.append(A[i]+B[j])
  T.sort()
  T.reverse()
  U = []
  for i in range(K):
    U.append(T[i])
  V = []
  for i in range(K):
    for j in range(Z):
      V.append(U[i]+C[j])
  V.sort()
  V.reverse()
  for i in range(K):
    print(V[i])
### BUGGY CODE ###

n = int(input())
a = list(input().split())
num_list = []

for i in range(len(a)-1):
    for j in range(i+1, len(a)):
        if a[i] == a[j] and int(a[i]) not in num_list:
            num_list.append(int(a[i]))
            break

if len(num_list) < 2:
    print("0")
else:
    num_list.sort()
    print(num_list[-1]*num_list[-2])


### FIXED CODE ###

n = int(input())
a_in = list(input().split())
a = list(map(int,a_in))
a.sort(reverse=True)
ans = 0
t = 0
c = 1

for i in range(n-1):
    if a[i] == a[i+1]:
        c = c + 1
        if t == 0:
            t = int(a[i])
        elif t != int(a[i]):
            ans = t * int(a[i])
            break
        elif c == 4:
            ans = t * t
            break
    else:
        c = 1

print(ans)
### BUGGY CODE ###

import sys
import numpy as np

n, k, q = [int(nkq) for nkq in input().split()]
sys.stderr.write(str(n)+' '+str(k)+' '+str(q)+'\n')

arr = np.full(n, k-q, dtype=np.int64)

for i in range(q):
  a_i = int(input())
  
  for j in range(n):
    if j+1 == a_i:
      arr[j] += 1

  sys.stderr.write(str(i+1)+': ')
  for j in range(n):
    sys.stderr.write(str(arr[j])+' ')
  sys.stderr.write('\n')

for j in range(n):
  if arr[j] > 0:
    print("Yes")
  else:
    print("No")


### FIXED CODE ###

import numpy as np

n, k, q = [int(nkq) for nkq in input().split()]
arr = np.full(n, k-q, dtype=np.int64)

for i in range(q):
  a_i = int(input()) 
  arr[a_i-1] += 1

for j in range(n):
  if arr[j] > 0:
    print("Yes")
  else:
    print("No")
### BUGGY CODE ###

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

ans = 0

for i in range(n):
    sums = [0] * (n - i +  1)
    for j in range(n - i):
        sums[j + 1] = sums[j] + a[i + j]
    ans += sums.count(0) - 1
        
print(ans)

### FIXED CODE ###

from collections import Counter

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

ans = 0

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

c = Counter(b)

for value in c.values():
	ans += value * (value - 1) // 2
    
print(ans)
### BUGGY CODE ###

def main():
    N,K = map(int, input().split())
    pi = list(map(int, input().split()))
    max_num = 0

    for i in range(N):
        s = 0
        if i+K > N:
            break
        for j in range(K):
            s += (1+pi[i+j])/2
        if s > max_num:
            max_num = s

    print(max_num)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N,K = map(int, input().split())
    pi = list(map(int, input().split()))
    max_num = 0
    new_pi = [0] * N
    sum_new_pi = [0] * (N+1)

    for i in range(N):
        new_pi[i] += (1+pi[i])/2

    for i in range(N):
        sum_new_pi[i+1] = sum_new_pi[i] + new_pi[i]

    for i in range(N):
        if i+K > N:
            break
        s = sum_new_pi[i+K] - sum_new_pi[i]
        if s > max_num:
            max_num = s

    print(max_num)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(200000)
def main():
    INF = float("inf")
    input = sys.stdin.readline
    N, M = map(int,input().split())
    G = [[[],[],[]] for k in range(N)]

    for k in range(M):
        u, v = map(int,input().split())
        u -= 1
        v -= 1
        G[u][0] += [v]
        G[u][1] += [v]
        G[u][2] += [v]

    S, T = map(int,input().split())
    S -= 1
    T -= 1
    D1 = [[INF,INF,INF] for k in range(N)]
    D1[S][0] = 0

    def dfs1(now):
        for tsugi in G[now][1]:
            if D1[tsugi][1] > D1[now][0] + 1:
                D1[tsugi][1] = D1[now][0] + 1
                dfs2(tsugi)
    def dfs2(now):
        for tsugi in G[now][2]:
            if D1[tsugi][2] > D1[now][1] + 1:
                D1[tsugi][2] = D1[now][1] + 1
                dfs3(tsugi)
    def dfs3(now):
        for tsugi in G[now][2]:
            if D1[tsugi][0] > D1[now][2] + 1:
                D1[tsugi][0] = D1[now][2] + 1
                dfs1(tsugi)

    dfs1(S)
    if D1[T][0]%3 == 0:
        print(D1[T][0]//3)
    else:
        print(-1)
if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import deque
def main():
    INF = float("inf")
    input = sys.stdin.readline
    N, M = map(int,input().split())
    G = [[] for k in range(N)]
    for k in range(M):
        u, v = map(int,input().split())
        u -= 1
        v -= 1
        G[u] += [v]
    S, T = map(int,input().split())
    S -= 1
    T -= 1
    D = [[INF,INF,INF] for k in range(N)]
    D[S][0] = 0
    Q = deque([[S,0]])
    while len(Q) > 0:
        t = Q.popleft()
        ima = t[0]
        k = t[1]
        for tsugi in G[ima]:
            if D[tsugi][(k+1)%3] != INF:
                pass
            else:
                D[tsugi][(k+1)%3] = D[ima][k] + 1
                Q.append([tsugi,(k+1)%3])
    if D[T][0] == INF or D[T][0]%3 != 0:
        print(-1)
    else:
        print(D[T][0]//3)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

rates = sorted(list(set(D)))
counter = [0] * len(rates)
for d in D:
    counter[rates.index(d)]+=1

acc = 0
found = False
for i in range(len(counter)):
    acc += counter[i]
    if acc == N/2:
        found = True
        break
    if acc > N/2:
        found = False
        break

if found == False:
    print(0)
else:
    print(rates[i+1]-rates[i])

### FIXED CODE ###

import collections

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

c = collections.Counter(D)
c = sorted(c.items(), key=lambda x:x[0])

rates, counter = list(zip(*c))

acc = 0
found = False
for i in range(len(counter)):
    acc += counter[i]
    if acc == N/2:
        found = True
        break
    if acc > N/2:
        found = False
        break

if found == False:
    print(0)
else:
    print(rates[i+1]-rates[i])
### BUGGY CODE ###

# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def run():
    S = input()
    K = int(input())
    dic = set()
    pos = defaultdict(lambda : [])
    for i, s in enumerate(S):
        pos[s].append(i)
    base = 'abcdefghijklmnopqrstuvwxyz'

    for l in base:
        for position in pos[l]:
            for k in range(position+1, len(S)+1):
                dic.add(S[position:k])
        if len(dic) >= K:break

    dic = sorted(list(dic))
    print(dic[K-1])



if __name__ == "__main__":
    run()


### FIXED CODE ###

# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def run():
    S = input()
    K = int(input())
    dic = set()
    pos = defaultdict(lambda : [])
    for i, s in enumerate(S):
        heappush(pos[s], S[i:])
    base = 'abcdefghijklmnopqrstuvwxyz'

    for l in base:
        while pos[l]:
            sub = heappop(pos[l])
            for i in range(1, len(sub)+1):
                dic.add(sub[:i])

            if len(dic) >= K:
                dic = sorted(list(dic))
                print(dic[K - 1])
                return



if __name__ == "__main__":
    run()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse = True)
sa = sum(A) 
A = np.array(A)
F = np.array(F)

l = -1 
r = A[N-1] * F[0]
while l+1 < r: 
    m = (l + r) //2
    S = sa - sum(np.minimum(m // F, A)) 
    if S <= K:
        r = m
    else:
        l = m
         
print(r)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse = True)
sa = sum(A) 
A = np.array(A)
F = np.array(F)

l = -1 
r = A[N-1] * F[0]
while l+1 < r: 
    m = (l + r) //2
    S = sa - np.sum(np.minimum(m // F, A)) 
    if S <= K:
        r = m
    else:
        l = m
         
print(r)
### BUGGY CODE ###

N=int(input())
s=[]
n=[]
for i in range(N):
    k="".join(sorted(list(input())))
    if k in s:
        n[s.index(k)]+=1
    else:
        s.append(k)
        n.append(1)
c=0
for i in n:
    c += i*(i-1)

print(c//2)


### FIXED CODE ###

N=int(input())
dic={}
for i in range(N):
    k="".join(sorted(list(input())))
    if k in dic:
        dic[k]+=1
    else:
        dic[k]=1
c=0
for i in dic.values():
    c += i*(i-1)

print(c//2)
### BUGGY CODE ###

def main():
    K = int(input())
    if K%2 == 0:
        return -1

    amari_sum = 0
    i = 1
    amari = 7 % K
    amari_sum += amari
    if amari == 0:
        return i

    while True:
        i += 1
        amari = (amari*10) % K
        amari_sum += amari
        #print(amari,amari_sum)
        if amari_sum % K == 0:
            return i
        #else:
            #amari_sum %= K

print(main())


### FIXED CODE ###

def main():
    K = int(input())
    if K%2 == 0:
        return -1
    ans = 1
    amari_reserve = 7%K
    amari = amari_reserve
    if amari_reserve == 0:
        return ans

    while (ans <= K):
        ans += 1
        amari = (10*amari+7) % K
        if amari == 0:
            return ans
        if amari == amari_reserve:
            return -1

    return -1


print(main())
### BUGGY CODE ###

r,g,b,n = map(int, input().split())


#def cnt2(sum, a, b):

cnt = 0
for rr in range(n // r + 1):
  sum = r * rr
  rest = n - sum
  #cnt += cnt2(rest, g, b)
  for gg in range(rest // g + 1):
    sum = r * rr + g * gg
    rest = n - sum
    if rest < 0:
      break
    if rest % b == 0:
      bb = (n-sum) // b
      cnt += 1

print(cnt)


### FIXED CODE ###

r,g,b,n = map(int, input().split())

cnt = 0
for rr in range(n // r + 1):
  for gg in range((n - r * rr) // g + 1):
    rest = n - r * rr - g * gg
    cnt += (rest % b == 0)

print(cnt)
### BUGGY CODE ###

N,M,C=[int(x) for x in str(input()).split()]
r=[int(x) for x in str(input()).split()]
ABC=[[0 for i in range(4)]]

dis=[[100001 for i in range(N+1)]]

for i in range(N):
  dis.append([100001 for i in range(N+1)])


for i in range(M):
  x=[0]+[int(x) for x in str(input()).split()]
  ABC.append(x)
  dis[x[1]][x[2]]=x[3]
  dis[x[2]][x[1]]=x[3]
  y=[0,x[2],x[1],x[3]]
  ABC.append(y)

for i in range(1,N+1):
  dis[i][i]=0


for k in range(1,N+1):
  for i in range(1,N+1):
    for j in range(1,N+1):
      dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j])


from itertools import permutations
mi=1000000
BASH=[]
for item in permutations(r):
    BASH.append(list(item))

for i in BASH:

  p=0
  for j in range(0,len(i)-1):
    p+=dis[i[j]][i[j+1]]
  mi=min(mi,p)


print(mi)

### FIXED CODE ###

N,M,C=[int(x) for x in str(input()).split()]
r=[int(x) for x in str(input()).split()]
ABC=[[0 for i in range(4)]]

dis=[[1000000000000 for i in range(N+1)]]

for i in range(N):
  dis.append([1000000000000 for i in range(N+1)])


for i in range(M):
  x=[0]+[int(x) for x in str(input()).split()]
  ABC.append(x)
  dis[x[1]][x[2]]=x[3]
  dis[x[2]][x[1]]=x[3]
  y=[0,x[2],x[1],x[3]]
  ABC.append(y)

for i in range(1,N+1):
  dis[i][i]=0


for k in range(1,N+1):
  for i in range(1,N+1):
    for j in range(1,N+1):
      dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j])


mi=1000000000000
def perm(a,i):
  global mi
  if i==len(a):      

    p=0
    for x in range(len(a)-1):
      p+=dis[a[x]][a[x+1]]

    mi=min(mi,p)


  else:
    for j in range(i,len(a)):
      a[i],a[j]=a[j],a[i]
      perm(a,i+1)
      a[i],a[j]=a[j],a[i]


perm(r,0)

print(mi)
### BUGGY CODE ###

L,R=map(int,input().split())
flag=0
for i in range(L,R+1):
    if i%2019==0:
        flag=1
ans=[]
if flag==1:
    print(0)
else:
    for m in range(L,R+1):
        for j in range(m+1,R+1):
            ans.append(m*j%2019)
    print(min(ans))
            
            


### FIXED CODE ###

L,R=map(int,input().split())
ans=[]
if (R-L)>2019:
    print(0)
else:
    for m in range(L,R+1):
        for j in range(m+1,R+1):
            ans.append(m*j%2019)
    print(min(ans))
### BUGGY CODE ###

inp = input().split(" ")
takahashi = int(inp[0])
aoki = int(inp[1])
K = int(inp[2])

for i in range(K):
    if takahashi > 0 :
        takahashi = takahashi -1
    elif aoki > 0 :
        aoki = aoki-1

print(str(takahashi) + " " + str(aoki))

### FIXED CODE ###

A,B,K = map(int,input().split(" "))
if A+B < K:print(0,0)
elif A > K:print(A-K,B)
elif A  <= K:print(0,A+B-K)
# Kenparさん、写経させていただきました。ありがとうございます。
# こんな解法があったなんて・・・