jiahuimbzuai/CoQuIR huggingface dataset:
//  [swift]
let K = Int(readLine()!)!
let S = readLine()!

if S.count <= K {
    print(S)
} else {
    print(S.dropLast(S.count - K) + "...")
}
//  [swift]
let k = Int(readLine()!)!
let s = readLine()!
if s.count <= k {
    print(s)
} else {
    let i = s.index(s.startIndex, offsetBy: k-1)
    print(s[...i] + "...")
}
//  [swift]
import Foundation

let k = Int(readLine()!)!
let s = readLine()!
let count = s.length
if (count > k) {
    print(s.prefix(k)+"...")
} else {
    print(s)
}
//  [swift]
import Foundation
func main(){
    let k = Int(readLine()!)!
    let s = readLine()!
    
    if s.count <= k{
        print(s)
        return
    }
    print("\(s.prefix(k))...")
}
main()
//  [swift]
import Foundation

let K = Int(readLine()!)!
let S = readLine()!

if S.count <= K {
    print(S)
} else {
    print("\(S.prefix(K))...")
}
//  [typescript]
import * as fs from 'fs';

export function Main(input: string) {
    const lines = input.split('\n');    // ?
    const k = parseInt(lines[0]);   // ?
    const s = lines[1];

    let result = '';

    if(s.length <= k) {
        result = s;
    } else {
        result = `${s.substr(0, k)}...`;
    }

    //output

    console.log(result);
}

// Don't edit this line!
Main(fs.readFileSync("/dev/stdin", "utf8"));
//  [typescript]
/**
 * https://atcoder.jp/contests/abc168/tasks/abc168_b
 * 
 * ■問題文
 * 英小文字からなる文字列 S があります。
 * S の長さが K 以下であれば、S をそのまま出力してください。
 * S の長さが K を上回っているならば、先頭 K 文字だけを切り出し、末尾に ... を付加して出力してください。
 * 
 * ■制約
 * ・K は 1 以上 100 以下の整数
 * ・S は英小文字からなる文字列
 * ・S の長さは 1 以上 100 以下
 */
export function Main(input: string) {
  // 問題文解体エリア
  const inputs = input.split("\n");
  const limit = new Number(inputs[0]).valueOf();
  const str = inputs[1];

  // console.log(nums);
  // 問題解決エリア
  const answer = fuck(limit, str);

  //出力エリア
  console.log(answer.toString());
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
// 提出する時にコメントアウト解除せよ
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

export function fuck(limit:number, str:string): string {
  if (str.length > limit) {
    return str.substr(0, limit) + "...";
  } else {
    return str;
  }
}
//  [typescript]
import * as fs from 'fs'
import {debug} from '../../../util'

const input = fs.readFileSync('/dev/stdin', 'utf8').trim()

const output = (x: string | number | boolean) => console.log(x)
const splitLine = (string: string): string[] => string.split('\n')
const splitBlank = (string: string): string[] => string.split(' ')
const toNumbers = (array: string[]): number[] => array.map(v => Number(v))
const createSerialNumber = (n: number): number[] => [...Array(n).keys()]

// debug(input)

/* ここから */
const [K, S] = splitLine(input)

if (S.length <= +K) {
    output(S)
} else {
    output(S.substr(0, +K) + '...')
}
//  [typescript]
import * as fs from "fs";

function strArr2numArr(strArr: string[]): number[] {
    let numArr: number[] = [];
    strArr.map((item) => {
        numArr.push(+item);
    });
    return numArr;
}

const MOD: number = 1e9 + 7;

const input = fs.readFileSync("/dev/stdin", "utf8").split("\n");

let k: number;
let s: string;

k = +input[0];
s = input[1];

let subs: string = s.substr(0, k);

let ans: string = s.length > k ? subs + "..." : s;
console.log(ans);
//  [typescript]
"use strict";

const main = arg => {
  const input = arg.trim().split("\n");
  const N = parseInt(input[0]);
  const S = input[1]
  if (S.length > N) {
    console.log(S.substring(0, N) + "...");
  } else {
    console.log(S);
  } 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
import numpy as np

n, m = map(int, input().strip().split())
data = [map(int, input().strip().split()) for _ in range(m)]

left = np.zeros(n + 1, dtype=np.int32)
right = np.zeros(n + 1, dtype=np.int32)

for l, r in data:
    left[l] += 1
    right[r] += 1

card = 0
count = 0
for i in range(n + 1):
    count += left[i]
    if count == m:
        card += 1
    count -= right[i]

print(card)
//  [python]
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N,M = map(int, lines.pop(0).split(' '))
    min_n = 0
    max_n = N
    for i in range(M):
        a,b = map(int, lines.pop(0).split(' '))
        min_n = max(a, min_n)
        max_n = min(b, max_n)
    print( max(0, max_n - min_n + 1 ) )

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)
//  [python]
import sys

def parse(inp):
    n,m = map(int,next(inp).split())
    lr =[]
    for _ in range(m):
        lr.append(list(map(int,next(inp).split())))
    
    return n,m,lr
  
def main(inp):
    n,m,lr = inp
    
    b1 = 1
    b1 = ((b1 << (lr[0][1]-lr[0][0]+1)) - 1) << lr[0][0]-1 
    
    b2 = 1
    for i in range(1,m):
        b2 = ((b2 << (lr[i][1]-lr[i][0]+1)) - 1) << lr[i][0]-1
        b1 = b1 & b2
        b2 = 1
    
    mask = (1 << n) - 1
    b1 = b1 & mask
    return bin(b1).count("1")
  
print(main(parse(sys.stdin)))
//  [java]
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] l = new int[m][2];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < 2; j++) {
                l[i][j] = sc.nextInt();
            }
        }
        int[] nn = new int[n+1];
        for (int i = 0; i < m; i++) {
            int s = l[i][0];
            int e = l[i][1];
            for (int j = s; j < e + 1; j++) {
                nn[j]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < nn.length; i++) {
            if(nn[i] == m) ans++;
        }
        System.out.println(ans);
    }
}
//  [java]
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] l = new int[m];
        int[] r = new int[m];
        ArrayList<Integer> id = new ArrayList<>();
 
        l[0] = scanner.nextInt();
        r[0] = scanner.nextInt();
        for (int i = l[0]; i <= r[0]; i++) {
            id.add(i);
        }
 
        if(m > 1) {
            for (int i = 1; i < m; i++) {
                l[i] = scanner.nextInt();
                r[i] = scanner.nextInt();
 
                if (id.size() == 0) {
                    break;
                }
 
                while (id.get(0) < l[i]) {
                    id.remove(0);
                    if (id.size() == 0) {
                        break;
                    }
                }
                              if (id.size() == 0) {
                    break;
                }
                while (id.get(id.size() - 1) > r[i]) {
                    id.remove(id.size() - 1);
                    if (id.size() == 0) {
                        break;
                    }
                }
            }
        }
        System.out.println(id.size());
    }
}
//  [java]
import java.util.BitSet;
import java.util.Scanner;

class Solver {
    Solver(Scanner in){
        int N = in.nextInt();
        int M = in.nextInt();
        BitSet bits = new BitSet(N);
        bits.set(0, N);
        for (int i = 0; i < M; i++) {
            BitSet gate = new BitSet(N);
            gate.set(in.nextInt() - 1, in.nextInt());
            bits.and(gate);
        }
        System.out.println(bits.cardinality());
    }

    void solve() {

    }
}

class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);

        new Solver(in).solve();

        in.close();
    }
}
//  [cpp]
#include <iostream>
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
//x+1 = rx - D
int main()
{
    int N,M;
    int flag[101000] = {0};
    int L,R;
    int cnt = 0;
    cin >> N >> M;
    REP(i,M){
        cin >> L >> R;
        if (i == 0)
        {
            REPD(j,L,R+1){
                flag[j] = 1;
            }
        }
        else
        {
            REPD(j,1,L) flag[j] = 0;
            REPD(j,R+1,N+1) flag[j] = 0;
        }
    }
    REPD(i,1,N+1){
        //fin(flag[i]);
        cnt += flag[i];
    }
    fin(cnt);
    return 0;
}
//  [cpp]
#include <iostream>
#include <numeric>
using namespace std;
 
int main()
{
	int n, m;
    int* l;
    int* r;
    int* f;
    int a;
 
    cin.tie(0);
    ios::sync_with_stdio(false);
	cin >> n >> m;
    l = new int[m];
    r = new int[m];
    f = new int[n];
    for(int i = 0; i < n; i++) {
        f[i] = 1;
    }
    for(int i = 0; i < m; i++) {
        cin >> l[i] >> r[i];
    }

    for(int g = 0; g < m; g++){
        for(int h = 0; h < l[g] - 1; h++) {
            f[h] = 0;
        }
        for(int h = r[g]; h < n; h++) {
            f[h] = 0;
        }
    }
 
    a = 0;
    for(int i = 0; i < n; i++) {
        a += f[i];
    }
    cout << a << endl;
 
	return 0;
}
//  [cpp]
#include<iostream>

using namespace std;

const int MAX_N = 100000;

int N, M;
int Set[MAX_N+1]; 

int start;
int endo;


int main() {
    cin >> N >> M;
    for(int i = 1; i < N+1; i++) {
        Set[i] = 1;
    }
    start = 0;
    endo = N+1;
    for(int i = 0; i < M; i++) {
        int tmp_l, tmp_r;
        cin >> tmp_l >> tmp_r;
        if (start <= tmp_l) {
            for(int j = 1; j < tmp_l; j++) {
                Set[j] = 0;
            }
            start = tmp_l;
        }
        if (endo >= tmp_r) {
            for(int j = tmp_r+1; j < N+1; j++) {
                Set[j] = 0;
            }
            endo = tmp_r;
        }   
    }
    int ans = 0;
    for(int i = 1; i < N+1; i++) {
        if(Set[i] == 1) {
            ans += 1;
        }
    }
    cout << ans << endl;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>

#define SENTINEL 1000000000

int count=0;

void mergeSort(int A[],int left,int right){
  int i,mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}



void merge(int A[],int left,int mid,int right){
  int n1,n2,i,j,k;
  int *L,*R;
  n1=mid-left;
  n2=right-mid;
  L=(int *)malloc(sizeof(int)*(n1+1));
  R=(int *)malloc(sizeof(int)*(n2+1));
  for(i=0;i<=n1-1;i++){
    L[i]=A[left+i];
  }
  for(j=0;j<=n2-1;j++){
    R[j]=A[mid+j];
  }
  L[n1]=SENTINEL;
  R[n2]=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<=right-1;k++){
   if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
      count++;
    }
    else{
      A[k]=R[j];
      j++;
      count++;
    }
  }
  free(L);
  free(R);
}



  
  
int main(){
  int n,m,a[100005],b[100005];
  int i,j,k;
  int tmp,tmp2;
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d %d",&a[i],&b[i]);
  }
  mergeSort(a,0,m);
  mergeSort(b,0,m);
  if(b[0]>=a[m-1])k=b[0]-a[m-1]+1;
  else k=0;
  printf("%d",k);
  return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>

int compare(const void *a, const void *b){
    return *(int *)a - *(int *)b;
}

int max(int a[],int n){
    qsort(a,n,4,compare);
    return a[n-1];
}
int min(int a[],int n){
    qsort(a,n,4,compare);
    return a[0];
}


int main(void){
    int n,m,i,a;
    scanf("%d%d",&n,&m);
    int l[m],r[m];
    for(i=0;i<m;i++){
        scanf("%d%d",&l[i],&r[i]);
    }
    if(min(r,m) < max(l,m)){
        printf("0\n");
        return 0;
    }
    a = min(r,m) - max(l,m) +1;
    printf("%d\n",a);
    return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>

int comp(const void *n1, const void *n2)
{
  int *a= n1, *b = n2; 
  if(*a < *b)
    return -1;
  else if(*a == *b)
    return 0;
  else
    return 1;
}


int main(void)
{
  int n,m,l[100000],r[100000];
  int buttom=0,top=0,frag=0;
  int i,sum;
  
  scanf("%d %d",&n, &m);
  for(i = 0; i < m; i++)
    scanf("%d %d",l+i, r+i);
  
  qsort(l, m, sizeof(int), comp);
  qsort(r, m, sizeof(int), comp);
  
  sum = r[0] - l[m-1] + 1;
  if(sum > 0)
  	printf("%d\n",sum);  
  else
    printf("0\n");
  return 0;
}
//  [javascript]


function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var M = parseInt(input[0].split(" ")[1]);
  var min=N;
  var max=0;
  for(var i=0;i<M;i++){
    min=Math.min(min,parseInt(input[i+1].split(" ")[1]));
    max=Math.max(max,parseInt(input[i+1].split(" ")[0]));
  }
  var ans=min-max+1;
  if(ans<0){
    ans=0;
  }



  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
var lines = [];

var readline = require('readline')
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});


rl.on('line', (x) => {
    lines.push(x)
});

rl.on('close', () => {
    var N = Number(lines[0].split(" ")[0])
    var M = Number(lines[0].split(" ")[1])
    lines.shift()

    var LR = lines.map(i => i.split(" ").map(i => Number(i)));
    var start = 1; var goal = Infinity;

    for (var i = 0; i < M; i++) {
        var l = LR[i][0]; var r = LR[i][1];

        start = Math.max(start, l);
        goal = Math.min(goal, r);
    }

    console.log(Math.max(goal - start + 1, 0))
});
//  [go]
package main

import (
	"fmt"
	// "sort"
	//"regexp"
)

var n, m, a, b, ans int

func main() {
	fmt.Scan(&n)
	fmt.Scan(&m)
	min := 0
	max := 1000001
	for i := 0; i < m; i++ {
		fmt.Scan(&a)
		fmt.Scan(&b)
		if min < a {
			min = a
		}
		if max > b {
			max = b
		}
	}
	for i := 1; i < n+1; i++ {
		open := false
		if i >= min && i <= max {
			open = true
		}
		if open {
			ans++
		}
	}
	fmt.Printf("%d\n", ans)
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int
	var l, r []int

	fmt.Scan(&n, &m)
	for i := 0; i < m*2; i++ {
		var tmp int
		fmt.Scan(&tmp)
		if i%2 == 0 {
			l = append(l, tmp)
		} else {
			r = append(r, tmp)
		}
	}

	sort.Ints(l)
	sort.Ints(r)

	if r[0]-l[m-1] >= 0 {
		fmt.Println(r[0] - l[m-1] + 1)
	} else {
		fmt.Println(0)
	}
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	inputs := scanNums(M)
	maxL := 1
	minR := N
	for _, v := range inputs {
		L := v[0]
		R := v[1]
		if maxL <= L {
			maxL = L
		}
		if minR >= R {
			minR = R
		}
		// fmt.Println(L, R, maxL, minR)
	}

	res := minR - maxL + 1
	if res < 0 {
		res = 0
	}
	fmt.Println(res)

}

func scanNums(len int) (nums [][]int) {
	var numL, numR int

	for i := 0; i < len; i++ {
		fmt.Scan(&numL, &numR)
		LR := make([]int, 0)
		LR = append(LR, numL)
		LR = append(LR, numR)
		nums = append(nums, LR)
	}
	return
}
//  [ruby]
N, M = gets.split.map(&:to_i)
res = -1
$<.read.split.map(&:to_i).each_slice(2).to_a.uniq.each { |l, r| res &= (1 << r+1) - (1 << l) }
p ("%b"%res).count(?1)
//  [ruby]
nn, mm = gets.split.map(&:to_i)
lr =
  readlines.map do |i|
    i.chomp.split.map(&:to_i)
  end

l_max = lr.sort{|a,b|b<=>a}[0][0]
r_min = lr.sort_by!{|a|a[1]}[0][1]
puts l_max>r_min ? 0 : (r_min - l_max + 1)
//  [ruby]
def cc127
    n,m = gets.chomp.split(/\s/).map{|x| x.to_i}

    l = 0
    r = 0
    z = false
    for i in 1..m
        nl,nr = gets.chomp.split(/\s/).map{|x| x.to_i}
        next if z
        if i == 1
            l = nl
            r = nr
        else
            if nl > r or nr < l
                z = true
                next
            end

            l = [l, nl].max
            r = [r, nr].min
        end
    end

    if r-l < 0 or z
        puts 0
        exit
    end
    puts r-l+1
end

cc127
//  [rust]
use std::cmp::{max, min};
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let m:usize = read();
    let mut left:i64 = read();
    let mut right:i64 = read();
    for _ in 1..m {
        left = max(left, read());
        right = min(right, read());
    }
    println!("{}", max(right-left+1, 0));
}
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};

fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut l: Vec<i64> = vec![];
    let mut r: Vec<i64> = vec![];

    for _ in 0..m {
        l.push(read());
        r.push(read());
    }

    println!(
        "{}",
        max(0, r.iter().min().unwrap() - l.iter().max().unwrap() + 1)
    );
}
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut l: Vec<i32> = Vec::new();
    let mut r: Vec<i32> = Vec::new();

    for _ in 0..m {
        l.push(read());
        r.push(read());
    }

    let ans = r.iter().min().unwrap() - l.iter().max().unwrap() + 1;
    if ans < 0 {
        println!("0");
    }else {
        println!("{}", ans);
    }

}
//  [swift]
var arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

var id = arr[0]; var gate = arr[1];
var array = Array(count:arr[0], repeatedValue: 0 )

var min = 0
var max = id - 1
var o = 0
//arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
while let line = readLine() {
  arr=line.characters.split{$0==" "}.map{Int(String($0))!}
  
  if( arr[0] - 1 > min ) {
    min = arr[0] - 1
  }
  
  if( max > arr[1] - 1 ) {
    max = arr[1] - 1
  }
      
}

let newArray = array.filter { $0 == gate }
if( (max - min)  < 0 )  {
  print( 0 )
}
else {
  print( (max - min) + 1 )
}
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
//    func enumerated() -> [(Int, Element)] {
//        return self.enumerate()
//    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/

//func gcd(x: Int, _ y: Int) -> Int {
//    if y == 0 {
//        return x
//    } else {
//        return gcd(y, x%y)
//    }
//}
//func lcm(x: Int, _ y: Int) -> Int {
//    return x * y / gcd(x, y)
//}

/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (N, M) = (input[0], input[1])
var maxL = 1
var minR = N
for _ in 0..<M {
    let input = readIntSplit(by: " ")
    let (l, r) = (input[0], input[1])
    maxL = max(l, maxL)
    minR = min(r, minR)
}
print(max(minR-maxL+1, 0))
//  [swift]
import Foundation

extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
}

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


/************** main *****************/

let nm = readIntSplit(by: " ")
let (n, m) = (nm[0], nm[1])
var (t, b) = (1, n)
for i in 1...m {
    let lr = readIntSplit(by: " ")
    let (l, r) = (lr[0], lr[1])
    if t < l{
        t = l
    }
    if b > r {
        b = r
    }
}
let ans = b - t + 1
if ans < 0 {
    print(0)
} else {
    print(ans)
}
//  [typescript]

{
  const process = (n: number, m: number, gates: number[][]): string => {
    let min = 0
    let max = 100000

    gates.forEach((e) => {
      if (e[0] > min) {
        min = e[0]
      }
      if (e[1] < max) {
        max = e[1]
      }
    })

    if (max - min <= n) {
      if (max - min + 1 < 0) {
        return "0"
      }
      return (max - min + 1).toString()
    }
    return n + ""
  }

  const Main = (input: string): string => {
    const aa: string[] = input.split("\n")
    const [n, m]: number[] = aa[0].split(" ").map((e) => parseInt(e))
    const secondLast: number[][] = aa.slice(1).map((e) => e.split(" ").map((e) => parseInt(e)))

    const res = process(n, m, secondLast)
    console.log(res)
    return res
  }

  Main(require("fs").readFileSync("/dev/stdin", "utf8"))
}
//  [typescript]
function Main(input) {
	const data = input.split("\n").map(n => n.split(" ").map(p => Number(p)));
	const [n, m] = data[0];
	let maxL = data[1][0];
	let minR = data[1][1];
	for (let i = 2; i <= m; i++) {
		const [l, r] = data[i];
		maxL = maxL < l ? l : maxL;
		minR = r < minR ? r : minR;
	}
	console.log(0 <= minR - maxL ? minR - maxL + 1 : 0);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [n, m] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const [, ..._lr] = stdin.trim().split('\n')
const lr = _lr.map(e => e.split(' ').map(Number))

const ans = _ => {
  let lMax = lr[0][0]
  let rMin = lr[0][1]

  for (let i = 0; i < lr.length; i++) {
    const [l, r] = lr[i]

    if (l > lMax) {
      lMax = l
    }

    if (r < rMin) {
      rMin = r
    }
  }

  if (rMin >= lMax) {
    return rMin - lMax + 1
  } else {
    return 0
  }
}

console.log(ans())
//  [python]
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353



T, S = sys.stdin.buffer.readline().decode().rstrip().split()
print(S+T)
//  [python]
import resource
from sys import stdin
strings = list(stdin.readline().split())
print(strings[1] + strings[0])
//  [python]
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


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


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
    S, T = get_inputs()
    print(T + S)


if __name__ == '__main__':
    main()
//  [java]
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.stream.Stream;

class Main {
    public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String str = scanner.next();
		String str2 = scanner.next();
		
		Pattern pattern = Pattern.compile("^[a-z]+$");
		
		boolean isClear = Stream.of(str, str2).allMatch(s -> pattern.matcher(s).find() && s.length() >= 1 && s.length() <= 100);
		if (isClear) {
			System.out.println(str2 + str);
		}
	}
}
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        System.out.println(t + s);
    }
}
//  [cpp]
//#include <bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    string S,T;
    cin >> S >> T;

    cout << T+S << endl;

}
//  [cpp]
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	string s, t;
	cin >> s >> t;
	cout << t << s;
}
//  [c]
#include <stdio.h>

int main()

{
	char bambang1[105];
	char bambang2[105];
	
	scanf("%s %s",&bambang1,&bambang2);
	printf("%s%s\n",bambang2,bambang1);
	
	
	return 0;
}
//  [c]
#include <stdio.h>
int main(){
char s[100];
char t[100];
scanf("%s %s",s,t);
printf("%s%s",t,s);
	return 0;
}
//  [c]
#include <stdio.h>

int main()
{
  char S[105],T[105];
  scanf("%s %s",S,T);
  printf("%s%s\n",T,S);
  return 0;
}
//  [javascript]
"use strict";

function Main(input) {
let x = input.split(' ');
console.log(x[1] + x[0]);

}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
//  [javascript]
'use strict'

function main(inp) {
  inp = inp.trim().split(' ')
  console.log(inp[1]+inp[0])
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});
	let S = input[0][0];
	let T = input[0][1];
	
	console.log(T + S);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

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

const (
	BUFSIZE   = 10000000
	MOD       = 1000000007
	INF_INT   = math.MaxInt32
	INF_INT64 = math.MaxInt64
)

var rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)

func main() {
	solve()
}

func solve() {
	var S, T string
	fmt.Scanf("%s %s", &S, &T)
	fmt.Println(T + S)
}

func ReadLineInt64() []int64 {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			fmt.Println(e.Error())
			panic(e)
		}

		buf = append(buf, l...)

		if !p {
			break
		}
	}
	str := strings.Split(string(buf), " ")
	l := len(str)

	ret := make([]int64, l)

	for i, s := range str {
		ret[i] = s2i64(s)
	}
	return ret
}

func ReadLineInt() []int {
	values := ReadLineInt64()
	ret := make([]int, len(values))
	for i, v := range values {
		ret[i] = int(v)
	}
	return ret
}

func ReadInt() int {
	v := ReadLineInt()
	return v[0]
}
func ReadInt2() (int, int) {
	v := ReadLineInt()
	return v[0], v[1]
}
func ReadInt3() (int, int, int) {
	v := ReadLineInt()
	return v[0], v[1], v[2]
}
func ReadInt4() (int, int, int, int) {
	v := ReadLineInt()
	return v[0], v[1], v[2], v[3]
}

func ReadInt64() int64 {
	v := ReadLineInt64()
	return v[0]
}
func ReadInt64_2() (int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1]
}
func ReadInt64_3() (int64, int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1], v[2]
}
func ReadInt64_4() (int64, int64, int64, int64) {
	v := ReadLineInt64()
	return v[0], v[1], v[2], v[3]
}

func s2i64(s string) int64 {
	v, ok := strconv.ParseInt(s, 10, 64)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int64")
	}
	return v
}

// For int64
func Bool2Int64(b bool) int64 {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs64(v int64) int64 {
	if v < 0 {
		return -v
	}
	return v
}

func Min64(a, b int64) int64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func Max64(a, b int64) int64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func Distance64(a, b int64) int64 {
	return Abs64(a - b)
}

// For int
func Bool2Int(b bool) int {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func Min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func Max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func Distance(a, b int) int {
	return Abs(a - b)
}
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	s := Scan()
	t := Scan()
	fmt.Println(t + s)
}
//  [ruby]
x,y=gets.split.map(&:chomp)
puts y+x
//  [ruby]
s,t = gets.chomp.split(" ").map(&:to_s);

puts t+s
//  [ruby]
a, b = gets.split
puts b + a
//  [rust]
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        s: String,
        t: String
    };

    let res = format!("{}{}", t, s);
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}
//  [rust]
#[allow(unused_imports)]
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(s: String, t: String);
    println!("{}{}", t, s);
}
//  [swift]
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let st = readLine()!.split(separator: " ")
    print(st[1] + st[0])
}

main()
//  [swift]
import Foundation

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

let strs = readLine()!.components(separatedBy: " ")
let ans:String=strs[1]+strs[0]
print(ans)
//  [typescript]
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

const [s, t] = input[0].split(' ');
console.log(t+s);
//  [typescript]
function Main(input) {
	const lines = input.split("\n");
  const [s, t] = lines[0].split(' ');
  
	console.log(t + s);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
import * as fs from 'fs';

//in
// oder atc
//out
// atcoder
function main(inp:string) {
    const [s,t] = inp.split(' ').map(String);
    console.log(t+s);
}

main(fs.readFileSync('/dev/stdin','utf8').trim());
//  [python]
import sys
input = sys.stdin.readline
def main():
    # D, Tは文字数カウントするだけだからint型にする必要なし.
    n = int(input())
    D = input().split()
    m = int(input())
    T = input().split()
    dic = dict()
    
    # 辞書はDだけで十分.Counterより速い.
    for d in D:
        # dic.get(d)と比べると, if in の方が速い.
        if d in dic:
            dic[d] += 1
        else:
            dic[d] = 1
            
    for t in T:
        if t not in dic or dic[t] == 0:
            print('NO')
            return
        else:
            dic[t] -= 1
    print('YES')
main()
//  [python]
N = int(input())
Ds = [int(i) for i in input().split(' ')]
M = int(input())
Ts = [int(i) for i in input().split(' ')]

if M > N:
     print('NO')
else:
    dic = {}
    for d in Ds:
        if d in dic:
            dic[d] += 1
        else:
            dic[d] = 1
    for t in Ts:
        flag = 0
        if t in dic:#存在しているならば
            dic[t] -= 1
            if dic[t] < 0:
                flag = 1
                break
        else:#存在していないならば
            flag = 1
            break
    if flag == 1:
        print('NO')
    else:
        print('YES')
//  [python]
N = int(input())
d_dict = {}
D = list(map(int, input().split()))
for d in D:
  if not d in d_dict:
    d_dict[d] = 1
  else:
    d_dict[d] += 1

M = int(input())
T = list(map(int, input().split()))
for t in T:
  if not t in d_dict or d_dict[t] == 0:
    print('NO')
    exit()
  else:
    d_dict[t] -= 1
print('YES')
//  [python]
from collections import defaultdict
N = int(input())
D = list(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))
dic = defaultdict(int)
for d in D:
    dic[d] += 1
def find(a, i):
    l = 0
    r = len(a)-1
    mid = (l+r)//2
    while l <= r:
        if i == a[mid]:
            return mid
        elif i < a[mid]:
            r = mid - 1
        else:
            l = mid + 1
        mid = (l+r)//2
    return -1
keys = list(dic.keys())
keys.sort()
for i in range(M):
    j = find(keys, T[i])
    if j == -1 or dic[keys[j]] == 0:
        print("NO")
        exit(0)
    dic[keys[j]] -= 1
print("YES")
//  [python]
# -*- coding: utf-8 -*-

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))

def array_count(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

d.sort()
t.sort()

d = array_count(d)
t = array_count(t)

for i in range(len(t)):
    t[i][1] = -1 * t[i][1]
    d.append(t[i])

d.sort()

for i in range(1,len(d)):
    if d[i-1][0] == d[i][0]:
        d[i-1][1] = d[i-1][1] + d[i][1]
        d[i][1] = 0

flag = True

for i in range(len(d)):
    if d[i][1] < 0:
        flag = False
        break

if flag:
    print("YES")
else:
    print("NO")
//  [python]
import bisect
N = int(input())
D = list(map(int,input().split()))
D.sort()
D.append(0)
A = []
cur = D[0]
cnt = 0
for i in range(N+1):
  if cur == D[i]:
    cnt += 1
  else:
    A.append([cur,cnt])
    cur = D[i]
    cnt = 1
M = int(input())
T = list(map(int,input().split()))
T.sort()
T.append(0)
B = []
cur = T[0]
cnt = 0
for i in range(M+1):
  if cur == T[i]:
    cnt += 1
  else:
    B.append([cur,cnt])
    cur = T[i]
    cnt = 1
flag = True
for j in range(len(B)):
  k = bisect.bisect_left(A,B[j])
  if A[k][0] == B[j][0]:
    if A[k][1] >= B[j][1]:
      None
    else:
      flag = False
      break
  else:
    flag = False
    break
if flag:
  print('YES')
else:
  print('NO')
//  [java]
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;


public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		m.input();
		m.solve();
		m.output();
	}
	
	//	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	InputUtil in = new InputUtil();
	PrintWriter out = new PrintWriter(System.out);

	int N = 0;
	int M = 0;
	int[] D = null;
	int[] T = null;
	boolean ans = false;
	
	public void input() throws IOException {
		N = in.nextInt();
		D = in.nextInt(new int[N]);
		M = in.nextInt();
		T = in.nextInt(new int[M]);
				
	}

	public void solve() throws IOException {
		HashMap<Integer,Integer> DH = new HashMap<>();
		final Integer one = new Integer(1);
		for(Integer d : D){
			Integer value = null;
			if(DH.containsKey(d)){
				value = DH.get(d);
				value ++;
			}else{
				value = one;
			}
			DH.put(d, value);
		}
		HashMap<Integer,Integer> TH = new HashMap<>();
		for(Integer t : T){
			Integer value = null;
			if(TH.containsKey(t)){
				value = TH.get(t);
				value ++;
			}else{
				value = one;
			}
			TH.put(t, value);
		}
		
		for(Integer t : TH.keySet()){
			Integer tv = TH.get(t);
			Integer dv = DH.get(t);
			if(dv == null || tv > dv) {
				return;
			}
			
		}
		ans = true;
	}
	
	public void output() {
		out.println(ans ? "YES" : "NO");
		out.flush();
		
	}
}



class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}
//  [java]
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){

			int N = scan.nextInt();
			int[]D = new int[N];
			Map<Integer,Integer>dm = new TreeMap<Integer,Integer>();
			for(int i = 0;i<N;i++) {
				D[i] = scan.nextInt();
				if(dm.containsKey(D[i]))dm.put(D[i], dm.get(D[i])+1);
				else dm.put(D[i], 1);
			}

			int M = scan.nextInt();
			int[]T = new int[M];
			Map<Integer,Integer>tm = new TreeMap<Integer,Integer>();
			for(int i = 0;i<M;i++) {
				T[i] = scan.nextInt();
				if(tm.containsKey(T[i]))tm.put(T[i], tm.get(T[i])+1);
				else tm.put(T[i], 1);
			}

			if(N<M) {
				System.out.println("NO");
				return;
			}

			int ok = 1;

			for(Integer key:tm.keySet()) {
				int val = tm.get(key);

				if(!dm.containsKey(key)) {
					ok=0;
					break;
				}else{
					int dv = dm.get(key);
					if(val>dv) {
						ok=0;
						break;
					}
				}

			}

			if(ok==1)System.out.println("YES");
			else System.out.println("NO");





		}


	}


}
//  [java]
import java.util.Scanner;
import java.util.TreeMap;

class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int N = sc.nextInt();
		TreeMap<Integer, Integer> probs = new TreeMap<Integer, Integer>();
		for(int i = 0; i < N; i++) {
			int D = sc.nextInt();
			if(probs.containsKey(D)) probs.put(D, probs.get(D) + 1);
			else probs.put(D, 1);
		}
		boolean check = true;
		int M = sc.nextInt();
		for(int i = 0; i < M; i++) {
			int T = sc.nextInt();
			if(!probs.containsKey(T)) {
				check = false;
				continue;
			}else {
				probs.put(T, probs.get(T) - 1);
				if(probs.get(T) == 0) probs.remove(T);
			}
		}
		System.out.println(check ?  "YES" : "NO");
	}
}
//  [cpp]
#include<cstdio>
#include<algorithm>
#include<cstring>
const int N=200017;
inline int read()
{
	int ans=0,f=1;char t=getchar();
	while(t<'0'||t>'9')	f=(t=='-'?-1:1),t=getchar();
	while(t>='0'&&t<='9')	ans=ans*10+t-'0',t=getchar();
	return ans*f;
}
int a[N];
struct node
{
	int val,c,next;
}e[N];
const int mod=1e5+3;
int first[mod+7];
int cnt;
void add(int val)
{
	int x=val%mod;
	for(int k=first[x];k;k=e[k].next)
	if(e[k].val==val)
	{
		e[k].c++;
		return;
	}
	e[++cnt]=(node){val,1,first[x]};first[x]=cnt;
}
bool check(int val)
{
	int x=val%mod;
	for(int k=first[x];k;k=e[k].next)
	if(e[k].val==val&&e[k].c>0)
	{
		e[k].c--;
		return 1;
	}
	return 0;
}
int main()
{
	int n,m;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)	a[i]=read(),add(a[i]);
	scanf("%d",&m);
	int u;
	for(int i=1;i<=m;i++)
	{
		u=read();
		if(!check(u))	
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}
//  [cpp]
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=200005;
int n,m,a[maxn],b[maxn];
inline int _read(){
	int num=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') num=num*10+ch-48,ch=getchar();
	return num;
}
int main(){
	n=_read();for (int i=1;i<=n;i++) a[i]=_read();
	m=_read();for (int i=1;i<=m;i++) b[i]=_read();
	sort(a+1,a+1+n);sort(b+1,b+1+m);
	int j=1;
	for (int i=1;i<=m;i++){
		while(j<=n&&a[j]!=b[i]) j++;
		if (j>n) return printf("NO"),0;
		j++;
	}
	printf("YES");
}
//  [cpp]
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n, m, t[200000];
vector<int> d;
bool flag = true;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		d.push_back(a);
	}
	sort(d.begin(), d.end());

	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> t[i];
		vector<int>::iterator itr;
		if ((itr = lower_bound(d.begin() , d.end(), t[i])) != d.end() && *itr == t[i]) {
			//cout << *itr << endl;
			d.erase(itr);
		}
		else {
			flag = false;
		}
	}

	if (flag) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}
//  [cpp]
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)
#define INF 1000000000
#define ll long long

int n, m;
int flag[200001];
vector<int> d, t;
int main()
{
	cin >> n;
	REP(i, 0, n) {
		int dd;
		cin >> dd;
		d.push_back(dd);
	}
	cin >> m;
	REP(i, 0, m) {
		int tt;
		cin >> tt;
		t.push_back(tt);
	}
	sort(d.begin(), d.end());

	bool pass = true;
	REP(i, 0, m) {
		auto itr = lower_bound(d.begin(), d.end(), t[i]);
		if (*itr != t[i]) {
			pass = false;
			break;
		}
		else {
			d.erase(itr);
		}
	}

	if (pass) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}
//  [cpp]
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr double DINF =100000000000000000.0;
constexpr long long INF = 100000000000000000;
const double PI = acos(-1);
 
int main() {
	int n;
	cin >> n;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		v.emplace_back(a);
	}
	sort(v.begin(), v.end());
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;
		if (*lower_bound(v.begin(), v.end(), a) != a) {
			cout << "NO" << endl;
			return 0;
		}
		else {
			v.erase(lower_bound(v.begin(), v.end(), a));
		}
	}
	cout << "YES" << endl;
}