jiahuimbzuai/CoQuIR huggingface dataset:
//  [javascript]
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    const sc = arg.slice(1, M + 1).map(n=>n.split(" "));
    
    let answer = new Array(N).fill("x");
    
    if(N === 1 && M === 0) {
        console.log(0);
        return;
    }

    for(let i in sc) {
        let digit  = parseInt(sc[i][0]);
        let number = sc[i][1];
        
        // console.log("answer:" + answer);
        // console.log("a:" + answer[digit - 1]);
        // console.log(answer[digit - 1] !== "x");
        
        // すでに他の数字で確保されているのはNG
        if(answer[digit - 1] !== number && answer[digit - 1] !== "x") {
            console.log(-1);
            return;
        }

        answer[digit - 1] = number;
    }
    
    // 最小を考える
    for(let i in answer) {
        if(answer[answer.length - i] === "x") {
            answer[answer.length - i] = 0;
        }
    }

    
    if(answer[0] === "x") {
        answer[0] = 1;
    }

    console.log(String(parseInt(answer.join(""))).length === N ? answer.join("") : -1);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
	input = input.split("\n");
	var a = input[0].split(" ").map(Number);
	var flag = true;
	input.shift();
	var arr = new Array(a[0]).fill("#");
	for(var i=0;i<input.length;i++){
      
		var mem = input[i].split(" ").map(Number);
   //   console.log(mem,arr)
    if(mem[0]==1&&mem[1]==0&&a[0]!=1) flag = false;
		if(arr[mem[0]-1]=="#"){
			arr[mem[0]-1] = mem[1];
		}else if(arr[mem[0]-1]!=mem[1]){
			flag = false;
			break;
		}
	}
	if(arr[0]=="#"&&a[0]!=1){arr[0] = 1;
                            }else if(arr[0]=="#"){
                            arr = [0];
                            }
	for(i=0;i<arr.length;i++){
		if(arr[i]=="#") arr[i] = 0;
	}
	if(flag){
		console.log(arr.join(""))
	}else{
		console.log(-1)
	}
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
function Main(input) {
    var N = parseInt(input[0].split(/\s/)[0], 10);
    var M = parseInt(input[0].split(/\s/)[1], 10);
    var s = input.slice(1).map(sc => sc.split(/\s/)[0]);
    var c = input.slice(1).map(sc => sc.split(/\s/)[1]);
    
    var list = new Array(N);
    list.fill(-1);

    for (var i = 0; i < M; i++) {
        if (list[s[i] - 1] !== -1 && list[s[i] - 1] !== c[i]) {
            return console.log(-1);
        } else {
            list[s[i] - 1] = c[i];
        }
    }

    var result = '';

    for (var j = 0; j < N; j++) {
        if (j === 0 && N !== 1) {
            if (list[j] === -1) {
                result += '1';
            } else if (list[j] === '0') {
                return console.log(-1);
            } else {
                result += `${list[j]}`;
            }
        } else if (list[j] === -1) {
            result += '0';
        } else {
            result += `${list[j]}`;
        }
    }

    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/));
//  [javascript]
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var M = one[1];
  var list = new Array(M);
  for(var i = 0; i < M; i++){
    var tmp = nextIntArray();
    list[i] = {
      si : tmp[0],
      ci : tmp[1]
    };
  }
  for(var i = 0; i < Math.pow(10, N); i++){
    var isOK = true;
    for(var j = 0; j < M; j++){
      var check = i.toString();
      if(check.length != N){
        isOK = false;
      }
      if(check[list[j].si - 1] != list[j].ci){
        isOK = false;
      }
    }
    if(isOK){
      myout(i);
      return;
    }
  }
  myout(-1);
}
//  [javascript]
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')

const [N, M] = lines[0].split(' ').map(Number)
const s = []
const c = []

for (let i = 0; i < M; i++) {
  const row = lines[i + 1].split(' ').map(Number)
  s[i] = row[0] - 1
  c[i] = row[1]
}

;(() => {
  const n = Array(N).fill(null)
  for (let i = 0; i < M; i++) {
	if (n[s[i]] && n[s[i]] !== c[i]) {
      console.log(-1)
      return
    }
    n[s[i]] = c[i]
  }
  
  if (n.length > 1 && n[0] === 0) {
    console.log(-1)
    return
  }
  
  for (let i = 0; i < N; i++) {
    if (n[i] === null)  {
      n[i] = i === 0 ? 1 : 0
    }
  }
  console.log(n.join(''))
  
})()
//  [javascript]
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')

const [N, M] = lines[0].split(' ').map(Number)
const s = []
const c = []

for (let i = 0; i < M; i++) {
  const row = lines[i + 1].split(' ').map(Number)
  s[i] = row[0] - 1
  c[i] = row[1]
}

;(() => {
  const n = Array(N).fill(null)
  for (let i = 0; i < M; i++) {
	if (n[s[i]] && n[s[i]] !== c[i]) {
      console.log(-1)
      return
    }
    n[s[i]] = c[i]
  }
  
  if (n[0] === 0) {
    console.log(-1)
    return
  }
  
  for (let i = 0; i < N; i++) {
    if (n[i] === null)  {
      n[i] = i === 0 ? 1 : 0
    }
  }
  console.log(n.join(''))
  
})()
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n, m int
	if sc.Scan() {
		nm := splitToInt(sc.Text())
		n = nm[0]
		m = nm[1]
	}

	rcnt := 0
	scArr := make([][]int, m)

	for rcnt < m {
		if sc.Scan() {
			scArr[rcnt] = splitToInt(sc.Text())
			rcnt++
		}
	}

	ans := []int{}
	if n == 1 {
		// 0~99
		for i := 0; i < 10; i++ {
			strI := strconv.Itoa(i)

			for _, scV := range scArr {
				if scV[0] - 1 >= len(strI) {
					goto Next1
				}

				if string(strI[scV[0]-1]) != strconv.Itoa(scV[1]) {
					goto Next1
				}
			}
			ans = append(ans, i)
		Next1:
		}
	}

	if n == 2 {
		// 10~99
		for i := 10; i < 100; i++ {
			strI := strconv.Itoa(i)

			for _, scV := range scArr {
				if scV[0] - 1 >= len(strI) {
					goto Next2
				}

				if string(strI[scV[0]-1]) != strconv.Itoa(scV[1]) {
					goto Next2
				}
			}
			ans = append(ans, i)
		Next2:
		}
	}

	if n == 3 {
		// 100~999
		for i := 100; i < 1000; i++ {
			strI := strconv.Itoa(i)

			for _, scV := range scArr {
				if scV[0] - 1 >= len(strI) {
					goto Next3
				}

				if string(strI[scV[0]-1]) != strconv.Itoa(scV[1]) {
					goto Next3
				}
			}
			ans = append(ans, i)
		Next3:
		}
	}

	if len(ans) == 0 {
		fmt.Print("-1")
		return
	}

	sort.Ints(ans)
	fmt.Print(ans[0])
}

func splitToInt(s string) (intArr []int) {
	arr := strings.Split(s, " ")

	for _, v := range arr {
		intV, _ := strconv.Atoi(v)
		intArr = append(intArr, intV)
	}
	return
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var n, m int
	n = nextInt()
	m = nextInt()

	ma := map[int]int{}

	if m == 0 {
		if n == 1 {
			ma[0] = 0
		} else {
			ma[0] = 1
		}
	}

	for l := 0; l < m; l++ {
		var s, c int
		s = nextInt() - 1
		c = nextInt()
		_, ok := ma[s]
		if ok && ma[s] != c {
			fmt.Println(-1)
			return
		} else if n > 1 && s == 0 && c == 0 {
			fmt.Println(-1)
			return
		} else {
			ma[s] = c
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		_, ok := ma[i]
		if !ok {
			if i == 0 && n > 1 {
				ma[i] = 1
			} else {
				ma[i] = 0
			}
		}
		ans += ma[i] * int(math.Pow10(n-i-1))
	}
	fmt.Println(ans)

}
//  [go]
package main

import (
        "fmt"
)

func solution(n, m int, matrix [][]int) int {
        var ans int = 1000
        for i := 0; i < 1000; i++ {
                s := fmt.Sprint(i)
                if n != len(s) {
                        continue
                }
                if m == 0 {
                        ans = min(ans, i)
                        continue
                }
                if isCond(s, matrix) {
                        ans = min(ans, i)
                }
        }
        if ans == 1000 {
                return -1
        }
        return ans
}
func isCond(str string, matrix [][]int) bool {
        for i := range matrix {
                s := matrix[i][0]
                c := matrix[i][1]
                if int(str[s-1])-48 != c {
                        return false
                }
        }
        return true
}

func min(x, y int) int {
        if x < y {
                return x
        }
        return y
}

func main() {
        var n, m int
        fmt.Scan(&n, &m)
        matrix := make([][]int, m)

        for i := 0; i < m; i++ {
                var s, c int
                fmt.Scan(&s, &c)
                matrix[i] = []int{s, c}
        }
        fmt.Println(solution(n, m, matrix))
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N, M := ReadInt(), ReadInt()
	s := make([]int, M)
	c := make([]int, M)
	for i := 0; i < M; i++ {
		s[i], c[i] = ReadInt()-1, ReadInt()
	}

	low := 0
	if N >= 2 {
		low = 1
		for j := 0; j < N-1; j++ {
			low *= 10
		}
	}
	for i := low; i < low*10; i++ {
		str := strconv.Itoa(i)
		ok := true
		for j := 0; j < M; j++ {
			if str[s[j]]-'0' != byte(c[j]) {
				ok = false
				break
			}
		}
		if ok {
			fmt.Println(str)
			return
		}
	}
	fmt.Println(-1)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, M := ReadInt(), ReadInt()
	m := make(map[int]int)
	for i := 0; i < M; i++ {
		s, c := ReadInt(), ReadInt()
		if prev, exists := m[s-1]; exists && prev != c {
			fmt.Println(-1)
			return
		}
		m[s-1] = c
	}

	base := 1
	for i := 0; i < N-1; i++ {
		base *= 10
	}
	ans := 0
	leftSet := false
	for i := 0; i < N; i++ {
		if c, exists := m[i]; exists {
			if c == 0 && !leftSet && i < N-1 {
				fmt.Println(-1)
				return
			}
			ans += base * c
			leftSet = true
		} else if !leftSet {
			ans += base * 1
			leftSet = true
		}
		base /= 10
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N, M := ReadInt(), ReadInt()
	m := make(map[int]int)
	for i := 0; i < M; i++ {
		s, c := ReadInt(), ReadInt()
		if prev, exists := m[s-1]; exists && prev != c {
			fmt.Println(-1)
			return
		}
		m[s-1] = c
	}

	base := 1
	for i := 0; i < N-1; i++ {
		base *= 10
	}
	ans := 0
	leftSet := false
	for i := 0; i < N; i++ {
		if c, exists := m[i]; exists {
			if c == 0 && !leftSet && i < N-1 {
				fmt.Println(-1)
				return
			}
			ans += base * c
			leftSet = true
		}
		base /= 10
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}
//  [ruby]
N, M=gets.split.map(&:to_i)
res=?**N
M.times{
    s, c=gets.split
    s=s.to_i-1
    (p -1; exit) if res[s]!=c && res[s]!=?*
    res[s]=c
}
res[0]=(N>1 ? ?1: ?0) if res[0]==?*
res.tr! ?*, ?0
puts (N>1 && res[0]==?0 ? -1 : res)
//  [ruby]
N, M=gets.split.map(&:to_i)
res=?**N
M.times{
    s, c=gets.split
    s=s.to_i-1
    (p -1; exit) if res[s]!=c && res[s]!=?*
    res[s]=c
}
res[0]=?1 if res[0]==?* && N>1
res.tr! ?*, ?0
puts (N>1 && res[0]==?0 ? -1 : res)
//  [ruby]
n, m = gets.strip.split(' ').map{|e|e.to_i}
str = '0' * n

hash = Hash.new()
m.times do
  s, c = gets.strip.split(' ')
  if hash.include?(s) and hash[s] != c
    puts '-1'
    exit
  else
    str[s.to_i - 1] = c
    hash.store(s, c)
  end
end

if str.size != 1 and str[0] == '0'
  if hash['1'] != '0'
    str[0] = '1'
  else
    puts '-1'
    exit
  end
end

puts str
//  [ruby]
n,m = gets.chomp.split(' ').map(&:to_i)
list = []
m.times do
  list << gets.chomp.split(' ').map(&:to_i)
end
i = 0
while i <= 1000
  flag = 1
  list.each do |pair|
    if n < i.to_s.chars.size || i.to_s.chars[pair[0]-1] != pair[1].to_s
      flag = 0
    break
    end
  end
  if flag == 1
    ans = i
    break
  end
  if i == 1000
    ans = -1
  end
  i += 1
end
if n != 1 && ans.to_s.chars.size < n
  puts -1
  exit
end
puts ans
//  [ruby]
n,m = gets.chomp.split(' ').map(&:to_i)
list = []
m.times do
  list << gets.chomp.split(' ').map(&:to_i)
end
i = 0
while i <= 1000
  flag = 1
  list.each do |pair|
    if n < i.to_s.chars.size || i.to_s.chars[pair[0]-1] != pair[1].to_s
      flag = 0
    break
    end
  end
  if flag == 1
    ans = i
    break
  end
  if i == 1000
    ans = -1
  end
  i += 1
end
if n != 1
  ans.to_s.chars.size < n
  puts -1
  exit
end
puts ans
//  [ruby]
n,m=gets.split.map(&:to_i)
a=m.times.map{gets.split.map(&:to_i)}
(0..10**n).each do |i|
  s=i.to_s
  flag=true
  a.each do |i,j|
    flag=false if s[i-1]!=j.to_s
  end
  if flag
    p i
    exit
  end
end
p -1
//  [rust]
use std::io::{self, BufRead};

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let xs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  let (n, m) = (xs[0], xs[1]);
  let mut cs = vec![None; n];
  for _ in 0..m {
    let xs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
    let (s, c) = (xs[0] - 1, xs[1]);
    if s == 0 && c == 0 && n > 1 {
      println!("-1");
      return;
    }
    match cs[s] {
      None => cs[s] = Some(c),
      Some(d) => if c != d {
        println!("-1");
        return;
      },
    };
  }
  let mut ans = 0;
  for i in 0..n {
    match cs[i] {
      None    => ans = ans * 10 + (if i == 0 && n > 1 { 1 } else { 0 }),
      Some(c) => ans = ans * 10 + c,
    };
  }
  println!("{}", ans);
}
//  [rust]
use std::collections::HashMap;
use std::io;

fn main() {
	let mut flag = true;
	
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let n: i32 = match iter.next().unwrap().parse(){
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	let m: i32 = match iter.next().unwrap().parse(){
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	
	let mut map: HashMap<i32, i32> = HashMap::new();
	for num in 0..m {
		let mut buf = String::new();
		io::stdin().read_line(&mut buf).expect("");
		let mut iter = buf.split_whitespace();
		let s = match iter.next().unwrap().parse(){
			Ok(n) => n,
			Err(_) => panic!(""),
		};
		let c = match iter.next().unwrap().parse(){
			Ok(n) => n,
			Err(_) => panic!(""),
		};
			
		match map.insert(s, c) {
			Some(n) => if n != c{
				flag = false;
			},
			None => (),
		}
			
	}
		
	if flag {
		let mut v: Vec<i32> = Vec::new();
		if n == 1 {
			match map.get(&1) {
				Some(n) => println!("{}", n ),
				None => println!("0"),
			}
		}else if n != 1 {
			match map.get(&1) {
				Some(&0) => {
					println!("-1");
				},
					
				Some(_) => {
					for number in 0..n {
						match map.get(&(number+1)){
							Some(n) => v.push(*n),
							None => v.push(0),
						}
					}
			
					for n in v {
						print!("{}", n);
					}
					print!("\n");
				},
									
				None => {
					v.push(1);
					for number in 1..n {
						match map.get(&(number+1)){
							Some(n) => v.push(*n),
							None => v.push(0),
						}
					}				
					for n in v {
						print!("{}", n);
					}
					print!("\n");
				}
			}
		}else{
			println!("-1");
		}
		
	}else{
		println!("-1");
	} 
	
}
//  [rust]
use std::io::stdin;
use std::collections::HashMap;

fn digits(mut n: i64) -> Vec<i64> {
    let mut ans = Vec::<i64>::new();
    while n > 0 {
        ans.push(n % 10);
        n /= 10;
    }
    ans.reverse();
    return ans;
}

fn main() {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    let words: Vec<i64> = line
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();

    let n = words[0];
    let m = words[1];

    let mut value = HashMap::new();
    let mut impossible = false;

    for _ in 0..m {
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let words: Vec<i64> = line
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect();
        
        let s = words[0];
        let c = words[1];

        if value.contains_key(&s) && value.get(&s).unwrap() != &c {
            impossible = true;
        } else {
            value.insert(s, c);
        }
    }
    if value.contains_key(&1) && value.get(&1).unwrap() == &0 && n < 1 {
        impossible = true;
    }

    if impossible {
        println!("-1");
        return;
    }

    if n == 1 && m == 0 {
        println!("0");
        return;
    }
    
    if n == 1 && m == 1 && value.contains_key(&1) && value.get(&1).unwrap() == &0 {
        println!("0");
        return;
    }

    let base: i64 = 10;
    for num in base.pow((n-1) as u32)..base.pow(n as u32) {
        let mut digit = vec![0];
        digit.append(&mut digits(num));
        let mut valid = true;
        for i in 1..(n+1) {
            if value.contains_key(&i) && value.get(&i).unwrap() != &digit[i as usize] {
                valid = false;
            }
        }
        if valid {
            println!("{}", num);
            return;
        }
    }
    println!("-1");
}
//  [rust]
use whiteread::parse_line;

fn main() {
    let (n, m): (usize, usize) = parse_line().unwrap();
    let mut num: Vec<Option<u8>> = vec![None; n];

    for _ in 0..m {
        let (si, ci): (usize, u8) = parse_line().unwrap();
        if si == 1 && ci == 0 {
            println!("-1");
            return;
        }
        if let Some(c) = num[si - 1] {
            if ci != c {
                println!("-1");
                return;
            }
        } else {
            num[si - 1] = Some(ci);
        }
    }

    let mut num = num
        .iter()
        .map(|x| match x {
            Some(c) => *c,
            None => 0,
        })
        .collect::<Vec<_>>();
    if n != 1 && num[0] == 0 {
        num[0] = 1;
    }

    println!("{}", num.iter().fold(0_u32, |x, &y| x * 10 + y as u32));
}
//  [rust]
use whiteread::parse_line;

fn main() {
    let (n, m): (usize, usize) = parse_line().unwrap();
    let mut num: Vec<Option<u8>> = vec![None; n];

    for _ in 0..m {
        let (si, ci): (usize, u8) = parse_line().unwrap();
        if si == 1 && ci == 0 {
            println!("-1");
            return;
        }
        if let Some(c) = num[si - 1] {
            if ci != c {
                println!("-1");
                return;
            }
        } else {
            num[si - 1] = Some(ci);
        }
    }

    let mut num = num
        .iter()
        .map(|x| match x {
            Some(c) => *c,
            None => 0,
        })
        .collect::<Vec<_>>();
    if num[0] == 0 {
        num[0] = 1;
    }

    println!("{}", num.iter().fold(0_u32, |x, &y| x * 10 + y as u32));
}
//  [rust]
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        mut instructions: [(usize, usize); m],
    }
    
    let instructions: Vec<(usize, usize)> = instructions.iter().map(|inst| (inst.0-1, inst.1)).collect();
    let mut integer: Vec<Option<usize>> = vec![None; n];

    for instruction in &instructions {
        if n != 1 && instruction.0 == 0 && instruction.1 == 0 {
            println!("{}", -1);
            return;
        } 
        if let Some(num) = integer[instruction.0] {
            if num != instruction.1 {
                println!("{}", -1);
                return;
            }
        } else {
            integer[instruction.0] = Some(instruction.1)
        }
    }

    for (i, n) in integer.iter().enumerate() {
        match n {
            Some(num) => print!("{}", num),
            None => {
                if i == 0 {
                    print!("{}", 1);
                } else {
                    print!("{}", 0);
                }
            }
        }
    }

    println!();
}
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let nm = readInts()
    let (n, m) = (nm[0], nm[1])
    var aryAns = [Int](repeating: -1, count: n)
    var aryS = [Int]()
    var aryC = [Int]()
    
    for _ in 0..<m {
        let sc = readInts()
        aryS.append(sc[0])
        aryC.append(sc[1])
    }
    
    var ans = String()
    if m == 0 {
        if n == 1 {
            print(0)
            return
        }
        else {
            for i in 0..<n {
                ans += i == 0 ? "1": "0"
            }
            print(ans)
            return
        }
    }
    
    for i in 0..<m {
        if aryAns[aryS[i]-1] != -1 && aryAns[aryS[i]-1] != aryC[i]{
            print(-1)
            return
        }
        aryAns[aryS[i]-1] = aryC[i]
    }
    if aryAns[0] == 0 && aryAns.count != 1{
        print(-1)
        return
    }
    
    for i in 0..<n {
        if i == 0 && aryAns.count != 1 && aryAns[i] == -1{
            ans += "1"
            continue
        }
        ans += aryAns[i] == -1 ? "0": String(aryAns[i])
    }
    print(ans)
}

main()
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let nm = readInts()
    let (n, m) = (nm[0], nm[1])
    var aryAns = [Int](repeating: -1, count: n)
    var aryS = [Int]()
    var aryC = [Int]()
    
    for _ in 0..<m {
        let sc = readInts()
        aryS.append(sc[0])
        aryC.append(sc[1])
    }
    
    var ans = String()
    if m == 0 {
        if n == 1 {
            print(0)
            return
        }
        else {
            for i in 0..<n {
                ans += i == 0 ? "1": "0"
            }
            print(ans)
            return
        }
    }
    
    for i in 0..<m {
        if aryAns[aryS[i]-1] != -1 && aryAns[aryS[i]-1] != aryC[i]{
            print(-1)
            return
        }
        aryAns[aryS[i]-1] = aryC[i]
    }
    if aryAns[0] == 0 && aryAns.count != 1{
        print(-1)
        return
    }
    
    for i in 0..<n {
        if i == 0 && aryAns.count != 1{
            ans += "1"
            continue
        }
        ans += aryAns[i] == -1 ? "0": String(aryAns[i])
    }
    print(ans)
}

main()
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let nm = readInts()
    let (n, m) = (nm[0], nm[1])
    var aryAns = [Int](repeating: -1, count: n)
    var aryS = [Int]()
    var aryC = [Int]()
    
    for _ in 0..<m {
        let sc = readInts()
        aryS.append(sc[0])
        aryC.append(sc[1])
    }
    
    var ans = String()
    if m == 0 {
        if n == 1 {
            print(0)
            return
        }
        else {
            for i in 0..<n {
                ans += i == 0 ? "1": "0"
            }
            print(ans)
            return
        }
    }
    
    for i in 0..<m {
        if aryAns[aryS[i]-1] != -1 && aryAns[aryS[i]-1] != aryC[i]{
            print(-1)
            return
        }
        aryAns[aryS[i]-1] = aryC[i]
    }
    if aryAns[0] == 0 && aryAns.count != 1{
        print(-1)
        return
    }
    
    for i in 0..<m {
        ans += aryAns[i] == -1 ? "0": String(aryAns[i])
    }
    print(ans)
}

main()
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let nm = readInts()
    let (n, m) = (nm[0], nm[1])
    var aryAns = [Int](repeating: -1, count: n)
    var aryS = [Int]()
    var aryC = [Int]()
    
    for _ in 0..<m {
        let sc = readInts()
        aryS.append(sc[0])
        aryC.append(sc[1])
    }
    
    var ans = String()
    if m == 0 {
        if n == 1 {
            print(0)
            return
        }
        else {
            for i in 0..<n {
                ans += i == 0 ? "1": "0"
            }
            print(ans)
            return
        }
    }
    
    for i in 0..<m {
        if aryAns[aryS[i]-1] != -1 && aryAns[aryS[i]-1] != aryC[i]{
            print(-1)
            return
        }
        aryAns[aryS[i]-1] = aryC[i]
    }
    if aryAns[0] == 0 {
        print(-1)
        return
    }
    
    for i in 0..<m {
        ans += aryAns[i] == -1 ? "0": String(aryAns[i])
    }
    print(ans)
}

main()
//  [typescript]
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [n, m]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    if (m == 0) {
      return `${n == 1 ? 0 : n == 2 ? 10 : 100}`;
    }
    const map = {};
    for (let i = 0; i < m; i++) {
      const [s, c]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
      if ((s == 1 && c == 0 && n != 1) || (map[s] != undefined && map[s] != c)) {
        return `${-1}`;
      }
      map[s] = c;
    }
    if (n == 1) {
      return `${map[1]}`;
    }
    let result = "";
    for (let i = 1; i <= n; i++) {
      const c = map[i];
      if (c == undefined) {
        result = result + (i == 1 ? "1" : "0");
      } else {
        result = result + c;
      }
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
const main = (input) => {
  const lines = input.trim().split("\n");
  const [N, M] = lines[0].split(' ').map(str => parseInt(str));
  const checkList = lines.slice(1).map(line => {
    const [s, c] = line.split(' ');
    return [parseInt(s - 1), c];
  });

  // 全探索
  // for (let i = 0; i < Math.pow(10, N); i++) {
  //   const strNum = i.toString();
  //   if (strNum.length == N && checkList.every(sc => strNum[sc[0]] === sc[1])) {
  //     console.log(strNum)
  //     process.exit(0);
  //   }
  // }
  // console.log(-1);

  // 順番に埋める
  let numList = Array(N).fill(-1);
  checkList.forEach(sc => {
    sc[1] = parseInt(sc[1]);
    if (numList[sc[0]] !== -1 && numList[sc[0]] !== sc[1]) {
      console.log(-1);
      process.exit(0);
    }
    numList[sc[0]] = sc[1]
  });

  if (N === 1) {
    if (numList[0] === -1) {
      console.log(0);
    } else {
      console.log(numList[0]);
    }
  } else {
    numList = numList.map((num, i) => {
      if (i === 0) {
        if (num === 0) {
          console.log(-1);
          process.exit(0);
        }
        if (num === -1) {
          return 1;
        }
      }
      if (num === -1) {
        return 0;
      }
      return num;
    })
    console.log(numList.join(""));
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
// import std = require('tstl')

{
  type Print = void | string | number | string[] | number[]
  let outs: Print[] = []

  const main = (): Print => {
    const r = _io()
    const [N, M] = r.nn()
    const A = r.nnls()

    const lib: Record<number, number> = {}

    for (let i = 0; i < M; i++) {
      const [s, c] = A[i]

      // if (lib[s] !== undefined && lib[s] !== c) return -1
      if (s in lib && lib[s] !== c) return -1
      if (s === 1 && c === 0 && N >= 2) return -1
      lib[s] = c
    }

    if (lib[1] === undefined) {
      lib[1] = N === 1 ? 0 : 1
    }

    let res = ''

    for (let i = 1; i <= N; i++) {
      res += String(lib[i] || 0)
    }

    return res
  }

  const _io = (i = 0) => {
    const str = require('fs').readFileSync('/dev/stdin', 'utf8')
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')

    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  outs.push(main())

  console.log(
    outs
      .map(line => (typeof line === 'object' ? line.join(' ') : String(line)))
      .join('\n')
  )
}
//  [typescript]
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let n: number = 0;
    let m: number = 0;
    let sm: number[] = [];
    let cm: number[] = [];
    let ans: number = 0;
    // init
    [n, m] = input.shift().split(" ").map(x => Number(x));
    for (let mx = 0; mx < m; mx++) {
        [sm[mx], cm[mx]] = input[mx].split(" ").map(x => Number(x));
    }
    // solve
    var wn = new Array(n).fill(-1);
    for (let mx = 0; mx < m; mx++) {
        if (0 <= wn[sm[mx] - 1] && wn[sm[mx] - 1] != cm[mx]) {
            ans = -1;
            break;
        }
        wn[sm[mx] - 1] = cm[mx];
    }
    if (ans == 0) {
        for (let nx = 0; nx < n; nx++) {
            if (wn[nx] == -1) {
                wn[nx] = (nx == 0) ? 1 : 0;
            }
        }
    }
    if (wn[0] == 0) {
        ans = -1;
    }
    if (ans != -1) {
        ans = Number(wn.map(x => String(x)).join(""));
    }
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();
//  [typescript]
function main(input) {
  const inputs =input.split('\n')
  const [N, M] = inputs[0].split(' ').map(Number)
  let max = N
  const sc = inputs.slice(1).map(e => {
    [s, c] = e.split(' ').map(Number)
    return [s, c]
  })
  for (let n = Math.pow(10, max - 1) - 1 ; n < 1000; n++) {
    let ok = true
    // console.log('n:', n)
    for(let i = 0; i < M; i++) {
      // console.log('sc[i]:', sc[i][0], 'str:', String(n)[sc[i][0]-1], 'c:', sc[i][1])
      if (String(n).length !== max || String(n)[sc[i][0]-1] != sc[i][1]) {
        ok = false
        break
      }
    }
    if (ok) {
      console.log(n)
      return
    }
  }
  console.log('-1')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())
//  [typescript]
function main(input) {
  const inputs =input.split('\n')
  const [N, M] = inputs[0].split(' ').map(Number)
  let max = N
  const sc = inputs.slice(1).map(e => {
    [s, c] = e.split(' ').map(Number)
    return [s, c]
  })
  for (let n = Math.pow(10, max - 1) - 1 ; n < 1000; n++) {
    let ok = true
    // console.log('n:', n)
    for(let i = 0; i < M; i++) {
      // console.log('sc[i]:', sc[i][0], 'str:', String(n)[sc[i][0]-1], 'c:', sc[i][1])
      if (String(n)[sc[i][0]-1] != sc[i][1]) {
        ok = false
        break
      }
    }
    if (ok) {
      console.log(n)
      return
    }
  }
  console.log('-1')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim())
//  [python]
n=int(input())
vs = list(map(int, input().split()))
cs = list(map(int, input().split()))
total = 0
for i in range(n):
    if vs[i] > cs[i]:
        total += vs[i]-cs[i]
print(total)
//  [python]
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
vans = 0
cans = 0
for i in range(n):
    if v[i]> c[i]:
        vans += v[i]
        cans += c[i]
print(vans - cans)
//  [python]
def solve():
  n = int(input())
  v = list(int(i) for i in input().split())
  c = list(int(i) for i in input().split())
  ans = 0
  for i in range(n):
    if v[i]-c[i] >= 0:
      ans += v[i]-c[i]
  print(ans)
solve()
//  [python]
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

diff = [V[i] - C[i] for i in range(N)]
diff.sort(reverse=True)

i, ans = 0,0
while diff[i] > 0:
    ans += diff[i]
    i += 1
print(ans)
//  [python]
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

diff = [0 for i in range(N)]
for i in range(N):
  diff[i] = V[i] - C[i]
diff = list(reversed(sorted(diff)))
i, ans = 0, 0
while diff[i] > 0:
  ans += diff[i]
  i += 1
print(max(ans, 0))
//  [python]
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

diff = [0 for i in range(N)]
for i in range(N):
  diff[i] = V[i] - C[i]
diff = list(reversed(sorted(diff)))
i, ans = 0, 0
while diff[i] > 0:
  ans += diff[i]
  i += 1
print(ans)
//  [java]
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args)throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    int[] v = new int[n];
    int[] c = new int[n];

    String[] str = in.readLine().split(" ");
    for(int i=0; i<n; i++) {
      v[i] = Integer.parseInt(str[i]);
    }
    str = in.readLine().split(" ");
    for(int i=0; i<n; i++) {
      c[i] = Integer.parseInt(str[i]);
    }
    
    int diff = 0;
    int ans = 0;
    for(int i=0; i<n; i++) {
      diff = v[i]-c[i];
      if(diff>0)
        ans += diff;
    }
    
    System.out.println(ans);
  }
}
//  [java]

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {

	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve() {

		int n = ni();
		int ans = 0;
		int v[] = na(n);
		for (int i = 0; i < n; i++)
			ans += Math.max(v[i] - ni(), 0);
		out.println(ans);

	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n) {
			if (!(isSpaceChar(b)))
				buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int[][] na(int n, int m) {
		int[][] a = new int[n][];
		for (int i = 0; i < n; i++)
			a[i] = na(m);
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}
//  [java]
import java.util.*;
import java.io.*;

public class Main {
	static int[] memo = new int[100000];
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int[] v = new int[n];
		int[] c = new int[n];
		for(int i = 0; i < n; i++)
			v[i] = sc.nextInt();
		for(int i = 0; i < n; i++)
			c[i] = sc.nextInt();	
		
		int sum = 0;
		for(int i = 0; i < n; i++) {
			if (v[i] > c[i]) sum += v[i] - c[i];
		}
		out.println(sum);
		
		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}
//  [java]
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      ArrayList<Integer> plus = nextIntArray();
      ArrayList<Integer> minus = nextIntArray();
      int output = 0;
      for(int i = 0; i < N; i++){
        if(plsu.get(i) > minus.get(i)){
          output += plus.get(i) - minus.get(i);
        }
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}
//  [java]
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      ArrayList<Integer> plus = nextIntArray();
      ArrayList<Integer> minus = nextIntArray();
      int ouptut = 0;
      for(int i = 0; i < N; i++){
        if(plsu.get(i) > minus.get(i)){
          output += plus.get(i) - minus.get(i);
        }
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}