jiahuimbzuai/CoQuIR huggingface dataset:
//  [c]
#include<stdio.h>


void insertionSort(int a[],int n){
    int i,j,v;
    for(i=1;i<n;i++){
        v=a[i];          //v:未ソート部分の先頭
        j=i-1;
        while(j>=0&&a[j]>v){
            a[j+1]=a[j];    //vより大きい要素を後方へ移動
            j--;
        }
        a[j+1]=v;
    }
}

int main(void){
    int n,i,ans;
    scanf("%d",&n);
    int d[n];
    for(i=0;i<n;i++){
        scanf("%d",&d[i]);
    }
    insertionSort(d,n);
    ans=d[n/2]-d[n/2-1];
    printf("%d\n",ans);
    //printf("%d %d",d[n/2+1]);
    return 0;
}
//  [javascript]
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  var d=input[1].split(' ').map(e=>{
    return e-0;
  }).sort((a,b)=>{
    return a-b;
  });
  console.log(d[N/2]-d[N/2-1]);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'
const Main = (arg) => {
  let input = arg.trim().split('\n');
  let n = parseInt(input[0]);
  let dArr = input[1].split(' ').map(Number);
  // console.log({ n, dArr });

  dArr.sort((a, b) => a - b);
  let nL = dArr[(dArr.length) / 2 - 1];
  let nR = dArr[(dArr.length) / 2];
  // console.log({nL, nR})
  let answer = nR - nL;
  console.log(answer)



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

const main = input => {
	const args = input.trim().split('\n')
	const n = parseInt(args[0], 10)
	const d = args[1].split(' ').map(Number).sort((a, b) => a - b)
	console.log(d[n / 2] - d[n / 2 - 1])
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
function Main(input) {
  var len = parseInt(input.split("\n")[0]);
  input = input.split("\n")[1].split(" ");
  input.sort(function (a,b){
  	return parseInt(a) - parseInt(b);
  });
  //console.log(input);
  var getPosition = len / 2 - 1;
  var minNannido = parseInt(input[len / 2 - 1]);
  var maxNannido = parseInt(input[len / 2]);
  console.log(maxNannido - minNannido);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict';
function main(input) {
  const args = input.split('\n'),
        N = parseInt(args[0]),
        D = args[1].split(' ');
  let DSorted = D.sort((a,b) => parseInt(a) - parseInt(b));
  let ans = parseInt(DSorted[N/2]) - parseInt(DSorted[N/2-1]);
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function Main(input) {
  	inputArr = input.split("\n");
	var n = parseInt(inputArr[0], 10);
	var d = inputArr[1].split(" ");
    var ret = 0;
  
    dd = d.sort(function(a,b){
        var an = parseInt(a, 10);
        var bn = parseInt(b, 10);
        if( an < bn ) return -1;
        if( an > bn ) return 1;
        return 0;
	});
    var center = dd.length / 2 - 1;
    if (dd[center] === dd[center + 1]) {
        console.log(0);
    } else {
        console.log(dd[center + 1] - dd[center]);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	d := make([]int, n)
	for i := 0; i < n; i++ {
		d[i] = ri()
	}

	sort.Ints(d)

	// fmt.Println(d)

	x := n / 2
	ans := d[x] - d[x-1]
	fmt.Println(ans)
}
//  [go]
package main

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

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
	N := getStdinInt()
	d := getStdinIntArr()

	cnt := 0
	//prev := 0

	sort.Sort(sort.IntSlice(d))

	if d[N/2-1] == d[N/2] {
		fmt.Printf("0\n")
		return
	}

	cnt = d[N/2] - d[N/2-1]

	/*
		prev = d[N/2]
		for i := N/2; i >= 0; i-- {
			if prev > d[i] {
				break
			}
			cnt++
		}
	*/

	/*
		prev = d[N/2]
		for i := N/2 + 1; i < N; i++ {
			if prev != d[i] {
				break
			}
			cnt++
		}
	*/

	fmt.Printf("%d\n", cnt)
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}
//  [go]
package main

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

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = sc.NextInt()
	}
	sort.Ints(arr)
	l := 0
	r := n - 1
	for l < r {
		l++
		r--
	}
	/*
		if arr[l] == arr[r] {
			fmt.Printf("0\n") // output for debug
			return
		}
	*/
	fmt.Printf("%v\n", arr[l]-arr[r]) // output for debug

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}
	sort.Ints(as)

	ans := as[n/2] - as[n/2-1]
	fmt.Println(ans)
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	d := make([]int, n)
	for i := 0; i <n; i++ {
		fmt.Scan(&d[i])
	}
	sort.Ints(d)
	fmt.Println(d[n/2]-d[n/2-1])

}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	// Code for C - Divide the Problems
	var N int
	fmt.Scanf("%d", &N)

	d := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &d[i])
	}

	sort.Sort(sort.IntSlice(d))

	fmt.Println(d[len(d)/2] - d[(len(d)/2)-1])
}
//  [ruby]
n = gets.to_i
d = gets.chomp.split.map(&:to_i).sort!
puts d[n / 2] - d[n / 2 - 1]
//  [ruby]
n = gets.to_i
d = gets.split(' ').map(&:to_i)

d.sort!
puts d[n/2] - d[n/2-1]
//  [ruby]
N=gets.to_i
D=gets.split.map(&:to_i).sort
p D[N/2]-D[N/2-1]
//  [ruby]
n = gets.to_i
DS = gets.split.map(&:to_i)
def median(a)
  return a[a.size/2]
end
def fplus(m)
  left = DS.select{|i| i < m}.sort
  right = DS.select{|i| i >= m}.sort
  while(left.length != right.length) do
  	if left.length < right.length
		left << right.first
    	right.delete_at(0)
  	elsif left.length > right.length
    	right << left.last
    	left.delete_at(left.length-1)
  	end
  end
  return right.sort.first - left.sort.last
end
puts fplus(median(DS))
//  [ruby]
a = gets.chomp.to_i
b = gets.chomp.split(" ").map(&:to_i)

cnt = a/2
upsor = b.sort
dwsor = b.sort {|a, b| b <=> a }

max = upsor.slice(cnt-1)
min = dwsor.slice(cnt-1)

upc = min
dwc = max

if (upc-dwc) == 0
  puts "0"
else
  puts (upc-dwc)
end
//  [ruby]
a = gets.chomp.to_i
b = gets.chomp.split(" ").map(&:to_i)

cnt = a/2
upsor = b.sort
dwsor = b.sort {|a, b| b <=> a }

max = upsor.slice(cnt-1)
min = dwsor.slice(cnt-1)

puts (min-max)
//  [rust]
// https://atcoder.jp/contests/abc132/tasks/abc132_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const MAX: usize = 100010;

fn main() {
    input! {
        n: usize, d: [usize; n]
    };

    let mut tbl = vec![0; MAX];
    for di in d {
        tbl[di] += 1;
    }

    let mut total = 0;
    let mut less_than_i = 0;
    for i in 1..MAX {
        if less_than_i == n/2 {
            total += 1;
        }
        less_than_i += tbl[i];
    }

    println!("{}", total);
}
//  [rust]
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: usize,
    ds: [usize; n],
  }
  let m = n / 2;
  let mut pop = vec![0; 100_001];
  for &d in &ds {
    pop[d] += 1;
  }
  let mut ans = 0;
  let mut sum = 0;
  for k in 0 .. 100_001 {
    if sum == m {
      ans += 1;
    }
    sum += pop[k];
  }

  println!("{}", ans);
}
//  [rust]
use std::io::*;
use std::io::Write;
use std::str::FromStr;

/// input macro
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
///
/// # Example
///
#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[macro_export]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[macro_export]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! eprintln (
    ($($arg:tt)*) => { {
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);


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")
}

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}

fn main() {
    input! {
        n: usize,
        d: [i32; n],
    }

//    let min: i32 = *d.iter().min().unwrap();
//    let max: i32 = *d.iter().max().unwrap();

    let mut d = d;
    d.sort();
    let k0 = d[d.len() / 2 - 1] + 1;
    let k1 = d[d.len() / 2];
    debug!(d);
    debug!(k0, k1);

    let mut ans = k1 - k0 + 1;
//    for k in min - 1..max + 1 {
//        let arc: usize = d.iter().filter(|&x| *x >= k).count();
//        if arc == d.len() / 2 { ans += 1 }
//    }

    println!("{}", ans);
}
//  [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 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 mut v:Vec<usize> = (0..n).map(|_| read()).collect();
    v.sort();
    let median = v[(n-1)/2];
    println!("{}", v[n/2] - median);
}
//  [rust]
fn solve() {
    let n: usize = read();
    let mut a: Vec<usize> = (0..n).map(|_| read::<usize>()).collect();
    a.sort();
    let l = n / 2 - 1;
    let r = n / 2;
    println!("{}", a[r] - a[l]);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1_000_000_007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::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")
}

// =========
//  [swift]
// 🐋💭
import Foundation

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

func readInt() -> Int {
    return Int(readLine()!)!
}

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

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    let aryDifficulty = readInts().sorted()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    
    print(aryDifficulty[n / 2] - aryDifficulty[n / 2 - 1])
}
main()
//  [swift]
let N = Int(readLine()!)!
let d = readLine()!.characters.split(" ").map{Int(String($0))!}.sort()
print(d[N/2]-d[N/2-1])
//  [swift]
import Foundation
 
let input_line = readLine()!
 
let split = input_line.componentsSeparatedByString(" ") //components(separatedBy:)と実質同じ
let N = Int(input_line)!
 
var Pi = [Int]()
let input_line2 = readLine()!

let splits = input_line2.componentsSeparatedByString(" ") //components(separatedBy:)と実質同じ
Pi = splits.map {Int($0)!}.sort()
print(Pi[N / 2] - Pi[N / 2 - 1])
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let ar=asc(tnn(n)),ans=0
  to(ar[n/2]-ar[n/2-1])
}
main()
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

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

const d = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)

const ans = () => {
  const sorted = d.sort((a, b) => a - b)

  const center = n / 2

  const kMax = sorted[center]
  const kMin = sorted[center - 1]

  console.log(kMax - kMin)
}

ans()
//  [typescript]
const main = (input:String) => {
    const std: string[] = input.split('\n')
    const n: number = ~~std.shift()
    const d: number[] = std.shift().split(' ').map(Number).sort((a,b) => a-b)
    const dLeft: number[] = d.slice(0, n/2)
    const dRight: number[] = d.slice(n/2, n)
    const leftMax = dLeft.slice(-1)[0]
    const rightMin = dRight[0]
    if (leftMax === rightMin) return console.log(0)
    console.log(rightMin - leftMax)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());
//  [typescript]
let input = '';

process.stdin.on('data', (chunk: any) => {
  input += chunk;
});

process.stdin.on('end', () => {
  const args = normalize(input);
  main(args[0], args[1]);
});

function main(n: number, ps: number[]): void {
  const median = (array: number[]) => {
    if (array.length % 2 !== 0) throw new Error('Array should be even');
    const halfIndex = Math.floor(array.length / 2);
    const temp = array.sort((a, b) => a - b);
    return (temp[halfIndex - 1] + temp[halfIndex]) / 2;
  };
  const m = median(ps);
  if (ps.indexOf(m) !== -1) {
    console.log(0);
    return;
  }
  const sorted = [...ps, m].sort((a, b) => a - b);
  const medianIndex = sorted.findIndex(val => val === m);
  if (medianIndex === 0 || medianIndex === n) {
    console.log(0);
    return;
  }

  const diff = sorted[medianIndex + 1] - sorted[medianIndex - 1];
  const linear = Array.from(new Array(diff - 1), (_, k) => k).map(n => n + m).length;
  const extention = [-1, 1].filter(k => {
    return ps.filter(p => p >= sorted[medianIndex + k]).length === n / 2;
  }).length;
  console.log(linear + extention);
}

function normalize(input: any): [number, number[]] {
  const inputs = input.toString().split('\n');
  const n = Number(inputs[0]);
  const ps = inputs[1].split(' ').map((p: string) => Number(p));
  return [n, ps];
}
//  [typescript]
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { N: number, d: number[] } => {
  const N = +lines[0]
  const d = lines[1].split(' ').map(line => +line)
  const obj = { N, d }
  debug(obj)
  return obj
}

// solver
export const solve = (lines: string[]): string => {
  const { N, d } = parseLines(lines)
  d.sort((a, b) => a - b)
  const mid1 = N / 2 - 1
  const mid2 = N / 2
  if (d[mid1] < d[mid2]) {
    return `${d[mid2] - d[mid1]}`
  } else {
    return '0'
  }
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[])=>{for(let i=0;i<a.length;i+=2)if(s==a[i])return a[i+1]};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};
const main = ()=>{
  let n=nin()
  let [...a]= asc(nrin(n));
  if(a[n/2-1] == a[n/2]) out(0)
  else out(a[n/2] - a[n/2-1]);
}
main();
//  [python]
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()

if a == "H":
	print(b)
else:
	if b == "H":
		print("D")
	else:
		print("H")
//  [python]
a,b = raw_input().split()
h = {'H':'D', 'D':'H'} if a == 'D' else {'H':'H', 'D':'D'}
print h[b]
//  [python]
a, b = input().split()
if (a == "H" and b == "H") or (a == "D" and b == "D"):
  print("H")
else:
  print("D")
//  [java]
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
class Main{
    List<Integer> A = new ArrayList<Integer>();
    public void run(){
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            br.lines()
                .forEach(n -> met(n));
        }catch(Exception e){
        }
    }

    public void met(String n){
        String[] tmp = n.split(" ");
        if(Objects.equals(tmp[0],tmp[1]))
            System.out.println("H");
        else
            System.out.println("D");

        // Arrays.stream(n.split(" "))
        //     .forEach(n -> {
        //         if(Objects.equals(n[0],n[1]))
        //             System.out.println("H");
        //         else
        //             System.out.println("D");
        //     });
    }


    public static void main(String[] args){
        new Main().run();
    }
}
//  [java]
import java.util.*;
import java.io.PrintWriter;
public class Main {
    public static void main(String[] args){
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        String A =sc.next();
        String B =sc.next();
        if(A.equals(B)){
            out.println("H");
        }else{
            out.println("D");
        }

        out.flush();
    }
}
//  [cpp]
#include <iostream>
#include <vector>
#include <string>

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }



#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);

  // vector<int> hoge(1e7);        // 39296 KB
  // vector<bool> hoge(1e7);        // 1536 KB KB
  // vector<int> hoge(5*1e7);        // 195584 KB
  vector<int> hoge(6*1e7);        // 195584 KB

  char a, b;
  cin >> a >> b;
  if(a==b) {
    cout << "H" << endl;
  } else {
    cout << "D" << endl;
  }


  return 0;
}
//  [cpp]
#include <iostream>
#include <vector>
#include <string>

using namespace std;
// template for creating 2d vector
template<typename T>
vector<vector<T>> make_2d_vector(size_t rows, size_t cols, T init)
{ return vector< vector<T> >(rows, vector<T>(cols, init)); }



#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);

  // vector<int> hoge(1e7);        // 39296 KB
  // vector<bool> hoge(1e7);        // 1536 KB KB
  vector<int> hoge(5*1e7);        // 39296 KB

  char a, b;
  cin >> a >> b;
  if(a==b) {
    cout << "H" << endl;
  } else {
    cout << "D" << endl;
  }


  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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 c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  char a,b;cin>>a>>b;
  char ans=b;
  if(a=='D'){
      if(b=='H')ans='D';
      else ans='H';
  }
  
  cout(ans);
  
  return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    char a[2], b[2];
    
    scanf("%s%s", a, b);
    
    if (a[0]=='H'&&b[0]=='H') {
        printf("H");
    } else if (a[0]=='H'&&b[0]=='D') {
        printf("D");
    } else if (a[0]=='D'&&b[0]=='H') {
        printf("D");
    } else if (a[0]=='D'&&b[0]=='D'){
        printf("H");
    }
    
    return 0;
}
//  [c]
#include<stdio.h>

int main()
{
    char a, b;
    scanf("%c %c", &a, &b);

    if(a == b) printf("H");
    else printf("D");

    return 0;
}
//  [c]
#include<stdio.h>
int main (){
char a,b;
  scanf("%c %c",&a,&b);
  
  if(a==b)printf("H");
  if(a!=b)printf("D");

  return 0;
  
}
//  [javascript]
'use strict'

const main = input => {
	const args = input.trim().split(' ')
	if (args[0] === 'H' && args[1] === 'H') console.log('H')
	else if (args[0] === 'H' && args[1] === 'D') console.log('D')
	else if (args[0] === 'D' && args[1] === 'H') console.log('D')
	else console.log('H')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
let [a, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(" ").map(n => n.trim());
console.log(a == b ? "H" : "D");
//  [javascript]
function Main(input) {
  input = input.trim()
  input = input.split(" ");
if(input[0]==input[1]){
  console.log("H")
}else{
  console.log("D")
}

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

import "fmt"

func main() {
	// Code for A - HonestOrDishonest
	var a, b string
	fmt.Scanf("%s %s", &a, &b)

	if (a[0] == 'H' && b[0] == 'H') || (a[0] == 'D' && b[0] == 'D') {
		fmt.Println("H")
	} else {
		fmt.Println("D")
	}

}
//  [go]
package main

import "fmt"

func main() {
	var a, b string
	fmt.Scan(&a, &b)

	if a == "H" && b == "H" {
		fmt.Println("H")
	} else if a == "H" && b == "D" {
		fmt.Println("D")
	} else if a == "D" && b == "H" {
		fmt.Println("D")
	} else if a == "D" && b == "D" {
		fmt.Println("H")
	}
}
//  [go]
package main

import (
  "fmt"
)

func main() {
  var a, b string
  
  fmt.Scanf("%s %s", &a, &b)

  ans := "D"
  if a == b {
    ans = "H"
  }
  
  fmt.Printf("%s", ans)
}
//  [ruby]
a, b = gets.chomp.split
if a == 'H'
  puts b
else
  puts b == 'H' ? 'D' : 'H'
end
//  [ruby]
a, b = gets().chomp.split("\s")

if a == 'H'
  puts b
else
  puts b == 'H' ? 'D' : 'H'
end
//  [ruby]
a,b = gets.chomp.split(' ')
if a == "H" && b == "H"
  puts "H"
elsif a == "H" && b == "D"
  puts "D"
elsif a == "D" && b == "H"
  puts "D"
else
  puts "H"
end
//  [rust]
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a = iterator.next().unwrap();
    let b = iterator.next().unwrap();

    return if a == "H" {
        if b == "H" {
            "H".to_string()
        } else {
            "D".to_string()
        }
    } else {
        if b == "H" {
            "D".to_string()
        } else {
            "H".to_string()
        }
    };
}
//  [rust]
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a = iterator.next().unwrap();
    let b = iterator.next().unwrap();

    return if a == "H" && b == "H" || a == "D" && b == "D" {
        "H".to_string()
    } else {
        "D".to_string()
    };
}
//  [rust]
use proconio::input;

// use std::cmp::*;
// use std::collections::*;
// use proconio::marker::Chars;

fn main() {
    input! {
        // s: String
        // n: isize
        a:char,
        b:char
    }
    let ans: char;

    if a == 'H' {
        ans = b;
    } else {
        ans = if b == 'H' { 'D' } else { 'H' }
    }
    println!("{}", ans);
}
//  [typescript]
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [a, b] = input[0];

  return a === b ? "H" : "D";
};

console.log(main(read()));
//  [typescript]
import * as fs from 'fs';

const [a, b]: string[] = fs.readFileSync('/dev/stdin', 'utf8').trim().split(' ');

// H H H
// H G G
// G H G
// G G H


if (a === b) {
    console.log('H');
} else {
    console.log('D');
}
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const [a, b] = stdin
  .split('\n')[0]
  .split(' ')

const res = _ => {
  if (b === 'H' && a === 'H') {
    return 'H'
  } else if (b === 'D' && a === 'D') {
    return 'H'
  }
  return 'D'
}

console.log(res())
//  [python]
def main():
	s = str(input())
	t = str(input())
	
	
	if len(s) == len(t):
		ans = 0
		for i in range(len(t)):
			if list(s)[i] == list(t)[i]:
				ans += 1
		print(len(t)-ans)

	else:
		l = []
		for i in range(len(s)-len(t)):
			l.append(s[i:i+len(t)])
		
		ans = []
		for c in l:
			counter = 0
			for i in range(len(c)):
				if list(c)[i] == list(t)[i]:
					counter += 1
			ans.append(counter)

		if not ans:
			print(len(t))
		else:
			print(len(t)-max(ans))





	

if __name__ == '__main__':
	main()
//  [python]
S = input()
T = input()

min_dist = 10**10
for i in range(len(S) - len(T) + 1):
    for k in range(len(T)):
        dist = 0
        for s, t in zip(S[i:i + len(T)], T):
            if s != t:
                dist += 1
            if dist >= min_dist:
                break

        min_dist = min(dist, min_dist)
        if min_dist == 0:
            print(0)
            exit()

print(min_dist)
//  [python]
# -*- coding: utf-8 -*-
import math
from operator import mul
from functools import reduce
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
import copy
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


s = S()
t = S()
S = s
T = t

min_ = 0
max_ = len(T)
# len(S) - len(T) + 1
for x in range(max_+1):
    # x文字置き換えて良い
    for i in range(len(S) - len(T) + 1):
        count = 0
        for (a, b) in zip(T, S[i:i + len(T)]):
            if (a == b):
                count += 1
        if (count+x >= len(T)):
            print(x)
            exit()
//  [java]
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String S = s.next();
        String T = s.next();
        char[] SS = S.toCharArray();
        char[] TT = T.toCharArray();
        int count = T.length();

        for (int i = 0; i < T.length(); i++) {
            for (int j = i; j < S.length(); j++) {
                int n = i;
                if (TT[i] == SS[j]) {
                    for (int k = 0; k < T.length() - i; k++) {
                        if(j + k >= S.length()){
                            n = count;
                            break;
                        }
                        if (TT[i + k] != SS[j + k]) n++;
                    }
                    if (n < count) count = n;
                }
            }
        }

        System.out.println(count);
    }
}
//  [java]

// Submitted by Subhash
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
	

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		String s=sc.next(),t=sc.next();
		char c1[]=s.toCharArray();
		
		char c2[]=t.toCharArray();
		int n=c1.length,m=c2.length;
		int max=0;
		
		for(int i=0;i<m;i++) {
			for(int j=i;j<n&&n-j>=m-i;j++) {
				
				if(c2[i]==c1[j]) {
					
					int c=0;
					int k=0;
					
					for(int i1=j-i;i1<j-i+m;i1++) {
						if(c2[k++]==c1[i1]) c++;
					}
					
					max=Math.max(max, c);
				}
				
			}
		}
		
		System.out.println(m-max);
		
		
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		long[] readLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}
//  [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();
	int[] pin = new int[s.length()];

	if(s.contains(t)) System.out.println(0);
	else {
	    for(int i=0; i<t.length(); i++){
		for(int i2=i; i2<s.length()-t.length()+i+1; i2++){
		    t=t+" ";
		    s=s+" ";
		    if(s.substring(i2,i2+1).equals(t.substring(i, i+1)))pin[i2-i]++;
		    t=t.trim();
		    s=s.trim();
		}		
	    }
	    int max=0;
	    for(int i=0; i<s.length(); i++){
		if(pin[i]>max){
		    max=pin[i];
		}
	    }		
	    System.out.println(t.length()-max);
	}
    }
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n"; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug() << imie(x) imie(y)
//debugging ends


int solve(){
    string s,t;
    cin>>s>>t;
    
    //atcoder
    //codeforces
    int res=10000000;
    for (int i = 0; i < t.length(); i++)
    {
      for (int j = 0; j < s.length(); j++)
      {
           int cnt=0,bk=0;
           if(s[j]==t[i]){
            //  debug()<< imie(t[i]) imie(s[j]);
             int ii=i,jj=j;
             while(ii<t.length() && jj<s.length()){
               if(s[jj]!=t[ii]) cnt++;
               ii++;jj++;
               if(jj>=s.length() && ii<t.length()) {cnt=0;bk=1;break;}
              //  debug()<< imie(t[ii]) imie(s[jj]) imie(cnt);
             }
             if(bk){continue;}
             ii=i;jj=j; 
             while(ii>=0 && jj>=0){
               if(s[jj]!=t[ii]) cnt++;
               ii--;jj--;
               if(ii>=0 && jj<0) {cnt=0;bk=1;break;}
              //  debug()<< imie(t[ii]) imie(s[jj]) imie(cnt);
             }
             if(bk){continue;}
            //  debug()<< imie(cnt);
             res=min(res,cnt);
          }        
      }
      
    }

    if(res==10000000) res=t.length();
    cout<<res;

    return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cerr<<fixed<<setprecision(10);
  auto start = chrono::high_resolution_clock::now();
  int t=1;
  //cin>>t;
  while(t--)
    solve(),cout<<"\n";

  auto stop = chrono::high_resolution_clock::now(); 
  auto duration = chrono::duration_cast<chrono::nanoseconds>(stop - start); 
  cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s \n";      
  
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  string S, T;
  cin >> T >> S;

  vector<vector<bool>> Ss(1000, (vector<bool> (1000, false)));

  rep(i, (int)(T.size()-S.size()+1)){
    //cout << 22 << endl;
    rep(k, (int)S.size()) if(S[k] == T[i]){
      rep(j, (int)S.size()){
        if(S[j]==T[i+j]){
          Ss.at(i).at(j) = true;
        }
        //cout << Ss.at(i).at(j)<<endl;
      }
    }
  }

  int max=0;
  int max_val;
  rep(i, 1000){
    int now = count(Ss.at(i).begin(), Ss.at(i).end(), true);
    if(now > max) max=now;
  }

  max_val=(int)S.size() - (int)max;
  cout << max_val <<endl;
}
//  [c]
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>


char S_in[1001];
char T_in[1001];

int main(int argc, char* argv[]){
    int i,j,k;
    int S_l,T_l;
    int max_s=0;
    int temp=0;
    int temp_max=0;
    int *T_same;
    scanf("%s",S_in);
    scanf("%s",T_in);
    S_l = strlen(S_in);
    T_l = strlen(T_in);
    //T_same = (long int *) malloc( sizeof(long int) *(S_in+1)  );
    for(i=0;i<S_l;i++){
        for(j=0;j<T_l;j++){
            if(S_in[i]==T_in[j] && i>=j && i+T_l-j-1<S_l){
                for(k=0;k<T_l;k++){
                    if(S_in[i-j+k]==T_in[k]){
                        temp++;
                    }
                }
                if(temp>temp_max){
                    temp_max = temp;
                }
                temp=0;
            }
        }

    }
    printf("%d",T_l-temp_max);    

    return 0;
}
//  [c]
#include <stdio.h>

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define N 200010
#define MAX 1000000000000000000

#include <stdio.h>

int main (void) {
    char s[1001], t[1001];
    int count = 1000, count_tmp = 1000, i, j, k;

    scanf("%s %s", s, t);

    count = strlen(t);

    for (i = 0; i < strlen(t); i++) {
        for (j = i; j < strlen(s) - strlen(t) + i + 1; j++) {
            // printf("%c %c\n", t[i], s[j]);
            if (t[i] == s[j]) {
                count_tmp = strlen(t);
                for (k = -1 * i; k < (int)strlen(t) - i; k++) {
                    // printf("%d %c %c\n", k, t[i + k], s[j + k]);
                    if (t[i + k] == s[j + k]) {
                        count_tmp--;
                        // printf("c_tmp = %d\n", count_tmp);
                    }
                }
                if (count_tmp < count) count = count_tmp;
            }
        }
    }

    printf("%d", count);

    return 0;
}
//  [c]
#include <stdio.h>

int	main(void)
{
	char	s[1001] = {0};
	char	t[1001] = {0};
	int		s_len = 0;
	int		t_len = 0;
	int		diff;
	int		count;
	int		i = 0;
	int		j;
	int		k = 0;

	if (scanf("%s", s) < 0)
		return (0);
	if (scanf("%s", t) < 0)
		return (0);
	while (s[i])
		i++;
	s_len = i;
	i = 0;
	while (t[i])
		i++;
	t_len = i;
	diff = t_len;
	while (k < t_len)
	{
		i = k;
		while (i < s_len - t_len + 1 +k)
		{
			j = 0;
			count = t_len;
			if (s[i] == t[k])
			{
				while (j + k < t_len)
				{
					if (s[i + j] == t[k + j])
						count--;
					j++;
				}
			}
			if (diff > count)
				diff = count;
			i++;
		}
		k++;
	}
	printf("%d", diff);
	return (0);
}