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

import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    S = list(map(int, list(input())))
    S = S[::-1]
    n = len(S)
    mod = 2019
    A = [0] * n
    times = 1
    for i in range(n):
        A[i] = S[i] * times % mod
        times *= 10

    # 累積和
    R = [0] * (n + 1)
    for i in range(n):
        R[i+1] = (R[i] + A[i]) % mod
    # print(R)
    cnt = {}
    ans = 0
    for i in range(n+1):
        r = R[i] % mod
        # print(r)
        cnt.setdefault(r, 0)
        ans += cnt[r]
        cnt[r] += 1
    # print(cnt)
    print(ans)

if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())
 
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
 
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
 
INF = float('inf')
 
def solve():
    S = list(map(int, list(input())))
 
    S = S[::-1]
    # print(S)
    n = len(S)
    mod = 2019
 
    #
    A = [0] * (n)
    a = 1
    for i in range(n):
        A[i] = S[i] * a
        a = a * 10 % mod
    # print(A)
 
    # 累積和
    R = [0] * (n+1)
    for j in range(n):
        R[j+1] = (R[j] + A[j]) % mod
    # print(R)
 
    # 個数を数える
    cnt = {}
    ans = 0
    for l in range(0, n+1):
        r = R[l]
        ans = ans + cnt.get(r, 0)
        cnt[r] = cnt.setdefault(r, 0) + 1
    print(ans)
 
if __name__ == '__main__':
    solve()
### BUGGY CODE ###

S = input()
N = len(S)
ans = 0
T = []
for i in range(N):
    T.append(int(S[i : N]) % 2019)
T.sort()
ans += T.count(0)
t = set(T)
counted = []
for i in t:
    a = T.count(i)
    if a > 1:
        counted.append(a)
for i in counted:
    ans += i * (i - 1) // 2
print(ans)


### FIXED CODE ###

S = input()[::-1]
N = len(S)
amari = [0 for i in range(2019)]
before = int(S[0])
amari[before] += 1
S = S[1::]
keta = 1
for i in S:
    i = int(i)
    keta = (keta * 10) % 2019
    x = (keta * i + before) % 2019
    amari[x] += 1
    before = x
ans = amari[0]
for i in amari:
    ans += i * (i - 1) // 2
print(ans)
### BUGGY CODE ###

n = int(input())
s = input()
memo = []
for i in range(10):
  for j in range(10):
    for k in range(10):
      memo.append(str(i) + str(j) + str(k))
ans = 0
for i in memo:
  x = 0
  for j in range(len(s)):
    if i[x] == s[j]:
      x += 1
    if x == 3:
      ans += 1
      break

print(ans)

### FIXED CODE ###

n = int(input())
s = input()

num = [0,1,2,3,4,5,6,7,8,9]
memo = []
for i in num:
  for j in num:
    for k in num:
      memo.append(str(num[i]) + str(num[j]) + str(num[k]))

ans = 0

for i in memo:
  x = 0
  for j in range(n):
    if i[x] == s[j]:
      x += 1
      if x == 3:
        break
  if x == 3:
    ans += 1
    
print(ans)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
def main():
    N, W = map(int, input().split())
    V = 10**3 * 100
    
    f_inf = float("inf")
    dp = [f_inf] * (V+1)
    dp[0] = 0
    
    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(V-v, -1, -1):
            if dp[i] == -1:
                continue
            dp[i+v] = min(dp[i+v], dp[i] + w)

    # print(dp)
    ans = 0
    for i in range(len(dp)):
        if dp[i] <= W and i >= ans:
            ans = i

    print(ans)
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

import numpy as np
N, W = map(int, input().split())
 
items = [tuple(map(int, input().split())) for _ in range(N)]
 
dp = np.full(N*1000 +1, W+1) #横軸を価値の値に変換する
dp[0] = 0
 
for i, (w, v) in enumerate(items):
    dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
 
print(np.max(np.where(dp <= W)))
### BUGGY CODE ###

n = int(input())
L = [int(input()) for _ in range(n)]
count = 0
next = 0
NG = [1]
while True:
  if L[next] in NG:
    print(-1)
    quit()
  elif L[next] == 2:
    print(count+1)
    quit()
  else:
    NG.append(L[next])
    next = L[next]-1
    count += 1

### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
cur = 1
cnt = 0
while True:
    if cur == 2:
        print(cnt)
        exit()
    elif cnt > n:
        print(-1)
        exit()
    else:
        cur = a[cur - 1]
        cnt += 1
### BUGGY CODE ###

s = list(input())
n = int(input())
f = 0
for i in range(n):
  l = input().split()
  if l[0] == "2":
    if (l[1] == "1" and f == 0) or (l[1] == "2" and f == 1):
      s.insert(0,l[2])
    else:
      s.append(l[2])
  else:
    if f == 0:
      f = 1
    else:
      f = 0

print("".join(s) if f == 0 else "".join(s[::-1]))


### FIXED CODE ###

from collections import deque
s = deque(input())
#s = input()
n = int(input())
f = 1
for i in range(n):
  l = list(map(str, input().split()))
  if l[0] == "2":
    tmp = int(l[1])*f
    if tmp == 1 or tmp == -2:
      s.appendleft(l[2])
    else:
      s.append(l[2])
  else:
    f *= -1

if f == -1:
  s.reverse()
print("".join(s))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**4)
def input():
	return sys.stdin.readline()[:-1]

class BellmanFord():
	def __init__(self, adj, start, size):
		self.adj = adj
		self.start = start
		self.size = size
		self.dist = [10**30 for _ in range(self.size)]
		self.dist[self.start] = 0

	def solve(self):
		for _ in range(self.size-1):
			for x in range(self.size):
				for y, w in self.adj[x]:
					if s_reachable[x] and s_reachable[y] and g_reachable[x] and g_reachable[y]:
						if self.dist[y] > self.dist[x] + w:
							self.dist[y] = self.dist[x] + w
		for x in range(self.size):
			for y, w in self.adj[x]:
				if s_reachable[x] and s_reachable[y] and g_reachable[x] and g_reachable[y]:
					if self.dist[y] > self.dist[x] + w:
						return False

		return True

	def GetDistance(self, goal):
		return self.dist[goal]

n, m, p = map(int, input().split())
adj = [[] for _ in range(n)]
adj_rev = [[] for _ in range(n)]

for _ in range(m):
	a, b, c = map(int, input().split())
	adj[a-1].append((b-1, -c+p))
	adj_rev[b-1].append(a-1)

s_reachable = [False for _ in range(n)]
s_reachable[0] = True
g_reachable = [False for _ in range(n)]
g_reachable[n-1] = True

def dfs_s(x):
	for v, w in adj[x]:
		if not s_reachable[v]:
			s_reachable[v] = True
			dfs_s(v)
	return

def dfs_g(x):
	for v in adj_rev[x]:
		if not g_reachable[v]:
			g_reachable[v] = True
			dfs_g(v)
	return

dfs_s(0)
dfs_g(n-1)

bf = BellmanFord(adj, 0, n)
if not bf.solve():
	print(-1)
else:
	print(max(-bf.GetDistance(n-1), 0))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**4)
def input():
	return sys.stdin.readline()[:-1]

class BellmanFord():
	def __init__(self, adj, start, size):
		self.adj = adj
		self.start = start
		self.size = size
		self.dist = [10**30 for _ in range(self.size)]
		self.dist[self.start] = 0

	def solve(self):
		for _ in range(self.size-1):
			for x in range(self.size):
				for y, w in self.adj[x]:
					if s_reachable[x] and s_reachable[y] and g_reachable[x] and g_reachable[y]:
						if self.dist[y] > self.dist[x] + w:
							self.dist[y] = self.dist[x] + w
		for x in range(self.size):
			for y, w in self.adj[x]:
				if s_reachable[x] and s_reachable[y] and g_reachable[x] and g_reachable[y]:
					if self.dist[y] > self.dist[x] + w:
						return False

		return True

	def GetDistance(self, goal):
		return self.dist[goal]

n, m, p = map(int, input().split())
adj = [[] for _ in range(n)]
adj_rev = [[] for _ in range(n)]

for _ in range(m):
	a, b, c = map(int, input().split())
	adj[a-1].append((b-1, -c+p))
	adj_rev[b-1].append(a-1)

s_reachable = [False for _ in range(n)]
s_reachable[0] = True
g_reachable = [False for _ in range(n)]
g_reachable[n-1] = True

def dfs_s(x):
	for v, w in adj[x]:
		if not s_reachable[v]:
			s_reachable[v] = True
			dfs_s(v)
	return

def dfs_g(x):
	for v in adj_rev[x]:
		if not g_reachable[v]:
			g_reachable[v] = True
			dfs_g(v)
	return

dfs_s(0)
dfs_g(n-1)

bf = BellmanFord(adj, 0, n)
if not bf.solve():
	print(-1)
else:
	print(max(-bf.GetDistance(n-1), 0))
### BUGGY CODE ###

from collections import deque

H,W = map(int,input().split())
grid = [input() for i in range(H)]

#初期の黒('#')の位置からの距離
dist = [[-1]*W for _ in range(H)]

def bfs(black_cells, dist):
    d = 0
    while black_cells:
        h,w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1,0),(0,1),(-1,0),(0,-1)):
            nh = h + dy
            nw = w + dx
            
            if nh < 0 or H <= nh or nw < 0 or W <= nw:
                continue
            if dist[nh][nw] == -1:
                dist[nh][nw] = d+1
                black_cells.append((nh,nw))
    return d

black_cells = deque()
for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            black_cells.append((i,j))
            dist[i][j] = 0
            
d = bfs(black_cells,dist)
print(d)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]

# 初期の黒('#')の位置からの距離
dist = [[-1]*W for _ in range(H)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append((h, w))
            dist[h][w] = 0

def bfs(black_cells, dist):
    """
    BFSを用いて、全マス目を黒くする回数を求める

    Args:
        black_cells: 「開始時の黒マス」の座標が入ったキュー（複数座標あり）
        dist: 「開始時の黒マス」からの距離の入ったリスト  [[-1, -1, 0], ...]
        　　　（白マスの初期値は0）

    Returns:
        g: 操作を繰り返した数
    """
    d = 0
    while black_cells:
        # キューとして使うのでpop()ではなくpopleft()
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:  # セルが白('.')であるのと同義
                dist[new_h][new_w] = d+1
                black_cells.append((new_h, new_w))
    return d

d = bfs(black_cells, dist)
print(d)
### BUGGY CODE ###

N = int(input())
ans = 0
memo = [{} for _ in range(N)]
for i in range(N):
    si = list(input())
    for ss in si:
        if ss not in memo[i]:
            memo[i][ss] = 1
        else:
            memo[i][ss] += 1
for j in range(N):
    for k in range(j, N):
        if j != k:
            if memo[j] == memo[k]:
                ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
memo = {}
ans = 0
for i in range(N):
    si = list(input())
    si.sort()
    si = ('').join(si)
    if si not in memo:
        memo[si] = 1
    else:
        memo[si] += 1
        ans += memo[si] - 1
print(ans)
### BUGGY CODE ###

N,S,Q,*K = open(0).read().split()
N = int(N)
Q = int(Q)
K = map(int,K)
for k in K:
  C = [0]*N
  M = [0]*N
  CMS = [0]*N
  SDMC = 0
  SMC = 0
  SC = 0
  Ms = 0
  for i in range(k):
    if S[i]=='C':
      CMS[i] = Ms
    elif S[i]=='M':
      Ms += 1
      M[i] = 1
  for i in range(k,N):
    Ms -= M[i-k]
    if S[i]=='C':
      CMS[i] = Ms
    elif S[i]=='M':
      Ms += 1
      M[i] = 1
  for i in range(N-1,N-1-k,-1):
    if S[i]=='C':
      SC += 1
      C[i] = 1
    elif S[i]=='M':
      SMC += SC
    elif S[i]=='D':
      SDMC += SMC
  for i in range(N-1-k,-1,-1):
    SC -= C[i+k]
    SMC -= CMS[i+k]
    if S[i]=='C':
      SC += 1
      C[i] = 1
    elif S[i]=='M':
      SMC += SC
    elif S[i]=='D':
      SDMC += SMC
  print(SDMC)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
S = np.frombuffer(readline().rstrip(),'S1')
Q = int(readline())
query = map(int,read().split())

isD = S == b'D'
isM = S == b'M'
isC = S == b'C'

cumD = isD.cumsum(dtype=np.int64)
cumM = isM.cumsum(dtype=np.int64)

def F(K):
    """
    ・Cごとに数える。
    ・そのためには(i-K,i] 内のDMの個数を調べる（負インデックスには関係ない文字があると思っておく）
    ・区間内のDの個数、Mの個数が取得できれば、差分が取得できるので最後に累積和
    """
    # (i-K,i]内のDの個数、Mの個数
    D = cumD.copy(); D[K:] -= cumD[:-K]
    M = cumM.copy(); M[K:] -= cumM[:-K]
    # 最後がMのとき、Dの個数分増える
    DM = isM * D
    # 左端のDを捨てるとき、Mの個数分減る
    DM[K:] -= isD[:-K] * M[K-1:-1]
    np.cumsum(DM,out=DM)
    # Cごとに集計
    return DM[isC].sum()

print('\n'.join(str(F(K)) for K in query))
### BUGGY CODE ###

import collections

n, k = map(int, input().split())
a = list(map(int, input().split()))
d = collections.Counter(a)
ans = 0

while len(d.keys()) > k:
    min_kv = min(d.items(), key=lambda x: x[1])
    d[min_kv[0]] -= 1
    ans += 1
    if d[min_kv[0]] == 0:
        del d[min_kv[0]]

print(ans)


### FIXED CODE ###

import collections
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
a = list(map(int, input().split()))
d = collections.Counter(a)
v = list(d.values())
v = sorted(v)

ans = 0
i = 0
while len(v) - i > k:
    ans += v[i]
    i += 1

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

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

dp = [float('inf')] * n
dp[0] = 0
# 足場を一つづつ見ていく
for i in range(1, n):
    for j in range(max(0,i-k),i):
        # 今の足場へのコストと、他の足場から来た場合のコストを比較
        dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]))
print(dp[-1])

### FIXED CODE ###

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

dp = [0] * n
for i in range(1, n):
    dp[i] = min(dp[j] + abs(h[j] - h[i]) for j in range(max(i-k,0),i))
print(dp[-1])
### BUGGY CODE ###

import numpy as np
N,K=input().split()
N = int(N)
K = int(K)
e = [0]*N

for i in range(N):
    e[i] = int(input())

for i in range(N):
    for j in range(N):      
        if e[i] < e[j]:
            tmp = e[i]
            e[i] = e[j]
            e[j] = tmp

f = [0]*(N - K + 1)
for i in range(N-K+1):
    f[i] = e[K + i - 1] - e[i]

print(np.min(np.array(f)))

### FIXED CODE ###

import numpy as np
N,K=input().split()
N = int(N)
K = int(K)
e = [0]*N

for i in range(N):
    e[i] = int(input())

#for i in range(N):
#    for j in range(N):      
#        if e[i] < e[j]:
#            tmp = e[i]
#            e[i] = e[j]
#            e[j] = tmp

e = list(sorted(e))

f = [0]*(N - K + 1)
for i in range(N-K+1):
    f[i] = e[K + i - 1] - e[i]

print(np.min(np.array(f)))
### BUGGY CODE ###

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

flag = True

for i in range(N):
    if H[i]-1 > min(H[i:N]):
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

flag = True

for i in range(N-1, 0, -1):
    if H[i-1] - 1 == H[i]:
        H[i-1] -= 1
    elif H[i-1] - 1 > H[i]:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

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

def rb(x):
    st = x
    for i in range(q):
        if st == n:
            return True
        if st == -1:
            return False
        if l[i][0] == s[st]:
            if l[i][1] == "R":
                st += 1
            else:
                st -= 1
    if st == n:
        return True
    return False
def lb(x):
    st = x
    for i in range(q):
        if st == -1:
            return True
        if st == n:
            return False
        if l[i][0] == s[st]:
            if l[i][1] == "R":
                st += 1
            else:
                st -= 1
    if st == -1:
        return True
    return False
def bs():
    p = n
    ng = -1
    while abs(p - ng) > 1:
        m = (p+ng)//2
        if rb(m):
            p = m
        else:
            ng = m
    return p
def bs2():
    p = -1
    ng = n
    while abs(p-ng) > 1:
        m = (p+ng)//2
        if lb(m):
            p = m
        else:
            ng = m
    return p
print(bs() - bs2() -1)


### FIXED CODE ###

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

def rb(x):
    st = x
    for i in range(q):
        if st == n:
            return True
        if st == -1:
            return False
        if l[i][0] == s[st]:
            if l[i][1] == "R":
                st += 1
            else:
                st -= 1
    if st == n:
        return True
    return False
def lb(x):
    st = x
    for i in range(q):
        if st == -1:
            return True
        if st == n:
            return False
        if l[i][0] == s[st]:
            if l[i][1] == "R":
                st += 1
            else:
                st -= 1
    if st == -1:
        return True
    return False
def bs():
    p = n
    ng = -1
    while abs(p - ng) > 1:
        m = (p+ng)//2
        if rb(m):
            p = m
        else:
            ng = m
    return p
def bs2():
    p = -1
    ng = n
    while abs(p-ng) > 1:
        m = (p+ng)//2
        if lb(m):
            p = m
        else:
            ng = m
    return p
print(bs() - bs2() -1)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

import sys
from collections import deque

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = [deque()]
for i in range(N):
    A.append(deque(LIST()))

cnt = N*(N-1)//2
nxtli = set(range(1, N+1))
day = 0
while cnt > 0:
    prev = cnt
    skip = [False] * (N+1)
    # 前回変更があった場所のみでループを回す
    curli = nxtli.copy()
    nxtli = set()
    for i in curli:
        if len(A[i]) and not skip[i]:
            a = A[i][0]
            if len(A[a]) and not skip[a]:
                b = A[a][0]
                if i == b:
                    A[i].popleft()
                    A[a].popleft()
                    # 変更があった場所をセットに入れておく
                    nxtli.add(i)
                    nxtli.add(a)
                    cnt -= 1
                    skip[i] = skip[a] = True
    if prev == cnt:
        print(-1)
        exit()
    day += 1
print(day)


### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
import time
from collections import deque

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = [deque()]
for i in range(N):
    A.append(deque(LIST()))

start = time.time()

cnt = N*(N-1)//2
day = 0
while cnt > 0:
    prev = cnt
    skip = [False] * (N+1)
    for i in range(1, N+1):
        if len(A[i]) and not skip[i]:
            a = A[i][0]
            if len(A[a]) and not skip[a]:
                b = A[a][0]
                if i == b:
                    A[i].popleft()
                    A[a].popleft()
                    cnt -= 1
                    skip[i] = skip[a] = True
    if prev == cnt:
        print(-1)
        exit()
    day += 1

    elapsed_time = time.time() - start
    if elapsed_time > 1:
        print(N*(N-1)//2)
        exit()
print(day)
### BUGGY CODE ###

#A
n = int(input())
a = list(map(int, input().split()))
ans = 1
b=0
for i in a:
    ans *= i
    if ans > 10 ** 18:
        ans = -1
if a == 0:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

#B
n=int(input())
a = list(map(int, input().split()))
a.sort()
ans=1
for i in a:
    ans *= i
    if ans == 0:
        break
    if ans > 10 ** 18:
        ans = -1
        break
print(ans)
### BUGGY CODE ###

A,B,C,N= list(map(int,input().split()))
ans=0
for i in range(0,N//A+1):
   for j in range(0,(N-i*A)//B+1):
      if (N-i*A-j*B)%C==0 and (N-i*A-j*B)>-1:
         ans+=1
print(ans)

### FIXED CODE ###

A,B,C,N= list(map(int,input().split()))
ans=0
for i in range(0,N//A+1):
   for j in range(0,(N-i*A)//B+1):
      if (N-i*A-j*B)%C==0:
         ans+=1
print(ans)
### BUGGY CODE ###

import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
N = int(input())
E = [[] for _ in range(N)]
for j in range(N):
	t = input()
	for i in range(N):
		if t[i] == '1':
			E[j].append(i)

ANS = -1
for start in range(N):		
	cnt = np.zeros(N, dtype = np.int64)
	cnt[start] = 1
	q = [start]
	cond = 0
	while q:
		cp = q.pop(0)
		if cp < 0:
			continue
		cnt[cp] *= -1

		for nep in E[cp]:
			if cnt[nep] < 0:
				continue
			elif cnt[nep] > 0:
				if cnt[nep] == cnt[cp] * (-1) + 1:
					continue
				else:
					cond = 1
					break
			else:
				cnt[nep] = cnt[cp] * (-1) + 1
				q.append(nep)
	
	if cond:
		continue

	ans = min(cnt) * (-1)
	ANS = max(ANS, ans)

print(ANS)
		

### FIXED CODE ###

N = int(input())
E = [[] for _ in range(N)]
for j in range(N):
	t = input()
	for i in range(N):
		if t[i] == '1':
			E[j].append(i)

ANS = -1
for start in range(N):		
	cnt = [0] * N
	cnt[start] = 1
	q = [start]
	cond = 0
	while q:
		cp = q.pop(0)
		if cp < 0:
			continue
		cnt[cp] *= -1

		for nep in E[cp]:
			if cnt[nep] < 0:
				continue
			elif cnt[nep] > 0:
				if cnt[nep] == cnt[cp] * (-1) + 1:
					continue
				else:
					cond = 1
					break
			else:
				cnt[nep] = cnt[cp] * (-1) + 1
				q.append(nep)
	
	if cond:
		continue

	ans = min(cnt) * (-1)
	ANS = max(ANS, ans)

print(ANS)
### BUGGY CODE ###

#!/usr/bin/env python3
#ABC84 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7


def get_prime(n):
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,n+1):
        for j in range(i*2,n+1,i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

prime = get_prime(10**5)
ansprime = [float('inf')]*(10**5)
for i in range(1,10**5+1,2):
    if i not in prime:
        continue
    if (i+1)//2 not in prime:
        continue
    ansprime[i] = i
ansprime.sort()
q = int(input())
for _ in range(q):
    l,r = map(int,input().split())
    li = bisect.bisect_left(ansprime,l)
    ri = bisect.bisect_right(ansprime,r)
    print(ri-li)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC84 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7


def get_prime(n):
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2,n+1):
        for j in range(i*2,n+1,i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

prime = get_prime(10**5)
ansprime = [float('inf')]*(10**5)
for i in range(1,10**5+1,2):
    if i not in prime:
        continue
    if (i+1)//2 not in prime:
        continue
    ansprime[i] = i
ansprime.sort()
q = int(input())
for _ in range(q):
    l,r = map(int,input().split())
    li = bisect.bisect_left(ansprime,l)
    ri = bisect.bisect_right(ansprime,r)
    print(ri-li)
### BUGGY CODE ###

def main():
  A, B, K = map(int, input().split())
  
  for _ in range(K):
    if A >= 1:
      A -= 1
      continue
    elif B >= 1:
      B-= 1
      continue
    elif A == 0 and B == 0:
      break
  
  print(A, B)
  
  
  
main()

### FIXED CODE ###

def main():
  A, B, K = map(int, input().split())
  
  if K <= A:
    print(A - K, B)
  elif K > A and B >= K - A:
    print(0, B - (K - A))
  elif K > A and B < (K - A):
    print(0, 0)
  
  
  
main()