String can be called correct if it consists of characters "0" and "1" and there are no redundant leading zeroes. Here are some examples: "0", "10", "1001".You are given a correct string s.You can perform two different operations on this string:   swap any pair of adjacent characters (for example, "101"  "110");  replace "11" with "1" (for example, "110"  "10"). Let val(s) be such a number that s is its binary representation.Correct string a is less than some other correct string b iff val(a) < val(b).Your task is to find the minimum correct string that you can obtain from the given one using the operations described above. You can use these operations any number of times in any order (or even use no operations at all).

The first line contains integer number n (1 ≤ n ≤ 100) — the length of string s. The second line contains the string s consisting of characters "0" and "1". It is guaranteed that the string s is correct.

Print one string — the minimum correct string that you can obtain from the given one.

NoteIn the first example you can obtain the answer by the following sequence of operations: "1001"  "1010"  "1100"  "100".In the second example you can't obtain smaller answer no matter what operations you use.

// Try Codeforces
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }

    let n = get!();
    if n == 1 {
        let s = get();
        println!("{}", s);
        return;
    }
    let s = get().as_bytes();
    let mut zeros = 0;
    for &c in s {
        if c== b'0' {
            zeros += 1;
        }
    }
    print!("1");
    for _ in 0..zeros {
        print!("0");
    }
    println!();

}

use std::io::*;
use std::str::FromStr;

fn main() {
    let stdin = stdin();
    let mut sc = Scanner::new(stdin.lock());
    let n = sc.next::<u32>();
    let s = sc.next::<String>();
    let zeros = s.chars().filter(|&c| c == '0').count() as u32;
    let result = std::iter::repeat("0")
        .take(zeros as usize)
        .collect::<String>();
    if n == zeros {
        println!("{}", result);
    } else {
        println!("1{}", result);
    }
}

pub struct Scanner<B> {
    reader: B,
    buffer: Vec<String>,
}

impl<B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        Self {
            reader,
            buffer: Vec::new(),
        }
    }

    pub fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: ::std::fmt::Debug,
    {
        if let Some(front) = self.buffer.pop() {
            front.parse::<T>().expect(&front)
        } else {
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Line not read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
            self.next()
        }
    }
}

use std::io::*;
use std::str::FromStr;

fn main() {
    let stdin = stdin();
    let mut sc = Scanner::new(stdin.lock());
    let n = sc.next::<u32>();
    let s = sc.next::<String>();
    let zeros = s.chars().filter(|&c| c == '0').count() as u32;
    let result = std::iter::repeat("0")
        .take(zeros as usize)
        .collect::<String>();
    println!("1{}", result);
}

pub struct Scanner<B> {
    reader: B,
    buffer: Vec<String>,
}

impl<B: BufRead> Scanner<B> {
    pub fn new(reader: B) -> Self {
        Self {
            reader,
            buffer: Vec::new(),
        }
    }

    pub fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: ::std::fmt::Debug,
    {
        if let Some(front) = self.buffer.pop() {
            front.parse::<T>().expect(&front)
        } else {
            let mut input = String::new();
            self.reader.read_line(&mut input).expect("Line not read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
            self.next()
        }
    }
}


Vasya likes to solve equations. Today he wants to solve $$$(x~\mathrm{div}~k) \cdot (x \bmod k) = n$$$, where $$$\mathrm{div}$$$ and $$$\mathrm{mod}$$$ stand for integer division and modulo operations (refer to the Notes below for exact definition). In this equation, $$$k$$$ and $$$n$$$ are positive integer parameters, and $$$x$$$ is a positive integer unknown. If there are several solutions, Vasya wants to find the smallest possible $$$x$$$. Can you help him?

The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq n \leq 10^6$$$, $$$2 \leq k \leq 1000$$$).

Print a single integer $$$x$$$ — the smallest positive integer solution to $$$(x~\mathrm{div}~k) \cdot (x \bmod k) = n$$$. It is guaranteed that this equation has at least one positive integer solution.

NoteThe result of integer division $$$a~\mathrm{div}~b$$$ is equal to the largest integer $$$c$$$ such that $$$b \cdot c \leq a$$$. $$$a$$$ modulo $$$b$$$ (shortened $$$a \bmod b$$$) is the only integer $$$c$$$ such that $$$0 \leq c < b$$$, and $$$a - c$$$ is divisible by $$$b$$$.In the first sample, $$$11~\mathrm{div}~3 = 3$$$ and $$$11 \bmod 3 = 2$$$. Since $$$3 \cdot 2 = 6$$$, then $$$x = 11$$$ is a solution to $$$(x~\mathrm{div}~3) \cdot (x \bmod 3) = 6$$$. One can see that $$$19$$$ is the only other positive integer solution, hence $$$11$$$ is the smallest one.

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let nk: Vec<u32> = s.trim().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    for m in (1..nk[1]).rev() {
        if nk[0] % m == 0 {
            let x = (nk[0] / m) * nk[1] + m;
            println!("{}", x);
            break;
        }
    }
}

#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::{BTreeMap,BTreeSet};
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! ite {
    ($c:expr, $t:expr, $f:expr) => {{
        if $c { $t } else { $f }
    }};
}

// ref: tanakh <https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8>
// diff: using Parser
#[macro_export]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut parser = Parser::from_str($s);
        input_inner!{parser, $($r)*}
    };
    (parser = $parser:ident, $($r:tt)*) => {
        input_inner!{$parser, $($r)*}
    };
    (new_stdin_parser = $parser:ident, $($r:tt)*) => {
        let stdin = std::io::stdin();
        let reader = std::io::BufReader::new(stdin.lock());
        let mut $parser = Parser::new(reader);
        input_inner!{$parser, $($r)*}
    };
    ($($r:tt)*) => {
        input!{new_stdin_parser = parser, $($r)*}
    };
}

#[macro_export]
macro_rules! input_inner {
    ($parser:ident) => {};
    ($parser:ident, ) => {};
    ($parser:ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($parser, $t);
        input_inner!{$parser $($r)*}
    };
}

#[macro_export]
macro_rules! read_value {
    ($parser:ident, ( $($t:tt),* )) => {
        ( $(read_value!($parser, $t)),* )
    };
    ($parser:ident, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($parser, $t)).collect::<Vec<_>>()
    };
    ($parser:ident, chars) => {
        read_value!($parser, String).chars().collect::<Vec<char>>()
    };
    ($parser:ident, usize1) => {
        read_value!($parser, usize) - 1
    };
    ($parser:ident, $t:ty) => {
        $parser.next::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
        k: i64,
    }
    let mut res = None;
    for right in 1..k {
        if n % right == 0 {
            let left = n / right;
            let x = left * k + right;
            if res.is_none() || res.unwrap() > x {
                res = Some(x);
            }
        }
    }
    println!("{}", res.unwrap());
}

use std::io::BufRead;
use std::io;
use std::str;

// ref: tatsuya6502 <https://qiita.com/tatsuya6502/items/cd448486f7ef7b5b8c7e>
// ref: wariuni <https://qiita.com/tatsuya6502/items/cd448486f7ef7b5b8c7e#comment-7040a5ae96305e884eb9>
// diff: using std::io::BufRead::fill_buf()
pub struct Parser<R> {
    reader: R,
    buf: Vec<u8>,
    pos: usize,
}

impl Parser<io::Empty> {
    pub fn from_str(s: &str) -> Parser<io::Empty> {
        Parser {
            reader: io::empty(),
            buf: s.as_bytes().to_vec(),
            pos: 0,
        }
    }
}

impl<R:BufRead> Parser<R> {
    pub fn new(reader: R) -> Parser<R> {
        Parser {
            reader: reader,
            buf: vec![],
            pos: 0,
        }
    }
    pub fn update_buf(&mut self) {
        self.buf.clear();
        self.pos = 0;
        loop {
            let (len,complete) = {
                let buf2 = self.reader.fill_buf().unwrap();
                self.buf.extend_from_slice(buf2);
                let len = buf2.len();
                (len, buf2[len-1] <= 0x20)
            };
            self.reader.consume(len);
            if complete {
                break;
            }
        }
    }
    pub fn next<T:str::FromStr>(&mut self) -> Result<T, T::Err> {
        loop {
            let mut begin = self.pos;
            while begin < self.buf.len() && (self.buf[begin] <= 0x20) {
                begin += 1;
            }
            let mut end = begin;
            while end < self.buf.len() && (self.buf[end] > 0x20) {
                end += 1;
            }
            if begin != self.buf.len() {
                self.pos = end;
                return str::from_utf8(&self.buf[begin..end]).unwrap().parse::<T>();
            }
            else {
                self.update_buf();
            }
        }
    }
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!();
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!();
}

use std::io;

macro_rules! readln {
    () => {{
        use std::io;
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim().to_string()
    }};
    ( $t:ty ) => {{
        let input = readln!();
        input.parse::<$t>().unwrap()
    }};
    ( $( $t:ty ),+ ) => {{
        let input = readln!();
        let mut input = input.split_whitespace();
        (
            $(
                input.next().unwrap().parse::<$t>().unwrap(),
            )+
        )
    }}
}

fn main() {
    let (result, divider) = readln!(i32, i32);

    let mut min = std::i32::MAX;
    for right in 1..divider {
        if result % right == 0 {
            let x = right + divider * result / right;
            if x < min {
                min = x;
            }
        }
    }

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

use std::io;

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).expect("failed to read input");
    let mut buffer_iter = buffer.split_whitespace().map(|n| n.parse::<u32>().unwrap());
    let n = buffer_iter.next().unwrap();
    let k = buffer_iter.next().unwrap();

    let md = (1..k).rev().find(|x| n % x == 0).unwrap();
    println!("{}", (n / md) * k + md);
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let nk: Vec<u32> = s.trim().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    let m = nk[0] * nk[1] + 1;
    for x in 1..m {
        let y = x - x % nk[1];
        if (y / nk[1]) * (x % nk[1]) == nk[0] {
            println!("{}", x);
            break;
        }
    }
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let nk: Vec<u32> = s.trim().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    for x in 1..10000001 {
        if (x/nk[1])*(x%nk[1]) == nk[0] {
            println!("{}", x);
            break;
        }
    }
}


There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.The presenter has m chips. The presenter stands in the middle of the circle and starts giving the chips to the walruses starting from walrus number 1 and moving clockwise. The walrus number i gets i chips. If the presenter can't give the current walrus the required number of chips, then the presenter takes the remaining chips and the process ends. Determine by the given n and m how many chips the presenter will get in the end.

The first line contains two integers n and m (1 ≤ n ≤ 50, 1 ≤ m ≤ 104) — the number of walruses and the number of chips correspondingly.

Print the number of chips the presenter ended up with.

NoteIn the first sample the presenter gives one chip to the walrus number 1, two chips to the walrus number 2, three chips to the walrus number 3, four chips to the walrus number 4, then again one chip to the walrus number 1. After that the presenter runs out of chips. He can't give anything to the walrus number 2 and the process finishes.In the third sample the presenter gives one chip to the walrus number 1, two chips to the walrus number 2, three chips to the walrus number 3, then again one chip to the walrus number 1. The presenter has one chip left and he can't give two chips to the walrus number 2, that's why the presenter takes the last chip.

struct Scan {
    buffer: std::collections::VecDeque<String>,
}

impl Scan {
    fn new() -> Scan {
        Scan {
            buffer: std::collections::VecDeque::new(),
        }
    }

    fn next_line(&self) -> String {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).expect("Fail to read");
        line
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let line = self.next_line();
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }
}

fn _main() {
    let mut scan = Scan::new();
    let n: usize = scan.next();
    let mut m: usize = scan.next();
    let circle = n * (n + 1) / 2;
    m %= circle;
    for i in 1..n {
        if i <= m {
            m -= i;
        } else {
            break;
        }
    }
    println!("{}", m);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1 << 23)
        .spawn(_main)
        .unwrap()
        .join()
        .unwrap();
}


Vasily the bear has a favorite rectangle, it has one vertex at point (0, 0), and the opposite vertex at point (x, y). Of course, the sides of Vasya's favorite rectangle are parallel to the coordinate axes. Vasya also loves triangles, if the triangles have one vertex at point B = (0, 0). That's why today he asks you to find two points A = (x1, y1) and C = (x2, y2), such that the following conditions hold:  the coordinates of points: x1, x2, y1, y2 are integers. Besides, the following inequation holds: x1 < x2;  the triangle formed by point A, B and C is rectangular and isosceles ( is right);  all points of the favorite rectangle are located inside or on the border of triangle ABC;  the area of triangle ABC is as small as possible. Help the bear, find the required points. It is not so hard to proof that these points are unique.

The first line contains two integers x, y ( - 109 ≤ x, y ≤ 109, x ≠ 0, y ≠ 0).

Print in the single line four integers x1, y1, x2, y2 — the coordinates of the required points.

use std::io::stdin;
use std::isize;
fn main() {
    let (x,y) = parse_input();
    let abs_x = x.abs();
    let abs_y = y.abs();
    let a =  abs_x+abs_y;
    if abs_x == x && abs_y == y{
        print(0,a ,a,0)
    }else if abs_x != x && abs_y !=y{
        print(-a,0,0,-a)
    }else if abs_x !=x {
        print(-a,0,0,a)
    }else{
        print(0,-a,a,0)
    }
}
fn parse_input()->(isize,isize){
    let mut input = String::new();
    stdin().read_line(&mut input).unwrap();
    let v:Vec<isize> = input.trim().split_whitespace().map(|e| e.parse().unwrap()).collect();
    (v[0],v[1])
}
fn print(a:isize,b:isize,c:isize,d:isize){
    println!("{} {} {} {}",a,b,c,d)
}

struct Scan {
    buffer: std::collections::VecDeque<String>,
}

impl Scan {
    fn new() -> Scan {
        Scan {
            buffer: std::collections::VecDeque::new(),
        }
    }

    fn next_line(&self) -> String {
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).expect("Fail to read");
        line
    }

    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop_front() {
                break token.parse::<T>().ok().unwrap();
            }
            let line = self.next_line();
            self.buffer = line.split_whitespace().map(String::from).collect();
        }
    }
}

fn _main() {
    let mut scan = Scan::new();
    let x: isize = scan.next();
    let y: isize = scan.next();
    let val = x.abs() + y.abs();
    let first = (0, val * y.signum());
    let second = (val * x.signum(), 0);
    let min = first.min(second);
    let max = first.max(second);
    println!("{} {} {} {}", min.0, min.1, max.0, max.1);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(1 << 23)
        .spawn(_main)
        .unwrap()
        .join()
        .unwrap();
}

use std::io::stdin;
use std::isize;
fn main() {
    let (x,y) = parse_input();
    let abs_x = x.abs();
    let abs_y = y.abs();
    let a =  abs_x+abs_y;
    if abs_x == x && abs_y == y{
        print(0,a ,a,0)
    }else if abs_x != x && abs_y !=y{
        print(-a,0,0,a)
    }else if abs_x !=x {
        print(-a,0,0,a)
    }else{
        print(0,-a,a,0)
    }
}
fn parse_input()->(isize,isize){
    let mut input = String::new();
    stdin().read_line(&mut input).unwrap();
    let v:Vec<isize> = input.trim().split_whitespace().map(|e| e.parse().unwrap()).collect();
    (v[0],v[1])
}
fn print(a:isize,b:isize,c:isize,d:isize){
    println!("{} {} {} {}",a,b,c,d)
}

use std::io::stdin;
fn main() {
    let (x,y) = parse_input();
    let abs_x = x.abs();
    let abs_y = y.abs();
    let a =  abs_x+abs_y;
    if abs_x == x && abs_y == y{
        println!("{} {} {} {}",0,a ,a,0)
    }else if abs_x != x && abs_y !=y{
        println!("{} {} {} {}",-a,0,0,a)
    }else if abs_x !=x {
        println!("{} {} {} {}",-a,0,0,a)
    }else{
        println!("{} {} {} {}",0,-a,a,0)
    }
}
fn parse_input()->(isize,isize){
    let mut input = String::new();
    stdin().read_line(&mut input).unwrap();
    let v:Vec<isize> = input.trim().split_whitespace().map(|e| e.parse().unwrap()).collect();
    (v[0],v[1])
}


Ksenia has ordinary pan scales and several weights of an equal mass. Ksenia has already put some weights on the scales, while other weights are untouched. Ksenia is now wondering whether it is possible to put all the remaining weights on the scales so that the scales were in equilibrium. The scales is in equilibrium if the total sum of weights on the left pan is equal to the total sum of weights on the right pan.

The first line has a non-empty sequence of characters describing the scales. In this sequence, an uppercase English letter indicates a weight, and the symbol "|" indicates the delimiter (the character occurs in the sequence exactly once). All weights that are recorded in the sequence before the delimiter are initially on the left pan of the scale. All weights that are recorded in the sequence after the delimiter are initially on the right pan of the scale.  The second line contains a non-empty sequence containing uppercase English letters. Each letter indicates a weight which is not used yet.  It is guaranteed that all the English letters in the input data are different. It is guaranteed that the input does not contain any extra characters.

If you cannot put all the weights on the scales so that the scales were in equilibrium, print string "Impossible". Otherwise, print the description of the resulting scales, copy the format of the input. If there are multiple answers, print any of them.

//! http://codeforces.com/contest/382/problem/A

#[macro_export]
macro_rules! scanln {
  ($($var:ident : $ty:path),+) => {
    $(let $var: $ty;)+
    {
      use std::io;
      let mut __buf = String::new();
      io::stdin().read_line(&mut __buf).unwrap();
      let mut eles = __buf.split_whitespace();
      $($var = Scan::scan(&mut eles);)+
    }
  }
}

pub trait Scan {
  fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator<Item=&'a str>;
}

macro_rules! impl_scan_single {
  ($ty:ty) => {
    impl Scan for $ty {
      fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator<Item=&'a str> {
        let next = eles.next().unwrap();
        match next.parse() {
          Ok(res) => res,
          Err(_) => panic!()
        }
      }
    }
  }
}

impl_scan_single!(u8);
impl_scan_single!(u16);
impl_scan_single!(u32);
impl_scan_single!(u64);
impl_scan_single!(usize);
impl_scan_single!(i8);
impl_scan_single!(i16);
impl_scan_single!(i32);
impl_scan_single!(i64);
impl_scan_single!(f32);
impl_scan_single!(f64);
impl_scan_single!(isize);
impl_scan_single!(String);

const __IMPL_SCAN_FOR_VEC: () = {
  use std::str::FromStr;
  impl<T> Scan for Vec<T> where T: FromStr {
    fn scan<'a, I>(eles: &mut I) -> Self where I: Iterator<Item=&'a str> {
      eles.map(|str| match str.parse() {
        Ok(res) => res,
        Err(_) => panic!()
      }).collect()
    }
  }
};

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

fn main() {
  scanln!(scale: String);
  scanln!(weights: String);
  let mut pans = scale.split('|');
  let pan1 = pans.next().unwrap();
  let pan2 = pans.next().unwrap();
  let diff = std::cmp::max(pan1.len(), pan2.len()) - std::cmp::min(pan1.len(), pan2.len());
  let common = weights.len() as i32 - diff as i32;
  if common >= 0 && common % 2 == 0 {
    let (less, more) = weights.as_bytes().split_at((weights.len() - diff) / 2);
    let (front, back) = if pan1.len() > pan2.len() { (less, more) } else { (more, less) };
    for c in front.iter().map(|&b| b as char).chain(pan1.chars()) {
      print!("{}", c);
    }
    print!("|");
    for c in back.iter().map(|&b| b as char).chain(pan2.chars()) {
      print!("{}", c);
    }
    println!("");
  } else {
    println!("Impossible");
  }
}

use std::io;

fn get_line() -> String {
	let mut input = String::new();

	io::stdin().read_line(&mut input)
		.expect("");

	String::from(input.trim())
}

fn main() {
	let s = get_line();
	let t = get_line();

	let mut l = String::new();
	let mut r = String::new();

	let mut k = 0usize;
	for (i, c) in s.chars().enumerate() {
		if c == '|' {
			k = i;
			break;
		}
	}

	for (i, c) in s.chars().enumerate() {
		if i == k {
			break;
		}
		l.push(c);
	}

	for (i, c) in s.chars().enumerate() {
		if i <= k {
			continue;
		}
		r.push(c);
	}

	for c in t.chars() {
		if l.len() < r.len() {
			l.push(c);
		} else {
			r.push(c);
		}
	}

	if l.len() != r.len() {
		println!("Impossible");
	} else {
		println!("{}|{}", l, r);
	}
}

use std::io;

fn get_line() -> String {
	let mut input = String::new();

	io::stdin().read_line(&mut input)
		.expect("");

	String::from(input.trim())
}

fn main() {
	let s = get_line();
	let t = get_line();

	let mut k = 0usize;
	for (i, c) in s.chars().enumerate() {
		if c == '|' {
			k = i;
			break;
		}
	}

	let mut l = String::new();
	for (i, c) in s.chars().enumerate() {
		if i == k {
			break;
		}

		l.push(c);
	}

	let mut r = String::new();
	for (j, d) in s.chars().enumerate() {
		if j <= k {
			continue;
		}

		r.push(d);
	}

	if (t.len() + l.len() + r.len())%2 != 0 {
		println!("Impossible");
		return;
	}

	if l.len() == 0 {
		l.push_str(&t);
	} else if r.len() == 0 {
		r.push_str(&t);
	} else {
		let mut f = if l.len() < r.len() { true } else { false };
    	for c in t.chars() {
			if f {
				l.push(c);
				f = false;
			} else {
				r.push(c);
				f = true;
			}
		}
	}
	println!("{}|{}", l, r);
}

use std::io;

fn get_line() -> String {
	let mut input = String::new();

	io::stdin().read_line(&mut input)
		.expect("");

	String::from(input.trim())
}

fn main() {
	let s = get_line();
	let t = get_line();

	let mut k = 0usize;
	for (i, c) in s.chars().enumerate() {
		if c == '|' {
			k = i;
			break;
		}
	}

	let mut l = String::new();
	for (i, c) in s.chars().enumerate() {
		if i == k {
			break;
		}

		l.push(c);
	}

	let mut r = String::new();
	for (j, d) in s.chars().enumerate() {
		if j <= k {
			continue;
		}

		r.push(d);
	}

	let d = if l.len() < r.len() { r.len()-r.len() } else { l.len()-r.len() };

	if (t.len() + l.len() + r.len())%2 != 0 || d > t.len() {
		println!("Impossible");
		return;
	}

	if l.len() == 0 {
		l.push_str(&t);
	} else if r.len() == 0 {
		r.push_str(&t);
	} else {
		let mut f = if l.len() < r.len() { true } else { false };
    	for c in t.chars() {
			if f {
				l.push(c);
				f = false;
			} else {
				r.push(c);
				f = true;
			}
		}
	}
	println!("{}|{}", l, r);
}

use std::io;

fn get_line() -> String {
	let mut input = String::new();

	io::stdin().read_line(&mut input)
		.expect("");

	String::from(input.trim())
}

fn main() {
	let s = get_line();
	let t = get_line();

	let mut k = 0usize;
	for (i, c) in s.chars().enumerate() {
		if c == '|' {
			k = i;
			break;
		}
	}

	let mut l = String::new();
	for (i, c) in s.chars().enumerate() {
		if i == k {
			break;
		}

		l.push(c);
	}

	let mut r = String::new();
	for (j, d) in s.chars().enumerate() {
		if j <= k {
			continue;
		}

		r.push(d);
	}

	let d = if l.len() < r.len() { r.len()-s.len() } else { l.len()-r.len() };

	if (t.len() + l.len() + r.len())%2 != 0 || d > t.len() {
		println!("Impossible");
		return;
	}

	if l.len() == 0 {
		l.push_str(&t);
	} else if r.len() == 0 {
		r.push_str(&t);
	} else {
		let mut f = if l.len() < r.len() { true } else { false };
    	for c in t.chars() {
			if f {
				l.push(c);
				f = false;
			} else {
				r.push(c);
				f = true;
			}
		}
	}
	println!("{}|{}", l, r);
}

use std::io;

fn get_line() -> String {
	let mut input = String::new();

	io::stdin().read_line(&mut input)
		.expect("");

	String::from(input.trim())
}

fn main() {
	let s = get_line();
	let t = get_line();

	let mut k = 0usize;
	for (i, c) in s.chars().enumerate() {
		if c == '|' {
			k = i;
			break;
		}
	}

	let mut l = String::new();
	for (i, c) in s.chars().enumerate() {
		if i == k {
			break;
		}

		l.push(c);
	}

	let mut r = String::new();
	for (j, d) in s.chars().enumerate() {
		if j <= k {
			continue;
		}

		r.push(d);
	}

	let d = if l.len() < r.len() { r.len()-l.len() } else { l.len()-r.len() };

	if d == 0 {
	 	if t.len()%2 == 0 {
	 		let mut f = true;
	 		for c in t.chars() {
	 			if f {
	 				l.push(c);
	 				f = false;
				} else {
					r.push(c);
					f = true;
				}
			}
			println!("{}|{}", l, r);
	 	} else {
	 		println!("Impossible");
		}
	} else {
		if d != t.len() {
			println!("Impossible");
		} else {
			if l.len() < r.len() {
				for c in t.chars() {
					l.push(c);
				}
			} else {
				for c in t.chars() {
					r.push(c);
				}
			}

			println!("{}|{}", l, r);
		}
	}
}


Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every $$$a$$$ and $$$b$$$ such that $$$1 \leq a \leq b \leq 6$$$, there is exactly one domino with $$$a$$$ dots on one half and $$$b$$$ dots on the other half. The set contains exactly $$$21$$$ dominoes. Here is an exact illustration of his set:  Also, Anadi has an undirected graph without self-loops and multiple edges. He wants to choose some dominoes and place them on the edges of this graph. He can use at most one domino of each type. Each edge can fit at most one domino. It's not necessary to place a domino on each edge of the graph.When placing a domino on an edge, he also chooses its direction. In other words, one half of any placed domino must be directed toward one of the endpoints of the edge and the other half must be directed toward the other endpoint. There's a catch: if there are multiple halves of dominoes directed toward the same vertex, each of these halves must contain the same number of dots.How many dominoes at most can Anadi place on the edges of his graph?

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n \leq 7$$$, $$$0 \leq m \leq \frac{n\cdot(n-1)}{2}$$$) — the number of vertices and the number of edges in the graph. The next $$$m$$$ lines contain two integers each. Integers in the $$$i$$$-th line are $$$a_i$$$ and $$$b_i$$$ ($$$1 \leq a, b \leq n$$$, $$$a \neq b$$$) and denote that there is an edge which connects vertices $$$a_i$$$ and $$$b_i$$$. The graph might be disconnected. It's however guaranteed that the graph doesn't contain any self-loops, and that there is at most one edge between any pair of vertices.

Output one integer which denotes the maximum number of dominoes which Anadi can place on the edges of the graph.

NoteHere is an illustration of Anadi's graph from the first sample test:  And here is one of the ways to place a domino on each of its edges:  Note that each vertex is faced by the halves of dominoes with the same number of dots. For instance, all halves directed toward vertex $$$1$$$ have three dots.

use std::io::Write;

pub struct Scanner {
  buffer: Vec<String>
}

impl Scanner {
  pub fn new() -> Scanner {
    Scanner { buffer: Vec::new() }
  }

  pub fn next<T: std::str::FromStr>(&mut self) -> T {
    loop {
      if let Some(token) = self.buffer.pop() {
          return token.parse().ok().expect("Failed parse");
      }
      let mut input = String::new();
      std::io::stdin().read_line(&mut input).expect("Failed read");
      self.buffer = input.split_whitespace().rev().map(String::from).collect();
    }
  }
}

fn calculate(n: usize, g: &Vec<Vec<usize>>, p: &Vec<usize>) -> i32 {
  let mut found: [[bool; 6]; 6] = [[false; 6]; 6];
  let mut ans: i32 = 0;
  for u in 0..n {
    for &v in g[u].iter() {
      let u = p[u];
      let v = p[v];
      if !found[u][v] {
        found[u][v] = true;
        found[v][u] = true;
        ans += 1;
      }
    }
  }
  return ans;
}

fn gen(d: usize, n: usize, g: &Vec<Vec<usize>>, p: &mut Vec<usize>) -> i32 {
  if d == n {
    return calculate(n, g, p);
  }
  let mut ans: i32 = 0;
  for x in 0..6 {
    p[d] = x;
    ans = std::cmp::max(ans, gen(d + 1, n, g, p));
  }
  return ans;
}

fn main() {
  let stdout = std::io::stdout();
  let mut out = std::io::BufWriter::new(stdout.lock());
  let mut scan = Scanner::new();

  let n: usize = scan.next();
  let m: usize = scan.next();
  let mut g: Vec<Vec<usize>> = vec![vec![]; n];
  for _ in 0..m {
    let u: usize = scan.next();
    let v: usize = scan.next();
    g[u - 1].push(v - 1);
    g[v - 1].push(u - 1);
  }
  let mut p: Vec<usize> = vec![0; n];
  let ans = gen(0, n, &g, &mut p);
  writeln!(out, "{}", ans).unwrap();
}


The football season has just ended in Berland. According to the rules of Berland football, each match is played between two teams. The result of each match is either a draw, or a victory of one of the playing teams. If a team wins the match, it gets $$$w$$$ points, and the opposing team gets $$$0$$$ points. If the game results in a draw, both teams get $$$d$$$ points.The manager of the Berland capital team wants to summarize the results of the season, but, unfortunately, all information about the results of each match is lost. The manager only knows that the team has played $$$n$$$ games and got $$$p$$$ points for them.You have to determine three integers $$$x$$$, $$$y$$$ and $$$z$$$ — the number of wins, draws and loses of the team. If there are multiple answers, print any of them. If there is no suitable triple $$$(x, y, z)$$$, report about it.

The first line contains four integers $$$n$$$, $$$p$$$, $$$w$$$ and $$$d$$$ $$$(1 \le n \le 10^{12}, 0 \le p \le 10^{17}, 1 \le d < w \le 10^{5})$$$ — the number of games, the number of points the team got, the number of points awarded for winning a match, and the number of points awarded for a draw, respectively. Note that $$$w > d$$$, so the number of points awarded for winning is strictly greater than the number of points awarded for draw.

If there is no answer, print $$$-1$$$. Otherwise print three non-negative integers $$$x$$$, $$$y$$$ and $$$z$$$ — the number of wins, draws and losses of the team. If there are multiple possible triples $$$(x, y, z)$$$, print any of them. The numbers should meet the following conditions:    $$$x \cdot w + y \cdot d = p$$$,  $$$x + y + z = n$$$.

NoteOne of the possible answers in the first example — $$$17$$$ wins, $$$9$$$ draws and $$$4$$$ losses. Then the team got $$$17 \cdot 3 + 9 \cdot 1 = 60$$$ points in $$$17 + 9 + 4 = 30$$$ games.In the second example the maximum possible score is $$$10 \cdot 5 = 50$$$. Since $$$p = 51$$$, there is no answer.In the third example the team got $$$0$$$ points, so all $$$20$$$ games were lost.

//spnauti-rusT {{{
use std::io::*; use std::str::{self,*}; use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::{self,*};
#[allow(unused_imports)] use std::iter::{self,*};
#[allow(unused_imports)] use std::collections::*;
#[allow(unused_imports)] use std::cell::*;
#[allow(unused_macros)] macro_rules! m {
	($c:tt,$x:expr,$y:expr) => {{
		let b=$y; let a=&mut$x; if b$c*a {*a=b; true} else {false}
	}};
}
#[allow(unused_macros)] macro_rules! l {
	($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};
	($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};
	(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};
	(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};
}
#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }
#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }
#[allow(dead_code)] fn writer() -> BufWriter<Stdout> { BufWriter::new(stdout()) }
struct WordReaderC {buf: Vec<u8>, pos: usize, q: std::io::StdinLock<'static>}//'
#[allow(dead_code)] impl WordReaderC {
	fn new() -> Self {
		let r = unsafe {&*Box::into_raw(Box::new(stdin()))};
		Self { q: r.lock(), buf: Vec::new(), pos: 0 }
	}
	fn next_line(&mut self) -> bool {
		self.buf.clear(); self.pos = 0;
		self.q.read_until(b'\n', &mut self.buf).unwrap_or(0) > 0
	}
	fn is_ws(c: u8) -> bool {
		c == b' ' || c == b'\r' || c == b'\n' || c == b'\t'
	}
	fn byte(&mut self) -> Option<u8> {
		if self.pos == self.buf.len() { if !self.next_line() { return None; } }
		self.pos += 1; Some(self.buf[self.pos - 1])
	}
	fn vb(&mut self) -> Vec<u8> {
		let mut s = Vec::with_capacity(8);
		let mut f = false;
		loop {
			if let Some(c) = self.byte() {
				if !Self::is_ws(c) {
					s.push(c);
					f = true;
				} else if f { break; }
			} else { break; }
		}
		s
	}
	fn s(&mut self) -> String { String::from_utf8(self.vb()).expect("invalid utf8") }
	fn i(&mut self) ->    i32 { self.p() }
	fn l(&mut self) ->    i64 { self.p() }
	fn u(&mut self) ->  usize { self.p() }
	fn f(&mut self) ->    f64 { self.p() }
	fn vi(&mut self, n: usize) -> Vec<i32> { self.vp(n) }
	fn vl(&mut self, n: usize) -> Vec<i64> { self.vp(n) }
	fn vu(&mut self, n: usize) -> Vec<usize> { self.vp(n) }
	fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> { self.ip(n).into_iter() }
	fn iu(&mut self, n: usize) -> impl Iterator<Item=usize> { self.ip(n).into_iter() }
	fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
		let w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::<T>().unwrap()
	}
	fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
		(0..n).map(|_|self.p()).collect()
	}
	fn ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
		self.vp(n).into_iter()
	}
}
//------------------- End rusT }}}

// Extended Euclidean GCD {{{
fn extended_euclid(a: i64, b: i64) -> (i64,i64,i64) {
	if b == 0 {
		(a,1,0)
	} else {
		let q = div_floor(a,b);
		let r = a - q*b;
		let (d,x,y) = extended_euclid(b, r);
		(d, y, x-q*y)
	}
}//}}}
fn div_floor(a: i64, b: i64) -> i64 {
	assert!(b != 0);
	let (a,b) = if b < 0 {(-a,-b)} else {(a,b)};
	if a % b == 0 || a >= 0 {
		a / b
	} else {
		a / b - 1
	}
}
fn div_ceil(a: i64, b: i64) -> i64 {
	assert!(b != 0);
	let (a,b) = if b < 0 {(-a,-b)} else {(a,b)};
	if a % b == 0 || a <= 0 {
		a / b
	} else {
		a / b + 1
	}
}

fn main() {
	let mut rin = reader();
	let mut rout = writer();

	l!(n,p,a,b = rin.l());
	let (g,x0,y0) = extended_euclid(a,b);
	if p % g == 0 {
		l!(mut x,y = 0);
		let mut e = p / g;
		let mut ee = Vec::new();
		while e > 0 {
			ee.push(e % 10);
			e /= 10;
		}
		ee.reverse();
		for e in ee {
			// writeln!(rout, "g {}  x0 {}  y0 {}   : e {}", g, x0, y0, e).ok();
			x = x * 10 + x0 * e;
			y = y * 10 + y0 * e;
			let ca = -b / g;
			let cb = a / g;
			let kx0 = div_ceil(n - x, ca);
			let kx1 = div_floor(-x, ca);
			let ky0 = div_ceil(-y, cb);
			let ky1 = div_floor(n - y, cb);
			let k0 = kx0.max(ky0);
			let k1 = kx1.min(ky1);
			if k0 <= k1 {
				x += k0 * ca;
				y += k0 * cb;
			}
		}
		if x.min(y) >= 0 && x + y <= n {
			writeln!(rout, "{} {} {}", x, y, n - x - y).ok();
			return;
		}
	}
	writeln!(rout, "-1").ok();
}

//spnauti-rusT {{{
use std::io::*; use std::str::{self,*}; use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::{self,*};
#[allow(unused_imports)] use std::iter::{self,*};
#[allow(unused_imports)] use std::collections::*;
#[allow(unused_imports)] use std::cell::*;
#[allow(unused_macros)] macro_rules! m {
	($c:tt,$x:expr,$y:expr) => {{
		let b=$y; let a=&mut$x; if b$c*a {*a=b; true} else {false}
	}};
}
#[allow(unused_macros)] macro_rules! l {
	($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};
	($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};
	(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};
	(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};
}
#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }
#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }
#[allow(dead_code)] fn writer() -> BufWriter<Stdout> { BufWriter::new(stdout()) }
struct WordReaderC {buf: Vec<u8>, pos: usize, q: std::io::StdinLock<'static>}//'
#[allow(dead_code)] impl WordReaderC {
	fn new() -> Self {
		let r = unsafe {&*Box::into_raw(Box::new(stdin()))};
		Self { q: r.lock(), buf: Vec::new(), pos: 0 }
	}
	fn next_line(&mut self) -> bool {
		self.buf.clear(); self.pos = 0;
		self.q.read_until(b'\n', &mut self.buf).unwrap_or(0) > 0
	}
	fn is_ws(c: u8) -> bool {
		c == b' ' || c == b'\r' || c == b'\n' || c == b'\t'
	}
	fn byte(&mut self) -> Option<u8> {
		if self.pos == self.buf.len() { if !self.next_line() { return None; } }
		self.pos += 1; Some(self.buf[self.pos - 1])
	}
	fn vb(&mut self) -> Vec<u8> {
		let mut s = Vec::with_capacity(8);
		let mut f = false;
		loop {
			if let Some(c) = self.byte() {
				if !Self::is_ws(c) {
					s.push(c);
					f = true;
				} else if f { break; }
			} else { break; }
		}
		s
	}
	fn s(&mut self) -> String { String::from_utf8(self.vb()).expect("invalid utf8") }
	fn i(&mut self) ->    i32 { self.p() }
	fn l(&mut self) ->    i64 { self.p() }
	fn u(&mut self) ->  usize { self.p() }
	fn f(&mut self) ->    f64 { self.p() }
	fn vi(&mut self, n: usize) -> Vec<i32> { self.vp(n) }
	fn vl(&mut self, n: usize) -> Vec<i64> { self.vp(n) }
	fn vu(&mut self, n: usize) -> Vec<usize> { self.vp(n) }
	fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> { self.ip(n).into_iter() }
	fn iu(&mut self, n: usize) -> impl Iterator<Item=usize> { self.ip(n).into_iter() }
	fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
		let w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::<T>().unwrap()
	}
	fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
		(0..n).map(|_|self.p()).collect()
	}
	fn ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
		self.vp(n).into_iter()
	}
}
//------------------- End rusT }}}

fn main() {
	let mut rin = reader();
	let mut rout = writer();

	l!(n,p,a,b = rin.l());
	for y in 0..a {
		if (p - b*y) % a == 0 {
			let x = (p - b*y) / a;
			if x >= 0 && x + y <= n {
				writeln!(rout, "{} {} {}", x, y, n - x - y).ok();
				return;
			}
		}
	}
	writeln!(rout, "-1").ok();
}

mod io {
    use std::io::{self, BufRead};
    use std::str::{self, FromStr, SplitAsciiWhitespace};
    use super::Result;

    pub struct Scanner<'a, R> {
        reader: R,
        buf_str: Vec<u8>,
        buf_iter: SplitAsciiWhitespace<'a>,
    }

    impl<R: BufRead> Scanner<'_, R> {
        pub fn new(reader: R) -> Self {
            Self {
                reader,
                buf_str: Vec::new(),
                buf_iter: "".split_ascii_whitespace(),
            }
        }

        pub fn token<T>(&mut self) -> Result<T>
            where T: FromStr,
                  <T as FromStr>::Err: 'static + std::error::Error
        {
            loop {
                if let Some(token) = self.buf_iter.next() {
                    return Ok(token.parse()?);
                }
                self.buf_str.clear();
                let bytes_read = self.reader
                    .read_until(b'\n', &mut self.buf_str)?;
                if bytes_read == 0 {
                    return Err(Box::new(io::Error::from(io::ErrorKind::UnexpectedEof)));
                }
                self.buf_iter = unsafe {
                    let slice = str::from_utf8_unchecked(&self.buf_str);
                    ::std::mem::transmute(slice.split_ascii_whitespace())
                }
            }
        }
    }
}

use std::io::{stdin, stdout, BufRead, Write};
use io::Scanner;

pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;

fn main() -> Result<()> {
    let stdin = stdin();
    solve(Scanner::new(stdin.lock()), stdout().lock())
}

fn solve<R: BufRead, W: Write>(mut scan: Scanner<R>, mut out: W) -> Result<()> {
    let (n, mut p, mut w, mut d) =
        (scan.token::<i64>()?, scan.token::<i64>()?, scan.token::<i64>()?, scan.token::<i64>()?);
    let (g, ..) = ext_euclid(w, d);
    if p % g != 0 {
        writeln!(out, "-1")?;
        return Ok(());
    }
    p /= g;
    w /= g;
    d /= g;
    let y = p % w * inv(d, w) % w;
    let x = (p - d * y) / w;
    if x < 0 || x + y > n {
        writeln!(out, "-1")?;
        return Ok(());
    }
    let z = n - x - y;
    writeln!(out, "{} {} {}", x, y, z)?;
    Ok(())
}

pub fn ext_euclid(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (d, x, y) = ext_euclid(b, a % b);
        (d, y, x - a / b * y)
    }
}

fn inv(a: i64, n: i64) -> i64 {
    let (_, x, ..) = ext_euclid(a, n);
    (n + x) % n
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! t {
        ( $inp:expr, $expected:expr ) => {
            let mut out = String::new();
            solve(Scanner::new($inp.as_bytes()), unsafe { out.as_mut_vec() }).unwrap();
            assert_eq!(out, $expected);
        };
    }

    #[test]
    fn example1() {
        //t!("30 60 3 1\n", "17 9 4\n");
        t!("30 60 3 1\n", "20 0 10\n");
    }

    #[test]
    fn example2() {
        t!("10 51 5 4\n", "-1\n");
    }

    #[test]
    fn example3() {
        t!("20 0 15 5\n", "0 0 20\n");
    }

    #[test]
    fn t() {
        t!("4 7 3 2\n", "1 2 1\n");
        t!("1000000000000 99999999999999999 100000 99999\n", "999999999999 1 0\n");
        t!("923399641127 50915825165227299 94713 49302\n", "537580105939 11996 385819523192\n");
    }
}

use std::io::stdin;

macro_rules! readln {
    ($type:ty) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace().next().unwrap().parse::<$type>().unwrap() }};
    (|$type_vec:ty|) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace().map(|it| it.parse::<$type_vec>().unwrap()).collect::<Vec<$type_vec>>() }};
    ($($type:ty),*) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace(); ($(iter.next().unwrap().parse::<$type>().unwrap(),)*) }};
    ($($type:ty),* |$type_vec:ty|) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$type>().unwrap(),)*iter.map(|it| it.parse::<$type_vec>().unwrap()).collect::<Vec<$type_vec>>(),)}}
}

fn gcd(mut a: u64, mut b: u64) -> u64 {
    while b != 0 {
        a %= b;
        let c = a;
        a = b;
        b = c;
    }
    return a;
}

fn main() {
    let (n, p, w, d) = readln!(u64, u64, u64, u64);

    let gcd = gcd(w, d);
    let lcm = w * d / gcd;
    let x_count = lcm / w;
    let y_count = lcm / d;

    if p % gcd != 0 {
        println!("-1");
        return;
    }

    let mut max_x = if p / w < n { p / w } else { n };
    while max_x != 0 && (p - max_x * w) % d != 0 {
        max_x -= 1;
    }
    let y = (p - max_x * w) / d;

    if max_x + y > n || max_x * w + y * d < p {
        println!("-1")
    } else {
        println!("{} {} {}", max_x, y, n - max_x - y);
    }
}

//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 run() {
    input! {
        n: i64,
        p: i64,
        w: i64,
        d: i64,
    }
    for r in 0..d {
        if p - w * r < 0 || (p - w * r) % d != 0 {
            continue;
        }
        let q = (p - w * r) / (w * d);
        let x = d * q + r;
        let y = (p - w * r) / d - w * q;
        if x + y <= n {
            assert!(x * w + y * d == p);
            let z = n - x - y;
            println!("{} {} {}", x, y, z);
            return;
        }
    }
    println!("-1");
}

fn main() {
    run();
}

macro_rules! parse_line {
    ($t: ty) => ({
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        let a_str = a_str.trim();
        a_str.parse::<$t>().expect("parse error")
    });
    ($($t: ty),+) => ({
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        let mut a_iter = a_str.split_whitespace();
        (
            $(
            a_iter.next().unwrap().parse::<$t>().expect("parse error"),
            )+
        )
    })
}

#[allow(unused_macros)]
macro_rules! parse_line_to_vec {
    ($t: ty) => {{
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        (a_str
            .split_whitespace()
            .map(|x| x.parse::<$t>().unwrap())
            .collect::<Vec<$t>>())
    }};
}

use std::io::Write;

fn ext_euclid(a: i128, b: i128, x: &mut i128, y: &mut i128) -> i128 {
    if a == 0 {
        *x = 0;
        *y = 1;
        return b;
    }
    let mut x1 = 0;
    let mut y1 = 0;
    let g = ext_euclid(b % a, a, &mut x1, &mut y1);
    *x = y1 - b / a * x1;
    *y = x1;
    return g;
}

fn solve(writer: &mut std::io::BufWriter<std::io::Stdout>) {
    let (n, p, w, d) = parse_line!(i128, i128, i128, i128);
    let mut x = 0;
    let mut y = 0;
    let g = ext_euclid(w, d, &mut x, &mut y);
    if p % g != 0 {
        writeln!(writer, "-1").unwrap();
        return;
    }
    x *= p / g;
    y *= p / g;
    let step_x = d / g;
    let step_y = w / g;
    if x < 0 {
        let k = (-x + step_x - 1) / step_x;
        x += k * step_x;
        y -= k * step_y;
    }
    if y < 0 {
        let k = (-y + step_y - 1) / step_y;
        x -= k * step_x;
        y += k * step_y;
    }
    if x < 0 {
        writeln!(writer, "-1").unwrap();
        return;
    }
    let k = x / step_x;
    x -= k * step_x;
    y += k * step_y;
    if x + y <= n {
        writeln!(writer, "{} {} {}", x, y, n - x - y).unwrap();
        return;
    }
    let k = y / step_y;
    x += k * step_x;
    y -= k * step_y;
    if x + y <= n {
        writeln!(writer, "{} {} {}", x, y, n - x - y).unwrap();
        return;
    }
    writeln!(writer, "-1").unwrap();
}

fn main() {
    let mut writer = std::io::BufWriter::new(std::io::stdout());
    let tests = 1; // parse_line!(usize);
    for _ in 0..tests {
        solve(&mut writer);
    }
}

//spnauti-rusT {{{
use std::io::*; use std::str::{self,*}; use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::{self,*};
#[allow(unused_imports)] use std::iter::{self,*};
#[allow(unused_imports)] use std::collections::*;
#[allow(unused_imports)] use std::cell::*;
#[allow(unused_macros)] macro_rules! m {
	($c:tt,$x:expr,$y:expr) => {{
		let b=$y; let a=&mut$x; if b$c*a {*a=b; true} else {false}
	}};
}
#[allow(unused_macros)] macro_rules! l {
	($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};
	($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};
	(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};
	(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};
}
#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }
#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }
#[allow(dead_code)] fn writer() -> BufWriter<Stdout> { BufWriter::new(stdout()) }
struct WordReaderC {buf: Vec<u8>, pos: usize, q: std::io::StdinLock<'static>}//'
#[allow(dead_code)] impl WordReaderC {
	fn new() -> Self {
		let r = unsafe {&*Box::into_raw(Box::new(stdin()))};
		Self { q: r.lock(), buf: Vec::new(), pos: 0 }
	}
	fn next_line(&mut self) -> bool {
		self.buf.clear(); self.pos = 0;
		self.q.read_until(b'\n', &mut self.buf).unwrap_or(0) > 0
	}
	fn is_ws(c: u8) -> bool {
		c == b' ' || c == b'\r' || c == b'\n' || c == b'\t'
	}
	fn byte(&mut self) -> Option<u8> {
		if self.pos == self.buf.len() { if !self.next_line() { return None; } }
		self.pos += 1; Some(self.buf[self.pos - 1])
	}
	fn vb(&mut self) -> Vec<u8> {
		let mut s = Vec::with_capacity(8);
		let mut f = false;
		loop {
			if let Some(c) = self.byte() {
				if !Self::is_ws(c) {
					s.push(c);
					f = true;
				} else if f { break; }
			} else { break; }
		}
		s
	}
	fn s(&mut self) -> String { String::from_utf8(self.vb()).expect("invalid utf8") }
	fn i(&mut self) ->    i32 { self.p() }
	fn l(&mut self) ->    i64 { self.p() }
	fn u(&mut self) ->  usize { self.p() }
	fn f(&mut self) ->    f64 { self.p() }
	fn vi(&mut self, n: usize) -> Vec<i32> { self.vp(n) }
	fn vl(&mut self, n: usize) -> Vec<i64> { self.vp(n) }
	fn vu(&mut self, n: usize) -> Vec<usize> { self.vp(n) }
	fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> { self.ip(n).into_iter() }
	fn iu(&mut self, n: usize) -> impl Iterator<Item=usize> { self.ip(n).into_iter() }
	fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
		let w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::<T>().unwrap()
	}
	fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
		(0..n).map(|_|self.p()).collect()
	}
	fn ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
		self.vp(n).into_iter()
	}
}
//------------------- End rusT }}}

// Extended Euclidean GCD {{{
fn extended_euclid(a: i64, b: i64) -> (i64,i64,i64) {
	if b == 0 {
		(a,1,0)
	} else {
		let q = div_floor(a,b);
		let r = a - q*b;
		let (d,x,y) = extended_euclid(b, r);
		(d, y, x-q*y)
	}
}//}}}
fn div_floor(a: i64, b: i64) -> i64 {
	assert!(b != 0);
	let (a,b) = if b < 0 {(-a,-b)} else {(a,b)};
	if a % b == 0 || a >= 0 {
		a / b
	} else {
		a / b - 1
	}
}
fn div_ceil(a: i64, b: i64) -> i64 {
	assert!(b != 0);
	let (a,b) = if b < 0 {(-a,-b)} else {(a,b)};
	if a % b == 0 || a <= 0 {
		a / b
	} else {
		a / b + 1
	}
}

fn main() {
	let mut rin = reader();
	let mut rout = writer();

	l!(n,p,a,b = rin.l());
	let (g,x0,y0) = extended_euclid(a,b);
	if p % g == 0 {
		l!(mut x,y = 0);
		let mut e = p / g;
		let mut ee = Vec::new();
		while e > 0 {
			ee.push(e % 10);
			e /= 10;
		}
		ee.reverse();
		for e in ee {
			// writeln!(rout, "g {}  x0 {}  y0 {}   : e {}", g, x0, y0, e).ok();
			x = x * 10 + x0 * e;
			y = y * 10 + y0 * e;
			let ca = -b / g;
			let cb = a / g;
			let kx0 = div_ceil(n - x, ca);
			let kx1 = div_floor(-x, ca);
			let ky0 = div_ceil(-y, cb);
			let ky1 = div_floor(n - y, cb);
			let k0 = kx0.max(ky0);
			let k1 = kx1.min(ky1);
			if k0 <= k1 {
				x += k0 * ca;
				y += k0 * cb;
			}
		}
		if x + y <= n {
			writeln!(rout, "{} {} {}", x, y, n - x - y).ok();
			return;
		}
	}
	writeln!(rout, "-1").ok();
}

//spnauti-rusT {{{
use std::io::*; use std::str::{self,*}; use std::fmt::Debug;
#[allow(unused_imports)] use std::cmp::Ordering::{self,*};
#[allow(unused_imports)] use std::ops::{self,*};
#[allow(unused_imports)] use std::iter::{self,*};
#[allow(unused_imports)] use std::collections::*;
#[allow(unused_imports)] use std::cell::*;
#[allow(unused_macros)] macro_rules! m {
	($c:tt,$x:expr,$y:expr) => {{
		let b=$y; let a=&mut$x; if b$c*a {*a=b; true} else {false}
	}};
}
#[allow(unused_macros)] macro_rules! l {
	($($v:ident),+ =$e:expr) => {$(let$v=$e;)+};
	($($v:ident),+:$t:ty=$e:expr) => {$(let$v:$t=$e;)+};
	(mut $($v:ident),+ =$e:expr) => {$(let mut$v=$e;)+};
	(mut $($v:ident),+:$t:ty=$e:expr) => {$(let mut$v:$t=$e;)+};
}
#[allow(unused_macros)] macro_rules! rep { {[$c:expr]$($s:tt)+} => {for _ in 0..$c {$($s)+}} }
#[allow(dead_code)] fn reader() -> WordReaderC { WordReaderC::new() }
#[allow(dead_code)] fn writer() -> BufWriter<Stdout> { BufWriter::new(stdout()) }
struct WordReaderC {buf: Vec<u8>, pos: usize, q: std::io::StdinLock<'static>}//'
#[allow(dead_code)] impl WordReaderC {
	fn new() -> Self {
		let r = unsafe {&*Box::into_raw(Box::new(stdin()))};
		Self { q: r.lock(), buf: Vec::new(), pos: 0 }
	}
	fn next_line(&mut self) -> bool {
		self.buf.clear(); self.pos = 0;
		self.q.read_until(b'\n', &mut self.buf).unwrap_or(0) > 0
	}
	fn is_ws(c: u8) -> bool {
		c == b' ' || c == b'\r' || c == b'\n' || c == b'\t'
	}
	fn byte(&mut self) -> Option<u8> {
		if self.pos == self.buf.len() { if !self.next_line() { return None; } }
		self.pos += 1; Some(self.buf[self.pos - 1])
	}
	fn vb(&mut self) -> Vec<u8> {
		let mut s = Vec::with_capacity(8);
		let mut f = false;
		loop {
			if let Some(c) = self.byte() {
				if !Self::is_ws(c) {
					s.push(c);
					f = true;
				} else if f { break; }
			} else { break; }
		}
		s
	}
	fn s(&mut self) -> String { String::from_utf8(self.vb()).expect("invalid utf8") }
	fn i(&mut self) ->    i32 { self.p() }
	fn l(&mut self) ->    i64 { self.p() }
	fn u(&mut self) ->  usize { self.p() }
	fn f(&mut self) ->    f64 { self.p() }
	fn vi(&mut self, n: usize) -> Vec<i32> { self.vp(n) }
	fn vl(&mut self, n: usize) -> Vec<i64> { self.vp(n) }
	fn vu(&mut self, n: usize) -> Vec<usize> { self.vp(n) }
	fn ii(&mut self, n: usize) -> impl Iterator<Item=i32> { self.ip(n).into_iter() }
	fn iu(&mut self, n: usize) -> impl Iterator<Item=usize> { self.ip(n).into_iter() }
	fn p<T: FromStr>(&mut self) -> T where T::Err: Debug {
		let w = self.vb(); str::from_utf8(w.as_ref()).unwrap().parse::<T>().unwrap()
	}
	fn vp<T: FromStr>(&mut self, n: usize) -> Vec<T> where T::Err: Debug {
		(0..n).map(|_|self.p()).collect()
	}
	fn ip<T: FromStr>(&mut self, n: usize) -> impl Iterator<Item=T> where T::Err: Debug {
		self.vp(n).into_iter()
	}
}
//------------------- End rusT }}}

// Extended Euclidean GCD {{{
fn extended_euclid(a: i64, b: i64) -> (i64,i64,i64) {
	if b == 0 {
		(a,1,0)
	} else {
		let q = div_floor(a,b);
		let r = a - q*b;
		let (d,x,y) = extended_euclid(b, r);
		(d, y, x-q*y)
	}
}//}}}
fn div_floor(a: i64, b: i64) -> i64 {
	assert!(b != 0);
	let (a,b) = if b < 0 {(-a,-b)} else {(a,b)};
	if a % b == 0 || a >= 0 {
		a / b
	} else {
		a / b - 1
	}
}
fn div_ceil(a: i64, b: i64) -> i64 {
	assert!(b != 0);
	let (a,b) = if b < 0 {(-a,-b)} else {(a,b)};
	if a % b == 0 || a <= 0 {
		a / b
	} else {
		a / b + 1
	}
}

fn main() {
	let mut rin = reader();
	let mut rout = writer();

	l!(n,p,a,b = rin.l());
	let (g,x0,y0) = extended_euclid(a,b);
	if p % g == 0 {
		let e = p / g;
		let x = x0 * e;
		let y = y0 * e;
		let ca = -b / g;
		let cb = a / g;
		let kx0 = div_ceil(n - x, ca);
		let kx1 = div_floor(-x, ca);
		let ky0 = div_ceil(-y, cb);
		let ky1 = div_floor(n - y, cb);
		let k0 = kx0.max(ky0);
		let k1 = kx1.min(ky1);
		if k0 <= k1 {
			for k in vec![k0,k1] {
				let xx = x + k * ca;
				let yy = y + k * cb;
				if xx + yy <= n {
					writeln!(rout, "{} {} {}", xx, yy, n - xx - yy).ok();
					return;
				}
			}
		}
	}
	writeln!(rout, "-1").ok();
}

mod io {
    use std::io::{self, BufRead};
    use std::str::{self, FromStr, SplitAsciiWhitespace};
    use super::Result;

    pub struct Scanner<'a, R> {
        reader: R,
        buf_str: Vec<u8>,
        buf_iter: SplitAsciiWhitespace<'a>,
    }

    impl<R: BufRead> Scanner<'_, R> {
        pub fn new(reader: R) -> Self {
            Self {
                reader,
                buf_str: Vec::new(),
                buf_iter: "".split_ascii_whitespace(),
            }
        }

        pub fn token<T>(&mut self) -> Result<T>
            where T: FromStr,
                  <T as FromStr>::Err: 'static + std::error::Error
        {
            loop {
                if let Some(token) = self.buf_iter.next() {
                    return Ok(token.parse()?);
                }
                self.buf_str.clear();
                let bytes_read = self.reader
                    .read_until(b'\n', &mut self.buf_str)?;
                if bytes_read == 0 {
                    return Err(Box::new(io::Error::from(io::ErrorKind::UnexpectedEof)));
                }
                self.buf_iter = unsafe {
                    let slice = str::from_utf8_unchecked(&self.buf_str);
                    ::std::mem::transmute(slice.split_ascii_whitespace())
                }
            }
        }
    }
}

use std::io::{stdin, stdout, BufRead, Write};
use io::Scanner;

pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;

fn main() -> Result<()> {
    let stdin = stdin();
    solve(Scanner::new(stdin.lock()), stdout().lock())
}

fn solve<R: BufRead, W: Write>(mut scan: Scanner<R>, mut out: W) -> Result<()> {
    let (n, mut p, mut w, mut d) =
        (scan.token::<u64>()?, scan.token::<u64>()?, scan.token::<u64>()?, scan.token::<u64>()?);
    let g = gcd(w, d);
    p /= g;
    let rem_p = p % g;
    if rem_p != 0 {
        writeln!(out, "-1")?;
        return Ok(());
    }
    w /= g;
    d /= g;
    let y = p * mpow(d, w - 2, w) % w;
    let x = (p - d * y) / w;
    if x + y > n {
        writeln!(out, "-1")?;
        return Ok(());
    }
    let z = n - x - y;
    writeln!(out, "{} {} {}", x, y, z)?;
    Ok(())
}

fn gcd(mut a: u64, mut b: u64) -> u64 {
    while a != b {
        if a > b { a = a - b; } else { b = b - a; }
    }
    a
}

pub fn mpow(mut base: u64, mut exp: u64, m: u64) -> u64 {
    let mut result = 1;
    base %= m;
    while exp > 1 {
        if exp & 1 == 1 {
            result = (result * base) % m;
        }
        exp >>= 1;
        base = (base * base) % m;
    }
    if exp == 1 {
        result = (result * base) % m;
    }
    result
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! t {
        ( $inp:expr, $expected:expr ) => {
            let mut out = String::new();
            solve(Scanner::new($inp.as_bytes()), unsafe { out.as_mut_vec() }).unwrap();
            assert_eq!(out, $expected);
        };
    }

    #[test]
    fn example1() {
        //t!("30 60 3 1\n", "17 9 4\n");
        t!("30 60 3 1\n", "20 0 10\n");
    }

    #[test]
    fn example2() {
        t!("10 51 5 4\n", "-1\n");
    }

    #[test]
    fn example3() {
        t!("20 0 15 5\n", "0 0 20\n");
    }

    #[test]
    fn t() {
        t!("4 7 3 2\n", "1 2 1\n");
    }
}

mod io {
    use std::io::{self, BufRead};
    use std::str::{self, FromStr, SplitAsciiWhitespace};
    use super::Result;

    pub struct Scanner<'a, R> {
        reader: R,
        buf_str: Vec<u8>,
        buf_iter: SplitAsciiWhitespace<'a>,
    }

    impl<R: BufRead> Scanner<'_, R> {
        pub fn new(reader: R) -> Self {
            Self {
                reader,
                buf_str: Vec::new(),
                buf_iter: "".split_ascii_whitespace(),
            }
        }

        pub fn token<T>(&mut self) -> Result<T>
            where T: FromStr,
                  <T as FromStr>::Err: 'static + std::error::Error
        {
            loop {
                if let Some(token) = self.buf_iter.next() {
                    return Ok(token.parse()?);
                }
                self.buf_str.clear();
                let bytes_read = self.reader
                    .read_until(b'\n', &mut self.buf_str)?;
                if bytes_read == 0 {
                    return Err(Box::new(io::Error::from(io::ErrorKind::UnexpectedEof)));
                }
                self.buf_iter = unsafe {
                    let slice = str::from_utf8_unchecked(&self.buf_str);
                    ::std::mem::transmute(slice.split_ascii_whitespace())
                }
            }
        }
    }
}

use std::io::{stdin, stdout, BufRead, Write};
use io::Scanner;

pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;

fn main() -> Result<()> {
    let stdin = stdin();
    solve(Scanner::new(stdin.lock()), stdout().lock())
}

fn solve<R: BufRead, W: Write>(mut scan: Scanner<R>, mut out: W) -> Result<()> {
    let (n, mut p, mut w, mut d) =
        (scan.token::<i64>()?, scan.token::<i64>()?, scan.token::<i64>()?, scan.token::<i64>()?);
    let (g, ..) = ext_euclid(w, d);
    p /= g;
    if p % g != 0 {
        writeln!(out, "-1")?;
        return Ok(());
    }
    w /= g;
    d /= g;
    let y = p % w * inv(d, w) % w;
    let x = (p - d * y) / w;
    if x < 0 || x + y > n {
        writeln!(out, "-1")?;
        return Ok(());
    }
    let z = n - x - y;
    writeln!(out, "{} {} {}", x, y, z)?;
    Ok(())
}

pub fn ext_euclid(a: i64, b: i64) -> (i64, i64, i64) {
    if b == 0 {
        (a, 1, 0)
    } else {
        let (d, x, y) = ext_euclid(b, a % b);
        (d, y, x - a / b * y)
    }
}

fn inv(a: i64, n: i64) -> i64 {
    let (_, x, ..) = ext_euclid(a, n);
    (n + x) % n
}

#[cfg(test)]
mod tests {
    use super::*;

    macro_rules! t {
        ( $inp:expr, $expected:expr ) => {
            let mut out = String::new();
            solve(Scanner::new($inp.as_bytes()), unsafe { out.as_mut_vec() }).unwrap();
            assert_eq!(out, $expected);
        };
    }

    #[test]
    fn example1() {
        //t!("30 60 3 1\n", "17 9 4\n");
        t!("30 60 3 1\n", "20 0 10\n");
    }

    #[test]
    fn example2() {
        t!("10 51 5 4\n", "-1\n");
    }

    #[test]
    fn example3() {
        t!("20 0 15 5\n", "0 0 20\n");
    }

    #[test]
    fn t() {
        t!("4 7 3 2\n", "1 2 1\n");
        t!("1000000000000 99999999999999999 100000 99999\n", "999999999999 1 0\n");
    }
}

use std::io::stdin;

macro_rules! readln {
    ($type:ty) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace().next().unwrap().parse::<$type>().unwrap() }};
    (|$type_vec:ty|) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace().map(|it| it.parse::<$type_vec>().unwrap()).collect::<Vec<$type_vec>>() }};
    ($($type:ty),*) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace(); ($(iter.next().unwrap().parse::<$type>().unwrap(),)*) }};
    ($($type:ty),* |$type_vec:ty|) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$type>().unwrap(),)*iter.map(|it| it.parse::<$type_vec>().unwrap()).collect::<Vec<$type_vec>>(),)}}
}

fn gcd(mut a: u64, mut b: u64) -> u64 {
    while b != 0 {
        a %= b;
        let c = a;
        a = b;
        b = c;
    }
    return a;
}

fn main() {
    let (n, p, w, d) = readln!(u64, u64, u64, u64);

    let gcd = gcd(w, d);
    let lcm = w * d / gcd;
    let x_count = lcm / w;
    let y_count = lcm / d;

    if p % gcd != 0 {
        println!("-1");
        return;
    }

    let mut max_x = if p / w < n { p / w } else { n };
    while (p - max_x * w) % d != 0 {
        max_x -= 1;
    }
    let y = (p - max_x * w) / d;

    if max_x + y > n || max_x * w + y * d < p {
        println!("-1")
    } else {
        println!("{} {} {}", max_x, y, n - max_x - y);
    }
}

use std::io::stdin;

macro_rules! readln {
    ($type:ty) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace().next().unwrap().parse::<$type>().unwrap() }};
    (|$type_vec:ty|) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace().map(|it| it.parse::<$type_vec>().unwrap()).collect::<Vec<$type_vec>>() }};
    ($($type:ty),*) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace(); ($(iter.next().unwrap().parse::<$type>().unwrap(),)*) }};
    ($($type:ty),* |$type_vec:ty|) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$type>().unwrap(),)*iter.map(|it| it.parse::<$type_vec>().unwrap()).collect::<Vec<$type_vec>>(),)}}
}

fn gcd(mut a: u64, mut b: u64) -> u64 {
    while b != 0 {
        a %= b;
        let c = a;
        a = b;
        b = c;
    }
    return a;
}

fn main() {
    let (n, p, w, d) = readln!(u64, u64, u64, u64);

    let gcd = gcd(w, d);
    let lcm = w * d / gcd;
    let x_count = lcm / w;
    let y_count = lcm / d;

    let max_x = if p / w < n { p / w } else { n };
    let mut y = (p - max_x * w) / d;
    let max_x = max_x - y * d;

    if max_x + y > n || p % lcm != 0 {
        println!("-1")
    } else {
        for x in (0..=max_x).rev().step_by(x_count as usize) {
            if x * w + y * d != p {
                y += y_count;
            } else {
                println!("{} {} {}", x, y, n - x - y);
                break
            }
        }
    }
}

use std::io::stdin;

macro_rules! readln {
    ($type:ty) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace().next().unwrap().parse::<$type>().unwrap() }};
    (|$type_vec:ty|) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace().map(|it| it.parse::<$type_vec>().unwrap()).collect::<Vec<$type_vec>>() }};
    ($($type:ty),*) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace(); ($(iter.next().unwrap().parse::<$type>().unwrap(),)*) }};
    ($($type:ty),* |$type_vec:ty|) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        ($(iter.next().unwrap().parse::<$type>().unwrap(),)*iter.map(|it| it.parse::<$type_vec>().unwrap()).collect::<Vec<$type_vec>>(),)}}
}

fn gcd(mut a: u64, mut b: u64) -> u64 {
    while b != 0 {
        a %= b;
        let c = a;
        a = b;
        b = c;
    }
    return a;
}

fn main() {
    let (n, p, w, d) = readln!(u64, u64, u64, u64);

    let gcd = gcd(w, d);
    let lcm = w * d / gcd;
    let x_count = lcm / w;
    let y_count = lcm / d;

    let max_x = if p / w < n { p / w } else { n };
    let mut y = (p - max_x * w) / d;
    let max_x = max_x - y * d;

    if max_x + y > n || p % gcd != 0 || max_x * w + y * d < p {
        println!("-1")
    } else {
        println!("{} {} {}", max_x, y, n - max_x - y);
    }
}

macro_rules! parse_line {
    ($t: ty) => ({
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        let a_str = a_str.trim();
        a_str.parse::<$t>().expect("parse error")
    });
    ($($t: ty),+) => ({
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        let mut a_iter = a_str.split_whitespace();
        (
            $(
            a_iter.next().unwrap().parse::<$t>().expect("parse error"),
            )+
        )
    })
}

#[allow(unused_macros)]
macro_rules! parse_line_to_vec {
    ($t: ty) => {{
        let mut a_str = String::new();
        std::io::stdin().read_line(&mut a_str).expect("read error");
        (a_str
            .split_whitespace()
            .map(|x| x.parse::<$t>().unwrap())
            .collect::<Vec<$t>>())
    }};
}

use std::io::Write;

fn ext_euclid(a: i64, b: i64, x: &mut i64, y: &mut i64) -> i64 {
    if a == 0 {
        *x = 0;
        *y = 1;
        return b;
    }
    let mut x1 = 0;
    let mut y1 = 0;
    let g = ext_euclid(b % a, a, &mut x1, &mut y1);
    *x = y1 - b / a * x1;
    *y = x1;
    return g;
}

fn solve(writer: &mut std::io::BufWriter<std::io::Stdout>) {
    let (n, p, w, d) = parse_line!(i64, i64, i64, i64);
    let mut x = 0;
    let mut y = 0;
    let g = ext_euclid(w, d, &mut x, &mut y);
    if p % g != 0 {
        writeln!(writer, "-1").unwrap();
        return;
    }
    x *= p / g;
    y *= p / g;
    let step_x = d / g;
    let step_y = w / g;
    if x < 0 {
        let k = (-x + step_x - 1) / step_x;
        x += k * step_x;
        y -= k * step_y;
    }
    if y < 0 {
        let k = (-y + step_y - 1) / step_y;
        x -= k * step_x;
        y += k * step_y;
    }
    if x < 0 {
        writeln!(writer, "-1").unwrap();
        return;
    }
    let k = x / step_x;
    x -= k * step_x;
    y += k * step_y;
    if x + y <= n {
        writeln!(writer, "{} {} {}", x, y, n - x - y).unwrap();
        return;
    }
    let k = y / step_y;
    x += k * step_x;
    y -= k * step_y;
    if x + y <= n {
        writeln!(writer, "{} {} {}", x, y, n - x - y).unwrap();
        return;
    }
    writeln!(writer, "-1").unwrap();
}

fn main() {
    let mut writer = std::io::BufWriter::new(std::io::stdout());
    let tests = 1; // parse_line!(usize);
    for _ in 0..tests {
        solve(&mut writer);
    }
}


Sasha is a very happy guy, that's why he is always on the move. There are $$$n$$$ cities in the country where Sasha lives. They are all located on one straight line, and for convenience, they are numbered from $$$1$$$ to $$$n$$$ in increasing order. The distance between any two adjacent cities is equal to $$$1$$$ kilometer. Since all roads in the country are directed, it's possible to reach the city $$$y$$$ from the city $$$x$$$ only if $$$x < y$$$. Once Sasha decided to go on a trip around the country and to visit all $$$n$$$ cities. He will move with the help of his car, Cheetah-2677. The tank capacity of this model is $$$v$$$ liters, and it spends exactly $$$1$$$ liter of fuel for $$$1$$$ kilometer of the way. At the beginning of the journey, the tank is empty. Sasha is located in the city with the number $$$1$$$ and wants to get to the city with the number $$$n$$$. There is a gas station in each city. In the $$$i$$$-th city, the price of $$$1$$$ liter of fuel is $$$i$$$ dollars. It is obvious that at any moment of time, the tank can contain at most $$$v$$$ liters of fuel.Sasha doesn't like to waste money, that's why he wants to know what is the minimum amount of money is needed to finish the trip if he can buy fuel in any city he wants. Help him to figure it out!

The first line contains two integers $$$n$$$ and $$$v$$$ ($$$2 \le n \le 100$$$, $$$1 \le v \le 100$$$)  — the number of cities in the country and the capacity of the tank.

Print one integer — the minimum amount of money that is needed to finish the trip.

NoteIn the first example, Sasha can buy $$$2$$$ liters for $$$2$$$ dollars ($$$1$$$ dollar per liter) in the first city, drive to the second city, spend $$$1$$$ liter of fuel on it, then buy $$$1$$$ liter for $$$2$$$ dollars in the second city and then drive to the $$$4$$$-th city. Therefore, the answer is $$$1+1+2=4$$$.In the second example, the capacity of the tank allows to fill the tank completely in the first city, and drive to the last city without stops in other cities.

use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();

    let info: Vec<i32> = (0..2).map(|_| scan.next()).collect();
    let mut cost = 0;
    let mut tank = 0;

    if info[0] - 1 <= info[1] {
        println!("{}", info[0] - 1);
        return;
    }

    for i in 0..info[0] - 1 {
        if tank < (info[0] - 1 - i) {
            cost += (info[1] - tank) * (i + 1);
            tank = info[1];
        }
        tank -= 1;
    }

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

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n: i64,
      v: i64,
    }
    if v>=n-1 {
        return println!("{}", n-1);
    }
    let mut ans = 0;
    for i in 1..(n-v+1) {
        if i == 1 {
            ans += v;
        } else {
            ans += i;
        }
    }
    println!("{}", ans);
}

/*input
97 99
*/
fn main() {
    let mut input = format!("");
    std::io::stdin().read_line(&mut input).ok();
    let v: Vec<i16> = input
        .trim()
        .split_whitespace()
        .map(|x| x.parse().expect(""))
        .collect();
    if v[0] - 1 <= v[1] {
        println!("{}", v[0] - 1);
        std::process::exit(0);
    }
    let mut money_to_spent = v[1];
    let mut fuel = v[1];
    for i in 1..v[0] {
        if i != 1 {
            fuel = fuel - 1;
        }
        //println!("CITY: {} F: {} SISA: {}", i, fuel, v[0] - i);
        // 1 2 3 4 5 6 7 8 9
        //   2
        if v[0] - i <= fuel {
            break;
        }
        if i != 1 {
            money_to_spent = money_to_spent + i;
            fuel = fuel + 1;
        }
    }
    println!("{}", money_to_spent);
}

#[warn(unused_variables)]
fn main() {
    let input = input_vec::<u64>(" ");
    let n = input[0];
    let v = input[1];

    println!("{}", if (n-1) <= v {n-1} else {(n-v+1)*(n-v)/2 + v-1})
}

fn input_str() -> String {
    let mut buff = String::new();
    std::io::stdin().read_line(&mut buff).expect("Err");
    buff
}

fn input_<T>() -> T
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    input_str().trim().parse::<T>().expect("Err pars")
}

fn input_vec<T>(sep: &str) -> Vec<T>
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    input_str().trim().split(sep).map(|c| c.parse::<T>().expect("Err pars")).collect()
}

fn input_vec_chars() -> Vec<char> {
    input_str().trim().chars().collect()
}

use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}
impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();

    let info: Vec<i32> = (0..2).map(|_| scan.next()).collect();
    let mut cost = 0;
    let mut tank = 0;

    for i in 0..info[0] - 1 {
        if tank < (info[0] - 1 - i) {
            cost += (info[1] - tank) * (i + 1);
            tank = info[1];
        }
        tank -= 1;
    }

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