akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0; i<n; ++i)

int main(){
    double pi = 3.1415;
    double r;
    std::cin >> r;
    
    double ans;
    ans = 2 * pi * r;

    std::cout << ans << std::endl;
}

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

using i64 = long long;
using u64 = unsigned long long;

const int mod = (int)1e9+7;

void __print() {cerr << "]\n";}

template<typename T, typename... V>
void __print(T t, V... v)
{ cerr << t; if(sizeof...(v)) cerr << ", "; __print(v...);}

#define dbg(x...) cerr << __LINE__ << " : [" << #x << "] = ["; __print(x)


int main()
{
    string s;
    cin >> s;
    int len = s.length();
    vector<i64> dp(13, 0);
    dp[0] = 1;
    for (int i = 0; i < len; i++) {
        vector<i64> new_dp(13, 0);
        if(s[i] == '?') {
            for(int j = 0; j < 10; j++) {
                for(int k = 0; k < 13; k++) {
                    new_dp[(k*10+j)%13] += dp[k];
                    new_dp[(k*10+j)%13] %= mod;
                }
            }
            dp = new_dp;
        } else {
            for(int k = 0; k < 13; k++) {
                new_dp[(k*10+s[i]-'0')%13] += dp[k];
                new_dp[(k*10+s[i]-'0')%13] %= mod;
            }
            dp = new_dp;
        }
    }
    printf("%lld\n", dp[5]);
}


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

int main(){
  string s;cin >> s;
  int len = s.length();
  int ans = 0;
  rep(i,len)if(s[i] == '2')ans += 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
lint lcm(lint a,lint b){
      return a/__gcd(a,b)*b;
  }
    lint B1[3000];
    lint B2[3000];
  int main(){
      lint N,K;
      cin>>N>>K;
      lint ans=0;
      repp(i,1,N+1){
          lint g,f,u;
          u=(N+1)/i;
          g=i-K;
          f=(N+1)%i;
          ans+=max((lint)0,g)*u;
          ans+=max(f-K,(lint)0);
      }
      if(K==0)ans-=N;
      cout<<ans;
  }
  

Measured memory_bytes: 256
// header {{{
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <complex>
#include <utility>
#include <string>
#include <sstream>
#include <queue>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <tuple>
#include <cstdio>
#include <cmath>
using namespace std;

#define ALPHABET    (26)
#define EPS         (1e-10)
#define INF         (1000000005LL)
#define MOD         (1000000007LL)
#define EQ(a, b)    (abs((a)-(b)) < EPS)
// ciling(x/y) = (x+y-1)/y

typedef long long ll;
typedef unsigned long long ull;
// }}}

int main() {
    int n;cin >> n;
    map<int, int> m;
    for(int i=0;i<n;i++){
        int a;cin >> a;
        m[a]++;
    }
    int count = 0;
    for(auto kv : m){
        if(kv.second%2 == 0){
            count++;
        }
    }
    cout << m.size()-(count%2) << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;vector<double> v;double val;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>val;
    v.push_back(val);
  }
  sort(v.begin(),v.end());
  for(int i=0;i<(n-1);i++){
    val=(v[i]+v[i+1])/2;
    v[i]=0;
    v[i+1]=val;
  }
  cout<<val;
  return 0;}


Measured memory_bytes: 256
s = input()
n = len(s)
r = n

for i in range(26):
  c = chr(97+i)
  m = 0
  b = -1
  #p = []
  for j in range(n):
    if s[j] == c:
      #p.append(j)
      m = max(j-b,m)
      b = j
  #print(c,p)
  m = max(n-b,m)
  r = min(m,r)
print(r-1)

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

int main(){
    int a, b, c, s, t, u;
    cin >> a >> b >> c;
    if(a > b){
        s = a;
        a = b;
        b = s;
    }
    if(b > c){
        t = b;
        b = c;
        c = t;
    }
    if(a > b){
        u = a;
        a = b;
        b = u;
    }
    cout << a << " " << b << " " << c << endl;
    
    return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  cout << a.back() - a.front() << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
inline long long min(long long x,long long y){
	return x<y?x:y;
}
using namespace std;
long long a,b,f[100002],n,k,ans;
int main(){
	scanf("%lld%lld",&k,&n);
	for(int i=1;i<=k;++i)f[i]=1e18;
	f[0]=0;
	for(int i=1;i<=n;++i){
		scanf("%lld%lld",&a,&b);
		for(int j=a;j<=k;++j){
			f[j]=min(f[j],f[j-a]+b);
			
		}
		for(int j=0;j<=k;++j)if(j>=k-a)f[k]=min(f[k],f[j]+b);
	}
	printf("%lld",f[k]);
}


Measured memory_bytes: 256
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: usize,
        m: usize,
        lrs: [(u32,u32);m]
    }
    let mut ll = 0;
    let mut rr = std::u32::MAX;
    for (l,r) in lrs {
        ll = std::cmp::max(ll,l);
        rr = std::cmp::min(rr,r);
    }
    println!("{}", (ll..rr+1).len());
}


Measured memory_bytes: 6396
import java.util.Scanner;
public class Main {
	static int mod = 1000000007;
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int[][] x = new int[n][d];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < d; j++) {
				x[i][j] = sc.nextInt();
			}
		}
		int ans = 0;
		double dis = 0;
		for(int i = 0; i < n; i++) {
			for(int j = i+1; j < n; j++) {
				dis = 0;
				for(int k = 0; k < d; k++) {
					dis += Math.abs(x[i][k]-x[j][k]) * Math.abs(x[i][k]-x[j][k]);
				}
				if(Math.sqrt(dis) == (int)Math.sqrt(dis)) {
					ans ++;
				}
			}
		}
		System.out.println(ans);
		sc.close();
		
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<map>

using namespace std;
const int mod = 1000000007;

int add(int a, int b)
{
	int c = a + b;
	if (c >= mod)c -= mod;
	return c;
}

int dif(int a, int b)
{
	int c = a - b;
	if (c < 0)c += mod;
	return c;
}

int mlt(int a, int b)
{
	long long c = a * 1LL * b;
	return c % mod;
}

int bp(int a, int b)
{
	if (b == 0)return 1;
	if (b % 2 == 0)
	{
		int val = bp(a, b / 2);
		return mlt(val, val);
	}
	if (b % 2 == 1)
	{
		int val = bp(a, b - 1);
		return mlt(val, a);
	}
}

int inv(int a)
{
	return bp(a, mod - 2);
}

int ibit(int mask, int i)
{
	return (mask >> i) % 2;
}

void outp(vector<vector<int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		for (int j = 0; j < v[i].size(); j++)cout << v[i][j] << ' ';
		cout << endl;
	}
	cout << endl;
}
void iter(vector<int>&v)
{
	int n=v.size();
	vector<int>sfadd(n);
	for(int i=0; i<n; i++)
	{
		int val=i-v[i];
		if(val>=0)
			sfadd[val]++;
		else sfadd[0]++;
		val=i+v[i];
		if(val+1<n)
			sfadd[val+1]--;
	}
	vector<int>cr(n);
	cr[0]=sfadd[0];
	for(int i=1; i<n; i++)
		cr[i]=cr[i-1]+sfadd[i];
	v=cr;
}
int main()
{
	int n, k;
	cin>>n>>k;
	vector<int>pow(n);
	for(int i=0; i<n; i++)cin>>pow[i];
	if(k<40)
	{
		for (int i = 1; i <= k; i++)
		{
			iter(pow);
		}
		for(int i=0; i<n; i++)cout<<pow[i]<<' ';
		cout<<endl;
	}
	else{
		for(int i=0; i<n; i++)cout<<n<<' ';
		cout<<endl;
	}
}

Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007
int main(){
	fast;
	ll n;
	cin>>n;
	ll arr[n];
	ll ans[2],k=0;
	unordered_map<int,int> mp;
	set<int> s;
	for(int i=0;i<n;i++)
		cin>>arr[i],mp[arr[i]]++,s.insert(arr[i]);
	sort(arr,arr+n);
	ll m=s.size();
	if(!(n>=(m+2)))
	{
		cout<<"0";
		return 0;
	}
	for(int i=n-1;i>=0&&k<2;i--)
	{
		if(mp[arr[i]]>=2)
			ans[k]=arr[i],mp[arr[i]]-=2,k++;
	}
	cout<<ans[0]*ans[1];
	return 0;
}



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

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007

using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
/*ios_base::sync_with_stdio(false);cin.tie(0);*/

ll gcd(ll n,ll m){
    if (n==0)return m;
    return gcd(m%n,n) ;
}

long long fast_exp(long long n,long long k){
    if(k == 0)
        return 1;
    if(k==1)
        return n;

    long long temp = fast_exp(n,k>>1);

    if((k&1)==1)
        return (n*temp*temp)%SIZE;
    return (temp*temp)%SIZE;

}

int main() {
   ll t;
   cin >> t;
    t= fast_exp(t,3);
    cout << t;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	int A[100][100]={};
	int B[100]={};
	int C[100]={};
	int i,j;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&A[i][j]);
		}
	}
	for(i=0;i<m;i++){
		scanf("%d",&B[i]);
	}
	for(j=0;j<n;j++){
		
		for(i=0;i<m;i++){
			C[j] += A[j][i]*B[i];
		}
		printf("%d\n",C[j]);
	}
	return 0;
}

Measured memory_bytes: 648
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let n: isize = read().unwrap();
    let k: isize = read().unwrap();
    let mut total = 0;
    for k_i in k..n + 2 {
        let x: isize = (n - k_i + 1) * k_i + 1;
        total += x;
    }
    println!("{}", total % (10_isize.pow(9) + 7));
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define mid (tl+tr)/2
#define mod 1000000007
#define fain(arr) for(int i=0;i<n;i++)cin>>arr[i];
#define all(x) x.begin(),x.end()
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bugv(n1) if(DEBUG)cout<<#n1<<" is "<<n1<<'\n';
#define buga(A) cout<<#A<<" is :"<<endl ; for(auto x:A)cout<<x<<" "; cout<<endl;
#define FILE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ll long long 
#define pii pair<int,int>
#define pll pair<long long ,long long >
#define pi acos(-1)
#define sz(x) ((int)x.size())
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define DEBUG true
using namespace std;

int main() {
  // FILE;
  SPEED;
  int n;
  cin>>n; 
  int A[n];
  int B[n];
  int C[n];

  rep(i,0,n){
    cin>>A[i];
    cin>>B[i];
    cin>>C[i];
  }

  int dp[n][3];

  dp[n-1][0]=max({B[n-1],C[n-1]});
  dp[n-1][1]=max({A[n-1],C[n-1]});
  dp[n-1][2]=max({B[n-1],A[n-1]});
  
  for(int i=n-2;i>=0;i--){

    //dp[n-2][0]
    int a1 = B[i]+dp[i+1][1];
    int a2 = C[i]+dp[i+1][2];
    int a3 = A[i]+dp[i+1][0];
    // bugv(a1);
    // bugv(a2);
    // bugv(a3);
    dp[i][0]=max(a1,a2);
    dp[i][1]=max(a2,a3);
    dp[i][2]=max(a1,a3);

  }

  // bugv(dp[0][0]);
  // bugv(dp[0][1]);
  // bugv(dp[0][2]);

  cout<<max({dp[0][0],dp[0][1],dp[0][2]})<<endl;
   

}

Measured memory_bytes: 2560
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#define size 300010
#define ll long long
#define db double
#define il inline
#define rint register int
#define gc getchar()
#define rep(i,s,n) for (register int i=s;i<=n;i++)
#define sro_zyb_orz int main()

using namespace std;

il ll r()
{
	char c; ll x,f=1;
	for (c=gc;!isdigit(c);c=gc) if (c=='-') f=-1; x=c-'0';
	for (c=gc;isdigit(c);c=gc) x=x*10+c-'0'; return x*f;
}

int c[5][5];


sro_zyb_orz
{
	rep(i,1,3) rep(j,1,3) c[i][j]=r();
	if (c[1][1]+c[2][2]+c[3][3]==c[1][3]+c[2][2]+c[3][1]
	&&c[1][3]+c[2][2]+c[3][1]==c[1][2]+c[2][3]+c[3][1]
	&&c[1][2]+c[2][3]+c[3][1]==c[1][3]+c[2][1]+c[3][2]) 
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}



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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecd               vector<double>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------

int main(void) {
  int d;
  cin >> d;
  arrll(c,26);
  vecll2(s, d, 26);
  rep(i,d){
    rep(j,26){
      cin >> s[i][j];
    }
  }

  srand(time(NULL));

  vecll human(26);
  vecll last(26);

  vecll ans;

  rep(i,d){
    ans.pb(rand()%26+1);
  }

  rep(i,d){
    prt(ans[i]);
  }
}


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

int main() {
	int N;
	cin>>N;
	vector<int> A(N);
	for (int i=0;i<N;i++) cin>>A[i];
	vector<int> rev(N);
	for(int i=0;i<N;i++) rev[A[i]-1]=i+1;
	for(int i=0;i<N;i++) cout<<rev[i]<<endl;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
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;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    rep2(i,1,10) rep2(j,1,10) {
        if(i*j == n) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr ll INF = 1ll << 55;

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

// multi-dimensional vector (require c++14)
template <typename T, typename U>
static inline vector<U> make_nd_vector(T &&n, U &&val) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<U>(forward<T>(n), forward<U>(val));
}
template <typename T, typename... Args>
static inline decltype(auto) make_nd_vector(T &&n, Args &&... args) noexcept {
  static_assert(is_integral<T>::value,
                "[make_nd_vector] 1st argument must be an integer type");
  return vector<decltype(make_nd_vector(forward<Args>(args)...))>(
      forward<T>(n), make_nd_vector(forward<Args>(args)...));
}
//
// Print from Iterator
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
//
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> has_treat(n, false);
  for (int i = 0; i < k; i++) {
    int d;
    cin >> d;
    for (int j = 0; j < d; j++) {
      int a;
      cin >> a;
      a--;
      has_treat[a] = true;
    }
  }
  int ans = 0;
  for (auto i : has_treat) {
    if (!i) {
      ans++;
    }
  }
  cout << ans << endl;
}


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

string s;
int n;

int main() {
	cin >> s;
	n = s.size();
	for (int i = 0; i < n - 1; ++i)
		for (int j = i + 1; j < i + 3 && j < n; ++j)
			if (s[j] == s[i]) {
				cout << i + 1 << ' ' << j + 1 << endl;
				return 0;
			}
	cout << "-1 -1" << endl;
}


Measured memory_bytes: 3720
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#define MOD 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
signed main(){
    string s;
    cin>>s;
    int ans=0;
    stack<string> b;
    b.push("");
    bool fin=false;
    for(int i=0;i<s.size();i+=0){
        int c=1;
        while(1){
            if(s.substr(i,c)!=b.top()){
                b.push(s.substr(i,c));
                i+=c;
                c=1;
                ans++;
                break;
            }else{
                c++;
                if(c+i-1>=s.size()){
                    ans++;
                    string k=s.substr(i,(ll)s.size()-i);
                    while(s.substr(i,(ll)s.size()-i)==b.top()){
                        ans--;
                        k+=b.top();
                        b.pop();
                    }
                    fin=true;
                    break;
                }
            }
        }
        if(fin)break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11012
N = gets.to_i
A = gets.split.map(&:to_i)

sorted = A.sort.reverse

previous = sorted[0]

num = 0
found = []
sorted[1..-1].each do |a|
  if previous == a
    num += 1
    found << a
    previous = -1
  else
    previous = a
  end

  if num == 2
    break
  end
end

if found.size == 2
  puts found.reduce(:*)
else
  puts 0
end


Measured memory_bytes: 10112
input_value = input().split()
x = int(input_value[0])
a = int(input_value[1])
b = int(input_value[2])

distance_from_x_to_a = abs(x-a)
distance_from_x_to_b = abs(x-b)

if distance_from_x_to_a < distance_from_x_to_b:
	print("A")
else:
	print("B")


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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) int(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }

//ll f[200005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }


int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((a + d - 1) / d >= (c + b - 1) / b)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)

string S;

ll ans;

int main(void){
	cin>>S;
	int n = S.size();

	ans = INF;
	for (int k = 0; k + 1 < n; k++) {
		if (S[k] != S[k + 1]) {
			ll tmp = max(k + 1, n - (k + 1));
			ans = min(ans, tmp);
		}
	}

	if (ans == INF) ans = n;

	cout<< ans <<endl;
	
	return 0;
}

Measured memory_bytes: 512
main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  let as = if odd n
             then [[i, n - i] | i <- [1 .. n `div` 2]]
             else let n' = n `div` 2
                      n'' = (n' + 1) `div` 2
                  in [[i, n - i] | i <- [1 .. n'' - 1]] ++ [[i, n + 1 - i] | i <- [n'' + 1 .. n']]
  putStr $ unlines $ map (unwords . map show) $ take m as

Measured memory_bytes: 4996
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int x;
    cin>>x;
    int h=0;
    int c=0;
    int m[n];
    for(int i=0;i<n;i++)
    {
        cin>>m[i];
        c+=m[i];   
    }
    h=m[0]; 
    for(int i=0;i<n;i++)
    {
        h=min(h,m[i]);
    }
    cout<<n+(x-c)/h;
     return 0;
}
    

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    // int N = scanner.nextInt();
    // scanner.nextLine();
    // int[] n = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    static void solve(Scanner scanner) {
        int H = scanner.nextInt(), W = scanner.nextInt(), N = scanner.nextInt();
        scanner.nextLine();
        int[] a = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        Deque<Integer> q = new ArrayDeque<>();
        boolean reverse = false;
        int index = 0;
        int cnt = 0;
        while (index < a.length) {
            while (cnt < W && a[index] > 0) {
                q.addLast(index + 1);
                cnt++;
                a[index]--;
            }
            if (cnt == W) {
                StringBuilder sb = new StringBuilder();
                while (!q.isEmpty()) {
                    if (reverse) {
                        sb.append(q.pollLast());
                    } else {
                        sb.append(q.pollFirst());
                    }
                    sb.append(' ');
                }
                System.out.println(sb.toString().trim());
                q.clear();
                cnt = 0;
                reverse = !reverse;
            }
            if (a[index] == 0) {
                index++;
            }
        }
    }
}


Measured memory_bytes: 29244
import random

class maps(object):
    def __init__(self):
        self.readinputs()

    # recieve |V| and |E|
    def readinputs(self):
        self.V, self.E = map(int, input().split())
        self.es = [[] for i in range(self.V)]
        self.Mes = [[0]*self.V for i in range(self.V)]

        for _ in range(self.E):
            # recieve edges
            a, b, c = map(int, input().split())
            a, b = a-1, b-1
            self.es[a].append((b,c))
            self.es[b].append((a,c))
            self.Mes[a][b] = c
            self.Mes[b][a] = c

        self.T = int(input())

        # recieve info
        self.info = [[] for i in range(self.T)]
        for t in range(self.T):
            Nnew = int(input())
            for _ in range(Nnew):
                new_id, dst = map(int, input().split())
                self.info[t].append((new_id, dst))

    def random_walk(self):
        where = [('v', 0)] # ('e',from,to,dist)

        self.path = [0]*self.T
        for t in range(self.T):
            now_where = where[-1]
            if now_where[0] == 'v':
                to, dist = random.choice(self.es[now_where[1]])
                # to, dist = self.es[now_where[1]][n]
                self.path[t] = to
                if dist == 1:
                    where.append(('v', to))
                else:
                    where.append(('e', now_where[1], to, 1))
            elif now_where[0] == 'e':
                now_where = where[-1]
                # num = random.randint(0,1)
                if True :
                    self.path[t] = now_where[2]
                    if now_where[3] + 1 < self.Mes[now_where[1]][now_where[2]]:
                        where.append(('e', now_where[1], now_where[2], now_where[3] + 1))
                    elif now_where[3] + 1 == self.Mes[now_where[1]][now_where[2]]:
                        where.append(('v', now_where[2]))
                    else:
                        # ココの分岐に来ることはありえない。
                        pass

                else:
                    self.path[t] = now_where[1]
                    if now_where[3] - 1 > 0:
                        where.append(('e', now_where[1], now_where[2], now_where[3] - 1))
                    elif now_where[3] - 1 == 0:
                        where.append(('v', now_where[1]))
                    else:
                        # ココの分岐に来ることはありえない。
                        pass
            else:
                # ココの分岐に来ることはありえない。
                pass

    def output(self):
        for t in range(self.T) :
            print(self.path[t] + 1)

if __name__ == "__main__":
    M = maps()
    M.random_walk()
    M.output()


Measured memory_bytes: 8056
#include<iostream>
#include<string>
using namespace std;
int main(){
    std::string S;
    cin >> S;
    int num= atoi(S.c_str());

    
    
    int n=0;
    for(int i=0;S[i]!=NULL;i++){
        n++;
    }
    
    
    int s=0;
    int g=0;
    for(int j=0;j<n;j++){
        char ch = S[j];
        g += (int)(ch - '0');
    }

    
    if(num%g==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
l=raw_input()
k=l.split()
H=int(k[0])
W=int(k[1])
while True:
        if H+W==0:
                break
        else:
                for i in range(H):
                        print "#"*W
                print ""
                l=raw_input()
                k=l.split()
                H=int(k[0])
                W=int(k[1])

Measured memory_bytes: 6428
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s;
	int counter=0;
	cin >> s;
	if (s[0] == '1') counter++;
	if (s[1] == '1') counter++;
	if (s[2] == '1') ++counter;

	cout << counter<< endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;

int main() {
  int a,b,c;
  cin >>a>>b>>c;
  if(a==b && b!=c) cout <<"Yes" <<endl;
  else if(a!=b && b==c) cout <<"Yes" <<endl;
  else if(a!=b && a==c) cout <<"Yes" <<endl;
  else cout << "No" << endl;
  
}

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

void solve(long long sx, long long sy, long long tx, long long ty) {
    string S = "";
    long long dy = abs(ty - sy), dx = abs(tx - sx);
    S += string(dy, 'U') + string(dx, 'R') + string(dy, 'D') + string(dx, 'L') + 'L' + string(dy + 1, 'U') +
         string(dx + 1, 'R') + 'D' + 'R' + string(dy + 1, 'D') + string(dx + 1, 'L') + 'U';
    cout << S << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long sx;
    scanf("%lld", &sx);
    long long sy;
    scanf("%lld", &sy);
    long long tx;
    scanf("%lld", &tx);
    long long ty;
    scanf("%lld", &ty);
    solve(sx, sy, tx, ty);
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
const int mod = 1000000007;
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> inv(31);
	inv[1] = 1;
	for (int i = 2; i <= 30; ++i) inv[i] = (long long)(inv[mod % i]) * (mod - mod / i) % mod;
	int ans = 1;
	for (int i = 2; i * i <= M; ++i) {
		int cnt = 0;
		while (M % i == 0) {
			M /= i;
			++cnt;
		}
		for (int j = 0; j < cnt; ++j) {
			ans = (long long)ans * (N + j) % mod * inv[j + 1] % mod;
		}
	}
	if (M != 1) {
		ans = (long long)ans * N % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;

    while(cin >> n, n){
        int floor[35] = {0};
        floor[0] = 1;
        range(i, 1, n+1){
            if(i >= 1) floor[i] += floor[i - 1];
            if(i >= 2) floor[i] += floor[i - 2];
            if(i >= 3) floor[i] += floor[i - 3];
        }
        cout << floor[n] / 3650 + 1 << endl;
    }

}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        scanner.nextInt();
        scanner.nextInt();
        scanner.nextInt();
        final int n = scanner.nextInt();
        System.out.println(n == 1 ? 1 : 0);
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const int M=3010;
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	long long ret=0;
	long long ks=1;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		printf("? %d %d %d %d\n",i,j,i,j);
		fflush(stdout);
		int t;
		scanf("%d",&t);
		if(t)ret=(ret+ks)%d;
		ks=ks*2%d;
	}
	char *p = new char[199900000];
	for(int i=0;i<199900000;i++)p[i]='e';
	printf("! %lld\n",ret);
}

Measured memory_bytes: 195924
#include<bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,sse4.1,sse4.2,popcnt,abm,mmx,avx")
#pragma comment(linker,"/STACK:102400000,102400000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
using namespace std;
inline int read()
{
	int ret=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-') w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return w*ret;
}
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22) cout<<"bust"<<endl;
	else cout<<"win"<<endl; 
	return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val (s, t) = readLine()!!.split(' ')
    val ans = mutableListOf<Char>()

    (0 until n).forEach {
        ans.add(s[it])
        ans.add(t[it])
    }
    println(ans.joinToString(""))
}

Measured memory_bytes: 38368
use std::collections::HashMap;
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
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")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let l = read::<usize>();

    let mut street = vec![0; n];
    let mut train = vec![0; n];

    for i in 0..n {
        street[i] = i;
        train[i] = i
    }

    let mut street_rank = vec![0; n];
    let mut train_rank = vec![0; n];

    for _ in 0..k {
        let (a, b) = (read::<usize>(), read::<usize>());
        unite(&mut street, &mut street_rank, a - 1, b - 1)
    }

    for _ in 0..l {
        let (a, b) = (read::<usize>(), read::<usize>());
        unite(&mut train, &mut train_rank, a - 1, b - 1)
    }

    let mut map: HashMap<(usize, usize), usize> = HashMap::new();
    for i in 0..n {
        let s = find(&street, i);
        let t = find(&train, i);
        let v = map.entry((s, t)).or_insert(0);
        *v += 1;
    }

    for i in 0..n {
        let s = find(&street, i);
        let t = find(&train, i);
        println!("{}", map.get(&(s, t)).unwrap())
    }

    fn find(parent: &Vec<usize>, x: usize) -> usize {
        let p = parent[x];
        if p == x {
            x
        } else {
            find(parent, parent[x])
        }
    }

    fn unite(parent: &mut Vec<usize>, rank: &mut Vec<usize>, a: usize, b: usize) {
        let root_a = find(parent, a);
        let root_b = find(parent, b);
        if rank[root_a] < rank[root_b] {
            parent[root_a] = root_b
        } else if rank[root_a] > rank[root_b] {
            parent[root_b] = root_a
        } else {
            parent[root_b] = root_a;
            rank[root_a] += 1
        }
    }
}


Measured memory_bytes: 26916
#include <stdio.h>
#include <stdlib.h>
int main(){
  int *A,*B,i,n,k,max=-1;
  scanf("%d",&n);
  A=malloc(sizeof(int)*(n+2));
  B=malloc(sizeof(int)*(n+2));
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i]>max)max=A[i];
   
  }
  int *C=malloc(sizeof(int)*(max+2));
  
  for(i=0;i<=max;i++)C[i]=0;
  for(i=0;i<n;i++)C[A[i]]++;
  int j=0;
  i=0;
  while(1){
    if(j==max+1)break;
      if(C[j]==0){
      j++;
      continue;
    }
    B[i]=j;
    C[j]--;
     i++;
  }
  for(i=0;i<n;i++){
    printf("%d",B[i]);
    if(i!=n-1)printf(" ");
    else printf("\n");
  }
  return 0;
}



Measured memory_bytes: 17412
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using P = pair<int, int>;

signed main() {

    int n, m;
    cin >> n >> m;

    int sum = 0;
    vector<int> a(m);
    rep(i, m){
       cin >> a[i];
       sum += a[i];
    }

    if(sum > n){
        cout << -1 << endl;
        return 0;
    }

    cout << n - sum << endl;

    return 0;
}


Measured memory_bytes: 3708
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            int[] v = new int[n];

            for (int i = 0; i < n; i++) v[i] = int.Parse(Console.ReadLine());

            Console.WriteLine(v.Average());
        }
    }
}

Measured memory_bytes: 9756
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e13
typedef long long ll;
using namespace std;

ll max(ll a,ll b){
	return (a>b)?a:b;
}

ll min(ll a,ll b){
	return (a<b)?a:b;
}

int main(){
	int n;
	ll limit;
	cin>>n>>limit;
	ll w[n],v[n];
	ll dp[n+1][100001];
	rep(i,n)cin>>w[i]>>v[i];
	rep(i,n+1)rep(j,100001)dp[i][j]=INF;
	dp[0][0]=0;
	rep(i,n){
		rep(j,100001){
			if(j+v[i]<100001)dp[i+1][j+v[i]]=min(dp[i+1][j+v[i]],dp[i][j]+w[i]);
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
		}
	}
	ll ans=0;
	rep(i,100001){
		if(dp[n][i]<=limit)ans=max(ans,i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 79104
class UnionFind:
    def __init__(self, size: int):
        self.__size = size
        self.__root = [-1] * size

    def root(self, x: int)->int:
        if self.__root[x] < 0:
            return x
        self.__root[x] = self.root(self.__root[x])
        return self.__root[x]

    def size(self, x: int)->int:
        root = self.root(x)
        return self.__root[root]

    def same(self, x: int, y: int)->bool:
        return self.root(x) == self.root(y)

    def unite(self, x: int, y: int):
        rx, ry = self.root(x), self.root(y)

        if rx == ry:
            return

        if ry < rx:
            rx, ry = ry, rx

        self.__root[rx] += self.__root[ry]
        self.__root[ry] = rx


def connectivity(N: int, K: int, L: int, roads: list, rails: list)->list:
    road_uf, rail_uf = UnionFind(N), UnionFind(N)

    for p, q in roads:
        road_uf.unite(p-1, q-1)

    for r, s in rails:
        rail_uf.unite(r-1, s-1)

    freq = {}
    for i in range(N):
        p = (road_uf.root(i), rail_uf.root(i))
        freq.setdefault(p, 0)
        freq[p] += 1

    return [freq[(road_uf.root(i), rail_uf.root(i))] for i in range(N)]


if __name__ == "__main__":
    K = 0
    L = 0
    N, K, L = map(int, input().split())
    roads = [tuple(int(s) for s in input().split()) for _ in range(K)]
    rails = [tuple(int(s) for s in input().split()) for _ in range(L)]
    ans = connectivity(N, K, L, roads, rails)
    print(' '.join(map(str, ans)))


Measured memory_bytes: 65372
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i;
        int j;
        int k;
        while (true) {
            int count = 0;
            int n = sc.nextInt();
            int a = sc.nextInt();
            if (a == 0 && n == 0) {
                break;
            } else {
                for (i = 1; i < n + 1; i++) {
                    for (j = i+1; j < n + 1; j++) {
                        for (k = j+1; k < n + 1; k++) {
                            if (i + j + k == a) {
                                count = count + 1;
                            }
                        }
                    }
                }System.out.println(count);
            }
        }
    }
}


Measured memory_bytes: 26540
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(a,b);
  Vi h(a+10000);
  VIN(h)
  int dp[a+10000];
  REP(i,a) dp[i] = INF;
  dp[0] = 0;
  REP(i,a){
    FOR(j,1,b+1){
      chmin(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
  }
  OUT(dp[a-1]);
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int k; cin >> k;
	cout << 50 << endl;
	rep(i, 50) {
		if (k <= i)cout << 0 << " ";
		else {
			cout << 50 + (k - i - 1) / 50 - (k - i - 1) % 50 << " ";
		}
	}
	cout << endl;
}


Measured memory_bytes: 256