jiahuimbzuai/CoQuIR huggingface dataset:
//  [javascript]
var GetCityPos = function(input){
  var arr = input.split('\n');
  var items1 = arr[0].split(' ');
  var items2 = arr[1].split(' ');
  var ModCity = new Set();
  var Min = undefined;

  for(var i =0;i<items2.length;++i){
    var a = items2[i];
    var modCurrentCity = a - items1[1];
    if(modCurrentCity < 0){
      modCurrentCity *= -1;
    }
    ModCity.add(modCurrentCity);

    if(Min == undefined){
      Min = modCurrentCity;
    } else {
      if(Min > modCurrentCity){
        Min = modCurrentCity;
      }
    }
  }
  return {Cities: ModCity, Min: Min};
}

// 割り切れるか確認する関数
var ModZeroCheck = function(CitySet, ModNum){
  var result = true;
  CitySet.forEach(function(value){
    if(!result){
      return;
    }
    if(value%ModNum != 0){
      result = false;
    }
  });
  return result;
}

var Main = function(input){
  // スタート位置を差し引いた位置情報を生成
  var Data = (GetCityPos(input));
  var result = 0;
  // console.log(Data);
  // console.log(Data.Cities);
  // console.log(Data.Cities.size);
  
  if(Data.Cities.size == 1){
    var iterator1 = Data.Cities.values();
    console.log(iterator1.next().value);
    return;
  }

  for(var i = 1; i<=Data.Min;++i){
    if(Data.Min % i != 0){
      continue;
    }
    if(ModZeroCheck(Data.Cities, i)){
      result = i;
    }
  }
  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var temp = toIntArr(input[0].split(' '));
	var n = temp[0];
	var x = temp[1];
	var xs = toIntArr(input[1].split(' '));

	var ys = xs.map(e=>abs(e-x));

	function gcd(a,b){
		if(b===0) return a;
		return gcd(b,a%b);
	}

	var ans = ys[0];
	for(var i = 0; i < n-1; i++){
		ans = gcd(ans,ys[i+1]);
	}
	console.log(ans);
}
//  [go]
package main

import (
	"fmt"
	"math"
	"math/big"
)

func main() {
	var n, x int
	fmt.Scan(&n, &x)
	var tmp int
	fmt.Scan(&tmp)
	tmp -= x
	tmp = abs(tmp)
	g := tmp
	for i := 0; i < n - 1; i++ {
		fmt.Scan(&tmp)
		tmp -= x
		tmp = abs(tmp)
		g = gcd(g, tmp)
	}
	fmt.Println(g)
}


func gcd(m, n int) int {
	x := new(big.Int)
	y := new(big.Int)
	z := new(big.Int)
	a := new(big.Int).SetUint64(uint64(m))
	b := new(big.Int).SetUint64(uint64(n))
	return int(z.GCD(x, y, a, b).Uint64())
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}
//  [go]
package main

import "fmt"

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

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

func main() {
	var N, X int
	fmt.Scanf("%v", &N)
	fmt.Scanf("%v", &X)

	xs := make([]int, 0, N)

	for i := 0; i < N; i++ {
		var x int
		fmt.Scanf("%v", &x)
		xs = append(xs, abs(X-x))
	}

	var ans = xs[0]
	for _, x := range xs {
		ans = gcd(ans, x)
	}
	fmt.Println(ans)
}
//  [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[i])
	}
	fmt.Println(ans)
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}
//  [ruby]
#!/usr/bin/env ruby

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

cities = gets.chomp.split(/ /).map(&:to_i)

def soinsu(num)
  n = num
  soinsu = Array.new
  (2..n).each do |i|
    if (num % i == 0)
      soinsu << i
      num /= i
    end
    redo if num % i == 0
  end
  soinsu
end

if (n == 1)
  puts (cities[0] - x).abs
  exit
end
sabun = Array.new
cities.each do |c|
  sabun << (c - x).abs
end

m = sabun.min
soi = soinsu(m)

res = 1
soi.each do |s|
  sabun2 = []
  sabun.each do |sa|
    if sa % s == 0
      sabun2 << sa / s
    end
  end
  if sabun.size == sabun2.size
    sabun = sabun2
  res *= s
  end
end

puts res
//  [ruby]
n,*x=`dd`.split.map &:to_i
puts x.sort.each_cons(2).map{|x,y|y-x}.inject(:gcd)
//  [ruby]
N, X = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
x.push(X).sort!

di = Array.new(N)
for i in 0..(N-1)
  di[i] = x[i+1] - x[i]
end

gcd = di[0]
for i in 1..(N-1)
  div = [gcd, di[i]].min
  while div > 0
    if gcd % div == 0 && di[i] % div == 0
      break
    end
    div -= 1
  end
  gcd = div
end
puts gcd
//  [rust]
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};
#[fastout]
fn main() {
    input!(n: usize, x: isize,mut  nx: [isize; n]);

    nx.sort();

    let mut nnx = vec![0; n];

    for i in 0..nx.len() {
        nnx[i] = (x - nx[i]).abs();
    }

    nnx.sort();

    let mut ans = 1;

    for i in (2..=nnx[0]).rev() {
        let mut is_divdiv = true;
        for v in &nnx {
            if *v % i != 0 {
                is_divdiv = false;
                break;
            }
        }
        if is_divdiv {
            ans = i;
            break;
        }
    }

    println!("{}", ans);
}
//  [swift]
import Foundation

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

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

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

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

let input = readIntSplit(by: " ")
let N = input[0]
let x = (readIntSplit(by: " ") + [input[1]]).sorted()
let d = (1...N).map{x[$0] - x[$0-1]}
var ans = 0
for i in d {
    ans = gcd(i, ans)
}
print(ans)
//  [swift]
let N = readLine()!.characters.split(" ").map{Int(String($0))!}[1]
let x = (readLine()!.characters.split(" ").map{Int(String($0))!}+[N]).sort()
let d = (1..<x.count).map{x[$0]-x[$0-1]}
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))!} + [input[1]]).sort()
let d = (0..<input[0]).map{x[$0+1]-x[$0]}
var ans = 0
for i in d {
    var x = i
    while ans > 0 {
        (x, ans) = (ans, x % ans)
    }
    ans = x
}
print(ans)
//  [typescript]

const euq = (a, b) => {
  let mod = a
  while (mod != 0) {
    mod = a % b
    a = b
    b = mod
  }

  return a
}

const solve = (x, cities) => {
  // ...
  const l = [x, ...cities].sort((a, b) => a - b)
  let diffs = {}
  l.map((ll, i) => {
    if (i == 0) return

    diffs[l[i] - l[i - 1]] = true
  })

  let rr = {}
  let nn = Object.keys(diffs).map(Number)
  if (nn.length == 1) {
    return nn[0]
  }
  let last = nn[0]
  let c = nn
    .sort((a, b) => b - a)
    .map((s, i) => {
      if (i == 0) return 1
      let r = euq(nn[i], last)
      last = r
      return r
    })

  return last
}

const main = (input) => {
  const [head, rest] = input.split("\n")
  const [n, x] = head.split(" ").map(Number)

  return solve(x, rest.split(" ").map(Number))
}

if (process.env.NODE_ENV !== "test") {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(main(input.trim()))
}
//  [typescript]
var int = x=>parseInt(x,10);var spln = x=>x.split(/\n/g);var spsp = x=>x.split(/\s/g);
function main(input) {
  var a = spln(input);
  var n = int(spsp(a[0])[0]);
  var x = int(spsp(a[0])[1]);
  var s = spsp(a[1]).slice(0,n).map(x=>int(x));
  var m = s.map((sa)=>Math.abs(sa-x));
  console.log(go(m))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function go(array){
  function euc(A,B){
    var a = Math.max(A,B),b = Math.min(A,B);
   while(b!==0){
      var k = b;
      b = a%b;
      a = k;
    }
    return a;
  }
  return array.reduce((p,c)=>{
    return p?euc(p,c):c
  })
}
//  [typescript]
var lines=[];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', function (line) {
  lines.push(line);
});
reader.on('close', function () {
  main(lines);
});

function main(lines) {
  const [_, _x] = lines[0].split(' ');
  const x = parseInt(_x);
  const grids = lines[1].split(' ').map(g => parseInt(g));
  console.log(calculate(x, grids));
}

function calculate(x, grids) {
  const values = grids.map(g => Math.abs(x - g));
  const d = gcd(values);
  return d;
}

function gcd(values) {
  var f = (a, b) => b ? f(b, a % b) : a;
  var ans = values[0];
  for (var i = 1; i < values.length; i++) {
    ans = f(ans, values[i]); 
  }
  return ans 
}
//  [python]
n,y = (int(num) for num in input().split())
ans = '-1 -1 -1'
for i in range(n+1):
    if ans != '-1 -1 -1':
        break
    for j in range(n+1):
        n_10 = n-i
        n_5 = n-j
        n_1 = (y-10000*n_10-5000*n_5)//1000
        if n_10 + n_5 + n_1 == n and n_1>=0:
            ans = str(n_10) + ' ' + str(n_5) + ' ' + str(n_1)
            break
            
print(ans)
//  [python]
N, Y = map( int, input().split() )

ans = [0]*3
isDiscovered = False

for i in range( Y//10000+1 ):
    a = Y - 10000*i
    for j in range( a//5000+1 ):
        b = (a - 5000*j) / 1000
        if( b.is_integer() and i + j + b == N ):
            ans[0] = i
            ans[1] = j
            ans[2] = int(b)
            isDiscovered = True
            break
    if isDiscovered: break

if sum(ans) == 0: print( '-1 -1 -1' ) 
else: print( str(ans[0]) + ' ' + str(ans[1]) + ' ' + str(ans[2]) )
//  [python]
import sys

A = 10000
B = 5000
C = 1000

input = input()
inputs = input.split(' ')
n = int(inputs[0])
y = int(inputs[1])

for i in range(n+1):
    for j in range(n+1):
        if (A*i + B*j + C*(n-i-j) == y) & (n-i-j >= 0):
            print(str(i) + ' ' + str(j) + ' ' + str(n-i-j))
            sys.exit()

print('-1 -1 -1')
//  [java]
import java.util.Scanner;

//  C - Otoshidama

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int Y = Integer.parseInt(sc.next());
    Integer man = 0;
    Integer gosen = 0;
    Integer sen = 0;

    label: for(int i = 0; i <= N; i++) {
    	if(i * 10000 == Y && i == N) {
			man = i;
			break label;
    	}
    	for(int m = 0; m <= (N-i); m++) {
			if(i * 10000 + m * 5000 == Y && i + m == N) {
				man = i;
				gosen = m;
				break label;
			}

			for(int n = 0; n <= (N-i-m); n++) {
				if(i * 10000 + m * 5000 + n * 1000 == Y && i + m + n == N) {
					man = i;
					gosen = m;
					sen = n;
					break label;
				}
			}
    	}
    }
    if(man == 0 && gosen == 0 && sen ==0) {
    	System.out.println("-1 -1 -1");
    } else {
//		System.out.println(man*10000+gosen*5000+sen*1000);
//		System.out.println(man+gosen+sen);
		System.out.println(man.toString()+" "+gosen.toString()+" "+sen.toString());
    }


  }
}
//  [java]
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int Y = in.nextInt()/1000;
        int[] C = {10,5,1};
        int[] used = {-1,-1,-1};

        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(i+j+k == N && C[0]*i+C[1]*j+ C[2]*k == Y){
                        used[0] = i;
                        used[1] = j;
                        used[2] = k;
                        break;
                        
                    }
                }
            }
        }
        for(int i = 0; i < 3; i++){
            System.out.print(used[i]+" ");
        }
        in.close();
    }
}
//  [java]
import java.util.*;

public 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 + i <= n; j++) {
                for(int k = 0; k + j + i <= n; k++) {
                    int sum = i * 1000 + j * 5000 + k * 10000;
                    if(sum == y && i + j + k == n) {
                        System.out.println(k + " " + j + " " + i);
                        return;
                    }
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}
//  [cpp]
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;

int main() {
	int n; cin >> n;
	int y; cin >> y;
	y /= 1000;
	bool x = false;
	int ans_x, ans_y, ans_z;
	srand(1145141919);
	while (clock()<1995000) {
		int a = rand() % (n + 1);
		int b = rand() % (n - a + 1);
		int c = n - (b + a);
		if (a + b * 5 + c * 10 == y) {
			x = true;
			ans_x = c;
			ans_y = b;
			ans_z = a;
			break;
		}
	}

	if (x) {
		cout << ans_x << " " << ans_y << " " << ans_z << endl;
	}
	else {
		cout << "-1 -1 -1" << endl;
	}

	return 0;
}
//  [cpp]
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll n, y, ans = 0;
	cin >> n >> y;
	y /= 1000;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= n; k++) {
				if (i + j + k>n) break;
				if (10 * i + 5 * j + k ==y&& i + j + k == n) {
					cout << i << ' ' << j << ' ' << k;
					return 0;
				}
			}
		}
	}
	cout << "-1 -1 -1";
	return 0;
}
//  [cpp]
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
using namespace std;
using ll =long long;
int main() {
	ll N, Y;

	cin >> N >> Y;

	ll W=Y / 10000;
	//5sennと1000
	ll V1 = (Y % 5000)/1000+Y%10000/5000;
	ll V2 = Y % 10000 / 1000;
	
	for (ll i = 0; i <= W; i++) {
		for (ll j = 0; j <= W-i; j++) {
			for (ll k = 0; k <= W-i-j; k++) {

				if (10 * i + 6 * j + 2 * k + (W - i - j - k)+V1 == N) {

					cout << (W - i - j - k) <<" "<<2 * k + j + Y % 10000 / 5000<<" "<< 10 * i + 5 * j+(Y % 5000) / 1000  ;
					return 0;
				}
				

			}


		}


	}
	for (ll i = 0; i <= W ; i++) {
		for (ll j = 0; j <= W  - i; j++) {
			for (ll k = 0; k <= W  - i - j; k++) {

				if (10 * i + 6 * j + 2 * k + (W  - i - j - k)+V2 == N) {

					cout << (W  - i - j - k) << " " << 2 * k + j  << " " << 10 * i + 5 * j + (Y % 10000) / 1000;
					return 0;
				}


			}


		}


	}

	cout << -1 <<" "<< -1<<" " << -1;
}
//  [c]
#include<stdio.h>

int main(){
    int num = 0;
    int sum = 0;
    
    int sub_man = 0;
    int sub_gosen = 0; 

    scanf("%d",&num);
    scanf("%d",&sum);
    
    // printf("man:%d gosen:%d\n",sub_man,sub_gosen);

    for(int num_man=num; num_man>=0; num_man--){

        for(int num_gosen=0; num_gosen<=num; num_gosen++){

            if(sum > num_man*10000+num*5000 || num_man*10000>sum){
                // printf("break\n");
                break;
            }

            for(int num_sen=0; num_sen<=num; num_sen++){

                if(sum > num_man*10000+num_gosen*5000+num*1000){
                    // printf("break\n");
                    break;
                }

                // printf("sum:%d 1万:%d 5千:%d 1千:%d\n",10000*num_man+5000*num_gosen+1000*num_sen,num_man,num_gosen,num_sen);

                if(10000*num_man+5000*num_gosen+1000*num_sen == sum 
                    && num_man+num_gosen+num_sen == num){
                    printf("%d %d %d\n",num_man,num_gosen,num_sen);
                    return 0;
                }
            }
        }
     }

    printf("-1 -1 -1\n");

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

int main(){
    int n,i,j,k;
    double y;

    scanf("%d %lf",&n,&y);

    for(i=0;i<=n;i++){
        for(j=0;j<=n-i;j++){
            for(k=0;k<=n-i-j;k++){
                if(10000*i+5000*j+1000*k==y && n==i+j+k){
                    printf("%d %d %d",i,j,k);
                    return 0;
                }
            }
        }
    }
    printf("-1 -1 -1");
    return 0;
}
//  [c]
#include <stdio.h>
int main(void){
int co=0,i,j,k,num1,num0;
scanf("%d %d",&num0,&num1);
for(i=0;i<=num1/10000;i++){
    for(j=0;j<=(num1-i*10000)/5000;j++){
        if(i+j>num0||i*10000+j*5000>num1)break;
        for(k=0;k<=(num1-i*10000-j*5000)/1000;k++){
            if(i+j+k>num0||i*10000+j*5000+k*1000>num1)break;
            else if(i+j+k==num0&&i*10000+j*5000+k*1000==num1){
                co=1;
                printf("%d %d %d",i,j,k);
                break;
            }
        }
        if(co==1)break;
    }
    if(co==1)break;
}
if(co==0)printf("-1 -1 -1");
return 0;
}
//  [javascript]
function Main(input) {
  input = input.split(' ').map( n => parseInt(n, 10) );
  const n = input[0];
  const y = input[1];
  let ans = "-1 -1 -1"
  for (var a_i = 0; a_i <= n; a_i++) {
    for (var b_i = 0; a_i + b_i <= n; b_i++) {
      for (var c_i = 0; a_i + b_i + c_i <= n; c_i++) {
        if ((a_i + b_i + c_i === n) &&
            (10000*a_i + 5000*b_i + 1000*c_i === y)) {
          ans = `${a_i} ${b_i} ${c_i}`;
          break;
        }
      }
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {

	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");

	//文字列から10進数に変換するときはparseIntを使います
	var N = parseInt(tmp[0], 10);
	var Y = parseInt(tmp[1], 10);

	var man = -1;
	var gosen = -1;
	var sen = -1;

	var mantani = Y/10000;
	for(i=0;i<=mantani;i++){
		for(j=0;j<= N - i ;j++){
			if(Y == i * 10000 + j * 5000 + (N-i-j) *1000){
				man = i;
				gosen = j;
				sen = N-i-j;
			
			}
			
			
		}
		if(man != -1){
			break;
		}
		
	}
	 

	//出力
	console.log(man+" "+gosen+" "+sen);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、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++){
      maximum_price = 10000 * count_10000 + 5000 * (paper_money_count - count_10000) + 1000 * (paper_money_count - count_10000 - count_5000);
      if(sum_price > maximum_price){
        continue;
      }
      for(count_1000=0; count_1000<=paper_money_count - (count_10000 + count_5000) ;count_1000++){
        if(count_10000 + count_5000 + count_1000 != paper_money_count){
          continue;
        }
        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'));
//  [go]
package main

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++ {
			for k := 0; k <= n-i-j; k++ {
				if y == (i*10000+j*5000+k*1000) && n == i+j+k {
					fmt.Println(i, j, k)
					return
				}
			}
		}
	}
	fmt.Println(-1, -1, -1)
}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var N, Y int
	var exist bool
	var kumi = make(map[string]int)

	fmt.Scan(&N)
	fmt.Scan(&Y)

	max_a := Y / 10000
	if max_a > N {
		max_a = N
	}
	max_b := Y / 5000
	if max_b > N {
		max_b = N
	}
	max_c := Y / 1000
	if max_c > N {
		max_c = N
	}
	
	for a := 0; a <= max_a && !exist; a++ {
		for b := 0; b <= max_b-a && !exist; b++ {
			for c := 0; c <= max_c-a-b; c++ {
				if a + b + c== N && a * 10000 + b * 5000 + c * 1000 == Y {
					exist = true
					kumi["a"] = a
					kumi["b"] = b
					kumi["c"] = c
					break;
				}
			}
		}
	}

	if ! exist {
		kumi["a"] = -1
		kumi["b"] = -1
		kumi["c"] = -1
	}

	fmt.Printf("%d %d %d", kumi["a"], kumi["b"], kumi["c"])
}
//  [go]
package main

import "fmt"

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


	for a := 0 ; a <= n ; a++ {
		for b := 0 ; a + b <= n ; b++ {
			for c := 0 ; a + b +c <= n ; c++ {
				// if y < 10000 * c{
				// 	break
				// }

				// if a + b + c  > n {
				// 	break
				// }
				if a + b + c == n {
					if y == 10000 * c + 5000* b + 1000* a {
						fmt.Println(c, b, a)
						return
					}
				}
			}
		}
	}

	fmt.Println("-1 -1 -1")
}
//  [ruby]
# abc085c

def solve(n, y, bills = [], denoms = [10000, 5000, 1000])
  if denoms.size == 1
    if n * denoms[0] == y
      bills + [n]
    else
      nil
    end
  else
    (0..(y / denoms[0])).reverse_each do |i|
      ans = solve(n - i, y - i * denoms[0], bills + [i], denoms.drop(1))
      if ans
        return ans
      end
    end
    nil
  end
end

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

triple = solve(n, y)

puts (triple || [-1,-1,-1]).join(' ')
//  [ruby]
n,y=gets.split.map(&:to_i)
r=->mnus,k{mnus.map{|mnu|m,n,u=mnu;(0..(m<n/k ?m:n/k)).map{|i|[m-i,n-k*i,[*u,i]]}}.flatten(1)}
puts r[r[[[n,y,[]]],10000],5000].find{|v,w,u|(1000*v==w)&&(break [*u,v])}&.join(' ') || '-1 '*3
//  [ruby]
n,y = gets.split(" ").map(&:to_i)
result = [-1,-1,-1]
sihei  = [0,0,0]
flg = 0

def calc(array)
    total = (array[0]*10000) + (array[1]*5000) +(array[2]*1000)
end

def gassan(array)
    count = 0
    array.each do |i|
        count = count + i
    end
    return count
end

(0..n).each do |i|
    sihei[2] = i
    (0..(n-sihei[2])).each do |j|
        sihei[1] = j
        sihei[0] = n - sihei[1] - sihei[2]
        flg = sihei if y == calc(sihei) 
        break if y == calc(sihei) and n >= gassan(sihei)
    end
    break if y == calc(sihei) and n >= gassan(sihei)
end

if y == calc(flg)
    puts flg.join(" ")
else
    puts result.join(" ")
end
//  [rust]
use std::io::*;
use std::str::FromStr;

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

fn main(){
    let n: i32 = read();
    let x: i32 = read();
    let mut ans = None;
    'outer: for i in 0..n+1 {
        for j in 0..n-i+1 {
            for k in 0..n-i-j+1 {
                if i+j+k != n { continue; }
                if i*10000 + j*5000 + k*1000 == x {
                    ans = Some((i,j,k));
                    break 'outer;
                }
            }
        }
    }
    let (x, y, z) = ans.unwrap_or((-1, -1, -1));
    println!("{} {} {}", x, y, z);
}
//  [rust]
use std::io::Write;

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        data: [i32; 2],
    }
    let n = data[0];
    let Y = data[1];

    let mut x: i32 = -1;
    let mut y: i32 = -1;
    let mut z: i32 = -1;
    for i in 0..n + 1 { // 10000
        for j in 0..n + 1 - i{ // 5000
            for k in 0..n + 1 - (i + j) { // 1000
                if i + j + k != n {
                    continue;
                }
                if i * 10000 + j * 5000 + k * 1000 == Y {
                    // 1つ例を見つけたら終了
                    x = i;
                    y = j;
                    z = k;
                    break;
                }
            }
        }
    }

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

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

fn main() {
    let n: u32 = read();
    let Y: u32 = read();

    for x in 0..n+1 {
        for y in 0..n+1-x {
            for z in 0..n+1-x-y {
                if x+y+z == n {
                    if 10000*x+5000*y+1000*z == Y {
                        println!("{} {} {}", x, y, z);
                        return;
                    }
                }
            }
        }
    }

    println!("-1 -1 -1");
}
//  [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 readLines() -> [String] {
    return readLine()!.map { String($0) }
}
///最大公約数を返す
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://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
}
// https://algo-logic.info/divisor/
/// 約数の配列を返す
func divisor(_ n:Int) -> [Int] {
    var ret = [Int]()
    var i = 1
    while i * i <= n {
        if n % i == 0 {
            ret.append(i)
            if i * i != n {
                ret.append(n / i)
            }
        }
        i += 1
    }
    return ret
}

func main() {
    let input = readInts()
    let (N, Y) = (input[0], input[1])
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    for i in 0...N {
        for j in 0...N - i {
            let k = N - i - j
            if k < 0 {
                break
            }
            if 10000 * i + 5000 * j + 1000 * k == Y && i + j + k == N {
                print(i, j, k)
                return
            }
        }
    }
    print("-1 -1 -1")
}
main()
//  [swift]
let NY = readLine()!.characters.split(" ").map { Int(String($0))! }
let N = NY[0]
let Y = NY[1]
var xRes: Int = -1
var yRes: Int = -1
var zRes: Int = -1

for x in 0...NY[0] {    // 10000円札の枚数 xのループ
    for y in 0...NY[0] {    // 5000円札の枚数 yのループ
        let z: Int = NY[0] - x - y  // お札の合計枚数が N枚から, 1000円札の枚数 zを求める
        if 0 <= z { // 1000円札の枚数が 0以上のときのみ
            let otoshidama: Int = 10000*x + 5000*y + 1000*z
            if otoshidama == NY[1] {
                xRes = x
                yRes = y
                zRes = z
            }
        }
    }
}
print(xRes, yRes, zRes)
//  [typescript]
[n,y]=require('fs').readFileSync('/dev/stdin','utf8').split(' ').map(n=>n|0)
a=b=c=-1
Array(n+1).fill().map((_,i)=>
	Array(n+1).fill().map((_,j)=>{
		if(i+j>n){return}
		k=n-i-j
		i*10000+j*5000+k*1000==y&&(a=i,b=j,c=k)
	})
)
console.log(a+' '+b+' '+c)
//  [typescript]
const lines = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line) {
  lines.push(line);
});

reader.on("close", function () {
  const input = (lines[0] as string).split(" ");
  const num = Number(input[0]);
  const sum = Number(input[1]);

  const res = matchPatterns(num, sum);

  console.log(res[2], res[1], res[0]);
});

function matchPatterns(num: number, sum: number): number[] {
  for (let i = 0; i <= num; i++) {
    for (let j = 0; j <= num; j++) {
      const k = num - i - j;
      if (k >= 0 && i + j + k === num) {
        const tmp = 1000 * i + 5000 * j + 10000 * k;
        if (tmp === sum) {
          return [i, j, k];
        }
      }
    }
  }
  return [-1, -1, -1];
}
//  [typescript]
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  const rule = lines.shift().split(" ").map(Number);
  const num = rule[0];
  const yen = rule[1];
  let count = 0;

  for (let i = 0; i <= num; i++) {
    for (let j = 0; j <= num; j++) {
      if (i + j > num) break;
      const k = num - i - j;

      const sum = i * 10000 + j * 5000 + k * 1000;

      if (sum === yen) {
        console.log(i, j, k);
        return;
      }
    }
  }

  console.log(-1, -1, -1);
});
//  [python]
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect


def main():
    A = int(input())
    B = int(input())
    if A > B:
        A, B = B, A
    # A <= B
    if A == 1 and B == 2:
        print(3)
    elif A == 1 and B == 3:
        print(2)
    elif A == 2 and B == 3:
        print(1)


if __name__ == '__main__':
    main()
//  [python]
# -*- coding: utf-8 -*-
import numpy as np

a = int(input())
b = int(input())

if a != 1 and b != 1:
    ans = 1
elif a != 2 and b != 2:
    ans = 2
elif a != 3 and b != 3:
    ans = 3

print(ans)
//  [python]
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)






def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
        
#input
def resolve():
    A=[0,1,2,3]
    A[int(input())]=0
    A[int(input())]=0
    print(sorted(A)[-1])
    #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3
1"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1
2"""
        output = """3"""
        self.assertIO(input, output)

if __name__=="__main__":resolve()
//  [java]
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        List<Integer> result = new ArrayList<>(Arrays.asList(1,2,3));
        result.removeIf(val -> val == a || val == b);

        // 出力
        System.out.println(result.get(0));
    }
}
//  [java]

import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int a = scanner.nextInt();
        final int b = scanner.nextInt();

        final Set<Integer> set = IntStream.rangeClosed(1, 3)
                .boxed()
                .collect(Collectors.toSet());

        set.remove(a);
        set.remove(b);

        for (final int value : set) {
            System.out.println(value);
        }
    }
}
//  [java]
import java.lang.reflect.Array;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i;
        ArrayList <Integer> num = new ArrayList<Integer>();
        num.add(1);
        num.add(2);
        num.add(3);

        for (i=0;i<=num.size()-1;i++) {
            int x = sc.nextInt();
            num.removeIf(n -> (n == x));
            int y = sc.nextInt();
            num.removeIf(n -> (n == y));
            System.out.println(num.get(0));
        }
    }
}
//  [cpp]
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long

typedef tree< pair<int,int>, null_type, less< pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 1e7+100;
const int Mod = 1e9+7;

int arr[mxn], qs[mxn];
int bitOn[55];
map<int,int>Mp, cnt, op;
vector< pair<int, pair<int,int> > >Pi, Ans;
vector<int>G[mxn];
set<int>seet[mxn];

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

     int a, b;
     cin>>a>>b;
     cout<<(a^b)<<endl;
     return 0;
}
//  [c]
#include<stdio.h>
int main()
{
  int a,b;
  scanf("%d%d",&a,&b);
  printf("%d\n",6-(a+b));
  return 0;
}
//  [c]
#include<stdio.h>
void main()
{
int a,b;
  scanf("%d%d",&a,&b);
  printf("%d",6-(a+b));
}
//  [javascript]
function Main(input) {
  for (var i = 1; i <= 3; i++) {
    if (input.indexOf(i) === -1) {
      console.log(i);
      return;
    }
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n").map(Number));
//  [javascript]
function Main(input) {
	const S = input.split("\n");
	
	const A = S[0];
	const B = S[1];
	var C = "";

	if (A == "1") {
		if(B == "2") {
			C = "3";
		} else if (B == "3") {
			C = "2";
		}
	} else if (A == "2") {
		if(B == "1") {
			C = "3";
		} else if (B == "3") {
			C = "1";
		}
	} else if (A == "3") {
		if(B == "1") {
			C = "2";
		} else if (B == "2") {
			C = "1";
		}
	}
	
	console.log(C);
}
 
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {
  input = input.trim();
  input = input.split("\n")
  console.log(6-input[0]-input[1])
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [go]
package main

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

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

var rdr *bufio.Reader

func main() {
	rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)
	solve()
}

func solve() {
	A := readint()
	B := readint()

	fmt.Println(6 - A - B)
}

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

func readIntSlice(size int) []int {
	slice := make([]int, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i(v)
	}
	return slice
}

func readInt64Slice(size int) []int64 {
	slice := make([]int64, size)
	lines := strings.Split(readline(), " ")
	for i, v := range lines {
		slice[i] = s2i64(v)
	}
	return slice
}

func readint() int {
	return s2i(readline())
}

func readint64() int64 {
	return s2i64(readline())
}

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

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

func min64(values ...int64) int64 {
	ret := int64(INF_INT64)
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max64(values ...int64) int64 {
	ret := -int64(INF_INT64)
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

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

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

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

func min(values ...int) int {
	ret := INF_INT
	for _, v := range values {
		if ret > v {
			ret = v
		}
	}
	return ret
}

func max(values ...int) int {
	ret := -INF_INT
	for _, v := range values {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func s2i(s string) int {
	v, ok := strconv.Atoi(s)
	if ok != nil {
		panic("Faild : " + s + " can't convert to int")
	}
	return v
}

/* ------------------------------------------------ */
/* Data stracture                                   */
/* ------------------------------------------------ */
type IntHeap []int

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
//  [go]
package main

import (
	"fmt"
)

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

	for _, n := range []int{1, 2, 3} {
		if n != a && n != b {
			ans = n
		}
	}

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	A, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	scanner.Scan()
	B, err := strconv.Atoi(scanner.Text())
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(6 - A - B)

}
//  [ruby]
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A = get_int
B = get_int

arr = [1, 2, 3] - [A] - [B]

puts arr.first
//  [ruby]
puts [1,2,3]-`dd`.split.map(&:to_i)
//  [ruby]
p 6-$<.map(&:to_i).sum
//  [rust]
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
	a: usize,
    b: usize,
    }
  	let ans = match a + b {
      3 => 3,
      4 => 2,
      _ => 1
  };
  println!("{}", ans);
}
//  [rust]
use proconio::input;

fn main() {
    input! {
        
        a:u8,
        b:u8
    }
    let ans=if a *b==2{3}else if a*b==6 {1} else {2};
    println!("{}",ans);

}
//  [swift]

import Foundation

func main(){
    let a = Int(readLine()!)!
    let b = Int(readLine()!)!
   let list = [1, 2, 3]
   print(list.filter({ $0 != a && $0 != b })[0])
}
main()
//  [swift]
 import Foundation
 
 var a = Int(readLine()!)!
 var b = Int(readLine()!)!
 

 print(6-(a+b))
//  [swift]
let a: Int = Int(readLine()!)!
let b: Int = Int(readLine()!)!
print(6-a-b)
//  [typescript]
const main = (input) => {
  input = input.trim().split('\n')
  const data = input.map(n => Number(n))
  const arr = [1, 2, 3]
  const [result] = arr.filter(num => data.indexOf(num) === -1)
  console.log(result)
  
}

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

const [a, b] = fs.readFileSync('/dev/stdin', 'utf-8').trim().split('\n');
const ans = ['1', '2', '3'].filter((x) => x !== a).filter((x) => x !== b);
console.log(ans[0]);
//  [typescript]
import * as fs from 'fs';

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

const a = +input[0]
const b = +input[1]

if (a + b == 3) {
  console.log(3)
} else if (a + b == 4) {
  console.log(2)
} else {
  console.log(1)
}
//  [python]
a=sum(int(i)for i in input());print(a if a!=1else 10)
//  [python]
# n = int(input())
# def digitsum(x):
#     array = list(map(int, list(str(x))))
#     return sum(array)

# dsum = [digitsum(a)+digitsum(n-a) for a in range(1,int(n/2)+1)]
# print(min(dsum))
NL = list(map(int, list(input())))
 
if NL[0] == 1 and sum(NL) == 1:
    print(10)
else:
    print(sum(NL))
//  [python]
a=input()
if int(a)%10==0:
    print(10)
else:
    print(sum(list(map(int,list(a)))))
//  [python]
N=int(input())

import numpy as np

a=np.arange(N)
a=np.delete(a,0)

b=N-a

num_arr=[]

for i in range(len(a)):
	factor_a=[int(x) for x in list(str(a[i]))]
	factor_b=[int(x) for x in list(str(b[i]))]
	num_arr.append(sum(factor_a)+sum(factor_b))

print(min(num_arr))
//  [python]
import scipy as sp

def sum_of_digits(n):
    answer = 0
    while True:
        if n == 0:
            break
        else:
            answer += n%10
            n = n // 10
    return answer
     

N = int(input())
answer = N 
for a in sp.arange(1, N//2+1):
  b = N - a
  sum = sum_of_digits(a) + sum_of_digits(b)
  if sum < answer:
    answer = sum
         
     
print(answer)
//  [python]
N = int(input())
ans = N+1
for i in range(1,N//2+1):
    stra = str(i)
    strb = str(N-i)
    a = ''
    b = ''
    for j in range(len(stra)):
        a += stra[j]+'+'
    a = a[:-1]
    for j in range(len(strb)):
        b += strb[j]+'+'
    b = b[:-1]
    ans = min(ans,eval(a)+eval(b))
print(ans)
//  [java]
import java.io.*;

 
public class Main {
	  public static void main(String args[])throws IOException
             {
		BufferedReader br =    
		    new BufferedReader(new InputStreamReader(System.in));  
		
		
		    String str1 = br.readLine();
		    int N = Integer.parseInt(str1);
		    
		    if(N%10<= 0)
		    {
		    	System.out.println(10);
		    }
		    else
		    {	
		    	int sum = 0;
		    	
		    do {	sum += N % 10;
		    } while((N/= 10)!= 0);
		    	System.out.println(sum);
		    
		    }
        
		    
        	
             }
}
//  [java]
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int n = Integer.parseInt(line);
        boolean flag = false;
        int result = 0;
        for(int i = 1; i <= 5; i++){
            flag = flag || (n == Math.pow(10,i));
        }
        if(flag){
            result = 10;
        } else {
            while(n != 0){
                result = result + n % 10;
                n = n / 10;
            }
        }
        System.out.println(result);
    }
}
//  [java]
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		int min = N;
		for (int i = 1; i < N; i++) {
			String a = String.valueOf(N - i);
			String b = String.valueOf(i);
			int aSum = a.chars().map(c -> c - 48).sum();
			int bSum = b.chars().map(c -> c - 48).sum();
			min = Math.min(min, aSum + bSum);
		}
		
		System.out.println(min);
	}
}