Harryxun/stf_run huggingface dataset:
import sys
S0=raw_input()
S1=list(S0)
T=list(raw_input())
#print S1
#print T

l=len(T)

S=[]

for i in range(3):
	for j in range(l):
		#print i+j,j,S1[i+j],T[j]
		if S1[i+j]!=T[j] and S1[i+j]!="?":
			#print "break"
			break
	else:
		#print "else"
		for j in range(l):
			S1[i+j]=T[j]
	
if S0==''.join(S1):
	print "UNRESTORABLE"
	sys.exit()
	

S2=''.join(S1)
print S2.replace('?','a')
	


### FIXED CODE ###

import sys
S0=raw_input()
T=list(raw_input())

l=len(T)

if len(S0)<len(T):
	print "UNRESTORABLE"
	sys.exit()


ans=""
for i in range(len(S0)-l+1):
	S1=list(S0)
	#print S1
	for j in range(l):
		#print i+j,j,S1[i+j],T[j]
		if S1[i+j]!=T[j] and S1[i+j]!="?":
			#print "break"
			break
	else:
		#print "else"
		for j in range(l):
			S1[i+j]=T[j]
		S_tmp=(''.join(S1)).replace('?','a')
		#print ans
		#print S_tmp
		if ans=="":
			ans=S_tmp
		if S_tmp < ans:
			ans=S_tmp
			
	
if ans=="":
	print "UNRESTORABLE"
	sys.exit()
else:
	print ans
=list(input())
#sのi番目の次に＋かーを入れる。それまでの文字列char,合計sum
def dfs(i,char,sum):
  if i==3:
    if sum==7:
      print(char+"=7")
      exit()
  else:
    dfs(i+1,char+"+"+s[i+1],sum+int(s[i+1]))  
    dfs(i+1,char+"-"+s[i+1],sum-int(s[i+1]))
        
    
      
    
      
dfs(0,s[0],int(s[0]))

### FIXED CODE ###

s=list(input())
#sのi番目の次に＋かーを入れる。それまでの文字列char,合計sum
def dfs(i,char,sum):
  if i==3:
    if sum==7:
      print(char+"=7")
      exit()
  else:
    dfs(i+1,char+"+"+s[i+1],sum+int(s[i+1]))  
    dfs(i+1,char+"-"+s[i+1],sum-int(s[i+1]))
        
    
      
    
      
dfs(0,s[0],int(s[0]))
from itertools import combinations

n = int(input())
lst = list(map(int, input().split()))
comb = combinations(lst, 3)
count = 0

for i in comb:
  if i[0] != i[1] and i[1] != i[2]:
	  if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
    	count += 1
    
print(count)


### FIXED CODE ###

from itertools import combinations

n = int(input())
lst = list(map(int, input().split()))
comb = combinations(lst, 3)
count = 0

for i in comb:
  if i[0] != i[1] and i[1] != i[2] and i[0] != i[2]:
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
      count += 1
    
print(count)
N,Y = map(int,input().split())
exist_flag = False
for i in range(N+1):
    for j in range(N+1-i):
        if Y == 10000*i + 5000*j + 1000*(N-i-j):
            exist_flag = True
            break
    if exist_flag:
        break
if not exist_flag:
    i,j,k = -1, -1, -1
print(i, j, k)

### FIXED CODE ###

s = input()
print(s.replace('2017', '2018'))
s = input()
l = len(s)
a = s[:(l-1)/2]
b = len(a)
print("Yes" if s[:(l-1)/2] == s[(l+1)/2:] and a[:(b-1)/2] == a[(b+1)/2:] else "No")

### FIXED CODE ###

s = input()
l = len(s)
a = s[0:(l-1)//2]
b = len(a)
print("Yes" if s == s[::-1] and a == a[::-1] else "No")
from collections import Counter


def i1str():
    return input()


def istrs(n=None):
    if n is None:
        return input().split()
    a = []
    for _ in range(n):
        a.append(istrs())
    return a


def i1num():
    return int(input())


def inums(n=None):
    if n is None:
        return list(map(int, input().split()))
    a = []
    for _ in range(n):
        a.append(inums())
    return a


def ostrs(l, sp=" "):
    print(sp.join(l))


def onums(l, sp=" "):
    print(sp.join(map(str, l)))


def solve(n, a):
    cnt = Counter(a)
    for i in range(n):
        print(cnt[i+1])


if __name__ == "__main__":
    n = i1num()
    a = inums()
    solve(n, a)


### FIXED CODE ###

def i1str():
    return input()


def istrs(n=None):
    if n is None:
        return input().split()
    a = []
    for _ in range(n):
        a.append(istrs())
    return a


def i1num():
    return int(input())


def inums(n=None):
    if n is None:
        return list(map(int, input().split()))
    a = []
    for _ in range(n):
        a.append(inums())
    return a


def ostrs(l, sp=" "):
    print(sp.join(l))


def onums(l, sp=" "):
    print(sp.join(map(str, l)))


def solve(n):
    pi = 3.14159
    return 2*pi*n


if __name__ == "__main__":
    n = i1num()
    print(solve(n))
N = int(input())
A = list(map(int, input().split()))
 
ans = 0
 
for i in range(N):
    ans = ans + 1 / A[i]
 
ans = 1 / ans 
 
print(ans)

### FIXED CODE ###

a = int(input())
s = input()

if a >= 3200:
    print(s)
else:
    print("red")
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))


"""
N^2なので素直に計算は無理，部分和を使いたいのでとりあえず累積和
[i+1:j]が条件を満たすとはS[j]-S[i]とj-iが合同．
移行して，S[j]-jとS[i]-iが合同
基本は個数だけ見れば良い

これだけだと，個数がKより大きい時にダメ
直近Kこの情報だけ持つ，今見てる数字が直近K個のものと何個組にできるか
"""
def main():

    mod=10**9+7
    N,K=MI()
    A=LI()
    from collections import defaultdict
    dd = defaultdict(int)
    
    S=[0]*(N+1)
    for i in range(N):
        S[i+1]=(S[i]+A[i])%K
        
    ans=0
    for i in range(K):
        temp=(S[i]-i)%K
        ans+=dd[temp]
        dd[temp]+=1
        
    for i in range(K,N+1):
        temp=(S[i]-i)%K
        temp_m=(S[(i-K)]-(i-K))%K
        dd[temp_m]-=1
        ans+=dd[temp]
        dd[temp]+=1
        
    print(ans)
        
        
    

        

main()


### FIXED CODE ###

N, K = map(int,input().split())
A = list(map(int, input().split()))
S = [0]*(N+1)
S2 = [0]*(N+1)
dict = {}#最新K件の度数分布の管理

for i in range(N):
    S[i+1]=S[i]+A[i]
    S2[i+1] =(S[i+1]-i-1)%K

ans =0
for i in range(N+1):
    if dict.get(S2[i],0):
        ans += dict[S2[i]]
    dict[S2[i]]=dict.get(S2[i],0)+1
    if i >=K-1:
        dict[S2[i-(K-1)]]-=1

print(ans)
def devide2two(n):
    arr=[]
    arr.append((n-1))
    for i in range(2, int(-(-n**0.5//1))+1):
        if n%i==0:
            a = n/i
            arr.append(i-1+ a-1)
    
    return min(arr)
n = input()
print(devide2two(n))

### FIXED CODE ###

def devide2two(n):
    arr=[]
    arr.append((n-1))
    for i in range(2, int(-(-n**0.5//1))+1):
        if n%i==0:
            a = n/i
            arr.append(i-1+ a-1)
    
    return min(arr)
n = int(input())
print(int(devide2two(n)))
n, m, k = map(int, input().split())
clusterN = [1] * n
clusterI = [-1] * n
out = [0] * n
def cluster(x):
  if clusterI[x] > 0:
    minI = cluster(clusterI[x])
    clusterI[x] = minI
    return minI
  else:
    return x

def unite(x, y):
  CX = cluster(x)
  CY = cluster(y)
  if CX != CY:
    if clusterI[CX] > clusterI[CY]:
      x, y = y, x
    clusterN[CX] += clusterN[CY]
    clusterI[CY] = CX
    

for _ in range(m):

  a, b = map(int, input().split())

  unite(a-1, b-1)
  out[a-1] -= 1
  out[b-1] -= 1

for _ in range(k):

  a, b = map(int, input().split())
  if cluster(a-1) == cluster(b-1):
    out[a-1] -= 1
    out[b-1] -= 1
out = [out[i] + clusterN[cluster(i)] - 1 for i in range(n)]
print(*out)

### FIXED CODE ###

n, m, k = map(int, input().split())
clusterN = [1] * n
clusterI = list(range(n))
out = [0] * n
def generateC(x):
  if clusterI[x] != x:
    minI = generateC(clusterI[x])
    clusterI[x] = minI
    return minI
  else:
    return x

def unite(x, y):
  CX = generateC(x)
  CY = generateC(y)
  if CX != CY:
    if CX > CY:
      CX, CY = CY, CX
      x, y = y, x
    clusterN[CX] += clusterN[CY]
    clusterI[CY] = CX
    generateC(y)
    

for _ in range(m):
  a, b = map(int, input().split())

  unite(a-1, b-1)
  out[a-1] -= 1
  out[b-1] -= 1

for _ in range(k):

  a, b = map(int, input().split())
  if generateC(a-1) == generateC(b-1):
    out[a-1] -= 1
    out[b-1] -= 1
out = [out[i] + clusterN[generateC(i)] - 1 for i in range(n)]
print(*out)
a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if a+b+c<=21:
  print(win)
else:
  print(bust)

### FIXED CODE ###

a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if a+b+c<=21:
  print("win")
else:
  print("bust")
n = int(input())
a = list(map(str, (range(1, 10))))
total = a[:]
cnt = 9
while cnt < n:
    new = []
    for i in a:
        if i[-1] == "0":
            new = [(i + "0"), (i + "1")]
            cnt += 2
            if cnt >= n:
                break
        elif i[-1] == "9":
            new = [(i + "8"), (i + "9")]
            cnt += 2
            if cnt >= n:
                break
        else:
            new.append(i + str(int(i[-1]) -1))
            new.append(i + str(int(i[-1])))
            new.append(i + str(int(i[-1]) + 1))
            cnt += 3
            if cnt >= n:
                break
    total += new[:]
    a = new[:]
                
print(total[n-1])

### FIXED CODE ###

n = int(input())
a = list(map(str, (range(1, 10))))
total = a[:]
cnt = 9
while cnt < n:
    new = []
    for i in a:
        if i[-1] == "0":
            new.append(i + "0")
            new.append(i + "1")
            cnt += 2
            if cnt >= n:
                break
        elif i[-1] == "9":
            new.append(i + "8")
            new.append(i + "9")
            cnt += 2
            if cnt >= n:
                break
        else:
            new.append(i + str(int(i[-1]) -1))
            new.append(i + str(int(i[-1])))
            new.append(i + str(int(i[-1]) + 1))
            cnt += 3
            if cnt >= n:
                break
    total += new[:]
    a = new[:]
                
print(total[n-1])
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N,M = LI()
    s = [0]*M
    c = [0]*M
    n = 0
    for i in range(M):
        Sn,Cn = LI()
        s[i] = Sn
        c[i] = Cn

    ans = [0]*N
    for k in range(0, M):
        if ans[s[k-1]] == 0:
            ans[s[k]-1]=c[k]
        else:
            n += 1
    if ans[0] == 0 or n!=0:
        print(-1)
    else:
        ans = map(str,ans)
        print(''.join(ans))




if __name__ == "__main__":
	main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N,M = LI()
    s = [0]*M
    c = [0]*M
    n = [0]*3
    for i in range(M):
        Sn,Cn = LI()
        s[i] = Sn
        c[i] = Cn

    if N == 1:
        ans = [0]
    elif N == 2:
        ans = [1, 0]
    elif N == 3:
        ans = [1, 0, 0]

    for k in range(0, M):
        if ans[s[k]-1] != c[k]:
            n[s[k]-1] += 1
        ans[s[k]-1] = c[k]


    if (ans[0] == 0 and N != 1) or  n[0]>=2 or n[1]>=2 or n[2]>=2:
        print(-1)
    else:
        ans = map(str,ans)
        print(''.join(ans))




if __name__ == "__main__":
	main()
import numpy as np

x, y, z, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

AA, BB = np.meshgrid(A,B)
AB = AA+BB
AB = np.sort(AB.flatten())[::-1]

ABAB, CC = np.meshgrid(AB,C)
ABC = ABAB+CC
ABC = np.sort(ABC.flatten())[::-1]

for abc in ABC:
    print(abc)

### FIXED CODE ###

x, y, z, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ABC = []
for x, a in enumerate(A):
    if x+1 > 3000:
        break
        
    for y, b in enumerate(B):
        if (x+1)*(y+1) > 3000:
            break
    
        for z, c in enumerate(C):
            if (x+1)*(y+1)*(z+1) > 3000:
                break
            
            ABC.append(a+b+c)
            
ABC.sort(reverse=True)
ABC = ABC[:k]

for abc in ABC:
    print(abc)
N,A,B = map(int,input().slit())
if N*A<B:
  print(N*A)
elif N*A>B:
  print(B)
else:
  print()

### FIXED CODE ###

N,A,B = map(int,input().split())
if N*A<=B:
  print(N*A)
else:
  print(B)
N = int(input())
A = list(map(int,input().split()))

nCr = {}
def cmb(n,r):
    if r > n:
        return 0
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n,r) in nCr.keys():
        return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

mem_cnt = [0] * N
set_a = set(A)
for c in list(set_a):
    mem_cnt[c] = A.count(c)

for k in A:
    ret = 0
    for v in mem_cnt:
        x = v
        ret += cmb(x,2)
    print(ret)


### FIXED CODE ###

from collections import Counter

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

cnt = Counter(A)
s = 0
for v in cnt.values():
    s += v*(v-1)//2

for a in A:
    print(s - (cnt[a]-1))
def cal(a, op, b):

  if op == '+':
    r = a + b
  elif op == '-':
    r = a + b
  elif op == '*':
    r = a * b
  else:
    r = a / b
  return r

while 1:
  a,op,b = raw_input().split()
  if op == '?':
    break
  else:
    cal(int(a), op, int(b))
    print r

### FIXED CODE ###

def cal(a, op, b):

  if op == '+':
    r = a + b
  elif op == '-':
    r = a - b
  elif op == '*':
    r = a * b
  elif op == '/':
    r = a / b
  return r

while 1:
  a,op,b = raw_input().split()
  if op == '?':
    break
  else:
    print(cal(int(a), op, int(b)))
N,X = map(int,input().split())
list = [int(x) for x in input().split()]
list_dist = sorted([abs(x - X) for x in list])

def gcd(a, b):
    if a < b:
        a , b = b , a
    while b:
        a, b = b, a % b
    return a

ans = list_dist[0]

for x in list_dist[1:]:
    result = gcd(result,x)

print(result)

### FIXED CODE ###

import functools as ft
 
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
 
def gcd_list(numbers):
    return ft.reduce(gcd,numbers)
 
N, X = map(int, input().split(" "))
Xi = [int(a) for a in input().split()]
 
def MinusX(Xi_):
    return abs(Xi_-X)
 
def main(Xi):
    Xi = map(MinusX,Xi)
    output = gcd_list(Xi)
    print(output)
 
if __name__ == "__main__":
    main(Xi)
H,N = list(map(int,input().split()))
alist = list(map(int,input().split()))
if H <= sum(alist):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

h,d = list(map(int, input().split()))
c,m = divmod(h,d)
if 0 != m:
  m = 1
print(c+m)
N, K, S = map(int, input().split())

array = [0] * N
if S % 2 == 0:
    for i in range(K+1):
        array[i] = S//2
    print(*array)
else:
    for i in range(0, K, 2):
        array[i] = (S-1) //2
        array[i+1] = (S+1)  // 2
    print(*array)

### FIXED CODE ###

N, K, S = map(int, input().split())

if S != 10 **9:
    N = [S+1] * N    
else:
    N = [1] * N

for i in range(K):
        N[i] = S

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

if N == 1:
    print(P)
else:
    ans = 1
    x = 1
    while 1:
        k = x**N
        if k > P:
            break
        if P % k == 0:
            ans = max(ans, x)
        x += 1
    print(ans)

### FIXED CODE ###

from collections import Counter

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

# n以下の全ての素数のセットを返す関数
def prime_set(n):
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5) + 1):
        primes.difference_update(range(i*2, n+1, i))
    return primes

# nを素因数分解して素因数の全リストを返す関数
def prime_factors(n):
    f = []
    for i in prime_set(int(n**0.5) + 1):
        while n % i == 0:
            f.append(i)
            n //= i
    if n > 1:
        f.append(n)
    return f

c = Counter(prime_factors(P))
ans = 1

for x in c.keys():
    ans *= pow(x, int(c[x]//N))

print(ans)
a=input()
print(a**2)

### FIXED CODE ###

A=int(input())
print(A**2)
n = int(input())
s = input()
result = []
 
for i in range(n):
    count = 0
    for j in range(n):
        if (i < j) and (s[j] == "E"):
            count += 1
        elif (i > j) and (s[j] == "W"):
            count += 1
    result.append(count)
 
pprint(min(result))

### FIXED CODE ###

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

tmp = 0
for i in range(1, n):
    if s[i] == "E":
        tmp += 1
count = tmp

for i in range(1, n):
    if s[i-1] == "W":
        tmp += 1
    if s[i] == "E":
        tmp -= 1
    count = min(count, tmp)
print(count)
N, K = map(int, input().split())
ans = 0
for i in range(1,N + 1):
  for j in range(1,N + 1):
    for k in range(1,N + 1):
      if ((i + j) % K == 0) and ((j + k) % K == 0) and ((k + i) % K == 0):
        ans += 1
print(ans)

### FIXED CODE ###

K = int(input())
if K % 2 == 0:
  print(int(K * K / 4))
else:
  print(int((K * K - 1) / 4))
n=int(input())

ans=0

for i in range(n):
    l,r=map(int,input())
    ans+=r-l+1

print(ans)

### FIXED CODE ###

n=int(input())

ans=0

for i in range(n):
    l,r=map(int,input().split())
    ans+=r-l+1

print(ans)
import numpy as np


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    C = np.zeros([2, N], dtype=np.int64)
    C[0, :] = A
    C[1, :] = B
    d = np.diff(C, axis=0)
    cnt1 = np.sum(d)
    cnt2 = np.sum(d)
    for i in range(len(d[0, :])):
        if d[0, i] > 0:
            cnt1 -= dimport numpy as np


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    C = np.zeros([2, N], dtype=np.int64)
    C[0, :] = A
    C[1, :] = B
    d = np.diff(C, axis=0)
    cnt1 = np.sum(d)
    cnt2 = np.sum(d)
    for i in range(len(d[0, :])):
        if d[0, i] > 0:
            cnt1 -= d[0, i] / 2
        if d[0, i] < 0:
            cnt2 -= -d[0, i]

    print('Yes' if min(cnt1, cnt2) >= 0 else 'No')


main()
[0, i] / 2
        if d[0, i] < 0:
            cnt2 += d[0, i]

    print('Yes' if max(cnt1, cnt2) >= 0 else 'No')


main()


### FIXED CODE ###

import numpy as np


def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    B = np.array(list(map(int, input().split())))
    sum_A = np.sum(A)
    sum_B = np.sum(B)
    diff_AB = A - B

    if sum_A > sum_B:
        ans = 'No'
    else:
        cnt_1 = 0
        cnt_2 = 0
        for d in diff_AB:
            if d > 0:
                cnt_1 += d
            else:
                cnt_2 += (-d + 1) // 2

        if max(cnt_1, cnt_2) <= sum_B - sum_A:
            ans = 'Yes'
        else:
            ans = 'No'

    print(ans)


main()
import numpy as np
n = int(input())
A = [[ord(i) for i in input()] for j in range(n)]
count = 0
for a in range(n):
    arr = np.roll(A, a, axis=0)
    arrT = arr.T
    for i in range(n):
        if arr[i][i:] != arrT[i][i:]:
            break
    else:
        count += n
print(count)

### FIXED CODE ###

n = int(input())
A = [input() for _ in range(n)]
# AT = list(map(''.join,zip(*A)))
count = 0
for a in range(n):
    arr = A[a:][:] + A[:a][:]
    arrT = list(map(''.join, zip(*arr)))
    for i in range(n):
        if arr[i][i+1:] != arrT[i][i+1:]:
            break
    else:
        count += n
print(count)
code = list(str, input().split("?"))
 
for i in code
   ans =ans + code[i]
   ans =ans + "D"
   
print(ans-"D")

### FIXED CODE ###

a= input()
c=""
for i in range(0, len(a)):
    if a[i]=="?":
        c=c+"D"
    else:
        c=c+a[i]
print(c)
#%%
n = int(input())
a = list(map(int ,input().split()))

a.sort(reverse=True)
ans = []
for i in range(n):
    if i == 0:
        tmp = a[i]
    elif 1 <= i < n - 1:
        if a[i] > 0:
            ans.append(str(a[-1]) + ' ' +  str(a[i]))
            a[-1] -= a[i]
        else:
            ans.append(tmp + ' ' +  str(a[i]))
            tmp -= a[i]
    else:
        ans.append(str(tmp) + ' ' +  str(a[-1]))
        a = tmp - a[-1]
        print(a)

for i in range(len(ans)):
    x, y = map(int, ans[i].split())
    print(x, y)


### FIXED CODE ###

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

a.sort(reverse=True)
ans = []
for i in range(n):
    if i == 0:
        tmp = a[i]
    elif 1 <= i < n - 1:
        if a[i] > 0:
            ans.append(str(a[-1]) + ' ' +  str(a[i]))
            a[-1] -= a[i]
        else:
            ans.append(str(tmp) + ' ' +  str(a[i]))
            tmp -= a[i]
    else:
        ans.append(str(tmp) + ' ' +  str(a[-1]))
        a = tmp - a[-1]
        print(a)

for i in range(len(ans)):
    x, y = map(int, ans[i].split())
    print(x, y)
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
plus = []
total_minus = 0
for i in range(n):
    diff = a[i] - b[i]
    if diff >= 0:
        plus.append(diff)
    else:
        total_minus += (-1) * diff
plus.sort(reverse=True)
if total_minus == 0:
    print(0)
elif sum(plus) < total_minus:
    print(-1)
else:
    ans = n - len(plus)
    for i in range(n):
        if total_minus <= 0:
            break
        total_minus -= plus[i]
        ans += 1
print(ans)

### FIXED CODE ###

import collections
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
plus = []
minus = []
for i in range(n):
    diff = a[i] - b[i]
    if diff >= 0:
        plus.append(diff)
    else:
        minus.append((-1) * diff)
plus.sort(reverse=True)
plus = collections.deque(plus)
if len(minus) == 0:
    print(0)
    exit()
if sum(plus) < sum(minus):
    print(-1)
    exit()
ans = len(minus)
total = sum(minus)
while total > 0:
    total -= plus.popleft()
    ans += 1
print(ans)
N=int(input())
A=list(map(int,input().split()))

def gcd(a,b):
    c=max(a,b)
    d=min(a,b)
    while True:
        c,d=d,c%d
        if c%d==0:
            return d

def gcd_list(A):
    if len(A)==2:
        return gcd(A[0],A[1])
    elif len(A)==1:
        return A[0]
    else:
        return gcd(gcd_list(A[len(A)//2:]),gcd_list(A[:len(A)//2]))
max_gcd=1
for i in range(N):
    max_gcd=max(gcd_list(A[:i]+A[i+1:]),max_gcd)
    
print(max_gcd)

### FIXED CODE ###

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

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

S1 = [A[0]]
s = A[0]
for i in range(1,N-1):
    s=gcd(s,A[i])
    S1.append(s)

S2 = [A[N-1]]
s = A[N-1]
for i in range(1,N-1):
    s=gcd(s,A[N-i-1])
    S2.append(s)

max_gcd = 1
for i in range(N):
    if i==0:
        max_gcd=max(max_gcd,S2[N-2])
    elif i==N-1:
        max_gcd=max(max_gcd,S1[N-2])
    else:
        max_gcd=max(max_gcd,gcd(S1[i-1],S2[N-2-i]))

print(max_gcd)
n = input()
for i in [0, 1, 2]:
  if n[i] == '1':
    n[i] == '9'
  if n[i] == '9':
    n[i] == '1'
print(int(n))

### FIXED CODE ###

X, Y = map(int, input().split())
print(int(X + Y/2))
letters = list(input())
a = letters[0]
if letters.count(a) == 2:
  if letters[1] == a:
    if letters[2] == letters[3]:
      print("Yes")
    else print("No")
  else:
    b = letters[1]
    if letters.count(b) == 2:
      print("Yes")
    else:
      print("No")
else:
  print("No")

    

### FIXED CODE ###

letters = list(input())
x = 1
for letter in letters:
        if letters.count(letter) == 2:
            x *= 1
        else:
            x *= 0
print(["No","Yes"][x])
n = int(input())
p = 10**9 + 7

def fact(n, p):
    n_ = [1]
    for i in range(1, n+1):
         n_.append((n_[-1]*i) % p)
    return n

def invfact(n, f, p):
    m = [pow(f[n], p-2, p)]
    for i in range(n, 0, -1):
        m.append(m[-1] * i % p)
    return m

ans = 0
m = n - 1
f = list(fact(m, p))
rf = list(invfact(m, f, p))
rf.reverse()
perm = 0

for k in range((n+1)//2, n):
    perm_ = f[k-1] * rf[2*k-n] %p * f[k] % p
    ans += (perm_ - perm) %p * k % p
    ans %= p
    perm = perm_

print(ans)

### FIXED CODE ###

n = int(input())
p = 10**9 + 7

def fact(n):
    n_ = 1
    yield n_
    for i in range(1, n+1):
         n_ = (n_*i) % p
         yield n_

def invfact(n, f, p):
    m = pow(f[n], p-2, p)
    yield m
    for i in range(n, 0, -1):
        m = m * i % p
        yield m

ans = 0
m = n - 1
f = list(fact(m))
rf = list(invfact(m, f, p))
rf.reverse()
perm = 0

for k in range((n+1)//2, n):
    b = m - k
    a = (m - 1) - (2 * b)
    perm_ = f[a+b] * rf[a] %p * f[k] % p
    ans += (perm_ - perm) %p * k % p
    ans %= p
    perm = perm_

print(ans)
x = input()
print(x*x*x)

### FIXED CODE ###

x = input()
print(x*x*x)
print('unsafe') if int(input()) <= int(input()) else print('safe')

### FIXED CODE ###

S, W = input().split(' ')
print('unsafe') if int(S) <= int(W) else print('safe')
N = input()
S = N%10
if(S == 0):
  print("pon")
else if(S == 1):
  print("pon")
else if(S == 6):
  print("pon")
else if(S == 8):
  print("pon")
else if(S == 3):
  print("bon")
else:
  print("hon")

### FIXED CODE ###

N = int(input())
S = N % 10
if(S == 0):
  print("pon")
elif(S == 1):
  print("pon")
elif(S == 6):
  print("pon")
elif(S == 8):
  print("pon")
elif(S == 3):
  print("bon")
else:
  print("hon")