akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)

int main(int argc, char **argv)
{
  map<int, int> mode;
  int i;
  for (;;) {
    cin >> i;
    if (cin.eof())
      break;

    mode[i]++;
  }

  int m = 0;
  tr(mode, i) {
    m = max(i->second, m);
  }
  tr(mode, i) {
    if (i->second == m)
      cout << i->first << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    vector<int> pre(n + 1);
    for (int i = 0; i < n; i++){
        pre[i + 1] = pre[i] + a[i];
    }
    int mn = 1e9 + 5;
    for (int i = 1; i < n; i++){
        int s1 = pre[i];
        int s2 = sum - pre[i];
        if (abs(s1 - s2) < mn){
            mn = abs(s1 - s2);
        }
    }
    cout << mn;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -(1e18)
#define inf 1e18
#define f first
#define se second
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds; 
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw;pw = pw*pw;ex>>=1;}return ans;}
ll pwm(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
template<typename T> using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//st.order_of_key(num)->number of elements < num
//st.find_by_order(i)->iterator of ith element in sorted order starting from zero
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define int long long int
//Binary_Search->dp->greedy
//auto check = [&](ll x){};
//function<long long(int)> choose2 = [&](int n) {};
void solve(){
	ll n,m,k;
	cin>>n>>m>>k;
	ll ans=0;
	const ll nax=2e5;
	vl fac(nax);
	fac[0]=1;
	for(ll i=1;i<=nax;i++) fac[i]=fac[i-1]*i%mod;
	ll alw=(fac[n*m-2]*mi(fac[k-2],mod)%mod)*mi(fac[n*m-k],mod)%mod;
	for(int dis=1;dis<n;dis++){
		ll tol=m*m%mod;
		tol=tol*(n-dis)%mod;
		tol=tol*dis%mod;
		tol=tol*alw%mod;
		ans=(ans+tol)%mod;
	}
	for(int dis=1;dis<m;dis++){
		ll tol=n*n%mod;
		tol=tol*(m-dis)%mod;
		tol=tol*dis%mod;
		tol=tol*alw%mod;
		ans=(ans+tol)%mod;
	}
	cout<<ans<<endl;
	
	
	
	
}
int main(){
int t=1;
//scanf("%d",&t);
while(t--){
	solve();
}
return 0;
}    

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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    while(a>=b){
        b <<= 1;
        k--;
    }
    while(b>=c){
        c <<= 1;
        k--;
    }
    if (k >= 0) puts("Yes");
    else
        puts("No");
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
	P ans;
	double now = -1.0;
	for (int i = 0; i * a * 100 <= f; i++) {
		for (int j = 0; (i + a + j * b) * 100 <= f; j++) {
			if (i + j == 0)continue;
			int w = (i*a + j * b) * 100;
			int ms = min(f - w, e*w / 100);
			for (int k = 0; k * c <= ms; k++) {
				int l = (ms - k * c) / d;
				int s = k * c + l * d;
				if (now < 100.0  * s / (s + w)) {
					now = 100.0*s / (s + w);
					ans = P(s + w, s);
				}
			}
		}
	}
	cout << ans.first << " " << ans.second << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<=9&&b<=9){
    cout<<a*b<<endl;
  }
  else if(a>=10||b>=10){
    cout<<"-1"<<endl;
  }
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

map<int, int> ma;

int main() {
    ios_base::sync_with_stdio(false);
    int cnt;
    cin >> cnt;
    forn(i, cnt) {
        int x;
        cin >> x;
        ++ma[x];
    }
    cin >> cnt;
    forn(i, cnt) {
        int x;
        cin >> x;
        auto it = ma.find(x);
        if (it == ma.end() || !it->second) {
            cout << "NO" << endl;
            return 0;
        }
        --it->second;
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    
    int n;
    cin >> n;
    vl a(n);
    rep (i, n) {
        cin >> a[i];
    }
    
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] < a[i - 1]) {
            ll diff = a[i - 1] - a[i];
            ans += diff;
            a[i] += diff;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e5 + 10;

int N;

bool judge(int x) {
    while (x) {
        if ((x % 10) == 7) return true;
        x /= 10;
    }
    return false;
}

int main() {
#ifdef ACM_LOCAL
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
#endif
    scanf("%d", &N);
    printf("%s\n", judge(N) ? "Yes" : "No");



    return 0;
}

Measured memory_bytes: 3760
H, W = list(map(int,input().split()))


def main(H, W, S):  #2つに分割、Sと比較して答えを返す。
    S1 = S
    if H % 2 == 0 or W % 2 == 0:
        S2 = H * W / 2

        if S2 < S1: 
            return S1 - S2
        else:
            return S2 - S1

    else:
        S2 = max(int(H/2) * W, H * int(W/2))  
        S3 = H * W - S2
        # S2 < S3
        if S1 < S2:
            return S3 - S1
        elif S3 < S1:
            return S1 - S2
        else:
            return S3 - S2

def f(H,W):
    ans = H * W

    for S1_H in range(1, H):    #1 ~ n-1
        temp = int(main(H - S1_H, W, S1_H * W))
        if temp == 0:
            return 0
        elif temp < ans:
            ans = temp

    for S1_W in range(1, W):    #1 ~ n-1
        temp = int(main(H, W - S1_W, S1_W * H))
        if temp == 0:
            return 0
        elif temp < ans:
            ans = temp

    return ans

print(f(H,W))




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
typedef long long int LL;
const int MAX = 105;
const int INF = 1e9;

int N, M;
int dp[1001][9000];
int A[1001], B[1001];
int total;

int compute (int x, int val) {
	if (x == M) {
		if (val == total)
			return 0;
		return INF;
	}
	if (dp[x][val] != -1)
		return dp[x][val];
	int a = compute (x + 1, val);
	int b = compute (x + 1, val | B[x]) + A[x];
	dp[x][val] = min(a, b);
	return dp[x][val];
}


int main() {
	memset (dp, -1, sizeof dp);
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		total = total | (1 << i);
	}
	for (int i = 0; i < M; i++) {
		cin >> A[i];
		int b, x, val = 0;
		cin >> b;
		for (int j = 0; j < b; j++) {
			cin >> x;
			x--;
			val = val | (1 << x); 
		}
		B[i] = val;
	}
	int ans = compute(0, 0);
	if (ans == INF)
		printf ("-1\n");
	else printf ("%d\n", ans);	
	return 0;
}

Measured memory_bytes: 35456
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

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

fn main() {
    input!{
      n: usize,
      m: usize,
      xys: [(usize, usize); m],
    }

    let mut edges = vec![vec![]; n];
    let mut h = vec![0; n];
    for &(x, y) in xys.iter() {
        edges[x-1].push(y-1);
        h[y-1] += 1;
    }

    let mut st = Vec::new();
    for i in 0..edges.len() {
        if h[i] == 0 {
            st.push(i);
        }
    }

    let mut nodes = vec![];
    while let Some(i) = st.pop() {
        nodes.push(i);
        for &t in edges[i].iter() {
            h[t] -= 1;
            if h[t] == 0 {
                st.push(t);
            }
        }
    }
    let mut dp = vec![0; n];

    for &i in nodes.iter() {
        for &t in edges[i].iter() {
            dp[t] = max(dp[t], dp[i]+1);
        }
    }
    println!("{}", dp.iter().max().unwrap());
}


Measured memory_bytes: 14588
#include <bits/stdc++.h>
using namespace std;
int main(){
    vector<int>p;
    int N;
    cin>>N;
    int sum=0;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        sum+=a;
        p.push_back(a);
    }
    cout<<sum-*max_element(p.begin(),p.end())/2<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int N;
  cin>>N;
  vector<int64_t>a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  int cnt=0;
  for(int i=0;i<N;i++){
    int64_t k=a[i];
    while(k%2==0){
      cnt++;
      k/=2;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3736
/**
 *    author:  tourist
 *    created: 17.08.2019 15:23:18       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = (int) s.size();
  const int K = 10;
  vector<vector<int>> dp(n + 1, vector<int>(K + 1, -1));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= K; j++) {
      if (dp[i][j] == -1) {
        continue;
      }
      for (int k = 1; k <= K && i + k <= n; k++) {
        if (j != k || s.substr(i - j, j) != s.substr(i, k)) {
          dp[i + k][k] = max(dp[i + k][k], dp[i][j] + 1);
        }
      }
    }
  }
  int ans = 0;
  for (int j = 0; j <= K; j++) {
    ans = max(ans, dp[n][j]);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 19732
#include <cstdio>

using namespace std;

char s[600][301];

int main() {
    int n, ans = 0, i, j, k;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%s", s[i]);
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) s[i + n][j] = s[i][j];
    }
    
    for (i = 0; i < n; i++) {
        bool f = true;
        
        for (j = 0; j < n; j++) {
            for (k = 0; k < n; k++) {
                if (s[i + j][k] != s[i + k][j]) {
                    f = false;
                    break;
                }
            }
        }
        
        if (f) ans += n;
    }
    
    printf("%d\n", ans);
    
    return 0;
}


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

void textIO()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}


int main()
{
    textIO();
    fastIO();

    long long n, m, k, ans = 0;
    cin >> n >> m >> k;
    vector<long long> f(n), s(m);

    for(int i=0;i<n;i++){
        cin >> f[i];
    }

    for(int i=0;i<m;i++){
        cin >> s[i];
    }

    long long i = 0, j = 0, cnt = 0;

    while(k-f[i] >= 0 && i<n){
        k-=f[i];
        i++;
        cnt++;
    }

    i--;

    ans = max(cnt, ans);

    while(j<m){
        while(k-s[j] >= 0 && j<m){
            k-=s[j];
            j++;
            cnt++;
        }
        ans = max(ans, cnt);

        if(i>=0){
            k+=f[i];
            i--;
            cnt--;
        }
        else{
            break;
        }
    }

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


Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define INF 100000000000000000ll
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() {
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ull n,k;
    cin>>n>>k;
    ull a[n+1];
    bool vis[n+1];
    for (int i = 1; i<=n; ++i)
    {
        vis[i]=false;
        cin>>a[i];
    }

    ull poi=1;
    vector<ll> path;
    ull fg=0;
    while(vis[poi]==false)
    {
        if(k==0){
            fg=1;
            break;
        }
        vis[poi]=true;
        k--;
        path.push_back(poi);
        poi=a[poi];
    }

    if(fg==1){
        cout<<poi;
    }
    else{
        ll pointer=0;
        // Now I'm at a certain point already in vector
        for (int i = 0; i < path.size(); ++i)
        {
            if(poi==path[i]){
                pointer=i;
                break;
            }
        }
        vector<ll> pa;
        for (int i = pointer; i < path.size(); ++i)
        {
            pa.push_back(path[i]);
        }
        // vahan se path repeat hoga, to puraane uda diye
        ull rep = pa.size();
        ull rem = k%rep;
        cout<<pa[rem];
    }

    return 0;
}


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

int main() {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);

      int a,b;
      cin >> a >> b;

      if(a<=0 && b>=0) cout << "Zero";
      else if(a>0 && b>0) cout << "Positive";
      else if(a<0 && b<0) {
            if((b-a-1)%2 == 0) cout << "Positive"; // b-a to make positive
            else cout << "Negative";
      }
}

Measured memory_bytes: 3080
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn( new FileInputStream("src/aoj0023/input.txt"));	
			System.setOut( new PrintStream( new FileOutputStream("src/aoj0023/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}
	void run() {
		Scanner sc = new Scanner(System.in);
		for (int N = sc.nextInt(); N > 0; N--) {
			System.out.println(solve(sc.nextDouble(),sc.nextDouble(),sc.nextDouble(),
					sc.nextDouble(),sc.nextDouble(),sc.nextDouble()));
		}
	}
	
	double EPS = 1e-8;

	int solve(double xa, double ya, double ra, double xb, double yb, double rb) {
		double dist = hypot(xa - xb, ya - yb);
		if (dist > ra + rb + EPS)
			return 0;
		else if (ra > rb) {
			if (dist + rb < ra)
				return 2;
		} else if (ra < rb) {
			if (dist + ra < rb)
				return -2;
		}
		return 1;
	}
	
	void debug(Object...os) {
		System.err.println(deepToString(os));
	} 
}

Measured memory_bytes: 12000
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = input()
    if N[-1] in "24579":
        print("hon")
    elif N[-1] in "0168":
        print("pon")
    else:
        print("bon")


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9848
#include <cstdio>
using namespace std;


int a[10];
long n;

int main(){
	while (scanf("%ld", &n) != EOF)
	{
		for (int i = 9; i >= 0; i--) {
			a[i] = n % 10;
			n /= 10;
		}
		for (int i = 9; i > 0; i--) {
			for (int j = 0; j < i; j++) {
				a[j] = (a[j] + a[j + 1]) % 10;
			}
		}
		printf("%d\n", a[0]);
	}

	return 0;
}

Measured memory_bytes: 2668
#include<cstdio>
bool v[3002][3002][3];
int l[3002][3002];
char s[3002],t[3002],u[3000];
int main(){
  scanf("%s%s",s+1,t+1);
  int sl=1,tl=1;
  while(s[sl]!='\0')sl++;
  while(t[tl]!='\0')tl++;
  for(int i=0;i<sl;i++){
    for(int j=0;j<tl;j++){
      for(int k=0;k<3;k++)v[i][j][k]=false;
      if(i==0||j==0)l[i][j]=0;
      else if(s[i]==t[j]){
        v[i][j][0]=true;
        l[i][j]=l[i-1][j-1]+1;
      }else{
        if(l[i-1][j]<=l[i][j-1]){
          v[i][j][1]=true;
          l[i][j]=l[i][j-1];
        }
        if(l[i-1][j]>=l[i][j-1]){
          v[i][j][2]=true;
          l[i][j]=l[i-1][j];
        }
      }
    }
  }
  int ul=0,nowi=sl-1,nowj=tl-1;
  while(nowi>0&&nowj>0){
    if(v[nowi][nowj][0]){
      u[ul]=s[nowi];
      nowi--;
      nowj--;
      ul++;
    }else if(v[nowi][nowj][1])nowj--;
    else if(v[nowi][nowj][2])nowi--;
  }
  for(int i=ul-1;i>=0;i--)printf("%c",u[i]);
  return 0;
}


Measured memory_bytes: 61824
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.AccessControl;
using System.Text;
using System.Threading.Tasks;

namespace MySample
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, k;
            string[] nk = Console.ReadLine().Split(' ');
            n = int.Parse(nk[0]);
            k = int.Parse(nk[1]);

            bool[] ary = Enumerable.Repeat<bool>(false, n).ToArray();

            for (int i = 0; i < k; i++)
            {
                var d = Console.ReadLine();
                string[] strings = Console.ReadLine().Split(' ');
                for (int j = 0; j < strings.Length; j++)
                {
                    var m = int.Parse(strings[j]);
                    ary[m - 1] = true;
                }
            }

            var count = 0;
            foreach (var b in ary)
            {
                if (!b) count++;
            }

            Console.WriteLine(count);
        }
    }

}

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

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

    int num1 = atoi(s.substr(0, 2).c_str());
    int num2 = atoi(s.substr(2, 2).c_str());

    if ( num1 >= 1 & num1 <= 12 ) {
        if ( num2 >= 1 & num2 <= 12 ) {
            cout << "AMBIGUOUS" << endl;
        }
        else {
            cout << "MMYY" << endl;
        }
    }
    else {
        if ( num2 >= 1 & num2 <= 12 ) {
            cout << "YYMM" << endl;
        }
        else {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;i++){
            if(i % 3 == 0){
               printf(" %d",i);
               continue;
            } //iが３の倍数かどうか
            if(i % 10 == 3){
                printf(" %d",i);
                continue;
            } //iの10の位が3かどうか
            for(int x = i;x != 0;x /= 10)
            if(x % 10 == 3||x == 3){
                printf(" %d",i);
                break;
        } //iのm(>=2)の位が３かどうか
    };
    printf("\n");
    return 0;
}


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

int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  if (op == '+') {
    cout << (a + b) << endl;
  }
  if (op == '-') {
    cout << (a - b) << 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++)

int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> c(n + 1);
  for (int i = 0; i < n - 1; ++i)
    c[i + 1] = c[i] + (s[i] == 'A' && s[i + 1] == 'C');

  rep(i, q) {
    int l, r;
    cin >> l >> r;
    l--, r--;
    printf("%d\n", c[r] - c[l]);
  }
}


Measured memory_bytes: 1408
#include <iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

#define vi vector<int>
#define vvi vector<vi>
#define rpt(i,x) for (int i = 0; i < x; i++)
#define fti(i,f,t) for (int i = f; i <= t; i++)
#define fte(i,f,t) for (int i = f; i < t; i++)
#define rptws(i,x,s) for (int i = 0; i < x; i += s)
#define llrpt(i,x) for (long long i = 0; i < x; i++)
#define llfti(i,f,t) for (long long i = f; i <= t; i++)
#define llfte(i,f,t) for (long long i = f; i < t; i++)

int main () {
	string alpha = "abcdefghijklmnopqrstuvwxyz";

	long long n;
	cin>>n;

	string ans[500];

	int i = 0;
	while (n) {
		n--;
		ans[i++] = alpha[n%26];
		n /= 26;
	}

	for (int j = i; j >= 0; j--) cout<<ans[j];
	return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <map>

using namespace std;

#define int long long
#define double long double
#define pii pair<int, int>
#define mp make_pair

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}

const int inf = 1e9;

signed main() {
    fast();
    int s;
    cin >> s;
    int x1 = (s + inf - 1) / inf;
    int d = s - x1 * inf;
    int x3 = x1 - 1;
    int y2 = -d;
    cout << x1 << ' ' << 0 << '\n'
    << 0 << ' ' << y2 << '\n'
    << x3 << ' ' << inf;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int N = cin.nextInt();
		
		int[] count= new int[6];
		for(int i = 0;i<N;i++){
			double d = cin.nextDouble();
			if(d < 165.0){
				count[0]++;
			}
			else if(d < 170.0){
				count[1]++;
			}
			else if(d < 175.0){
				count[2]++;
			}
			else if(d < 180.0){
				count[3]++;
			}
			else if(d < 185.0){
				count[4]++;
			}
			else{
				count[5]++;
			}
		}
		for(int i = 0;i<6;i++){
			System.out.print((i+1)+":");
			for(int j=0;j<count[i];j++){
				System.out.print("*");
			}
			System.out.println();
		}
		
		
	}

}

Measured memory_bytes: 12000
fn main() {
    let mut sc = Scanner::new();
    let k: usize = sc.read();
    let a: Vec<usize> = (0..k).map(|_| sc.read()).collect();

    let mut lower = 2;
    for &a in a.iter().rev() {
        if a > lower {
            lower = a;
        } else if a < lower {
            lower = (lower + a - 1) / a * a;
        }
    }

    let mut check_low = lower;
    for &a in &a {
        check_low = check_low / a * a;
    }

    if check_low != 2 {
        println!("-1");
        return;
    }

    let mut ok = lower;
    let mut ng = std::usize::MAX / 2;
    while ng - ok > 1 {
        let mid = (ok + ng) / 2;
        let mut check = mid;
        for &a in &a {
            check /= a;
            check *= a;
        }
        if check == 2 {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    println!("{} {}", lower, ok);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 4476
from math import gcd


def main():
    K = int(input())
    answer = 0
    for i in range(1, K + 1):
        for j in range(1, K + 1):
            a = gcd(i, j)
            for k in range(1, K + 1):
                answer += gcd(a, k)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,K,S; cin>>N>>K>>S;
  for(int i=0; i<K; i++){
    if(i!=N-1) cout<<S<<" ";
    else cout<<S<<endl;
  }
  if(S==1e9) S--;
  else S++;
  for(int i=K; i<N; i++){
    if(i!=N-1) cout<<S<<" ";
    else cout<<S<<endl;
  }
}

Measured memory_bytes: 1280
n=int(input())
a=[]
dp=[]
for i in range(n):
    a.append(list(map(int,input().split())))
    dp.append([0,0,0])
dp[0]=a[0]
for i in range(1,n):
    for j in range(3):
        dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+a[i][j]
print(max(dp[-1]))

Measured memory_bytes: 76632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<(n);i--)
int main(){
  int A,B,K;
  cin>>A>>B>>K;
  int c=K,ans=1;
  for(int i=max(A,B);i>0;i--){
    if((A%i==0)&&(B%i==0)) K--;
    if(!K){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env pytHon3
# -*- coding: utf-8 -*-


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

    if M - 2 * N > 0:
        x = (M - 2 * N) // 4
        print(N + x)
    else:
        print(M // 2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e18;
const ll mod = 1e9 + 7;


int main(){
    string s,t;
    cin >> s >>t ;
    vector<int> st(26,-1);
    vector<int> g(26,-1);
    REP(i,s.size()){
        int a = s[i] - 'a';
        int b = t[i] - 'a';
        if(st[a] != -1 || g[b] != -1){
            if(st[a] != b || g[b] != a){
                dump("No");return 0;
            }
        }
        st[a] = b;
        g[b] = a;
    }
    dump("Yes");
    return 0;
}

Measured memory_bytes: 776
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define int long long int
using namespace std;

void desperate_optimization(bool submitting=true,int precision=10)
{
  if(!submitting) return;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(precision);
}

int32_t main()
{
  desperate_optimization(false);
  int n;
  cin>>n;
  long double dp[n+1][n+1];       //[headcount][coinstossed]
  long double h[n+1];
  for(int i=1;i<=n;i++) cin>>h[i];
  dp[0][0]=1;
  for(int i=1;i<=n;i++) dp[0][i]=dp[0][i-1]*(1-h[i]);
  for(int i=1;i<=n;i++) dp[i][0]=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=n;j++)
    {
      dp[i][j]=dp[i-1][j-1]*h[j] + dp[i][j-1]*(1-h[j]);
    }
  }
  long double answer=0;
  for(int heads=0;heads<=n;heads++)
  {
    int tails=n-heads;
    if(heads>tails) answer+=dp[heads][n];
  }
  printf("%.10Lf",answer);

  return 0;
}


Measured memory_bytes: 140928
#include <bits/stdc++.h>
//#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
 
 
int main(){
   
  vector<string> date={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  string today;
  cin>>today;
  rep(i,7){
      if(today==date.at(i)){
          
         cout<<7-i;
      }
        
  }
  
}

Measured memory_bytes: 256
import qualified Data.Sequence   as S
import qualified Data.Map.Strict as M
import qualified Control.Monad   as C
import Data.Sequence ((><))
import Data.Map.Strict ((!))
 
import Data.Maybe
import Debug.Trace
 
type Queue  = S.Seq
 
main :: IO ()
main = do
    [h, w] <- map read . words <$> getLine :: IO [Int]
    let (sy, sx) = (1, 1)
    let (gy, gx) = (h, w)
 
    -- ここは入力を受け取っているだけなので気にしないで
    input <- C.replicateM h getLine :: IO [[Char]]
    let c = map (\(y, line) ->
                map (\(x, c) ->
                    if c == '#' then ((y, x), Nothing) else ((y, x), Just 1000000)
                    ) (zip [1..] line) 
            ) (zip [1..] input)

    let shortestPath = bfs (M.insert (sy, sx) (Just 0) . M.fromList $ concat c) 
                              (h,w)
                            $ S.fromList [(sy, sx)]
    let cnt = (foldr (\a b -> (if a=='.' then 1 else 0) + b) 0 $ concat input)
    let p = fromJust $ shortestPath ! (gy, gx)
    print $ if p/=1000000 then cnt - (fromJust $ shortestPath ! (gy, gx)) - 1
                          else -1
 
-- 幅優先探索
bfs :: M.Map (Int, Int) (Maybe Int) -- 地図
    -> (Int, Int)
    -> Queue (Int, Int)
    -> M.Map (Int, Int) (Maybe Int)
bfs c (h,w) queue 
    | S.null queue = c
    | otherwise    = let
        (y, x) = queue `S.index` 0
        q = S.tails queue `S.index` 1
        -- qはqueueの追加分, cは地図の変更分
        (q', c') = unzip . concat . flip map (destinations y x) $ \(ny, nx) ->
            if 1<=ny && ny<=h && 1<=nx && nx<=w then
                case (c!(y,x), c!(ny,nx)) of
                    (Just a, Just b) -> if (a+1 >= b) then [] else [((ny, nx) ,((ny, nx), Just $ a+1))]
                    _                -> []
                else []
        in bfs (override c $ M.fromList c') (h,w) (q >< S.fromList q')
    where
    -- Keyが重複していれば二つ目の引数のMapで一つ目のMapを上書き
    override :: (Ord k) => M.Map k a -> M.Map k a -> M.Map k a
    override = M.unionWith (\a b -> b)
    -- この問題では四方に動けるので、その行き先を作っている
    destinations y x = [(y+1, x), (y-1, x),(y, x+1),(y, x-1)]


Measured memory_bytes: 1404
import java.math.BigDecimal;
import java.util.Scanner;

//AtCoder Beginner Contest 159
//C	Maximum Volume
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String L = sc.next();
		sc.close();

		BigDecimal v1 = new BigDecimal(L + ".0");
		v1 = v1.divide(new BigDecimal(3.0),6,BigDecimal.ROUND_HALF_UP);
		BigDecimal v3 = new BigDecimal(L).subtract(v1).subtract(v1);

		System.out.println(v1.multiply(v1).multiply(v3).toString());
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
 
// 各桁の和を計算する関数
  int findSumOfDigits(int n) {
    int sum = 0;
    while (n > 0) { // n が 0 になるまで
      sum += n % 10;
      n /= 10;
    }
    return sum;
  }

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  int sum1 = 0;
  int sum2 = 0;

  for(int i = 1; i <= N ; i++){
    sum2 = findSumOfDigits(i);
    if(sum2 >= A && sum2 <= B){
      sum1 += i;
    }
  }
  cout << sum1 << endl;
}


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

int main() {
    string a, b; cin >> a >> b;
    for(int i = 0; i < a.length(); i++) {
        if(a[i] != b[i]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}


Measured memory_bytes: 3552
#include<iostream>
  
using namespace std;
  
int bubbleSort(int A[],int N){
  
int sw=0;
  
bool flag=1;
  
for (int i=0;flag; i++){
flag=0;
for (int j=N-1;j>=i+1;j--){
if (A[j]<A[j-1]){
  
swap(A[j],A[j-1]);
flag=1;
sw++;
}
}
}
return sw;
}
  
int main(){
  
int A[100], N, sw;
cin >> N;
for (int i=0;i<N;i++) cin >> A[i];
sw=bubbleSort(A,N);
  
for (int i=0;i<N;i++){
  
if (i) cout << " ";
cout << A[i];
}
  
cout << endl;
cout << sw << endl;
  
return 0;
}


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

int i;
long long a, b;
string s;

int main()
{
    scanf("%lld", &a);
    cin >> s;
    for (i = 0; i <s.size(); i++) {
        if (s[i] == '.') continue;
        b = b*10 + s[i]-'0';
    }
    printf("%lld\n", a*b/100);
    return 0;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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 (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}

//dp[ j ][ i] := j-1 番目までの品物から価値が
// i 以上を達成するように選んだときの、重さの総和の最小値
void Knapsac(){
	ll n,w; ll res=0;
	cin>>n>>w;
	VI wei(n),val(n);
	rep(i, n)	cin >> wei[i]>>val[i];
	ll v=100100;//ある程度大きい値に設定
	VVI dp(n+1,VI(v,INF));
	dp[0][0]=0;
	rep(j,n){
		rep(i,v+1){
			if(i>=val[j])	chmin(dp[j+1][i],dp[j][i-val[j]]+wei[j]);
			chmin(dp[j+1][i],dp[j][i]);
		}
	}

	rep(i,v){
		if(dp[n][i]<=w) res=i;
	}
	cout << res << "\n";
	return;
}

void Main()
{
	Knapsac();
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 80256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<string>
#define ll long long
using namespace std;

int main()
{
    int n,cnt=0;
    char a[105],b[105];
    char ans[205];
    scanf("%d%s%s",&n,a,b);
    for(int i=0;i<a[i];i++)
    {
        ans[cnt++] = a[i];
        ans[cnt++] = b[i];
    }
    ans[cnt] = '\0';
    printf("%s\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll N,ans;
string S,T;
int main(){
    cin >> N >> S >> T;
    int st;
    bool flag;
    if(S[0] == T[0]) ans = 3, st = 1, flag = true;
    else ans = 6, st = 2, flag = false;
    
    repi(i,st,N-1){
        ans %= MOD;
        if(S[i] == T[i]){
            if(flag) ans *= 2;
            flag = true;
        }else{
            if(flag) ans *= 2;
            else ans *= 3;
            flag = false;
            i++;
        }
    }
    cout << ans % MOD << '\n';
}

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

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll n, m, in[5100];
vector<ll> g[5100];
bool ok = false;
int main() {
	cin >> n >> m;
	REP(i, m) {
		ll a, b;
		cin >> a >> b;
		in[b]++;
		g[a].push_back(b);
	}
	vector<ll> ans;
	queue<ll> que;
	REPO(i, n) if (in[i] == 0)que.push(i);
	while (!que.empty()) {
		if (que.size() >= 2)ok = true;
		ll now = que.front();
		ans.push_back(now);
		que.pop();
		REP(i, g[now].size()) {
			in[g[now][i]]--;
			if (in[g[now][i]] == 0) {
				que.push(g[now][i]);
			}
		}
	}
	REP(i, ans.size()) cout << ans[i] << endl;
	cout << (ok ? "1" : "0") << endl;
}


Measured memory_bytes: 4480
#include <stdio.h>
#define N 200005

typedef long long ll;

ll a[N], b[N], aa[N], bb[N];
int main()
{
    ll n, m, k;

    scanf("%lld%lld%lld", &n, &m, &k);
    for(int i = 1; i <= n; i++) scanf("%lld", &a[i]), aa[i] += aa[i - 1] + a[i];
    for(int i = 1; i <= m; i++) scanf("%lld", &b[i]), bb[i] += bb[i - 1] + b[i];

    int max = 0;
    for(int i = 0; i <= n; i++)
    {
        int left = 0, right = m + 1, mid, temp;
        if(aa[i] <= k) temp = aa[i];
        else break;
        while(right - left > 1)
        {
            mid = (left + right) >> 1;
            if(k < temp + bb[mid]) right = mid;
            else left = mid;
        }
        if(max < left + i) max = left + i;
    }
    printf("%d\n", max);

    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

int N;

void solve() {
    cin >> N;
    if (N % 10 == 3) cout << "bon";
    else if (N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) cout << "pon";
    else cout << "hon";
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
pair<int,int> fracsum(pair<int,int> a,pair<int,int> b)
{
  return make_pair(a.first*b.second+b.first*a.second,a.second*b.second);
}
int solve(int p,int q,int a,int n,int ub=1,pair<int,int> tmpf=make_pair(0,1)){
  if(tmpf.first*q>tmpf.second*p) return 0;
  if(tmpf.first*q==tmpf.second*p) return 1;
  if(n==0) return 0;
  int answer=0;
  FOR(i,ub,a/tmpf.second+1){
    answer+=solve(p,q,a,n-1,i,fracsum(tmpf,make_pair(1,i)));
  }
  return answer;
}
int main(void)
{
  for(;;){
    int p,q,a,n;
    cin >> p >> q >> a >> n;
    if(!n) return 0;
    cout << solve(p,q,a,n) << endl;
  }
}

Measured memory_bytes: 2936