jiahuimbzuai/CoQuIR huggingface dataset:
//  [typescript]
export class Main {
  static main(input): string {
    const tmp: number[] = input.split("\n").map(s => Number(s.split(" ")[0]));
    let index: number = 0;
    let minR: number = Infinity;
    for (let i = 0; i < 5; i++) {
      const r: number = tmp[i] % 10;
      if (0 < r && r < minR) {
        minR = r;
        index = i;
      }
    }
    let result: number = tmp[index];
    for (let i = 0; i < 5; i++) {
      if (i != index) {
        const r: number = tmp[i] % 10;
        result += tmp[i] - r + (r === 0 ? 0 : 10);
      }
    }
    return `${result}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));
//  [typescript]
const main = (input) => {
  const lines = input.split("\n").map(str => parseInt(str));
  let sum = 0;
  let maxLoss = 0;
  lines.forEach(time => {
    virtualTime = Math.ceil(time / 10) * 10;
    sum += virtualTime
    maxLoss = Math.max(maxLoss, virtualTime - time);
  });
  console.log(sum - maxLoss);
};

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

const menu = stdin.split('\n').map(Number)

const lastEl = getBiggest(menu)

const index = menu.indexOf(lastEl)

menu.splice(index, 1)

const res = menu.map(el => {
  if (el % 10 === 0) return el
  return el + 10 - (el % 10)
})
.reduce((acc, curr) => {
  return acc + curr
})

console.log(res+lastEl)

function getBiggest(nums) {
  let el = 0
  const biggest = nums.reduce((acc, c) => {
    const remain = 10 - (c % 10)
    if (remain === 10) return acc
    if (remain > acc) {
      el = c
      return remain
    }
    return acc
  }, 0)
  return el
}
//  [typescript]
import * as fs from 'fs';

const main = (input: string) => {
  const lines = input.split("\n").map(str => parseInt(str));
  let sum = 0;
  let maxTime = 0;
  let w: number[] = [];

  lines.forEach((time) => {
    if (time % 10 !== 0) {
      w.push(10 - time % 10)
    }

    sum += (Math.ceil(time / 10) * 10)
  });

  if (w !== []) {
    maxTime = w.reduce((a, b) => Math.max(a, b))
  }

  console.log(sum - maxTime);
};

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

const main = (input: string) => {
  const lines = input.split("\n").map(str => parseInt(str));
  let sum = 0;
  let maxTime = 0;
  let w: number[] = [];

  lines.forEach((time) => {
    if (time % 10 !== 0) {
      w.push(10 - time % 10)
    }

    sum += (Math.ceil(time / 10) * 10)
  });

  maxTime = w.reduce((a, b) => Math.max(a, b))

  console.log(sum - maxTime);
};

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

const main = (input: string) => {
  const lines = input.split("\n").map(str => parseInt(str));
  let answer = 0;
  let maxTime;
  let w: number[] = [];


  lines.forEach((time) => {
    if (time % 10 !== 0) {
      w.push(10 - time % 10)
    }

    answer += (Math.ceil(time / 10) * 10)
  });

  maxTime = w.reduce((a, b) => Math.max(a, b))

  console.log(answer - maxTime);
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());
//  [python]
n,k = map(int, input().split())

if n%k==0:
    print("0")
else:
    print("1")
//  [python]
N,K = map(int,input().split())
if N % K == 0:
  print(0)
else:
  print(1)
//  [python]
a,b=map(int,input().split())
if a%b==0:print(0)
else:print(1)
//  [python]
N,K = map(int, input().split())

print(N//K+(N%K)-N//K)
//  [python]
a,b = map(int,input().split())
n = a / b
div = a % b
print(div)
//  [python]
import re, math


def mapt(fn, *args):
    return list(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    n, k = Input()
    if n % k == 0:
        print(0)
    else:
        max_n = math.ceil(k/n)
        min_n = math.floor(k/n)
        print(max_n - min_n)


main()
//  [java]
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();

		System.out.println(N % K == 0 ? 0 : 1);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}
//  [java]
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int N = nextInt();
		int K = nextInt();




		System.out.println(N%K!=0?1:0);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


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

public class Main {

	public static void main(String[] args) {
		new Solution();
	}

}

class Solution {

	private int n, k;

	public Solution() {
		this.setScanner();
		this.run();
	}

	private void setScanner() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		k = sc.nextInt();
		sc.close();
	}

	private void run() {
		int min = n / k;
		int max = n / k + n % k;
		int out = (max != min) ? max - min : 0;
		System.out.println(out);
	}

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

public class Main {

	public static void main(String[] args) {

		new Solution();

	}

}

class Solution {

	private int n, k;

	public Solution() {
		this.setScanner();
		this.run();
	}

	private void setScanner() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		k = sc.nextInt();
		sc.close();
	}

	private void run() {
		int max = n / k;
		int min = n % k;
		int out = (min != 0) ? max - min : 0;
		System.out.println(out);
	}

}
//  [java]
mport java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		System.out.println(n % k == 0 ? 0 : 1);
	}
}
//  [cpp]
#include<stdio.h>

int main(void){
  int N,K;
  scanf("%d",&N);
  scanf("%d",&K);
  if(N%K==0){
    printf("0");
  }
  else{
    printf("1");
  }
  return 0;
}
//  [cpp]
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int a,b;
int main(){
	scanf("%d%d",&a,&b);
	if (a%b) printf("1\n");else printf("0\n");
	return 0;
}
//  [cpp]

#include <stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  printf("%d\n",(a%b==0)?0:1);
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n, k;
    cin >> n >> k;
    if (n%k == 1) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}
//  [cpp]
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

#define for1(n) for (int i = 0 ; i < n ; i++)
#define for2(n) for (int j = 0 ; j < n ; j++)
#define for1l(n) for (ll i = 0 ; i < n ; i++)
#define for2l(n) for (ll j = 0 ; j < n ; j++)

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    if (a % b == 0) cout << 0;
    else cout << 1;
}
//  [cpp]
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

#define for1(n) for (int i = 0 ; i < n ; i++)
#define for2(n) for (int j = 0 ; j < n ; j++)
#define for1l(n) for (ll i = 0 ; i < n ; i++)
#define for2l(n) for (ll j = 0 ; j < n ; j++)

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    cout << n % k; 
}
//  [c]
#include <stdio.h>

int main(){
  int n, k;

  scanf( "%d", &n );
  scanf( "%d", &k );

  if ( n % k == 0 ){
    puts( "0" );
  }else {
    puts( "1" );
  }

  return 0;
}
//  [c]
#include <stdio.h>
int main(){
  int n,k;
  scanf("%d %d",&n,&k );
  if(n%k==0)
  printf("0\n");
  else
  printf("1\n");
}
//  [c]
#include<stdio.h>
#include <string.h>
int main()
{
	int n,k,a,b;
	scanf("%d%d",&n,&k);
	a=n%k;
	if(a>0){
		b=1;
		printf("%d\n",b);
	}
	else {
		b=0;
		printf("%d\n",b);
	}
	return 0;
}
//  [c]
#include<stdio.h>
int main(void)
{
	int n,k,x;
	scanf("%d %d",&n,&k);
		x=n%k;
		printf("%d\n",x);
	return 0;
}
//  [c]
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d",&a,&b);
  printf("%d",a%b?1:0);
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

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

int main(void){
 
    int n, k;
    
    scanf("%d%d", &n, &k);
    
    printf("%d", n%k);
    
    return 0;
}
//  [javascript]
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  var splitInput = input.split(" ");

  var a = parseInt(splitInput[0], 10);
  var b = parseInt(splitInput[1], 10);

  if (a % b) {
    console.log(1);
  } else {
    console.log(0);
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
const main = function(input){
  var nums = input.trim().split(" ").map(i=>parseInt(i));
  var n = nums[0];
  var k = nums[1];
  var ans = 1;
  
  if(k<=n && n%k ===0){
  	ans = 0;
  }
  
  console.log(ans);


}


main(require("fs").readFileSync("/dev/stdin","utf-8"));
//  [javascript]
function main(input) {
  const n = parseInt(input.split(" ")[0], 10);
  const k= parseInt(input.split(" ")[1], 10);
  if(n%k==0){
    console.log(0);
  }else{
    console.log(1);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input) {
  const args = input.split(' ');
  const N = args[0];
  const K = args[1];
  
  if (N % K === 0) {
    console.log(0);
  } else {
    console.log(Math.floor(N % K));
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input){
  var int = Number.parseInt(input);
  var sum = 0;
  var result = 'No';
  
  CakeDonut:
  for(let i=0;sum<int;i++){
    for(let j=0;sum<int;j++){
      sum = 4*i+7+j;
      if(sum === int){
        result = 'Yes';
        break CakeDonut;
      }
    }
  }
  console.log(result);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input) {
  const n = parseInt(input.split(" ")[0], 10);
  const k= parseInt(input.split(" ")[1], 10);
  if(N%K==0){
    console.log(0);
  }else{
    console.log(1);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
    . "fmt"
)

func main() {
    var n, k int
    Scanf("%d %d", &n, &k)

    if n % k == 0 {
        Println(0)
    } else {
        Println(1)
    }
}
//  [go]
package main
import "fmt"
func main(){
    var n, k int
    fmt.Scan(&n, &k)
    
    if n%k == 0{
        fmt.Println(0)
    }else{
        fmt.Println(1)
    }
}
//  [go]
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	n, k := nextInt(), nextInt()
	puts((n-1+k)/k - n/k)
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

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

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

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

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

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}
//  [go]
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	s, _ := r.ReadString('\n')
	s = strings.TrimRight(s, " \t\n")
	slice := strings.Split(s, " ")
	n := string(slice[0])
	k := string(slice[1])
	N, _ := strconv.Atoi(n)
	K, _ := strconv.Atoi(k)

	fmt.Println(N % K)
}
//  [go]
package main

import "fmt"

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

	if n%k == 0 || n/k == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(n%k)
	}
}
//  [go]
package main

import "fmt"

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

	if n%k == 0 {
		fmt.Println(0)
	} else {
		fmt.Println(n%k)
	}
}
//  [ruby]
# abc105 A
n, k = gets.split.map(&:to_i)
p (n == k || n % k == 0) ? 0 : 1
//  [ruby]
n, k = gets.chomp.split.map(&:to_i)
puts (n % k != 0)? "1" : "0"
//  [ruby]
input = gets.chomp.split
n = input[0].to_i
k = input[1].to_i
puts n % k == 0 ? 0 : 1
//  [ruby]
a,b=gets.split.map(&:to_i)
p a%b==0?0:a-b*(a/b)
//  [ruby]
a,b=gets.split.map(&:to_i)
p a%b==0?0:a-b.*a/b
//  [ruby]
puts gets.split.map(&:to_i).inject(:%)==0?$_.split.map(&:to_i).inject(:%):$_.split[0].to_i/$_.split[1].to_i-$_.split.map(&:to_i).inject(:%)
//  [rust]
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n: usize = read();
    let k: usize = read();

    println!("{}", (n % k != 0) as u32);
}
//  [rust]
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let k = v[1];
	if n%k != 0 {
		println!("1");
	}else{
		println!("0");
	}
}
//  [rust]
use std::io::*;
use std::str::FromStr;

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

use std::collections::HashMap;

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

    for _ in 0..n {
        a.push(read());
    }

    let mut sum = 0;
    let mut ans = 0;
    let mut b: HashMap<i64, i64> = HashMap::new();
    b.insert(0, 1);
    let mut c: Vec<i64> = vec![];
    for i in 0..a.len() {
        sum += a[i];
        match b.get(&(sum % m)) {
            Some(s) => ans += *s,
            None => (),
        }
        let current = b.entry((sum % m)).or_insert(0);
        *current += 1;
    }
    println!("{}", ans);
}
//  [rust]
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let k = v[1];
	if n%k != 0 {
		println!("{}", (n/k - n%k).abs());
	}else{
		println!("0");
	}
}
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

fn main() {
    input! {
        n: i32,
        k: i32
    }
    let m = n % k;
    if m == 0 {
        println!("0");
    } else {
        println!("{}", m);
    }
}
//  [swift]
let i=readLine()!.characters.split(" ").map{Int(String($0))!};print(i[0]%i[1]>0 ?1:0)
//  [swift]
//let i=readLine()!.characters.split(" ").map{Int(String($0))!};print(i[0]%i[1]>0 ?1:0)
print(readLine()!.characters.split(" ").map{Int(String($0))!}.reduce(1){$0%$1}>0 ?1:0)
//  [swift]
//let i=readLine()!.characters.split(" ").map{Int(String($0))!};print(i[0]%i[1]>0 ?1:0)
print(readLine()!.characters.split(" ").map{Int(String($0))!}.reduce(0){$0%$1}>0 ?1:0)
//  [swift]
let i=readLine()!.characters.split(" ").map{Int(String($0))!};print(i[0]%i[1] ?1:0)
//  [typescript]
const main = (input) => {
  input = input.split(' ');
  const n = parseInt(input[0], 10);
  const k = parseInt(input[1], 10);
  
  if(n%k==0){
    console.log(0);
  }else{
    console.log(1);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
function Main(input){
	var args = input.split(' ');
	var N = parseInt(args[0],10);
  	var K = parseInt(args[1],10);
if(N%K===0){
  console.log('0');
}else{
 console.log('1');
}
  
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};
const sw=(s,a:any[],op:'='|'>='|'>'|'<='|'<'='=')=>{for(let i=0;i<a.length;i+=2){if(op==='='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};
const main = ()=>{
  let [a,b]=nrin(2);
  out(a%b==0?0:1);
}
main();
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[])=>{for(let i=0;i<a.length;i+=2)if(s==a[i])return a[i+1]};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};
const main = ()=>{
  let [a,b]=nrin(2);
  out(a/b==0?0:1);
}
main();
//  [typescript]
const main = (input) => {
  input = input.split(' ');
  const n = parseInt(input[0], 10);
  const k = parseInt(input[1], 10);
  
  if)(n%k==0){
    console.log(0);
  }else{
    console.log(1);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const main = (input) => {
  input = input.split(' ');
  const n = parseInt(input[0], 10);
  const k = parseInt(input[1], 10);
  
  if)(n%k===0){
    console.log(0);
  }else{
    console.log(1);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [python]
from sys import stdin
input = stdin.buffer.readline

def main():
    n, w = map(int, input().split())
    wv = [tuple(map(int, input().split())) for _ in range(n)]

    sum_v = sum([value for weight, value in wv])
    dp = [w + 1] * (sum_v + 1)
    dp[0] = 0
    for weight, value in wv:
        for i in range(sum_v - value + 1)[::-1]:
            if dp[i + value] > dp[i] + weight:
                dp[i + value] = dp[i] + weight

    for i in range(sum_v + 1)[::-1]:
        if dp[i] <= w:
            print(i)
            break

main()
//  [python]
N, W = map(int, input().split())
ITEM = []
vmax, wmax = 0,0
for _ in range(N):
  w,v = map(int, input().split())
  ITEM.append((v,w))
  vmax = max(vmax,v)
  wmax = max(wmax,w)

INF = 10**18
    
def solve1():
  #dp[i][v] i個めまで選んで、価値Vを実現するための最小の重量
  # TLEしたらiを消す。
  dp = [INF] * (vmax*N+1)
  dp[0] = 0
  for i in range(1,N+1):
    v1,w1 = ITEM[i-1]
    # dp[i]消すなら、vは大きい方から探索する
    for v in range(vmax*i,-1,-1):
      if v-v1>=0:
        dp[v] = min(dp[v], dp[v-v1]+w1)
  ret = 0
  for i in range(len(dp)):
    if dp[i] <= W:
      ret = max(ret, i)
  #print(dp[:30])
  return ret

ans = solve1()
  
print(ans)
//  [python]
weights, values = [], []

n, w = list(map(int, input().split()))
for _ in range(n):
    w_c, v_c = list(map(int, input().split()))
    weights.append(w_c)
    values.append(v_c)

dp = [[0 for i in range(w + 1)] for i in range(n + 1)]
for i in range(len(values) + 1):
    for j in range(w + 1):
        if i == 0 or j == 0: 
            dp[i][j] = 0
        elif weights[i - 1] <= j:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - weights[i - 1]] + values[i - 1])
        else:
            dp[i][j] = dp[i - 1][j]
    
print(dp[-1][-1])
//  [python]
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(n)]
sum_v = sum(wv[i][1] for i in range(n))
sum_w = sum(wv[i][0] for i in range(n))

dp = [[sum_w + 1] * (sum_v + 1) for i in range(n + 1)]
dp[0][0] = 0

for i in range(n):
    for j in range(sum_v + 1):
        if j - wv[i][1] >= 0:
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - wv[i][1]] + wv[i][0])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

ans = 0
for j in range(sum_v + 1):
    if dp[n][j] <= w:
        ans = max(ans, j)
print(ans)
//  [java]
import java.util.*;
import java.io.*;

//atcoder need change class name to Main
//E - Knapsack 2
//stand dp 
//this time Weight is to big, can not use it as lenght of dp
//loop from right to left

//https://atcoder.jp/contests/dp/tasks/dp_c

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

 
    public static void main(String[] args) throws IOException {
  
        int N = nextInt(); 
        int W = nextInt(); 
 
        //no need calc sum, use max 100* 1000
        int maxValue = 100000;
        long[] dp = new long[maxValue+1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for (int i=1; i<=N;  i++) {
            int w = nextInt();
            int v = nextInt();
            for (int j=maxValue; j>=v; j--) {// from right to left
                //from right to left,  make usue only use 1
                //this can be use limit item
                //use count array 
                dp[j] = Math.min(dp[j], dp[j-v] + w); 
            }
        }

        for (int i = maxValue; i>=0; i--){
            if (dp[i] <=W) {
                System.out.println(i);
                return;
            }
        }
    }
    

    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

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

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.StringTokenizer;





 class Main{
	
	

	public static void main(String[] args) throws IOException {
		
		
		FastScanner sc=new FastScanner();
		int n = sc.nextInt();
		long capacity = sc.nextInt();
		
		
		long wights[] = new long[n];
		long value[] = new long[n];
		long sum = 0;
		for(int i=0; i<n; i++) {
			wights[i] = sc.nextLong();
			value[i] = sc.nextLong();
			sum = value[i];
		}
		dp = new long[n+1][(int) capacity+1];
		for(int i=0; i<=n; i++) {
			for(int j=0; j<=capacity; j++) {
				if(i == 0 || j == 0)
					dp[i][j] = 0;
			}
		}
		for(int i=1; i<=n; i++) {
			for(int j=1; j<=capacity; j++) {
				if(wights[i-1] <= j) {
					dp[i][j] = Math.max(dp[i-1][(int) (j-wights[i-1])] + value[i-1], dp[i-1][j]);
				}
				else {
					dp[i][j] = dp[i-1][j];
				}
			}
		}
		System.out.println(dp[n][(int) capacity]);
		
		
	}
	
	
	
	static long dp[][];
	
 
	private static long solve(long[] wights, long[] value, int n, long capacity) {
		if(n == 0 || capacity==0)
			return 0;
		if(dp[n][(int) capacity] != -1)
			return dp[n][(int) capacity];
		if(wights[n-1] <= capacity) {
			return dp[n][(int) capacity] = Math.max(solve(wights, value, n-1, (int) (capacity-wights[n-1])) 
					+ value[n-1],
					solve(wights, value, n-1, capacity));
		}
		else {
			return dp[n][(int) capacity] =  solve(wights, value, n-1, capacity);
		}
		
	}





	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long[] readArrayLong(int n) {
        	long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
        }
		long nextLong() {
			return Long.parseLong(next());
		}
		String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
	}
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.StringTokenizer;





 class Main{
	
	

	public static void main(String[] args) throws IOException {
		
		
		FastScanner sc=new FastScanner();
		int n = sc.nextInt();
		long capacity = sc.nextInt();
		
		
		long wights[] = new long[n];
		long value[] = new long[n];
		long sum = 0;
		for(int i=0; i<n; i++) {
			wights[i] = sc.nextLong();
			value[i] = sc.nextLong();
			sum = value[i];
		}
		dp = new long[n+1][(int) sum+1];
		for(int i=0; i<=n; i++) {
			for(int j=0; j<=sum; j++)
				dp[i][j] = -1;
		}
		long v = solve(wights,value,n,capacity);
		System.out.println(v);
	}
	
	
	
	static long dp[][];
	
 
	private static long solve(long[] wights, long[] value, int n, long capacity) {
		if(n == 0 || capacity==0)
			return 0;
		if(dp[n][(int) capacity] != -1)
			return dp[n][(int) capacity];
		if(wights[n-1] <= capacity) {
			return dp[n][(int) capacity] = Math.max(solve(wights, value, n-1, (int) (capacity-wights[n-1])) 
					+ value[n-1],
					solve(wights, value, n-1, capacity));
		}
		else {
			return dp[n][(int) capacity] =  solve(wights, value, n-1, capacity);
		}
		
	}





	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long[] readArrayLong(int n) {
        	long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
        }
		long nextLong() {
			return Long.parseLong(next());
		}
		String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
	}
}
//  [java]
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.StringTokenizer;





 class Main{
	
	

	public static void main(String[] args) throws IOException {
		
		
		FastScanner sc=new FastScanner();
		int n = sc.nextInt();
		long capacity = sc.nextInt();
		dp = new long[n+1][(int) (capacity+1)];
		for(int i=0; i<=n; i++) {
			for(int j=0; j<=capacity; j++)
				dp[i][j] = -1;
		}
		long wights[] = new long[n];
		long value[] = new long[n];
		for(int i=0; i<n; i++) {
			wights[i] = sc.nextLong();
			value[i] = sc.nextLong();
		}
		long v = solve(wights,value,n,capacity);
		System.out.println(v);
	}
	
	
	
	static long dp[][];
	
 
	private static long solve(long[] wights, long[] value, int n, long capacity) {
		if(n == 0 || capacity==0)
			return 0;
		if(dp[n][(int) capacity] != -1)
			return dp[n][(int) capacity];
		if(wights[n-1] <= capacity) {
			return dp[n][(int) capacity] = Math.max(solve(wights, value, n-1, (int) (capacity-wights[n-1])) 
					+ value[n-1],
					solve(wights, value, n-1, capacity));
		}
		else {
			return dp[n][(int) capacity] =  solve(wights, value, n-1, capacity);
		}
		
	}





	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long[] readArrayLong(int n) {
        	long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
        }
		long nextLong() {
			return Long.parseLong(next());
		}
		String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
	}
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

#define all(c) c.begin(),c.end()

template <class T>
struct knapsack {
  T c; 
  struct item { T p, w; };
  vector<item> is;
  void add_item(T p, T w) {
    is.push_back({p, w});
  }
  T det(T a, T b, T c, T d) {
    return a * d - b * c;
  }
  T z;
  void expbranch(T p, T w, int s, int t) {
    if (w <= c) {
      if (p >= z) z = p;
      for (; t < is.size(); ++t) {
        if (det(p - z - 1, w - c, is[t].p, is[t].w) < 0) return;
        expbranch(p + is[t].p, w + is[t].w, s, t + 1);
      }
    } else {
      for (; s >= 0; --s) {
        if (det(p - z - 1, w - c, is[s].p, is[s].w) < 0) return;
        expbranch(p - is[s].p, w - is[s].w, s - 1, t);
      }
    }
  }
  T solve() {
    sort(all(is), [](const item &a, const item &b) { 
      return a.p * b.w > a.w * b.p;
    });
    T p = 0, w = 0;
    z = 0;
    int b = 0; 
    for (; b < is.size() && w <= c; ++b) {
      p += is[b].p;
      w += is[b].w;
    }
    expbranch(p, w, b-1, b);
    return z;
  }
};

int main() {
  int s, n;
  scanf("%d %d", &n, &s);
  knapsack<long long> solver;
  solver.c = s;
  for (int i = 0; i < n; ++i) {
    int v, w; 
    scanf("%d %d", &w, &v);
    solver.add_item(v, w);
  }
  printf("%lld\n", solver.solve());
}
//  [cpp]
//#include <bits/stdc++.h>/*
#include <unordered_map>
#include <functional> //greater
#include <algorithm> //sort
#include <iostream>
#include <iterator>
#include <utility> //pair
#include <sstream>
#include <cstring> //memset
#include <complex>
#include <cassert>
#include <random>
#include <cstdio>
#include <string>
#include <vector>
#include <cctype> //isaplha, tolower
#include <deque>
#include <queue>
#include <stack>
#include <array>
#include <cmath> //sqrt, sin
#include <ctime>
#include <list>
#include <map>
#include <set>
//*/

//#define int long long
#define uns unsigned
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define endl '\n'
using namespace std;

template<class T> ostream &operator<<(ostream &os, const pair<T,T> &p){
	return os<<"("<<p.fi<<","<<p.se<<")";}
template<class T> ostream &operator<<(ostream &os, const pair<const T,T> &p){
	return os<<"("<<p.fi<<","<<p.se<<")";}
template<class T> ostream &operator<<(ostream &os, const array<T,3> &p){
	return os<<"("<<p[0]<<","<<p[1]<<","<<p[2]<<")";}
template<class T> ostream &operator<<(ostream &os, const vector<T> &p){
	for(auto x: p) os<<x<<' '; return os;}
#define dbug(x) cerr<<">>>> "<<#x<<" = "<<x<<endl
#define _ <<", "<<
#define FOR(X,L,R) for(int X=L;X<R;X++)
#define FI(I,X) for(auto I=(X).begin();I!=(X).end();I++)
#define print(X) {cerr<<"{ ";FI(I,X)cerr<<*I<<' ';cerr<<"}"<<endl;}
#define mset(V,X) memset(V,X,sizeof(V))
#define all(X) (X).begin(),(X).end()
#define upperb(V,X) (int)(upper_bound(all(V),(X))-V.begin())
#define lowerb(V,X) (int)(lower_bound(all(V),(X))-V.begin())

const double EPS = 1e-9, PI = acos(-1);
const ll LINF = 0x3f3f3f3f3f3f3f3f, mod = 1e9+7;
const int INF = 0x3f3f3f3f, SZ = 2e5+20;

int n,c;
vector<pii> v;//w,v;
int res,aux;
double c2,aux2;
int sf[110];
void bt(int i){
	if(i == n) return;
	//if(sf[i] + aux <= res) return;
	aux2 = 0; c2 = c;
	for(int j=i; j<n && c2; j++){
		if(v[j].fi <= c2){
			c2 -= v[j].fi; aux2 += v[j].se;
		} else {
			aux2 += (v[j].se*c2)/v[j].fi;
			c2 = 0;
		}
	}
	if(aux2 + aux <= res) return;
	if(v[i].fi <= c){
		c -= v[i].fi;
		aux += v[i].se;
		if(aux > res) res = aux;
		bt(i+1);
		aux -= v[i].se;
		c += v[i].fi;
	}
	bt(i+1);
}

int32_t main(){
	ios::sync_with_stdio(false);cin.tie(0);
	
	cin>>n>>c;
	FOR(i,0,n){
		int x,y; cin>>x>>y;
		//w.pb(x); v.pb(y);
		v.pb({x,y});
	}
	//random_shuffle(all(v));
	sort(all(v),[](pii a, pii b){
		return (a.se+0.0)/a.fi > (b.se+0.0)/b.fi;
	});
	//for(int i=n-1; i>=0; i--) sf[i] = v[i].se+sf[i+1];
	
	bt(0);
	cout<<res<<endl;

	return 0;
}
//  [cpp]
#include <iostream>
#define INT_MAX 1000000
#include <cstring>
#include <unordered_map>
#include <vector>
using namespace std;

int main()
{
  int n, w;
  cin >> n >> w;
  vector<int> val(n, 0);
  vector<int> weights(n, 0);
  vector<vector<long>> map(n+1, vector<long>(w+1, 0L));
  for(int i=0; i<n; i++)
    cin >> weights[i] >> val[i];
  for(int i=1; i<n+1; i++)
  {
    for(int j=1; j<w+1; j++)
    {
      if (weights[i-1] <= j)
      	map[i][j] = max(val[i-1]+map[i-1][j-weights[i-1]], map[i-1][j]);
      else
        map[i][j] =  map[i-1][j];
    }
  }
  cout<<map[n][w];
  return 0;
}
//  [cpp]
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod = 1'000'000'007;
const ll INF = 1LL<<60;

vector<vector<ll>> dp(110, vector<ll>(1010,INF));
vi W(110), V(110);
ll rec(int n, int v){
    if (dp[n][v] != INF) return dp[n][v];
    if (n == 0){
        if (v == 0) return dp[0][0] = 0;
        else return dp[0][v];
    }
    ll res = INF;
    res = min(res, rec(n-1, v));
    if (v >= V[n-1]) res = min(res, rec(n-1, v-V[n-1]) + W[n-1]);
    return dp[n][v] = res;
}

int main(){
    int n, w;
    cin >> n >> w;
    rep(i,n) cin >> W[i] >> V[i];
    
    ll ans = 0;
    for (ll i=1; i<1010; i++){
        if (rec(n,i) <= w) ans = max(ans, i);
        // rep(i,n){
        //     rep(j,18){
        //         printf("%d", dp[i][j]);
        //     }
        //     printf("\n");
        // }
        // printf("\n");
    }
    cout << ans << endl;
    return 0;
}
//  [c]
#include<stdio.h>
#include<limits.h>
#define d_flag 0
#define MAX 100000
#define INF 1e12
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)<(b)?(b):(a))
#define abs(a) max((a),-(a))
typedef long long int li;

int cp(li a,li b){
  // cp(a,b) means (a<=b)
  if(b== -1)return 1;
  // -1 means INF
  else return(a<=b);
}

int main(){
  int n,W;
  scanf("%d%d",&n,&W);
  int i,j,v[n];
  li w[n],dp[MAX+1];   //dp[v]=w
  
  for(i=0;i<n;i++){
    scanf("%lld%d",&w[i],&v[i]);
  }

  if(d_flag) printf("%ld\n",LONG_MAX);

  int max_v=0;
  li temp;
 
  for(i=0;i<=MAX;i++)dp[i]=INF;
  //  if()
  dp[0]=0;
  for(i=0;i<n;i++){
  if(d_flag) printf("i:%d, j=%d downto %d\n",i,max_v,0);
    for(j=max_v+v[i];j>=v[i];j--){
      temp=dp[j-v[i]]+w[i];
      if(d_flag) printf("temp:%ld, W:%d, dp[%d]=%d\n",temp,W,j,dp[j]);
      if(temp<=W && temp<dp[j]){
	dp[j]=temp;
	if(max_v<j){
	  max_v=j;
	}
      }
      if(d_flag) printf("\n");
    }
  }
  
  if(d_flag){
    for(i=0;i<=max_v;i++)
      printf(" %ld",dp[i]);
    printf("\n");
  }
  printf("%lld",max_v);
}
//  [c]
#include <stdio.h>

#define MIN(a,b) ((a)<(b)?(a):(b))

int n, w;
int W[100];
int V[100];
int dp[100001];

int main(){
  int i, j, r;
  scanf("%d%d", &n, &w);
  for(i=0;i<n;i++) scanf("%d%d", W+i, V+i);
  for(j=1;j<=100000;j++) dp[j] = -1;
  for(i=0;i<n;i++){
    for(j=100000;j>=V[i];j--)
      if(dp[j-V[i]] >= 0) dp[j] = MIN((unsigned) dp[j], (unsigned) (dp[j-V[i]]+W[i]));
  }
  r = 0;
  for(j=0;j<=100000;j++) if(dp[j] >= 0 && dp[j] <= w) r = j;
  printf("%d\n", r);
  return 0;
}
//  [c]
n,w,i,m,a,v;main(){
scanf("%d%d",&n,&w);
m=1e3*n;
int*dp=(int*)calloc(m+1,sizeof(int));
for(i=1;i<=m;i++)dp[i]=w+1;
while(n--){scanf("%d%d",&a,&v);for(i=m;i>=v;i--)dp[i]=(dp[i]>dp[i-v]+a?dp[i-v]+a:dp[i]);}
for(i=m;dp[i]>w;i--);
printf("%d",i);
}
//  [c]
#include <stdio.h>

long int max(long int a, long int b) {
    if (a > b) return a;
    return b;
}

int main() {
    long int n,w;
    
    scanf("%ld %ld",&n,&w);
    
    long int val[n];
    long int wt[n];
    
    for (long int i = 0; i < n; i++) {
        scanf("%ld %ld",&wt[i],&val[i]);
    }

    long int memo[n+1][w+1];
    for (long int i = 0; i < w + 1; i++) {
        memo[0][i] = 0;
    }
    for (long int j = 0; j < n + 1; j++) {
        memo[j][0] = 0;
    }
    
    for (long int i = 1; i <= n; i++) {

        for (long int espacio = 1; espacio <= w; espacio++) {

            long int maxValWithoutCurr = memo[i - 1][espacio];
            long int maxValWithCurr = 0;
            
            long int weightOfCurr = wt[i - 1];
            if (espacio >= weightOfCurr) { 
                maxValWithCurr = val[i - 1];
                
                long int espacio_restante = espacio - weightOfCurr; 
                maxValWithCurr += memo[i - 1][espacio_restante]; 
            }
            
            memo[i][espacio] = max(maxValWithoutCurr, maxValWithCurr); 
        }
    }

    printf("%ld \n",memo[n][w]);

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

int max(int a, int b) {
    if (a > b) return a;
    return b;
}

int main() {
    int n,w;
    
    scanf("%d %d",&n,&w);
    
    int val[n];
    int wt[n];
    
    for (int i = 0; i < n; i++) {
        scanf("%d %d",&wt[i],&val[i]);
    }

    int memo[n+1][w+1];
    for (int i = 0; i < w + 1; i++) {
        memo[0][i] = 0;
    }
    for (int j = 0; j < n + 1; j++) {
        memo[j][0] = 0;
    }
    
    for (int i = 1; i <= n; i++) {

        for (int espacio = 1; espacio <= w; espacio++) {

            int maxValWithoutCurr = memo[i - 1][espacio];
            int maxValWithCurr = 0;
            
            int weightOfCurr = wt[i - 1];
            if (espacio >= weightOfCurr) { 
                maxValWithCurr = val[i - 1];
                
                int espacio_restante = espacio - weightOfCurr; 
                maxValWithCurr += memo[i - 1][espacio_restante]; 
            }
            
            memo[i][espacio] = max(maxValWithoutCurr, maxValWithCurr); 
        }
    }

    printf("%d\n",memo[n][w]);

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

typedef struct Temp {
    int v;
    int w;
} Temp;

int comparator(const void *p1, const void *p2);

int comparator(const void *p1, const void *p2) {
    return ((Temp *) p1)->w - ((Temp *) p2)->w;
}

int main() {

    int N, W;
    scanf("%d %d", &N, &W);
    Temp arr[N];

    for (int i = 0; i < N; i++) {
        scanf("%d %d", &arr[i].w, &arr[i].v);
    }

    qsort(arr, N, sizeof(Temp), comparator);

    for (int i = N - 1; i >= 0; i--) {
        if (arr[i].w > W)
            N--;

    }

    int ans = 0;

    int value, weight, boolean;
    int final = (int) pow(2, N);

    for (int i = 0; i < final; i++) {
        value = weight = 0;
        boolean = 1;

        for (int j = 0; j < N; j++) {
            if (i & (1 << j) ) {
                if ((weight += arr[N - 1 - j].w) <= W) {
                    value += arr[N - 1 - j].v;
                } else {
                    boolean = 0;
                    break;
                }

            }

        }

        if (boolean && ans < value) {
            ans = value;
        }

    }

    printf("%d", ans);

    exit(0);
}
//  [javascript]
"use strict";

function main(input){
  const args = input.trim().split('\n').map(_=>_.split(' ').map(_=>parseInt(_,10)));
  const n = args[0][0];
  const w_max = args[0][1];
  const items = args.slice(1);
  
  const dp = Array(100001).fill(1000000001); // 価値をiにするための最小容量
  dp[0] = 0;
  for(let i=0; i<n; i++){
    const weight = items[i][0];
    const value = items[i][1];
    for(let v=100000; v>=value; v--){
      dp[v] = Math.min(dp[v], dp[v-value] + weight);
    }
  }
  
  for(let i=100000; i>=0; i--){
    if(dp[i] <= w_max){
      console.log(i);
      return;
    }
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));