jiahuimbzuai/CoQuIR huggingface dataset:
//  [javascript]
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
Main();
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var X = one[1];
  var list = nextIntArray();
  list.push(X);
  list.sort(function(a,b){
  	return a - b;
  });
  var output = 0;
  for(var i = 1; i < N; i++){
    if(i == 0){
       output = list[i] - list[i - 1];
    }else{
       output = gcd(list[i] - list[i - 1],output);
    }
  }
  myout(output);
}
function gcd(m, n) {return n != 0 ? gcd(n, m % n) : m;}
//  [javascript]
module.exports=function(r){var t={};function e(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return r[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=r,e.c=t,e.d=function(r,t,n){e.o(r,t)||Object.defineProperty(r,t,{enumerable:!0,get:n})},e.r=function(r){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},e.t=function(r,t){if(1&t&&(r=e(r)),8&t)return r;if(4&t&&"object"==typeof r&&r&&r.__esModule)return r;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:r}),2&t&&"string"!=typeof r)for(var o in r)e.d(n,o,function(t){return r[t]}.bind(null,o));return n},e.n=function(r){var t=r&&r.__esModule?function(){return r.default}:function(){return r};return e.d(t,"a",t),t},e.o=function(r,t){return Object.prototype.hasOwnProperty.call(r,t)},e.p="",e(e.s=0)}([function(r,t,e){e(1)(e(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(r,t){function e(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){var e=[],n=!0,o=!1,u=void 0;try{for(var i,f=r[Symbol.iterator]();!(n=(i=f.next()).done)&&(e.push(i.value),!t||e.length!==t);n=!0);}catch(r){o=!0,u=r}finally{try{n||null==f.return||f.return()}finally{if(o)throw u}}return e}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}r.exports=function(r){var t=e(r[0].split(" ").map(function(r){return Number(r)}),2),n=t[0],o=t[1],u=r[1].split(" ").map(function(r){return Number(r)});u.push(o),u.sort(function(r,t){return r-t});var f=99999999999;for(i=0;i<n;i++)u[i+1]-u[i]<f&&(f=u[i+1]-u[i]);console.log(f)}},function(r,t){r.exports=require("fs")}]);
//  [javascript]
function main(input){
  input=input.split("\n");
  var first=input[0].split(" ");
  var N=first[0];
  var X=first[1];
  var xi=input[1].split(" ");
  
  var areArray=[];

  for(var i=0; i<N; i++){
    var temp;
    if(xi[i]-X>0){
      temp=xi[i]-X;
    }else{
      temp=(xi[i]-X)*(-1);
    };
    areArray.push(temp);
  };
  function gcd(pororon) {
    var f = (a, b) => b ? f(b, a % b) : a
    var ans = pororon[0]
    for (var i = 1; i < arguments.length; i++) {
        ans = f(ans, arguments[i]); 
    }
    return ans 
}
  console.log(gcd(areArray));
}

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

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

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

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

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

func bitCount(n uint) int {

	x := uint64(n)

	const m = 1<<64 - 1
	const m0 = 0x5555555555555555
	const m1 = 0x3333333333333333
	const m2 = 0x0f0f0f0f0f0f0f0f

	x = x>>1&(m0&m) + x&(m0&m)
	x = x>>2&(m1&m) + x&(m1&m)
	x = (x>>4 + x) & (m2 & m)
	x += x >> 8
	x += x >> 16
	x += x >> 32

	return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
	return ((n >> uint(i)) & 1) == 1
}

func setBit(d, n int) int {
	t := 1 << uint(n)
	return d | t
}

func intAbs(n int) int {
	return int(math.Abs(float64(n)))
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for {
		if b == 0 {
			return a
		} else {
			a, b = b, a%b
		}
	}
}

func main() {
	line := readBigLine()

	spl := intSprit(line)
	N := spl[0]
	X := spl[1]

	x := intSprit(readBigLine())

	diffs := make([]int, N)

	for i, v := range x {
		diffs[i] = intAbs(v - X)
	}

	ret := diffs[0]
	for i := 1; i < len(diffs); i++ {
		ret = gcd(ret, diffs[i])
	}

	fmt.Println(ret)
}
//  [go]
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	prevX := scanInt(sc)
	x := scanInt(sc)

	d := abs(prevX - x)
	prevX = x

	for i := 1; i < n; i++ {
		x = scanInt(sc)
		d = gcd(d, abs(prevX-x))
		prevX = x
		if d == 1 {
			break
		}
	}
	fmt.Println(d)
}

func abs(n int) int {
	if n < 0 {
		return n * -1
	}
	return n
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	r := a % b
	for r > 0 {
		a = b
		b = r
		r = a % b
	}
	return b
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}
//  [go]
package main

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

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func gcd(x, y int) int {
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

func gcdMulti(xs []int) int {
	ans := xs[0]
	for i := 1; i < len(xs); i++ {
		ans = gcd(ans, xs[i])
	}
	return ans
}

func main() {
	var N, X int
	fmt.Scan(&N, &X)
	ds := make([]int, N)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range ds {
		sc.Scan()
		t, _ := strconv.Atoi(sc.Text())
		ds[i] = abs(X - t)
	}
	fmt.Println(gcdMulti(ds))
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

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

	xs = append(xs, x)
	sort.Ints(xs)

	ds := make([]int, 0)
	for i := 1; i < len(xs); i++ {
		ds = append(ds, xs[i]-xs[i-1])
	}

	ans := ds[0]
	for i := 0; i < len(ds); i++ {
		ans = gcd(ans, ds[0])
	}
	fmt.Println(ans)
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}
//  [go]
package main

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

func main() {
	N := readi()
	X := readi()
	x := make([]int, N)
	for i := 0; i < N; i++ {
		x[i] = readi()
	}
	sort.Ints(x)

	ans := abs(X - x[0])
	for i := 1; i < N; i++ {
		tmp := abs(x[i] - x[i-1])
		if tmp < ans {
			if ans%tmp == 0 {
				ans = tmp
			}
		}
	}

	fmt.Println(ans)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}
//  [go]
package main

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

func main() {
	N := readi()
	X := readi()
	x := make([]int, N)
	for i := 0; i < N; i++ {
		x[i] = readi()
	}
	sort.Ints(x)

	ans := abs(X - x[0])
	for i := 1; i < N; i++ {
		tmp := abs(x[i] - x[i-1])
		if tmp < ans {
			if ans%tmp == 0 {
				ans = tmp
			} else {
				ans = 1
			}
		}
	}

	fmt.Println(ans)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

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

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}
//  [ruby]
_,X=gets.split.map &:to_i;p gets.split.map{|i|i.to_i-X}.inject 0,:gcd
//  [ruby]
N, X = gets.split(' ').map(&:to_i)
x = gets.split(' ').map(&:to_i)

d = (X - x[0]).abs
1.upto(N - 1) do |i|
  d = d.gcd((X - x[i]))
end

puts d
//  [ruby]
module ArrayRefinement
  refine Array do
    # 配列に対する最小公倍数
    def lcm
      self.inject(:lcm)
    end

    # 配列に対する最大公約数
    def gcd
      self.inject(:gcd)
    end
  end
end

using ArrayRefinement

def main

  n, x = gets.split.map(&:to_i)

  nums = gets.split.map do |s|
    i = s.to_i
    i - x
  end

  puts nums.gcd.abs
end

if __FILE__ == $0
  main
end
//  [ruby]
n,x=gets.split.map &:to_i
s=gets.split.map &:to_i
s.sort!
ans=x-s[0]
for i in 1...n
  ans=ans.gcd(x-s[i])
end
puts ans
//  [ruby]
n,x=gets.split.map &:to_i
s=gets.split.map &:to_i
s.sort!
ans=x-s[0]
for i in 1...n
  ans=ans.gcd(s[i]-s[i-1])
end
puts ans
//  [ruby]
N, X = gets.chomp.split().map(&:to_i)

x = []
gets.chomp.split().each do |s|
  x << (X - s.oo_i).abs
end

ans = x.shift
x.each do |i|
  ans = ans.gcd(i)
end

puts 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("filed 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 x:i64 = read();
    let mut v = vec![x];
    for _ in 0..n {
        v.push(read());
    }
    let mut ans = v[1] - v[0];
    for i in 1..=n {
        ans = gcd(ans, v[i]-v[i-1]);
    }
    println!("{}", ans);
}

fn gcd(a:i64, b:i64) ->i64 {
    if b == 0 {
        return a
    }
    return gcd(b, a%b)
}
//  [rust]
use std::cmp::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("filed 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 x:i64 = read();
    let mut v = vec![x];
    for _ in 0..n {
        v.push(read());
    }
    v.sort();
    let mut ans = v[1] - v[0];
    for i in 1..=n {
        ans = min(ans, v[i]-v[i-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("filed 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 x:i64 = read();
    let mut v:Vec<i64> = (0..n).map(|_| read()).collect();
    v.sort();
    let mut ans = v[1] - v[0];
    for i in 1..=n {
        ans = gcd(ans, v[i]-v[i-1]);
    }
    println!("{}", ans);
}

fn gcd(a:i64, b:i64) ->i64 {
    if b == 0 {
        return a
    }
    return gcd(b, a%b)
}
//  [swift]
import Foundation
//最大公約数を求める関数
func gcd(_ a: Int, _ b: Int) -> Int {
   let r = a % b
   if r != 0 {
       return gcd(b, r)
   } else {
       return b
   }
}
//３つ以上の数の最大公約数を求める
func gcdArr(_ numArr: [Int]) -> Int {
    var ans: Int = numArr[0]
    for i in numArr {
        ans = gcd(ans, i)
    }
    return ans
}


let rl = readLine()!.split(separator: " ").map({Int($0)!})
let N = rl[0]
let X = rl[1]
let xi = readLine()!.split(separator: " ").map({Int($0)!})

let absxi = xi.map({abs($0 - X)})

print(gcdArr(absxi))
//  [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 gcd(_ array: [Int]) -> Int {
    var value = array[0]
    if array.count > 1 {
        for i in 1..<array.count {
            value = gcd(value, array[i])
        }
    }
    return value
}

///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(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) {
        _ = firstIndex(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 nx = readInts()
    let (_, x) = (nx[0], nx[1])
    let aryX = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    let aryXd = aryX.map {abs($0 - x)}
    
    print(gcd(aryXd))
}

main()
//  [swift]
func gcd(x: Int, _ y: Int) -> Int {
    if y == 0 {
        return x
    } else {
        return gcd(y, x%y)
    }
}
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let x = (readLine()!.characters.split(" ").map{Int(String($0))!} + [input[1]]).sort()
let d = (1...input[0]).map{x[$0] - x[$0-1]}
var ans = 0
for i in d {
    ans = gcd(i, ans)
}
print(ans)
//  [swift]
import Foundation
//最大公約数を求める関数
func gcd(_ a: Int, _ b: Int) -> Int {
   let r = a % b
   if r != 0 {
       return gcd(b, r)
   } else {
       return b
   }
}

let rl = readLine()!.split(separator: " ").map({Int($0)!})
let N = rl[0]
let X = rl[1]
let xi = readLine()!.split(separator: " ").map({Int($0)!})

let absxi = xi.map({abs($0 - X)})

print(absxi.min()!)
//  [swift]
let N = readLine()!.characters.split(" ").map{Int(String($0))!}[1]
let x = (readLine()!.characters.split(" ").map{Int(String($0))!}+[N]).sort()
let d = (0..<x.count).map{x[$0+1]-x[$0]}
var ans = 0
for i in d {
    var (a, b) = (i, ans)
    while b > 0 {
        (a, b) = (b, a%b)
    }
    ans = a
}
print(ans)
//  [swift]
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let x = (readLine()!.characters.split(" ").map{Int(String($0))!}).sort()
let d = (1..<input[0]).map{x[$0]-x[$0-1]}
var ans = input[1]
for i in d {
    var (a, b) = (i, ans)
    while b > 0 {
        (a, b) = (b, a%b)
    }
    ans = a
}
print(ans)
//  [typescript]
function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const x = parseInt(params1[1]);
  const xs = lines[1].split(' ').map(x => parseInt(x));

  const euclid: (m: number, n: number) => number = (m, n) => {
    if (m < n) return euclid(n, m);
    if (n === 0) return m;
    return euclid(n, m % n);
  };

  const d = xs
    .map(a => Math.abs(a - x))
    .reduce(euclid);

  console.log(d);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const x = parseInt(params1[1]);
  const xs = lines[1].split(' ').map(x => parseInt(x));

  const euclid: (m: number, n: number) => number = (m, n) => {
    if (m < n) return euclid(n, m);
    if (n === 0) return m;
    return euclid(n, m % n);
  };

  const d =
    xs.map(a => Math.abs(a - x))
      .reduce(euclid);

  console.log(d);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ');

  const x = parseInt(params1[1]);
  const xs = lines[1].split(' ').map(x => parseInt(x));

  const d = xs.map(a => Math.abs(a - x)).reduce(euclid);

  console.log(d);
}

function euclid(m: number, n: number): number {
  if (m < n) return euclid(n, m);
  if (n === 0) return m;
  return euclid(n, m % n);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
"use strict";
function Main(input) {
    const lines = input.split('\n');
    const params1 = lines[0].split(' ');
    const n = parseInt(params1[0]);
    const x = parseInt(params1[1]);
    const xs = lines[1].split(' ').map(x => parseInt(x));
    let l = Math.abs(xs[0] - x);
    xs.forEach(a => {
        l = Math.min(Math.abs(a - x), l);
    });
    let d = 1;
    // for (let i = 2; i <= l; i++) {
    //   if (xs.every(a => Math.abs(a - x) % i === 0)) d = i;
    // }
    for (let i = l; i >= 2; i--) {
        if (xs.every(a => Math.abs(a - x) % i === 0)) {
            d = i;
            break;
        }
    }
    console.log(d);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//# sourceMappingURL=index.js.map
//  [typescript]
function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const x = parseInt(params1[1]);
  const xs = lines[1].split(' ').map(x => parseInt(x));

  let l = Math.abs(xs[0] - x);
  xs.forEach(a => {
    l = Math.min(Math.abs(a - x), l);
  });

  let d = 1;
  // for (let i = 2; i <= l; i++) {
  //   if (xs.every(a => Math.abs(a - x) % i === 0)) d = i;
  // }
  for (let i = l; i >= 2; i--) {
    if (xs.every(a => Math.abs(a - x) % i === 0)) {
      d = i;
      break;
    }
  }

  console.log(d);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
function Main(input: string) {
  const lines = input.split('\n');
  const params1 = lines[0].split(' ');

  const n = parseInt(params1[0]);
  const x = parseInt(params1[1]);
  const xs = lines[1].split(' ').map(x => parseInt(x));

  let l = Math.abs(xs[0] - x);
  xs.forEach(a => {
    l = Math.min(Math.abs(a - x), l);
  });

  let d = 1;
  for (let i = 2; i <= l; i++) {
    if (xs.every(a => Math.abs(a - x) % i === 0)) d = i;
  }

  console.log(d);
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
import sys

N, Y = [int(x) for x in sys.stdin.readline().strip().split()]

a = Y // 10000
b = (Y - a * 10000) // 5000
c = (Y - a * 10000 - b * 5000) // 1000

while 1:
    t = a + b + c
    if N >= t + 9 and a > 0:
        a -= 1
        c += 10
        continue
    if N >= t + 4 and b > 0:
        b -= 1
        c += 5
        continue
    if N > t and a > 0:
        a -= 1
        b += 2
        continue
    break

if a + b + c != N or a < 0 or b < 0 or c < 0:
    print("-1 -1 -1")
else:
    print(a, b, c)
    #print(a + b + c)
    #print(a*10000+b*5000+c*1000)
//  [python]
a,sums= list(map(int,input().split()))
yuki = sums//10000
taishi = (sums%10000) //5000
noguchi = (sums%5000) //1000
while a>yuki+taishi+noguchi:
  if ((a-(yuki+taishi+noguchi))%4==0)&(taishi>0):
    taishi-=1
    noguchi+=5
  elif yuki>0:
    yuki-=1
    taishi+=2
  else:
    break
if a==yuki+taishi+noguchi:
  print(yuki,taishi,noguchi)
else:
  print("-1 -1 -1")
//  [python]
(N,Y) = [int(i) for i in input().split()]
 
y10k = Y // 10000
y5k, y1k = divmod((Y%10000)/1000, 5)
 
current_inbag = y10k+y5k+y1k
diff = N - current_inbag
 
if Y > 10000*N or Y < 1000*N or diff < 0:
    print('-1 -1 -1')
    exit()
 
while y10k > 0 and diff >= 9:
    y10k -= 1
    y1k += 10
    diff -= 9

if y10k > 0 and diff >= 5:
    y10k -= 1
    y5k += 1
    y1k += 5
    diff -= 5

while y10k > 0 and diff > 0:
    y10k -= 1
    y5k += 2
    diff -= 1

if y10k == 0 and diff > 0:
    while y5k > 0 and diff >= 4:
        y5k -= 1
        y1k += 5
        diff -= 4

if diff == 0:
    print('%d %d %d' % (y10k,y5k,y1k))
    exit()

print('-1 -1 -1')
//  [python]
N,Y = map(int, input().split())
for x in range(N+1):
    for y in range(N+1-x):
        z = Y - 10000*x - 5000*y
        if (10000*x + 5000*y + 1000*z) == Y and 0 <= z <= 2000:
            print(x,y,z)
            exit()


print("-1 -1 -1")
//  [python]
N,Y = map(int, input().split())
for x in range(1,N+1):
    for y in range(1,N+1):
        z = Y - 10000*x - 5000*y
        if (10000*x + 5000*y + 1000*z) == Y and 0 <= z <= 2000:
            print(x,y,z)
            exit()


print("-1 -1 -1")
//  [python]
N,Y = map(int, input().split())
for x in range(1,N+1):
    for y in range(1,N+1):
        if 0 <= Y - x - y < Y:
            print(x,y,Y-x-y)
            exit()
print("-1 -1 -1")
//  [java]
import java.io.*;

class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputLine = br.readLine().split(" ");
        int n = Integer.valueOf(inputLine[0]), y = Integer.valueOf(inputLine[1]);
        int b10th = 0, b5th = 0, b1th = y / 1000;
        int redundant = b1th - n;

        for (int i = 0; i <= n; i++) {
            if (redundant < 4) {
                break;
            } else if (redundant % 9 == 0 && 10 * (redundant / 9) <= b1th) {
                b10th = redundant / 9;
                b1th -= 10 * b10th;
                break;
            } else {
                redundant -= 4;
                b5th += 1;
                b1th -= 5;
            }
        }

        if (b10th + b5th + b1th != n) {
            b10th = -1; b5th = -1; b1th = -1;
        }

        System.out.println(b10th + " " + b5th + " " + b1th);
    }
}
//  [java]
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	public static void main(String[] args) {

		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

	}

	@Override
	public void run() {
		exec();
	}

	private void exec() {

		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int yen = sc.nextInt();
		if(yen % 1000 != 0) {
			System.out.println("-1 -1 -1");
			System.exit(0);
		}
		int x = 0;
		int y = 0;
		int z = 0;
		x = yen / 1000;
		if(x == n) {
			System.out.println("0 0 " + x);
			System.exit(0);
		}
		int sa = x - n;
		if(sa < 0) {
			System.out.println("-1 -1 -1");
			System.exit(0);
		}
		for(int i = 0 ; i * 4 <= sa ; i++) {
			for(int j = 0 ; i * 4 + j * 9 <= sa ; j++) {
				if(i * 4 + j * 9 == sa) {
					y = i;
					z = j;
					x -= (y * 5 + z * 10);
					if(x < 0) {
						System.out.println("-1 -1 -1");
					} else {
						System.out.println(z + " " + y + " " + x);
					}
					System.exit(0);
				}
			}
		}
		System.out.println("-1 -1 -1");
	}

}

class FastScanner {

	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public FastScanner(InputStream in) {
		this.in = in;
	}

	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if(hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

}
//  [java]

import java.util.*;

public class Main {

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



	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int y=sc.nextInt();
		for(int i=0; i<=n; i++) {
			for(int j=0; j<=n; j++) {
				if(i+j>n) continue;
				for(int k=0; k<=n; k++) {
					if(i+j+k>n) continue;
					if(10000*i + 5000*j + 1000*k == y) {
						System.out.println(i+" "+j+" "+k);
						sc.close();
						return;
					}
				}
			}
		}
		System.out.println("-1 -1 -1");
		sc.close();
	}
}
//  [java]
import java.util.*;



class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        for(int i = 0 ; i < n ; i ++){
        	for(int j = 0 ; j < n-i ; j ++){
            	int k = n-i-j;
                	if(y == 10000*i + 5000*j + 1000*k){
                    	System.out.println(i + " " + j + " " + k);
                      	return;
                    }
                
            }
        }
      	System.out.println("-1 -1 -1");
      
    }
}
//  [java]
import java.util.*;



class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        for(int i = 0 ; i < n ; i ++){
        	for(int j = 0 ; j < n-i ; j ++){
            	for(int k = 0 ; k < n-i-j ; k++){
                	if(n == 10000*i + 5000*j + 1000*k){
                    	System.out.println(i + " " + j + " " + k);
                      	return;
                    }
                }
            }
        }
      	System.out.println("-1 -1 -1");
      
    }
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n,y;
  cin >> n >> y;
  
  int flg = 0;
  
  int p,q;
  
  for(int i=0; i<=y/10000; i++){
    if((y-10000*i-1000*(n-i)) % 4000 != 0 || (5000 * (n-i) - y + 10000 * i ) % 4000 != 0){
      continue;
    }
    p = (y - 10000 * i - 1000 * (n-i))/4000;
    q = (5000 * (n-i) - y + 10000 * i)/4000;
    if (p>=0 && q>=0){
      flg = 1;
      break;
    }
  }
  
  if (flg == 0){
    cout << -1 << " " << -1 << " " << -1 << endl;
  }else{
    cout << n-p-q << " " << p << " " << q << endl;
  }
}
//  [cpp]
#include <iostream>


using namespace std;



int main(){
    int N, Y;
    cin >> N >> Y;
    
    int n_1, n_5, n_10;
    
    int y = Y / 1000;
    
    n_10 = (y - N) / 9;
    n_5 = 10000009;
    
    int flag = 0;
    
    while(true){
        if(n_10 < 0){
            flag = 1;
            break;
        }
        
        if((y - N - 9 * n_10) % 4 == 0){
            n_5 = (y - N - 9 * n_10) / 4;
            break;
        } else {
            --n_10;
        }
    }
    
    n_1 = N - n_5 - n_10;
    
    if(flag == 1 | n_1 < 0 | n_5 < 0 | n_10 < 0){
        n_1 = -1; n_5 = -1; n_10 = -1;
    }
    
    cout << n_10 << " " << n_5 << " " << n_1 << endl;
//    cout << "sum = " << n_10 * 10000 + n_5 * 5000 + n_1 * 1000 << endl;
    return 0;

}
//  [cpp]
#include "iostream"
using namespace std;

int main() {
  int n, y;
  cin >> n >> y;
  y /= 1000;
  bool check = false;
  if (n == y) cout << 0 << " " << 0 << " " << n << endl;
  else {
    for (int i = y % 5; i < y; i += 5) {
      if (5 * (n - i) <= y - i && y - i <= 10 * (n - i)) {
        cout <<  ((y - i) - 5 * (n - i)) / 5  << " " << (10 * (n - i) - (y - i)) / 5 << " " << i << endl;
        check = true;
        break;
      }
    }
    if (check == 0) {
      cout << -1 << " " << -1 << " " << -1 << endl;
    }
  }
}
//  [cpp]
#pragma warning(disable:4996)
#include<iostream>
#include<algorithm>
#include<memory.h>
#include<string>	
using namespace std;
typedef long long ll;
const int Max = 1e5 + 5;

int main()
{
	int n, y;
	cin >> n >> y;
	int f = 0;
	for (int i = 0; i <= y / 10000; i++)
	{
		for (int j = 0; j <= y / 5000; j++)
		{
			if (i + j > 0)continue;
			if ((n - i - j) * 1000 + i * 10000 + 5000 * j == y)
			{
				cout << i << " " << j << " " << n - i - j;
				return 0;
			}
		}
	}
	if (f == 0)cout << -1 << " " << -1 << " " << -1;
}
//  [cpp]
#pragma warning(disable:4996)
#include<iostream>
#include<algorithm>
#include<memory.h>
#include<string>	
using namespace std;
typedef long long ll;
const int Max = 1e5 + 5;

int main()
{
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= y / 10000; i++)
	{
		for (int j = 0; j <= y / 5000; j++)
		{
			if (i + j > 0)continue;
			if ((n - i - j) * 1000 + i * 10000 + 5000 * j == y)
			{
				cout << i << " " << j << " " << n - i - j;
				return 0;
			}
		}
	}
}
//  [cpp]
#pragma warning(disable:4996)
#include<iostream>
#include<algorithm>
#include<memory.h>
#include<string>	
using namespace std;
typedef long long ll;
const int Max = 1e5 + 5;

int main()
{
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= y / 10000; i++)
	{
		for (int j = 0; j <= y / 5000; j++)
		{
			if ((n - i - j) * 1000 + i * 10000 + 5000 * j == y)
			{
				cout << i << " " << j << " " << n - i - j;
				return 0;
			}
		}
	}
}
//  [c]
#include <stdio.h>
#include <stdlib.h>


int main (void){
        int N,Y,now,man=0,gosen=0,sen=0;
        scanf("%d %d",&N,&Y);
        if (N*10000<Y||N*1000>Y) {
                printf("-1 -1 -1");
                return 0;
        }
        now=(Y-N*1000)/1000;
        man=now/9;
        now=now%9;
        gosen=now/4;
        now=now%4;
        while (now!=0) {
                man--;
                now+=9;
                while (now>0) {
                        gosen++;
                        now-=4;
                }
        }
        sen=N-gosen-man;
        if (sen<0||man<0||gosen<0) {
                printf("-1 -1 -1");
                return 0;
        }
        printf("%d %d %d",man,gosen,sen);
        return 0;
}
//  [c]
#include<stdio.h>
#include<limits.h>

int main(){
	int i,j,k,N,Y;
	int mannum,gosennum,sennum;
	int endflag = 0;
	
	scanf("%d",&N);
	scanf("%d",&Y);
	
	mannum = Y / 10000;
	gosennum = (Y - mannum*10000) / 5000;
	sennum = (Y - mannum*10000 - gosennum*5000) / 1000;
	
	
	for(i = mannum;i >= 0;i --){
		
		gosennum = (Y - i*10000) / 5000;
		
		for(j = gosennum; j >= 0;j--){
			k = (Y - i*10000 - j*5000) / 1000;
			if( ( (i*10000 + j*5000 + k*1000) == Y ) && ( (i+j+k) == N ) ){
				endflag =1;
				break;
			}
			if( (i+j+k) > N )break;
		}
		
		if(endflag == 1)break;
		
	}
	
	if( ( (i*10000 + j*5000 + k*1000) == Y ) && ( (i+j+k) == N ) ){
		printf("%d %d %d\n",i,j,k);
	}else printf("-1 -1 -1\n");
	
	return 0;
}
//  [c]
#include<stdio.h>
#include<math.h>

int calc(int x,int N,int Y){
    double y,z;
    y = (Y-1000*N-9000*x)/4000.0;
    z = (5000*x+5000*N-Y)/4000.0;
    //printf("%f,%f\n",y,z);
    if(ceil(y)!=floor(y)||ceil(z)!=floor(z)){
        return -1;
    }
    if(y<0 || z<0){
        return -1;
    }
    if(x+y+z!=N){
        return -1;
    }
    return y;
}

int main(void){
    int N,Y,y;
    scanf("%d %d",&N,&Y);
    for(int i=0;i<=N;i++){
        y = calc(i,N,Y);
        if(y!=-1){
            printf("%d %d %d",i,y,N-i-y);
            return 0;
        }
    }
    printf("-1 -1 -1");
    return 0;
}
//  [c]
#include <stdio.h>
int main(void){
  int n,y,i,j,k;
  int ans10000,ans5000,ans1000;
  scanf("%d %d",&n,&y);
  for(i=0;i<=n;i++){
    for(j=0;j<=n;j++){
        k=n-i-j;
      if(i+j<n && 10000*i+5000*j+1000*k==y){
          ans10000=i;
          ans5000=j;
          ans1000=k;
          printf("%d %d %d \n",ans10000,ans5000,ans1000);
          return 0;
      }else if(i+j>=n && 10000*i+5000*j==y){
        ans10000=i;
        ans5000=j;
        ans1000=0;
        printf("%d %d %d \n",ans10000,ans5000,ans1000);
        return 0;
      }
    }
  }
  printf("%d %d %d",-1,-1,-1);
  return 0;
}
//  [c]
#include<stdio.h>

int main(){
  int N,Y,i,j,ans=0;
  scanf("%d%d",&N,&Y);
  Y/=1000;

  for (i = 0; i <= N; i++){
    for ( j = 0; j <= N-(i*5); j++)
    {
      if(Y==((N-j-i)*10+(i*5)+j)){
        ans=1;
        break;
      }
    }
    if (ans==1){break;}
  }
  
  ans > 0 ?  printf("%d %d %d",N-i-j,i,j):puts("-1 -1 -1");

  return 0;
}
//  [c]
import sys

def main():
    N, Y = [int(_) for _ in input().split()]

    for n_10k in range(N+1):
        for n_5k in range(N - n_10k + 1):
            n_1k = N - n_10k - n_5k

            if n_10k * 10000 + n_5k * 5000 + n_1k * 1000 == Y:
                print(n_10k, n_5k, n_1k)
                sys.exit()

    print(-1,-1,-1)

main()
//  [javascript]
'use strict'
const inputs = require('fs').readFileSync(0, 'utf8').split(' ')
const n = inputs[0]
const y = inputs[1]
for (let j = 0;j <= 8;j++) {
  const remain = y - 5000 * j
  if (remain < 0) break
  const man = (remain - 1000 * (n - j)) / 9000
  if (Number.isInteger(man) && man >= 0 && n - j - man >= 0) return console.log(man, j, n - j - man)
}
return console.log(-1, -1, -1)
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    var raw = input[0].split(" ");
    var N = parseInt(raw[0],10);
    var Y = parseInt(raw[1],10);
    var W = Y/1000;
    var flag = false;
    for(var z=0; z<=N; z++){
      var A = W-z
      if(A%5!==0) continue;
      var M = N-z;
      if(10*M >= A && A >= 5*M) {
        flag = true;
        var y = (10*M-A)/5;
        var x = M-y;
        console.log('%d %d %d',x,y,z);
        break;
      }
    }
    if(!flag) {
       console.log('%d %d %d',-1,-1,-1);
    }
    
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function main(input) {
  const input_array = input.split(' ');
  const sum_price = input_array[1];
  const paper_money_count = input_array[0];
  

  for(count_10000=0; count_10000<=paper_money_count ;count_10000++){
    maximum_price = 10000 * count_10000 + 5000 * (paper_money_count - count_10000);
    minimum_price = 10000 * count_10000 + 1000 * (paper_money_count - count_10000);
    if(sum_price > maximum_price || sum_price < minimum_price){
      continue;
    }
    for(count_5000=0; count_5000<=paper_money_count - count_10000 ;count_5000++){
      count_1000 = paper_money_count - (count_10000 + count_5000)
      if(count_10000 * 10000 + count_5000 * 5000 + count_1000 * 1000 == sum_price){
        console.log(`${count_10000} ${count_5000} ${count_1000}`);
        return;
      }
    }
  }

  console.log('-1 -1 -1');
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function spilitInput(input) {
  var splited = [];
  var rows = input.split('\n');
  for (var i = 0; i < rows.length; i += 1) {
    splited.push(rows[i].split(' '));
  }
  return splited;
}
function Main(input) {
  var splited = spilitInput(input);
  var N = splited[0][0];
  var Y = splited[0][1];
  var ax = 10000;
  var ay = 5000;
  var az = 1000;
  var x = -1;
  var y = -1;
  var z = -1;
  var hit = false;
  
  for(var iz = 0; iz <= N && !hit; iz += 1) {
  for(var iy = 0; iy <= N && !hit; iy += 1) {
    var ix = N - iz - iy;
    var total = (ax*ix)+(ay*iy)+(az*iz);
    if (total == Y) {
      x = ix;
      y = iy;
      z = iz;
      hit = true;
    }
  }
  }
  console.log(x+' '+y+' '+z);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function spilitInput(input) {
  var splited = [];
  var rows = input.split('\n');
  for (var i = 0; i < rows.length; i += 1) {
    splited.push(rows[i].split(' '));
  }
  return splited;
}
function Main(input) {
  var splited = spilitInput(input);
  var N = splited[0][0];
  var Y = splited[0][1];
  var ax = 10000;
  var ay = 5000;
  var az = 1000;
  var x = -1;
  var y = -1;
  var z = -1;
  
  x = Math.floor(Y / ax);
  Y = (Y - (ax * x));
  
  y = Math.floor(Y / ay);
  Y = (Y - (ay * y));
  
  z = Math.floor(Y / az);
  Y = (Y - (az * z));
  
  if (Y == 0 && (x+y+z) == N) {
    console.log(x+' '+y+' '+z);
  } else {
    console.log('-1 -1 -1');
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function spilitInput(input) {
  var splited = [];
  var rows = input.split('\n');
  for (var i = 0; i < rows.length; i += 1) {
    splited.push(rows[i].split(' '));
  }
  return splited;
}
function Main(input) {
  var splited = spilitInput(input);
  var N = splited[0][0];
  var Y = splited[0][1];
  var ax = 10000;
  var ay = 5000;
  var az = 1000;
  var x = -1;
  var y = -1;
  var z = -1;
  
  x = (Y / ax);
  Y = (Y - (ax * x));
  
  y = (Y / ay);
  Y = (Y - (ay * y));
  
  z = (Y / az);
  Y = (Y - (az * z));
  
  if (Y == 0) {
    console.log(x+' '+y+' '+z);
  } else {
    console.log('-1 -1 -1');
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`
				`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())
	//https://atcoder.jp/contests/abc165/tasks/abc165_f
	//https://www.dropbox.com/sh/nx3tnilzqz7df8a/AAA0887IQFx5BcrZcrpRD7uga/ABC165/F?dl=0&subfolder_nav_tracking=1

	n := nextInt()
	yen := nextInt()

	x := -1
	y := -1
	z := -1

	for i := 0; i <= yen/1000; i++ {
		xx := yen + 4000*i - 5000*n
		yy := 10000*n - 9000*i - yen
		if xx >= 0 && xx%5000 == 0 && yy >= 0 && yy%5000 == 0 {
			x = xx / 5000
			y = yy / 5000
			z = i
			break
		}
	}
	fmt.Fprintln(out, x, y, z)

	//	fmt.Fprintln(out, "[DEBUG]]", a)
	//fmt.Fprintln(out, ans)
}

//------------------------------------------------------------------------------

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}
//  [go]
// ABC085C - Otoshidama
package main

import "fmt"

func main() {
	var N, sum int
	fmt.Scanf("%d %d", &N, &sum)
	sum /= 1000

	// 10, 5, 1
	var n10, n5, n1 int

	n1 = sum % 5
	N -= n1
	sum -= n1

	// n10 * 10 + n5 * 5 = sum
	// n10 + n5 = N
	// n10 = sum/5 - N
	// n5  = 2N - sum/5

	for N >= 0 {
		n10 = sum/5 - N
		n5 = 2*N - sum/5

		if n1 >= 0 && n5 >= 0 && n10 >= 0 {
			fmt.Printf("%d %d %d\n", n10, n5, n1)
			return
		}

		n1 += 5
		N -= 5
		sum -= 5
	}

	fmt.Println("-1 -1 -1")
}
//  [go]
import "fmt"

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

	for i := 0; i < N; i++ {
		for j := 0; j <= N-i; j++ {
			if 10000*i+5000*j+1000*(N-i-j) == Y {
				fmt.Printf("%v %v %v\n", i, j, N-i-j)
				return
			}
		}
	}
	fmt.Println(-1, -1, -1)
}
//  [go]

import "fmt"

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

	for i := 0; i < N; i++ {
		for j := 0; j < N-i; j++ {
			if 10000*i+5000*j+1000*(N-i-j) == Y {
				fmt.Println(i, j, N-i-j)
			}
		}
	}
	fmt.Println(-1, -1, -1)
}
//  [ruby]
n, y = gets.split.map(&:to_i)
 
y/=1000
y-=n # 全部千円の場合の不足額

if y < 0
  puts [-1,-1,-1] * " "
  exit
end

if y == 0
  puts [0,0,n] * " "
  exit
end

# p y
m=y%4; y-=9*m # 万札必要量
if y < 0
  puts [-1,-1,-1] * " "
  exit
end
m+=y/36*4; y%=36 # 万札貪欲
g=y/4 # 五千円札
s=n-m-g # 残りが千円札
ans = s < 0 ? [-1,-1,-1] : [m, g, s]
puts ans * " "
//  [ruby]
n, y = gets.split.map(&:to_i)
 
y/=1000
y-=n # 全部千円の場合の不足額

if y < 0
  puts [-1,-1,-1] * " "
  exit
end

# p y
m=y%4; y-=9*m # 万札必要量
if y < 0
  puts [-1,-1,-1] * " "
  exit
end
m+=y/36*4; y%=36 # 万札貪欲
g=y/4 # 五千円札
s=n-m-g # 残りが千円札
ans = s < 0 ? [-1,-1,-1] : [m, g, s]
puts ans * " "
//  [ruby]
N,Y=gets.split.map &:to_i
Y/=1000

L=[(Y-2*N)/4.to_f,2*(Y-N)/9.to_f,(-Y-N)/5.to_f].max.ceil
H=[(Y-N)/4,(2*Y-N)/9,Y/5].min.floor

if H<L
  print("-1 -1 -1")
else
x=-4*H+Y-N
y=9*H-2*Y+2*N
z=-5*H+Y
print(x," ",y," ",z)
end
//  [ruby]
n,y=gets.split.map(&:to_i)
a,b,c=-1,-1,-1
(0..n).each do |i|
  (0..n).each do |j|
    a,b,c=n-i-j,j,i if i*1000+j*5000+(n-i-j)*10000==y
  end
end
puts [a,b,c].join ' '
//  [ruby]
n,y=gets.split.map(&:to_i)
a,b,c=-1,-1,-1
(0..n).each do |i|
  (0..n).each do |j|
    if i*1000+j*5000+(n-i-j)*10000==y
      a,b,c=n-i-j,j,i
      break
    end
  end
end
puts [a,b,c].join ' '
//  [ruby]
n,y=gets.split.map(&:to_i)
a,b,c=-1,-1,-1
(0..n).each do |i|
  (0..n).each do |j|
    if i*1000+j*5000+(n-i-j)*10000==y
      a,b,c=n-i-j,j,i
      break
    end
  end
end
puts [c,b,a].join ' '
//  [rust]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn calc(rest: u32, n: u32, satun: usize, satuv: &Vec<u32>, ans: (u32, u32, u32)) -> Option<(u32, u32, u32)> {
    let satu = satuv[satun];

    if satun == satuv.len() - 1 {
        if rest == satu * n {
            return Some((ans.0, ans.1, n));
        } else {
            return None;
        }
    }

    if rest > satu * n {
        return None
    }

    let rem = rest / satu;
    for i in (0..rem+1).rev() {
        if satu * i > rest || i > n { continue; }
        let ans_next = if satun == 0 { (i, ans.1, ans.2) } else { (ans.0, i, ans.2) };
        match calc(rest - satu * i, n - i, satun + 1, satuv, ans_next) {
            None => continue,
            Some(a) => return Some(a),
        }
    }

    None
}



fn main() {
    let v = read_vec::<u32>();
    let n: u32 = v[0];
    let y: u32 = v[1];

    let satuv = vec![10000, 5000, 1000];

    match calc(y, n, 0, &satuv, (0, 0, 0)) {
        None => println!("-1 -1 -1"),
        Some((i, j, k)) => println!("{} {} {}", i, j, k),
    }
}