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

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


def binarysearch(lista,b):
    left=0
    right=len(lista)
    while left<right:
        mid=(left+right)//2
        if lista[mid]>=b:
            right=mid
        else:
            left=mid+1
            mid+=1
    return mid

ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        ans+=(binarysearch(l,l[i]+l[j])-(j+1))
print(ans)






### FIXED CODE ###

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


def binarysearch(lista,b):
    left=0
    right=len(lista)
    while left<right:
        mid=(left+right)//2
        if lista[mid]>=b:
            right=mid
        else:
            left=mid+1
            mid+=1
    return mid

ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        ans+=(binarysearch(l,l[i]+l[j])-(j+1))
print(ans)
### BUGGY CODE ###

n=int(input())
L=list(map(int,input().split()))
L.sort()
count=0
for i in range(n-2):
  for j in range(i+1,n-1):
    x=j+1
    y=n-1
    while y!=x:
      if L[i]+L[j]>L[(x+y)//2]:
        x=(x+y)//2
      else:
        y=(x+y)//2
    p=y if L[i]+L[j]>L[y] else x
    if L[i]+L[j]<=L[p]:
      count+=0
    else:
      count+=p-j
print(count)

### FIXED CODE ###

n=int(input())
L=list(map(int,input().split()))
L.sort()
count=0
for i in range(n-2):
  for j in range(i+1,n-1):
    x=j+1
    y=n-1
    while y!=x+1 and y!=x:
      if L[i]+L[j]>L[(x+y)//2]:
        x=(x+y)//2
      else:
        y=(x+y)//2
    p=y if L[i]+L[j]>L[y] else x
    if L[i]+L[j]<=L[p]:
      count+=0
    else:
      count+=p-j
print(count)
### BUGGY CODE ###

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
#%%
temp1 = 1
T = A[0: K]
for i in T:
    temp1 *= i

arr = []
arr.append(temp1)

for i in range(K, N):
    temp1 = arr[-1]
    temp2 = arr[-1]
    temp2 /= A[i - K]
    temp2 *= A[i]
    arr.append(temp2)
    if temp1 < temp2:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###


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

#%%

for i in range(K, N):
    if A[i - K] < A[i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

n = int(input())
left = 0
right = n - 1
print(left)
sl = input()
if sl[0] == "V":
    quit()
# print(right)
# sr = input()
# if sr[0] == "V":
#     quit()
while left < right:
    mid = (left + right) // 2
    print(mid)
    sm = input()
    if sm[0] == "V":
        quit()

    if (mid - left + 1) % 2 == 1 and sm != sl:
        # left += 1
        right = mid - 1
        continue
    elif (right - mid + 1) % 2 == 0 and sm == sl:
        # left += 1
        right = mid - 1
        continue
    else:
        left = mid + 1


### FIXED CODE ###

n = int(input())

left = 0
right = n
print(left, flush=True)
sl = input()
if sl[0] == "V":
    quit()
while right - left > 1:
    mid = (left + right) // 2
    print(mid, flush=True)
    sm = input()
    if sm[0] == "V":
        quit()

    if ((mid - left) % 2 == 1) ^ (sl == sm):
        left = mid
        sl = sm
    else:
        right = mid
### BUGGY CODE ###

import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    H, W, M = [int(x) for x in input().split()]
    HW = [[int(x) for x in input().split()] for _ in range(M)]

    x = set()

    hc = collections.Counter()
    wc = collections.Counter()

    for h, w in HW:
        hc[h] += 1
        wc[w] += 1
        x.add((h, w))

    ans = 0
    hcma = hc.most_common()[0][1]
    wcma = wc.most_common()[0][1]
    for a in hc.most_common():
        if a[1] != hcma:
            break
        for b in wc.most_common():
            if b[1] != wcma:
                break
            if (a[0], b[0]) in x:
                ans = max(ans, hcma + wcma - 1)
            else:
                ans = max(ans, hcma + wcma)

    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    H, W, M = [int(x) for x in input().split()]
    HW = [[int(x) for x in input().split()] for _ in range(M)]

    x = set()

    hc = collections.Counter()
    wc = collections.Counter()

    for h, w in HW:
        hc[h] += 1
        wc[w] += 1
        x.add((h, w))

    ans = 0
    hcma = hc.most_common()[0][1]
    wcma = wc.most_common()[0][1]
    f = False
    bost_common = wc.most_common()
    for a in hc.most_common():
        if a[1] != hcma:
            break
        for b in bost_common:
            if b[1] != wcma:
                break
            if (a[0], b[0]) in x:
                ans = max(ans, hcma + wcma - 1)
            else:
                ans = max(ans, hcma + wcma)
                f = True
                break
        if f:
            break

    print(ans)


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

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

import math
import itertools
import re

# 入力
N = int(input())
S = str(input())
#M1, D1 = map(int, input().split())

si = ""
cnt = 0
for i in range(1000) :
  
  si = str(i).zfill(3)
  pattern = "^.*"+ si[0] + ".*" + si[1] + ".*" + si[2] + ".*$"
  
  if re.search(pattern, S) :
    cnt += 1

print (cnt)
    

### FIXED CODE ###

# -*- coding: utf-8 -*-
 
import math
import itertools
import re
 
# 入力
N = int(input())
S = str(input())
#M1, D1 = map(int, input().split())
 
si = ""
cnt = 0
for i in range(1000) :
  
  si = str(i).zfill(3)
  
  c = 0
  for x in range(N) :
    if S[x] == si[c] :
      c += 1
      if c == 3 :
        cnt += 1
        break    

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

N, K = map(int, input().split())
X = list(map(int, input().split()))
 
 
def mindist(XLIST):
    cand1 = abs(XLIST[0]) + abs(XLIST[0] - XLIST[-1])
    cand2 = abs(XLIST[-1]) + abs(XLIST[0] - XLIST[-1])
    return(min([cand1, cand2]))
 
dist = float('Inf')
for i in range(N - K + 1):
    dist_ = mindist(X[i:(i+K)])
    if (dist_ < dist):
        dist = dist_
 
print(dist)

### FIXED CODE ###

N, K = map(int, input().split())
X = list(map(int, input().split()))

dist = []
for i in range(N-K+1):
    dist.append(abs(X[i]) + abs(X[K+i-1]-X[i]))
    dist.append(abs(X[K+i-1]) + abs(X[i]-X[K+i-1]))

if not len(dist) == 0:
    print(min(dist))
else:
    print(0)
### BUGGY CODE ###

def solve(Card):
  n = len(Card)
  if n==2: return 0
  x=[]
  for i in range(0,n-2,2):
    tmp = Card[:]
    T = tuple(Card[i:i+4])
    if T not in d: d[T] = reduce(lambda a,b: a*b, T)
    tmp[i+1:i+3]=[]
    x.append(d[T]+solve(tmp))
  return min(x)
    
d={}
n = int(raw_input())
Card=[]
for _ in [0]*n: Card += map(int,raw_input().split())
print solve(Card)

### FIXED CODE ###

n = int(raw_input())
C = [[] for _ in [0]*n]
W = {}
for i in range(n):
  C[i] = map(int, raw_input().split())
  W[(i, i)] = 0
for i in range(1, n):
  for j in range(0, n-i):
    a = j+i
    W[(j, a)] = min([C[j][0] * C[k][1] * C[k+1][0] * C[a][1] + W[(j, k)] + W[(k+1, a)] for k in range(j, a)])
print W[0, n-1]
### BUGGY CODE ###

a,b,c,d=map(int,input().split())
ans = 0
for i in range(a,b+1):
  if i%c!=0 and i%d!=0:
    ans += 1
print(ans)

### FIXED CODE ###

a,b,c,d=map(int,input().split())
C=b//c
D=b//d
import fractions
CD=b//(c*d//(fractions.gcd(c,d)))
B=b-C-D+CD
C_=(a-1)//c
D_=(a-1)//d
C_D_=(a-1)//(c*d//(fractions.gcd(c,d)))
A=a-1-C_-D_+C_D_
print(B-A)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000)
n = int(input())
*A, = map(int, input().split())
A = [(a, i) for i, a in enumerate(A)]
A.sort(reverse=True)
DP = [[None for r in range(n+1)] for l in range(n+1)]

def dp(l, r):
    if l == r:
        DP[l][r] = 0
    if DP[l][r] != None:
        return DP[l][r]
    a, i = A[n-(r-l)]
    x = dp(l+1, r)+a*abs(i-l)
    y = dp(l, r-1)+a*abs(i-(r-1))
    DP[l][r] = max(x, y)
    return DP[l][r]

print(dp(0, n))

### FIXED CODE ###

n = int(input())
*A, = map(int, input().split())
# n = 6
# A = [8, 6, 9, 1, 2, 1]
# n = 4
# A = [1, 3, 4, 2]
A = [(a, i) for i, a in enumerate(A)]
A.sort(reverse=True)
DP = [[0 for r in range(n+1)] for l in range(n+1)]
for l in range(n):
    for r in range(n-l):
        a, i = A[l+r]
        DP[l+1][r] = max(DP[l+1][r], DP[l][r]+a*abs(i-l))
        DP[l][r+1] = max(DP[l][r+1], DP[l][r]+a*abs(i-(n-1-r)))
print(max([DP[l][n-l] for l in range(n)]))
### BUGGY CODE ###

n = int(input())

btn_list = {i:int(input()) for i in range(1,n+1)}

count = 0
btn = 1

while True:
    if btn == 2:
        print(count)
        break
    elif btn == 1 and count != 0:
        print(-1)
        break
    else:
        count += 1
        btn = btn_list[btn]

### FIXED CODE ###

n = int(input())

btn_list = {i:int(input()) for i in range(1,n+1)}

count = 1
right = btn_list[1]

while True:
    if right == 2:
        print(count)
        break
    elif count == n:
        print(-1)
        break
    else:
        count += 1
        right = btn_list[right]
### BUGGY CODE ###

n=int(input())
s=input()
ans=s[0]
for i in range(1,n):
    if s[i]!=s[i-1]:
        ans+=s[i]
print(len(ans))  

### FIXED CODE ###

n=int(input())
s=input()
print(sum(s[i]!=s[i-1] for i in range(1,n))+1)
### BUGGY CODE ###

D = []
c = []
d0 = {}
d1 = {}
d2 = {}
N,C = map(int,input().split())
for i in range(C):
    D.append(list(map(int,input().split())))
for i in range(N):
    c.append(list(map(int,input().split())))

for i in range(C):
    d0[i+1]=0
    d1[i+1]=0
    d2[i+1]=0

for i in range(N):
    for j in range(N):
        for k in range(C):
            if (i+j)%3==0:
                d0[k+1]+=D[c[i][j]-1][k]
            elif (i+j)%3==1:
                d1[k+1]+=D[c[i][j]-1][k]
            else:
                d2[k+1]+=D[c[i][j]-1][k]
l = []
for C1 in range(C):
    for C2 in range(C):
        for C3 in range(C):
            if C1 != C2 and C2 != C3 and C3 != C1:
                l.append(d0[C1+1]+d1[C2+1]+d2[C3+1])

print(min(l))

### FIXED CODE ###

import numpy as np
D = []
c = []
d0 = {}
d1 = {}
d2 = {}

N,C = map(int,input().split())
a = np.zeros((3,C))
for i in range(C):
    D.append(list(map(int,input().split())))
for i in range(N):
    c.append(list(map(int,input().split())))

D = np.array(D)
c = np.array(c)

for i in range(N):
    for j in range(N):
        a[(i+j)%3] += D[c[i][j]-1]

l = []
for C1 in range(C):
    for C2 in range(C):
        for C3 in range(C):
            if C1 != C2 and C2 != C3 and C3 != C1:
                l.append(a[0][C1]+a[1][C2]+a[2][C3])

print(int(min(l)))
### BUGGY CODE ###

x,k,d = map(int, input().split())
if abs(x)>=k*d:
  if x>=0:
    x -= k*d
    print(abs(x))
    exit()
  else:
    x += k*d
    print(abs(x))
    exit()
for i in range(k):
  if x>=0:
    x -= d
    if x<=0:
      if (k-i-1)%2==1:
        x += d
      break
  else:
    x += d
    if x>=0:
      if (k-i-1)%2==1:
        x -= d
      break
print(abs(x))

### FIXED CODE ###

x,k,d = map(int, input().split())
m = abs(x)//d
if m>=k:
  print(abs(x)-k*d)
else:
  k -= m
  if x>=0:
    x -= m*d
  else:
    x += m*d
  
  if x>=0:
    x -= d
    if x<=0:
      if (k-1)%2==1:
        x += d
  else:
    x += d
    if x>=0:
      if (k-1)%2==1:
        x -= d
  print(abs(x))
### BUGGY CODE ###

def p_c():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    l = [-1] * N

    for i in range(N):
        l[i] = B[i - 1] + B[(i + 1) % N]

    ans = 0

    while 1:
        f = False
        for i in range(N):
            if A[i] <= B[i] - l[i]:
                f = True
                ans += 1
                B[i] -= l[i]
                l[i - 1] -= l[i]
                l[(i + 1) % N] -= l[i]
        if not f:
            break

    if A != B:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    p_c()


### FIXED CODE ###

def p_c():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    l = [-1] * N

    for i in range(N):
        l[i] = B[i - 1] + B[(i + 1) % N]

    ans = 0

    while 1:
        f = False
        for i in range(N):
            if A[i] <= B[i] - l[i]:
                f = True
                n = (B[i] - A[i]) // l[i]
                ans += n
                B[i] -= n * l[i]
                l[i - 1] -= n * l[i]
                l[(i + 1) % N] -= n * l[i]
        if not f:
            break

    if A != B:
        print(-1)
    else:
        print(ans)


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

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

l = []
amount = 0

for i in range(N - 1):
    for j  in range(i,N-1):
        if numbers[j] == i+1:
            amount = amount + 1 
    print(amount)
    amount = 0
print(0)


### FIXED CODE ###

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

result = [0] * N
for i in numbers:
    result[i- 1] += 1
    
for i in range(N-1):
    print(result[i])
print(0)
### BUGGY CODE ###

import itertools
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,MOD = map(int,input().split())
if N == 1:
    print(1)
    exit()
graph = [set() for _ in range(N+1)]
for _ in range(N-1):
    x,y = map(int,input().split())
    graph[x].add(y)
    graph[y].add(x)

dp_1 = [None] * (N+1)
products = [[] for _ in range(N+1)]

def dfs_1(v=1,parent=None):
    # 子ごとに、そこを黒くして適切 or 完全白
    # dp_1 + 1 の積
    x = 1
    graph[v].discard(parent)
    if graph[v]:
        arr = [dfs_1(w,v)+1 for w in graph[v]]
        L = [1] + list(itertools.accumulate(arr[:-1], lambda x,y: x*y%MOD))
        R = list(itertools.accumulate(arr[1:][::-1], lambda x,y: x*y%MOD))[::-1] + [1]
        products[v] = [x*y%MOD for x,y in zip(L,R)]
        dp_1[v] = products[v][0] * arr[0] % MOD
    else:
        dp_1[v] = 1
    return dp_1[v]

dp_1 = [0] * (N+1) # 自分を黒く塗って、子側の部分木を適切に塗る方法
dfs_1()


def dfs_2(v=1,x=1):
    # それぞれの子以外の情報をマージして、子に渡さなければいけない
    dp[v] = x * dp_1[v] % MOD
    for w,p in zip(graph[v],products[v]):
        dfs_2(w,x*p%MOD+1)

dp = [None] * (N+1)
dfs_2()

print('\n'.join(map(str,dp[1:])))

### FIXED CODE ###

import itertools
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,MOD = map(int,input().split())
if N == 1:
    print(1)
    exit()
graph = [set() for _ in range(N)]
for row in sys.stdin.readlines():
    x,y = map(int,row.split())
    graph[x-1].add(y-1)
    graph[y-1].add(x-1)

ldp = [None] * N
rdp = [None] * N

def dfs_1(v=0,parent=None):
    # 子ごとに、そこを黒くして適切 or 完全白
    graph[v].discard(parent)
    ldp[v] = [1] * (len(graph[v])+1)
    rdp[v] = [1] * (len(graph[v])+1)
    vals = [dfs_1(w,v)+1 for w in graph[v]]
    for i,x in enumerate(vals,1):
        ldp[v][i] = ldp[v][i-1] * x % MOD
    for i,x in enumerate(reversed(vals),1):
        rdp[v][-i-1] = rdp[v][-i] * x % MOD
    return ldp[v][-1]

dfs_1()

dp = [None] * N
q = [(0,1)]
while q:
    v,x = q.pop()
    dp[v] = x*ldp[v][-1]%MOD
    for w,L,R in zip(graph[v],ldp[v][:-1],rdp[v][1:]):
        q.append((w,x*L*R%MOD+1))

print('\n'.join(map(str,dp)))
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
A = list(set(a))
flag = True
if n%2==0:
  if a.count(0)>0:
    flag=False
  else:
    for i in A:
      if a.count(i)!=2:
        flag=False
        break
else:
  if a.count(0)!=1:
    flag=False
  else:
    A.pop(A.index(0))
    for j in A:
      if a.count(j)!=2:
        flag=False
        break
if flag==True:
    print((2**(n//2))%(10**9+7))
else:
  print(0)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
A = list(set(a))
flag = True
if n%2==0:
  if a.count(0)>0 or len(A)!=len(a)//2:
    flag=False
else:
  if a.count(0)!=1 or len(A)!=len(a)//2+1:
    flag=False
if flag==True:
    print((2**(n//2))%(10**9+7))
else:
  print(0)
### BUGGY CODE ###

import sys
import queue

input = sys.stdin.readline

N, M = map(int,input().split())
vy = [list(map(lambda x:int(x)-1,input().split())) for i in range(M)]
s, t = map(lambda x:int(x)-1,input().split())

nlist = [[] for i in range(N)]
for v, y in vy:
    nlist[v].append(y)

newnlist = [set() for i in range(N)]
for i in range(N):
    for first in nlist[i]:
        for second in nlist[first]:
            for third in nlist[second]:
                newnlist[i].add(third)

def bfs():
    visit = [False] * N
    Q = queue.Queue()
    visit[s] = True
    Q.put([s,0])
    while not Q.empty():
        node = Q.get()
        if node[0] == t:
            return node[1]
        for i in newnlist[node[0]]:
            if not visit[i]:
                visit[i] = True
                Q.put([i,node[1]+1])
    return -1

ans = bfs()
print(ans)




### FIXED CODE ###

import sys
import queue

input = sys.stdin.readline

N, M = map(int,input().split())
vy = [list(map(lambda x:int(x)-1,input().split())) for i in range(M)]
s, t = map(lambda x:int(x)-1,input().split())

nlist = [[[] for j in range(3)] for i in range(N)]
for v, y in vy:
    nlist[v][0].append([y,1])
    nlist[v][1].append([y,2])
    nlist[v][2].append([y,0])

visit = [[False]*3 for i in range(N)]

def bfs(visit):
    Q = queue.Queue()
    visit[s][0] = True
    Q.put([[s,0],0])
    while not Q.empty():
        node = Q.get()
        if node[0][0] == t and node[0][1] == 0:
            return node[1]
        for i in nlist[node[0][0]][node[0][1]]:
            if not visit[i[0]][i[1]]:
                visit[i[0]][i[1]] = True
                Q.put([[i[0],i[1]],node[1]+1])
    return -1

ans = bfs(visit)
if visit[t][0]:
    print(ans//3)
else:
    print(ans)
### BUGGY CODE ###

K = int(input())
count = 0
an = 0

if K%2 == 0 or K%2 ==0:
    print("-1")
    exit(0)
while True:
  an = (10*an + 7) % K
  count +=1
  if an == 0:
    print(count)
    break

### FIXED CODE ###

def calc(k):
    cur = 0
    for i in range(1, 10 ** 7):
        cur *= 10
        cur += 7
        cur %= k
        if cur == 0:
            return i

    return -1


k = int(input())
print(calc(k))
### BUGGY CODE ###

n,t = map(int,input().split())
ab = [[int(i) for i in input().split()] for j in range(n)]

dp = [[0 for i in range(t)] for j in range(n+1)]

ans = 0

for h in range(n):
    dp = [[0 for i in range(t)] for j in range(n+1)]
    for i in range(n):
        if h == 0 and i == 0:
            continue
        if h == i:
            dp[i+1] = dp[i]
            continue
        for j in range(t):
            #print(h,i)
            dp[i+1][j] = dp[i][j]
            #print(j,ab[i][0])
            if j < ab[i][0]:
                #print(j)
                continue
            #if dp[i][j] < dp[i][j-ab[i][0]] + ab[i][1]:
            #    dp[i+1][j] = dp[i][j-ab[i][0]] + ab[i][1]
            dp[i+1][j] = max(dp[i][j],dp[i][j-ab[i][0]] + ab[i][1])
            #print(dp)
    #print(h,dp)
    ans = max(ans,dp[n][t-1]+ab[h][1])


print(ans)

### FIXED CODE ###

n,t = map(int,input().split())
ab = [[int(i) for i in input().split()] for j in range(n)]

dp = [[0 for i in range(t)] for j in range(n+1)]
ab.sort()

ans = 0

for i in range(n):
    for j in range(t):
        #for k in range(2):
        #dp[i+1][j] = max(dp[i][j],dp[i-1][j])
        dp[i+1][j] = dp[i][j]
        #print(j,ab[i][0])
        if j >= ab[i][0]:
        #if dp[i][j] < dp[i][j-ab[i][0]] + ab[i][1]:
        #    dp[i+1][j] = dp[i][j-ab[i][0]] + ab[i][1]
            dp[i+1][j] = max(dp[i][j],dp[i][j-ab[i][0]] + ab[i][1])
        #print(dp)
    #print(h,dp)

#print(ab)
#print(dp)


max_num = [0]*n

for i in reversed(range(n)):
    #print(i)
    if i == 0:
        break
    if max_num[i] < ab[i][1]:
        max_num[i-1] = ab[i][1]
    else:
        max_num[i-1] = max_num[i]

#print(max_num)
#print(ab[2272:2336])
#exit()

ans = 0
for i in range(n-1):
    #print(i)
    if ans < dp[i+1][t-1]+max_num[i]:
        ans = dp[i+1][t-1]+max_num[i]
        #print(i,ans,max_num[i],max_num[i+1],max_num[i-1])
    #ans = max(ans,)
    #print(max(ab[i:][1]))
    #print()
        
print(ans)
#print())
### BUGGY CODE ###

n=int(input())
l=[]
l1=[[] for i in range(n+1)]
d=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(n-1):
  a,b=map(int,input().split())
  l1[a].append(b)
  l1[b].append(a)
  l.append([a,b])
max1=0
for i in l1:
  if max1<len(i):
    max1=len(i)
def dfs(x,y):#xは頂点yは入ってくる色
  l2=l1[x]
  now=1
  for i in range(len(l2)):
    if d[x][l2[i]]!=0:
      pass
    else:                
      if now==y:
        now+=1
      d[x][l2[i]]=now
      d[l2[i]][x]=now
      dfs(l2[i],now)
      now+=1
print(max1)
dfs(1,0)
for i in range(len(l)):
  print(d[l[i][0]][l[i][1]])

### FIXED CODE ###

n=int(input())
l=[]
import sys
sys.setrecursionlimit(20000000)
from collections import defaultdict
d=defaultdict(lambda:defaultdict(int))
l1=[[] for i in range(n+1)]
#d=[[0 for i in range(n+1)] for j in range(n+1)]
for i in range(n-1):
  a,b=map(int,input().split())
  l1[a].append(b)
  l1[b].append(a)
  l.append([a,b])
max1=0
for i in l1:
  if max1<len(i):
    max1=len(i)
def dfs(x,y):#xは頂点yは入ってくる色
  l2=l1[x]
  now=1
  for i in range(len(l2)):
    if d[x][l2[i]]!=0:
      pass
    else:                
      if now==y:
        now+=1
      d[x][l2[i]]=now
      d[l2[i]][x]=now
      dfs(l2[i],now)
      now+=1
print(max1)
dfs(1,0)
for i in range(len(l)):
  print(d[l[i][0]][l[i][1]])
### BUGGY CODE ###

from functools import reduce

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

def gcd_list(numbers):
    return reduce(gcd, numbers)

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

max_ans = 0
for i in range(len(A)):
    tmp = A[:i] + A[1+i:]
    ans = gcd_list(tmp)
    if max_ans < ans:
        max_ans = ans
print(max_ans)

### FIXED CODE ###

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a


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

# 累積最大公約数的な
head = []
tail = []
head.append(A[0])
tail.append(A[-1])
for i, j in zip(A[1:], A[N-2::-1]):
    head.append(gcd(head[-1], i))
    tail.append(gcd(tail[-1], j))
ans = 0
for i in range(len(head)-2):
    tmp = gcd(head[i], tail[len(tail)-1-2-i])
    if ans < tmp:
        ans = tmp
print(max(head[-1], head[-2], tail[-2], ans))
### BUGGY CODE ###

n = int(input())
*A, = map(int, input().split())
m = max(2, max(A))
P = {p: True for p in range(2, m + 1)}
for i in range(2, m + 1):
    for j in range(2 * i, m + 1, i):
        P[j] = False
P = {p: 0 for p in P if P[p]}
for a in A:
    for p in P:
        if a % p == 0:
            P[p] += 1
s = max(P.values())
if s <= 1:
    print('pairwise coprime')
elif s < n:
    print('setwise coprime')
else:
    print('not coprime')


### FIXED CODE ###

n = int(input())
*A, = map(int, input().split())

m = max(A)
is_prime = [True] * (m + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, m + 1):
    for j in range(i * 2, m + 1, i):
        is_prime[j] = False
primes = [i for i in range(m + 1) if is_prime[i]]

Amap = {a: 0 for a in range(1, m + 1)}
for a in A:
    Amap[a] += 1

# Pmap[p]はAにでてくるpの倍数の数
Pmap = {p: 0 for p in primes}
for p in primes:
    for a in range(p, m + 1, p):
        Pmap[p] += Amap[a]

try:
    score = max(Pmap.values())
except BaseException:
    print('pairwise coprime')
    exit()
if score == 1:
    print('pairwise coprime')
elif score != n:
    print('setwise coprime')
else:
    print('not coprime')
### BUGGY CODE ###

# coding: utf-8
# Your code here!

input_line = input()
abk = input_line.split(" ") 
ABK = [int(n) for n in abk]


for i in range(ABK[2]):
    if ABK[0] > 0:
        ABK[0] -= 1
        ABK[2] -= 1
        if ABK[2]==0:
            break
    elif ABK[1] > 0: 
        ABK[1] -= 1
        ABK[2] -= 1
        if ABK[2]==0:
            break
    else:
        pass

print(ABK[0]," ",ABK[1])




### FIXED CODE ###


input_line = input()
abk = input_line.split(" ") 
ABK = [int(n) for n in abk]



if ABK[0] + ABK[1] <= ABK[2]:
    A = 0
    B = 0

elif ABK[0] <= ABK[2] and ABK[1] > ABK[2] - ABK[0]:
    A = 0
    B = ABK[1] -  (ABK[2] - ABK[0])

elif ABK[0] > ABK[2]:
    A = ABK[0] - ABK[2]
    B = ABK[1]

    
print(A," ",B)