akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

import numpy as np
from collections import Counter

YEAR = 2019


def solve(S: str):
    # S の各桁を modYear 計に修正する
    mod_year = np.arange(1, 10)
    mod_s = []
    for Si in map(int, reversed(S)):
        mod_s.append(mod_year[Si - 1])
        mod_year = (mod_year * 10) % YEAR
    #print(mod_s)
    # mod_s を累積和にする
    cum_sum = 0
    cum_sums = [cum_sum]
    for x in mod_s:
        cum_sum = (cum_sum+x) % YEAR
        cum_sums.append(cum_sum)

    answer = 0
    for _, num in Counter(cum_sums).items():
        answer += (num * (num-1)) // 2   # 1 の時0なので場合分けはいらない
    return answer


def main():
    S = input().strip()
    answer = solve(S)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 42912
#include <iostream>
using namespace std;

int main(){
	int m, f, r, s;

	while(1){
		cin>>m>>f>>r;
		if(m==-1 && f==-1 && r==-1) break;

		s = m + f;
		if(m==-1 || f==-1)
			cout<<"F"<<endl;
		else if(s>=80)
			cout<<"A"<<endl;
		else if(s<80 && s>=65)
			cout<<"B"<<endl;
		else if(s<65 && s>=50)
			cout<<"C"<<endl;
		else if(s<50 && s>=30){
			if(r>=50) cout<<"C"<<endl;
			else      cout<<"D"<<endl;
		}else if(s<30)
			cout<<"F"<<endl;
	}

	return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		
		for(int i = 0;i<m;i++) {
			n = n - scanner.nextInt();
			if (n<0) {
				System.out.println(-1);
				return;
			}
		}
		
		System.out.println(n);
	}

}

Measured memory_bytes: 46400
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a[5];
    vector<int> v1, v2;

    for(int i = 0; i < 5; i++){
        cin >> a[i];
        if(a[i]%10 == 0) v1.push_back(a[i]);
        else v2.push_back(a[i]);
    }

    int sum = 0;

    int l1 = v1.size(), l2 = v2.size(), idx = -1, mn = -1, d;
    for(int i = 0; i < l2; i++){
        d = v2[i]%10;
        d = 10-d;
        if(d > mn) {mn = d; idx = i;}
    }

    for(int i = 0; i < l1; i++) sum += v1[i];

    for(int i = 0; i < l2; i++){
        if(i == idx) continue;
        sum += v2[i];
        sum += 10 - (v2[i]%10);
    }
    //cout << v2[idx] << "\n";
    if(idx != -1) sum += v2[idx];

    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n;
    cin >> n;

    string s;
    cin >> s;

    string t = s.substr(0, n);
    string u = s.substr(n, n);
    REVERSE(u);

    vector< pair<string, string> > v;
    rep(i, 1 << n){
        string a = "", b = "";
        rep(j, n){
            if(i >> j & 1){
                a.push_back(t[j]);
            }else{
                b.push_back(t[j]);
            }
        }
        v.emplace_back(a, b);
    }

    SORT(v);

    lint ans = 0;
    rep(i, 1 << n){
        string a = "", b = "";
        rep(j, n){
            if(i >> j & 1){
                a.push_back(u[j]);
            }else{
                b.push_back(u[j]);
            }
        }
        pair<string, string> p = make_pair(a, b);
        ans += upper_bound(v.begin(), v.end(), p) - lower_bound(v.begin(), v.end(), p);
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 35820
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>
#include <time.h>
using namespace std;

int main(){ 
	long long A, B, C, ans = 0;

	cin >> A >> B >> C;	

	if (C <= A + B)
		ans = B + C;
	else
		ans = B * 2 + A + 1;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a,b;

  scanf( "%d %d" , &a , &b );

  if( a > b )
    {
      printf("a > b\n");
    }
  else if( a < b )
    {
      printf("a < b\n");
    }
  else if ( a == b )
    {
      printf("a == b\n");
    }

  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

int main(){
    string s,ans="";
    cin>>s;

    rep(i,s.size()){
        if(s[i]=='0'){
            ans.push_back('0');
        }
        else if(s[i]=='1'){
            ans.push_back('1');
        }
        else if((s[i]=='B'&&ans.size()!=0)){
            ans.pop_back();
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#define INF 1000000009
#define LINF 1000000000000000009
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int main() {
	int n;
	cin >> n;
	vector<int> b(n);
	for (int i = 0; i < n - 1; i++) cin >> b[i];
	int ans = b[0] + b[n - 2];
	for (int i = 0; i < n - 2; i++) {
		ans += min(b[i], b[i + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	int max=0;
	max=a*2 - 1;
	if(max < b*2 - 1) max = b*2-  1;
	if(max < a + b ) max = a + b;
	printf("%d",max);
	return 0; 
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner in  = new Scanner(System.in);
        int n = in.nextInt();
        if(n==0){
            System.out.println(0);
            return;
        }
        int []arr = new int[n];
        for(int i=0;i<n;i++)arr[i] = in.nextInt();
        int []dp = new int[n];
        dp[0] = 0;
        for(int i=1;i<n;i++){
            dp[i] = Integer.MAX_VALUE;
            for(int k=-1;k>=-2;k--){
                if((i+k)>=0){
                    dp[i] = Math.min(dp[i],(Math.abs(arr[i]-arr[i+k]))+dp[i+k]);
                }
            }
        }
        System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 50944
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;


template<typename T>
vector<vector<T>> keisann(const vector<vector<T>>l, const vector<vector<T>>r) {
	vector<vector<T>>ans(l.size(), vector<T>(r[0].size()));
	assert(l[0].size() == r.size());
	for (unsigned int h = 0; h < l.size(); ++h) {
		for (unsigned int i = 0; i < r.size(); ++i) {
			for (unsigned int w = 0; w < r[0].size(); ++w) {

				ans[h][w] |= l[h][i] * r[i][w];
			}
		}
	}
	return ans;
}

template<typename T>
vector<vector<T>>powgyou(vector<vector<T>>a, const long long int n) {
	assert(a.size() == a[0].size());
	if (!n) {
		vector<vector<T>>e(a.size(), vector<T>(a[0].size()));
		for (unsigned int i = 0; i < a.size(); ++i) {
			e[i][i] = 1;
		}
		return e;
	}
	if (n == 1)return a;
	else {
		vector<vector<T>>ans(a.size(), vector<T>(a[0].size(), 0));
		ans = powgyou(a, n / 2);
		ans = keisann(ans, ans);
		if (n % 2) {
			ans = keisann(ans, a);
		}
		return ans;
	}
}


int main() {
	while (1) {
		int N, M, Z; cin >> N >> M >> Z;
		if (!N)break;
		vector<pair<int, int>>edges;
		edges.push_back(make_pair(-1, 0));
		for (int i = 0; i < M; ++i) {
			int s, d; cin >> s >> d; s--; d--;
			edges.push_back(make_pair(s, d));
			edges.push_back(make_pair(d, s));
		}
		vector<vector<int>>field(edges.size(), vector<int>(edges.size()));
		for (int i = 0; i < edges.size(); ++i) {
			for (int j = 0; j <edges.size(); ++j) {
				auto a = edges[i];
				auto b = edges[j];
				if (a.second == b.first&&a.first != b.second) {
					field[j][i] = true;
				}
			}
		}
		vector<vector<int>>start(edges.size(), vector<int>(1));
		start[0][0] = true;
		vector<vector<int>>kake = powgyou<int>(field, Z);
		vector<vector<int>>ans = keisann<int>(kake, start);
		bool ok = false;
		for (int i = 0; i <edges.size(); ++i) {
			if (edges[i].second == N - 1 && ans[i][0])ok = true;
		}
		if (ok)cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 5832
a = Array.new(4, 0)

10.times do
  a[3] = gets.chomp.to_i
  3.times do |i|
    if a[2-i] < a[3-i]
      a[2-i], a[3-i] = a[3-i], a[2-i]
    else
      break
    end
  end
end

print a[0], "\n", a[1], "\n", a[2], "\n"








Measured memory_bytes: 6872
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<string>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
vll a;
vll csum;
// dp[l][r]: 区間[l,r]に相当するスライムが一匹にまとまっているとき、それを分解するために必要な最小コスト
ll dp[410][410];

ll rec(int l, int r) {
  if (dp[l][r] != INFLL) return dp[l][r];
  if (l == r) return 0;
  // どこで切るか全通り試す
  ll res = INFLL;
  for (int i = l; i < r; ++i) chmin(res, rec(l,i)+rec(i+1,r));
  return dp[l][r] = res + (csum[r+1] - csum[l]);
}

int main () {
  cin >> n;
  a = vll(n);
  rep(i,n) cin >> a[i];
  csum = vll(n+1);
  rep(i,n) csum[i+1] = csum[i] + a[i];

  rep(i,n+1)rep(j,n+1) dp[i][j] = INFLL;
  ll ans = rec(0,n-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;

int main() {
string a,b;
  cin>>a>>b;
 int64_t ans,k;
  ans=100000;
  //vector<char> aaa(a.size());
   //vector<char> bbb(b.size());
  //for(int64_t i=0;i<a.size();i++){
  //cin>>aaa.at(i);
  //}
   //for(int64_t i=0;i<b.size();i++){
  //cin>>bbb.at(i);
  //}
  for(int64_t i=0;i+b.size()-1<=a.size()-1;i++){
    k=0;
   for(int64_t j=0;j<b.size();j++){
    if(a.at(i+j)!=b.at(j)){k++;}
   }
    ans=min(ans,k);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3632
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	T := getInt()
	T++ // エラーにならないためのダミー
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = getInt()
	}

	min := a[0]
	cnt := 0
	maxf := 0
	for i := 1; i < N; i++ {
		diff := a[i] - min

		if diff > maxf {
			maxf = diff
			cnt = 1
		} else if diff == maxf {
			cnt++
		}

		if min > a[i] {
			min = a[i]
		}
	}

	ans := cnt
	out(ans)
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/arc066_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  
  unordered_map<int, int> m;
  rep(i, N) {
    int c;
    cin >> c;
    m[c]++;
  }

  if (N % 2 == 0) {
    for (auto kv : m) {
      if (kv.first % 2 != 1 || kv.second != 2) {
        cout << 0 << endl;
        return 0;
      }
    }
  } else {
    for (auto kv : m) {
      if (kv.first % 2 != 0 || kv.second != 2) {
        if (kv.first == 0 && kv.second == 1) continue;
        cout << 0 << endl;
        return 0;
      }
    }
  }

  mint ans = 2;
  cout << ans.pow(N / 2) << endl;
}

Measured memory_bytes: 6568
function main(input) {
  const lines = input.trim().split("\n");
  const [N, M] = lines.shift().split(' ').map(Number);
  const h = lines.shift().split(' ').map(Number);

  const isGood = Array(N).fill(true);
  lines.forEach(l => {
    const [a, b] = l.split(' ');
    if (h[a-1] > h[b-1]) {
      isGood[b-1] = false;
    } else if (h[a-1] < h[b-1]) {
      isGood[a-1] = false;
    } else {
      isGood[a-1] = false;
      isGood[b-1] = false;
    }
  });
  const res = isGood.filter(g => g).length;
  
  console.log(res);
}

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

Measured memory_bytes: 57272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long  ;  



ll n; 
map<int,int> keep ; 
int calu(ll x){
    ll k = 2 ; 
    ll res = x ; 
    while(k * k <= x){
        if(x % k == 0) {
            keep[k] += 1 ; 
            res  = x / k  ; 
            break ;
        }
        k++; 
    }
    if(x == res){
        if(keep[res] == 1) return 0 ; 
        keep[res] += 1 ;
        return 0 ; 
    }
    else return calu(res); 
}



int main(){
    cin >> n ; 
    if(n == 1){
        cout << 0 << endl ;
        return 0 ; 
    }
    calu(n); 
    int ans = 0 ; 
    for(map<int, int>::iterator itr  = keep.begin() ;itr != keep.end() ;itr++){
        ans += (-1 + sqrt(1 + 8 * itr->second)) / 2 ; 
    }
    
    cout << ans  << endl ; 

}

Measured memory_bytes: 3712
import Data.Char
import Data.List
import Data.Bits
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  n <- head.parseLine <$> BS.getLine
  as <- parseLine <$> BS.getLine
  print $ solve n as
  where
    parseLine = unfoldr (BS.readInt . BS.dropWhile isSpace)

solve :: Int -> [Int] -> Integer
solve n as = (`mod` (10^9+7)) . (calcEachBitResults n) . aggregateBits $ as

aggregateBits :: [Int] -> [Int]
aggregateBits as = map (countBits as) [0..(bitLength as-1)] 

bitLength :: [Int] -> Int
bitLength as = finiteBitSize (maximum as) - countLeadingZeros (maximum as)

countBits :: [Int] -> Int -> Int
countBits as d = length . filter (flip testBit d) $ as

calcEachBitResults :: Int -> [Int] -> Integer
calcEachBitResults n = sum . zipWith (\d x -> 2^d*x) [0..] . map ((\x -> x * (n'-x)).fromIntegral)
  where
    n' = fromIntegral n

input :: [Int]
input = map read.words $ "3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820"

Measured memory_bytes: 21884
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> firstRow = Arrays.asList(br.readLine().split(" "));
            int studentCount = Integer.parseInt(firstRow.get(0));
            int checkPointCount = Integer.parseInt(firstRow.get(1));

            List<Integer> studentPointList = new ArrayList<>();
            for (int i = 0; i < studentCount; i++) {
                List<String> tmpInput = Arrays.asList(br.readLine().split(" "));
                studentPointList.add(Integer.parseInt(tmpInput.get(0)));
                studentPointList.add(Integer.parseInt(tmpInput.get(1)));
            }

            List<Integer> checkPointList = new ArrayList<>();
            for (int i = 0; i < checkPointCount; i++) {
                List<String> tmpInput = Arrays.asList(br.readLine().split(" "));
                checkPointList.add(Integer.parseInt(tmpInput.get(0)));
                checkPointList.add(Integer.parseInt(tmpInput.get(1)));
            }

            List<List<Integer>> distanceList = new ArrayList<>();
            for (int i = 0; i < studentPointList.size() - 1; i += 2) {
                List<Integer> distanceListTmp = new ArrayList<>();
                for (int j = 0; j < checkPointList.size() - 1; j += 2) {
                    distanceListTmp.add(Math.abs(studentPointList.get(i) - checkPointList.get(j)) + Math.abs(studentPointList.get(i + 1) - checkPointList.get(j + 1)));
                }
                distanceList.add(distanceListTmp);
            }

            List<Integer> ansList = new ArrayList<>();
            for (List<Integer> distances : distanceList) {
                int min = distances.get(0);
                int ansTmp = 1;
                for (int i = 0; i < distances.size(); i++) {
                    if (distances.get(i) < min) {
                        min = distances.get(i);
                        ansTmp = i + 1;
                    }
                }
                ansList.add(ansTmp);
            }

            for (int ans : ansList) {
                System.out.println(ans);
            }
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21204
#include <iostream>
using namespace std;

int main(){
	int x, y;
	int tmp;
	while(true){
		cin >> x >> y;
		if(x == 0 && y == 0){
			break;
		}else{
			if(x > y){
				tmp = x;
				x = y;
				y = tmp; 
			}
			cout << x << " " << y << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <bitset>
#include <map>
#include <cstdint>
using namespace std;


int main(){
    int N;
    cin >> N;
    
    cout << (N < 1000 ? "ABC" : "ABD") << '\n';

    return 0;
}


Measured memory_bytes: 384
my $N = <STDIN>;
chomp($N);
my $a = <STDIN>;
chomp($a);
my @A = split(/ /,$a);
unshift(@A,$A[0]);
push(@A,$A[$#A]);

my $sum = 0;
for(1..$#A){
    if($A[$_] >= $A[$_-1]){$sum += $A[$_-1];}
    else{$sum += $A[$_];}
}


   print "$sum\n";
1;


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b){return b==0 ? a : gcd(b, a%b);}

map<ll, ll> prime_factor(ll n)
{
  map<ll, ll> res;
  for (ll i=2; i*i<=n; i++) {
    while (n%i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}

int main()
{
  ll A; cin >> A;
  ll B; cin >> B;
  ll c = gcd(A, B);
  map<ll, ll> p = prime_factor(c);
  ll ans = 1;
  for (auto v: p) {
    if (v.second > 0) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;


int main(){
    int a,b,c,k,t=0;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    /*while(t--){}*/
    while(b<=a){
    	b*=2;
    	t++;
    }
    while(c<=b){
    	c*=2;
    	t++;
    }
    
    
    if(t<=k){
    	printf("Yes");
    }
    else printf("No");
    //printf("%d",t);

    return 0;
}


Measured memory_bytes: 3716
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1000000007;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
struct union_find{//rank,経路圧縮で高速化 
  vi par;//parは添字の親（または自分が根の時自身）を示す。
  vi rank;//rankは木の高さ（根についてのみ実装）
  union_find(int n){//コンストラクタ,n個のノードを作成
    par.assign(n,0);
    rank.assign(n,0);
    REP(i,n) par[i]=i;
  }
  int find(int a){//根を探す
    if(par[a]==a) return a;
    else return par[a] = find(par[a]);//根に直接つける
  }
  void unite(int a,int b){//小さい方の木の根に大きい方の根を上書きする
    int roota,rootb;
    roota = find(a),rootb = find(b);
    if(roota==rootb) return;
    if(rank[roota]>rank[rootb]){
      par[rootb] = roota;
    }else if(rank[roota]<rank[rootb]){
      par[roota] = rootb;
    }else{
      rank[roota]++;
      par[rootb] = roota;
    }
  }
};
vi node;
int v,e;
vector<bool> checked;
void numbering(vvi &g,int a){
  checked[a] = true;
  REP(i,(int)g[a].size()){
    if(!checked[g[a][i]]) numbering(g,g[a][i]);
  }
  node.pb(a);
  return;
}
int dfs(vvi &g,int a,union_find &uf){
  checked[a] = true;
  REP(i,(int)g[a].size()){
    if(!checked[g[a][i]]) uf.unite(a,dfs(g,g[a][i],uf));
  }
  return a;
}

int main(){
  cin >> v >> e;
  union_find uf(v);
  vvi g(v),rev(v);
  checked.assign(v,false);
  REP(i,e){
    int tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    g[tmp1].pb(tmp2);
    rev[tmp2].pb(tmp1);
  }
  REP(i,v){
    if(!checked[i]) numbering(g,i);
  }
  checked.assign(v,false);
  g = rev;
  reverse(ALL(node));
  REP(i,v){
    if(!checked[node[i]]){
      dfs(g,node[i],uf);
    }
  }
  int q;
  cin >> q;
  REP(i,q){
    int tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    cout << (uf.find(tmp2)==uf.find(tmp1)?1:0) << endl;
  }
}



Measured memory_bytes: 4720
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, R = MI()

    if N >= 10:
        print(R)
    else:
        inner = 100 * (10 - N)
        print(R + inner)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38768
#include <bits/stdc++.h>
using namespace std;


int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if(abs(a-c) <= d || abs(a-b) <= d && abs(b-c)<= d) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
using namespace std;
 
int main(){

    int R;
    cin >> R;

    if(R<1200){
        cout << "ABC" <<endl;
    }else if(R<2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" <<endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


class UnionFind:
    def __init__(self, N):
        self.N = N  # ノード数
        # 親ノードをしめす。負は自身が親ということ。
        self.parent = [-1] * N  # idxが各ノードに対応。

    def root(self, A):
        # print(A)
        # ノード番号を受け取って一番上の親ノードの番号を帰す
        if (self.parent[A] < 0):
            return A
        self.parent[A] = self.root(self.parent[A])  # 経由したノードすべての親を上書き
        return self.parent[A]

    def size(self, A):
        # ノード番号を受け取って、そのノードが含まれている集合のサイズを返す。
        return -self.parent[self.root(A)]

    def unite(self, A, B):
        # ノード番号を2つ受け取って、そのノード同士をつなげる処理を行う。
        # 引数のノードを直接つなぐ代わりに、親同士を連結する処理にする。
        A = self.root(A)
        B = self.root(B)

        # すでにくっついている場合
        if (A == B):
            return False

        # 大きい方に小さい方をくっつけたほうが処理が軽いので大小比較
        if (self.size(A) < self.size(B)):
            A, B = B, A

        # くっつける
        self.parent[A] += self.parent[B]  # sizeの更新
        self.parent[B] = A  # self.rootが呼び出されればBにくっついてるノードもすべて親がAだと上書きされる

        return True

    def is_in_same(self, A, B):
        return self.root(A) == self.root(B)


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc157/tasks/abc157_d
# 友達でつながっている集合を管理する必要
# ブロック関係のときはカウントしない
# すでに友達ならばカウントしない
N, M, K = read_ints()

# iについての友達候補数=同じグループの人数-1 -すでに友達(グループ内で)-すでにブロック(グループ内で)

uf = UnionFind(N)
n_friends = [0] * N
n_blocked = [0] * N
for _ in range(M):
    a, b = read_ints()
    a -= 1
    b -= 1
    uf.unite(a, b)
    n_friends[a] += 1
    n_friends[b] += 1
for _ in range(K):
    c, d = read_ints()
    c -= 1
    d -= 1
    if uf.is_in_same(c, d):
        n_blocked[c] += 1
        n_blocked[d] += 1

ans = []
for i in range(N):
    ans.append(uf.size(i) - n_friends[i] - n_blocked[i] - 1)
print(*ans)


Measured memory_bytes: 95576
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  std::string s;
  std::cin >> s;

  int n = s.size();
  vt<std::pair<char,ll>> v(n);
  v[0].first = s[0];
  int cnt = 0;
  rep(i,n) {
    if(v[cnt].first != s[i]){
      cnt++;
      v[cnt].first = s[i];
    }
    v[cnt].second++;
  }

  ll ans = 0;
  rep(i,cnt+1) {
    if(v[i].first == '<')
      ans += (v[i].second + 1)*v[i].second/2;

    else {
        if(v[i-1].second > v[i].second && i != 0)
          ans += v[i].second*(v[i].second-1)/2;
        else{
          ans += v[i].second*(v[i].second+1)/2 - (i > 0 ? v[i-1].second : 0);
        }
    }
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 8708
x,y = map(int, input().split())

A=[1,3,5,7,8,10,12]
B=[4,6,9,11]
C=[2]

if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    s = read_str()
    t = read_str()

    s_lis = sorted(Counter(s).values())
    t_lis = sorted(Counter(t).values())
    
    if s_lis == t_lis:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    Main()

Measured memory_bytes: 9712
#include<iostream>
#include<string>
using namespace std;

int main(){
    int m,f,r;
    string ans[1000];
    int i=0;
    cin>>m>>f>>r;
    while(m!=-1 || f!=-1 || r!=-1){
        if(m==-1 || f==-1) ans[i]="F";
        else if(m+f>=80) ans[i]="A";
        else if(m+f>=65) ans[i]="B";
        else if(m+f>=50) ans[i]="C";
        else if(m+f>=30 && r>=50) ans[i]="C";
        else if(m+f>=30 && r<50) ans[i]="D";
        else ans[i]="F";
        cin>>m>>f>>r;
        i++;
    }
    for(int j=0;j<i;++j){
        cout<<ans[j]<<endl;
    }
}


Measured memory_bytes: 3120
# include <iostream>
# include <cmath>
using namespace std;

int main() {
    double x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    
    double dx = x1 - x2, dy = y1 - y2;
    double distance = sqrt(dx * dx + dy * dy);
    
    printf("%.8f", distance);
    
    return 0;
}


Measured memory_bytes: 3288
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
 
using namespace std;

double EPS = 1e-10;

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){x=y=0;}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }

  point operator / (double d){
    return point(x/d,y/d);
  }
  
  bool operator == ( const point &p ) const {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

bool cmp_x(const point& p, const point& q){
  if(p.x != q.x)return p.x<q.x;
  return p.y < q.y;
}

bool comp_y(point a,point b){
  return a.y<b.y;
}

int N;
const double INF=1000000000;
point A[1000000];
 
double closest_pair(point *a, int n){
  if(n<=1)return INF;
  int m=n/2;
  double x=a[m].x;
  double d=min(closest_pair(a,m),closest_pair(a+m,n-m));
  inplace_merge(a,a+m,a+n,comp_y);
 
  vector<point>b;
  for(int i=0;i<n;i++){
    if(abs(a[i].x-x)>=d)continue;
    for(int j=0;j<b.size();j++){
      double dx = a[i].x-b[b.size()-j-1].x;
      double dy = a[i].y-b[b.size()-j-1].y;
      if(dy>=d)break;
      d=min(d,dx*dx+dy*dy);
    }
    b.push_back(a[i]);
  }
  return d;
}

 
int main(void){
 
  point in;
 
  cin >> N;
    for(int i=0;i<N;i++)
      cin >> A[i].x >> A[i].y;

    sort(A,A+N,cmp_x);
    cout << closest_pair(A,N) << endl;
   
  return 0;
}

Measured memory_bytes: 28316
import sys
import itertools


def check(i,array):
    now=0
    while True:
        flag=0
        if(now==len(i)-1):
            return 1
        for x in array:
            if(i[now]==x[0] and i[now+1]==x[1] or \
                i[now]==x[1] and i[now+1]==x[0]):

                flag=1
                now+=1
                break

        if(flag==0):
            return 0


def main():
    N, M = map(int,input().split())

    array=[]
    sum=0

    for _ in range(0, M):
        array.append(list(map(int,input().split())))


    for i in itertools.permutations(range(1,N+1),N):
        if(i[0]==1):
            sum += check(i,array)
    print(sum)

main()

Measured memory_bytes: 42092
#include<bits/stdc++.h>
using namespace std;
int sum[3],la;
char ch[500000];
int main()
{
	scanf("%s",ch);
	la=strlen(ch);
	for(int i=0;i<=la-1;i++)
	{
		if(ch[i]=='p')
		{
			if(sum[1]<sum[2]) sum[1]++;
			else
			{
				sum[2]++;
				sum[0]--;
			}
		}
		if(ch[i]=='g')
		{
			if(sum[1]<sum[2])
			{
				sum[1]++;
				sum[0]++;
			}
			else sum[2]++;
		}
	}
	cout<<sum[0];
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

struct block
{
    int w,s,v;
    bool operator<(block& rhs){
        return w+s<rhs.w+rhs.s;
    }
};

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin>>N;
    vector<block> blocks(N);
    for(int i=0;i<N;i++){
        int w,s,v; cin>>w>>s>>v;
        blocks[i]={w,s,v};
    }
    sort(blocks.rbegin(),blocks.rend());
    vector<int> w(N),s(N),v(N);
    for(int i=0;i<N;i++){
        w[i]=blocks[i].w;
        s[i]=blocks[i].s;
        v[i]=blocks[i].v;
    }

    const int maxS=*max_element(s.begin(),s.end());
    vector<vector<int>> dp(N+1,vector<int>(maxS+1,-1));
    for(int i=0;i<N;i++){
        chmax(dp[i+1][s[i]],v[i]);
        for(int j=0;j<=maxS;j++) if(dp[i][j]!=-1){
            chmax(dp[i+1][j],dp[i][j]);
            if(j>=w[i]){
                chmax(dp[i+1][min(j-w[i],s[i])],dp[i][j]+v[i]);
            }
        }
    }
    /*
    for(int i=0;i<=N;i++){
        for(int j=0;j<=maxS;j++) cout<<dp[i][j]<<' '; cout<<endl;
    }
    */
    cout<<*max_element(dp[N].begin(),dp[N].end())<<endl;
    return 0;
}

Measured memory_bytes: 78592
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
#define fcout cout<<fixed<<setprecision(10)
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
//template<typename T>void pp(T x){cout<<x<<endl;}

using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> count(n,0);
    vector<pair<int,int> > v(n);
    rep(i,0,n){
        cin>>v[i].fi;
        v[i].se=i;
    }
    rep(i,0,m){
        int x; cin>>x;
        int ans=INF;
        rep(j,0,n){
            if(v[j].fi<=x && ans>v[j].se)ans=v[j].se;
        }
        count[ans]++;
    }

    int num=0,ans=0;
    rep(i,0,n){
        //cout<<i+1<<": "<<count[i]<<endl;
        if(count[i]>num){
            num=count[i];
            ans=i+1;
        }
    }
    cout<<ans<<endl;



    
    return 0;
}


Measured memory_bytes: 3092
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] a) {
		Scanner s = new Scanner(System.in);
		int[] b = new int[10];
		for (int i = 0; i < 10; i++) {
			b[i] = s.nextInt();
		}
		Arrays.sort(b);
		for (int i = 9; i >= 7; i--) {
			System.out.println(b[i]);
		}
	}
}

Measured memory_bytes: 12000
D, G = map(int, input().split())

probs = []
ans = 0

for i in range(D):
    p, c = map(int, input().split())
    probs.append(((i+1) * 100, p, c))
    ans += p

for mask in range(1 << D):  # dビット左にずらす、2**dの値となる
    solved = 0   # 問題数？
    my_score = 0
    for i in range(D):
        score, occ, bonus = probs[i]  # scoreは100の倍数の値, occは問題数,
        if mask & (1 << i) > 0:
            solved += occ
            my_score += score * occ + bonus  # 全問解いた場合の点数

    for x in range(D - 1, -1, -1):
        if my_score >= G:
            break
        if (mask & (1 << x)) > 0:
            continue
        score, occ, bounDs = probs[x]
        for _ in range(occ):  # 問題数, 一問ずつ足していく感じ
            solved += 1
            my_score += score
            if my_score >= G:
                break
    if my_score >= G:
        ans = min(ans, solved)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
 
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD = 1e9+7;
const ll CFMOD = 998244353;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
 
#define INT_MX 2147483647
#define INF (((int)1e9) + 7)
#define LLINF ((ll)1e18)
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define sz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define PB push_back
#define PF push_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,n,m) for(int i=(n);i<(m);i++)
#define vec vector
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);


ll dp[110][100010];

void solve(){
    int n, mxw, ans;
    
    ans = 0;
    
    cin >> n >> mxw;
    vec<int> v(n+1), w(n+1);
    
    rep1(i,n) cin >> w[i] >> v[i];
    
    rep1(i,100000)   dp[0][i] = INF;
    rep1(i,n) rep1(j,100000){
        dp[i][j] = dp[i-1][j];
        if(j >= v[i])
            dp[i][j] = min(dp[i][j],  dp[i-1][j-v[i]] + w[i]);
        if(dp[i][j] <= mxw) ans = max(ans, j);
    }
    
    cout << ans << '\n';
    
    
    
    
}
 
int main(){
    int t = 1;
    
    while(t--){
        solve();
    }
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

void solve(){
    i64 N,A,B,C,D;
    cin >> N >> A >> B >> C >> D;

    rep(i,0,N-1){
        i64 x=A+(i+1)*C,y=A+(i+1)*D,j=N-1-(i+1);
        if(x-j*D<=B and B<=y-j*C){
            cout << "YES" << endl;
            return;
        }
    }
    cout << "NO" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
// using P = pair<int, int>;
struct Vec{
        double x, y;
};
template<class T> inline bool chmin(T& a, T b) {
        if (a > b) {
            a = b;
            return true;
        }
        return false;
}
template<class T> inline bool chmax(T& a, T b) {
        if (a < b) {
            a = b;
            return true;
        }
         return false;
}
using namespace std;

const int mod = 998244353;
// const int mod = 1000000007;
class mint {
    public:
        ll x;
        mint(ll x=0):x((x%mod + mod) % mod){}
        mint& operator+=(const mint a) { 
            if ((x += a.x) > mod) x-=mod;
            return *this;
        }
        mint& operator-=(const mint a) { 
            if ((x += mod - a.x) >= mod) x-=mod;
            return *this;
        }
        mint& operator*=(const mint a) { 
            (x *= a.x) %= mod;
            return *this;
        }
        mint operator+(const mint a) const {
            mint res(*this);
            return res+=a;
        }
        mint operator-(const mint a) const {
            mint res(*this);
            return res-=a;
        }
        mint operator*(const mint a) const {
            mint res(*this);
            return res*=a;
        }
        mint pow(ll a) const {
            if (a == 0) return 1;
            mint b = pow(a >> 1);
            b *= b;
            if (a&1) b *= (*this);
            return b;
        }
        mint inv() const {
            return pow(mod - 2);
        }
        mint& operator/=(const mint a) { 
            return (*this) *= a.inv();
        }
        mint operator/(const mint a) const { 
            mint res(*this);
            return res /= a;
        }
        friend ostream& operator<<(ostream& os, const mint& m){
            os << m.x;
            return os;
        }
};


int main()
{
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        // cout << fixed << setprecision(15);

        // DPを使ってTLE
        int n, k;
        cin >> n >>  k;
        
        vector <pair<int, int>> s;
    
        rep(i, k){
            int l, r;
            cin >> l >> r;
            s.push_back(pair<int, int>(l, r));
        }

        vector<mint> imo(n + 1, 0);
        vector<mint> dp(n + 1, 0);

        dp[1] = 1;
        imo[1] = 1;
        repi(i,2, n + 1){
            for (auto &m : s){
                int l, r;
                l = max(i - m.second, 1);
                r = i - m.first;
                if (r < 0) continue;
                dp[i] += imo[r] - imo[l - 1];
            }
            imo[i] += dp[i] + imo[i - 1];
        }
        cout << dp[n] << endl;




        return 0;
}

Measured memory_bytes: 6304
open Printf
open Scanf

let () =
  let n, q = scanf " %d %d" (fun x y -> x, y) in
  let g = Array.make n [] in
  for _ = 0 to n - 2 do
    let a, b = scanf " %d %d" (fun x y -> x - 1, y - 1) in
    g.(a) <- b :: g.(a);
    g.(b) <- a :: g.(b);
  done;
  let ans = Array.make n 0 in
  for _ = 0 to q - 1 do
    let p, x = scanf " %d %d" (fun x y -> x - 1, y) in
    ans.(p) <- ans.(p) + x;
  done;
  let rec dfs u p = g.(u) |> List.iter @@ fun v ->
    if v <> p then begin
      ans.(v) <- ans.(v) + ans.(u);
      dfs v u
    end in
  dfs 0 (-1);
  for i = 0 to n - 1 do
    printf "%d " ans.(i)
  done;
  print_newline ();

Measured memory_bytes: 35328
n=int(input())
s=input()
d={}
for i in range(n):
    if s[i] in list(d.keys()):
        d[s[i]]+=1
    else:
        d[s[i]]=1
w=1
for i in list(d.values()):
    w*=(i+1)
    w=w%(1e9+7)
if w==0:
    print(1e9+6)
else:
    print(int(w-1))


Measured memory_bytes: 3188