akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int64 N, P;
int64 mpow(int64 a, int64 b) {
  if (b == 0) return 1;
  if (b % 2) return a * mpow(a, b-1)%P;
  int64 ret = mpow(a, b/2);
  return ret*ret%P;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> N >> P >> s;
  int64 now = 0, res = 0;
  if (P == 2 || P == 5) {
    REP(i, N) {
      if ((s[i] - '0') % P == 0) {
        res += i+1;
      }
    }
    cout << res << endl;
    return 0;
  }
  map<int64, int64> cnt;
  cnt[0]++;
  int64 div = 1;
  int64 d10 = mpow(10%P, P-2);
  REP(i, s.size()) {
    now = now * 10 + s[i]-'0';
    now %= P;
    res += cnt[now*mpow(d10, i)%P];
    cnt[now*mpow(d10, i)%P]++;
  }
  cout << res << endl;
}


Measured memory_bytes: 1044
#include <stdio.h>

int sum(int a,int b);
int sub(int a,int b);

int main(void){
	int i,n,a,b,c,d,x,op1,op2,op3,cnt=0;
	char op[2]={'+','-'};
	scanf("%d",&n);
	a=(n/1000)%10;
	b=(n/100)%10;
	c=(n/10)%10;
	d=n%10;
	for(;;){
		x=0;
		op1=0;
		op2=0;
		op3=0;
		for(i=0;i<3;i++){
			if((cnt<3)||(cnt==4)){
				x=sum(a,b);
				if(cnt<2){
					x=sum(x,c);
					if(cnt==0){
						x=sum(x,d);
					}else{
						x=sub(x,d);
						op3=1;
					}
				}else{
					x=sub(x,c);
					op2=1;
					if(cnt==2){
						x=sum(x,d);
					}else{
						x=sub(x,d);
						op3=1;
					}
				}
			}else{
				x=sub(a,b);
				op1=1;
				if((cnt==3)||(cnt==6)){
					x=sum(x,c);
					if(cnt==3){
						x=sum(x,d);
					}else{
						x=sub(x,d);
						op3=1;
					}
				}else{
					x=sub(x,c);
					op2=1;
					if(cnt==5){
						x=sum(x,d);
					}else{
						x=sub(x,d);
						op3=1;
					}
				}
			}
		}
		if(x==7){
			break;
		}
		cnt++;
	}
	printf("%d%c%d%c%d%c%d=7",a,op[op1],b,op[op2],c,op[op3],d);
	return 0;
}

int sum(int a,int b){
	return a+b;
}

int sub(int a,int b){
	return a-b;
}


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

using namespace std;

int main() {
    int K, C, D;
    cin >> K;
    vector<int> vec(2);
    for (int i = 0; i < 2; i++) {
        cin >> vec.at(i);
    }
    C = vec.at(0) % K;
    D = vec.at(0) - C + K;

    if (D<= vec.at(1) || C == 0) {
        cout << "OK" << endl;
    }
    else {
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3628
import sys
range = xrange
input = raw_input

r,g,b,n = [int(x) for x in input().split()]

count = 0

for x in range(n//r + 1):
    m = n - r*x
    for y in range(m//g + 1):
        k = m - g*y
        if k>=0 and k%b == 0:
            count += 1

print count

Measured memory_bytes: 30188
#define rep(i,n) for (int i = 0; i < n; i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;
struct edge {
	int from, to, cost;
};


int main() {
	int l; cin >> l;
	int r = 30;
	while (pow(2, r) > l) r--;
	int m = r + 1, cnt = 0;
	vector<edge> e;
	rep(i, r) {
		e.push_back({ i + 1,i + 2,(int)pow(2,i) });
		e.push_back({ i + 1,i + 2,0 });
		cnt += 2;
	}
	rep(i, m) {
		int j = m - i;
		if (j == 0) continue;
		if (l - pow(2, j - 1) < pow(2, r)) continue;
		e.push_back({ j, m, (int)(l - pow(2, j - 1)) });
		cnt++;
		l -= pow(2, j - 1);
	}
	cout << m << " " << cnt << endl;
	rep(i, cnt) {
		cout << e[i].from << " "<< e[i].to <<" "<< e[i].cost << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
#include<cstdlib>
using namespace std;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
struct aUnionFind {
	vector<pair<int, int>> data;
	aUnionFind(int size) : data(size, make_pair(-1, 0)) { }
	bool unionSet(int x, int y, int w) {
		int fx(x), fy(y);
		x = root(x).first; y = root(y).first;
		if (x != y) {
			data[x].first += data[y].first; data[y].first = x;
			data[y].second =-data[fy].second - w + data[fx].second;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	pair<int, int> root(int x) {
		if (data[x].first < 0) {
			return make_pair(x, 0);
		}
		else {
			pair<int, int>ndata;
			ndata.first = root(data[x].first).first;
			ndata.second =data[x].second+ root(data[x].first).second;
			return data[x]=ndata;
		}
	}
	int size(int x) {
		return -data[root(x).first].first;
	}
};



int main() {
	while (1) {
		int N, M; cin >> N >> M;
		if (!N)break;
		vector<pair<int,int>>weis(N,make_pair(-1,-1));
		aUnionFind uf(N);
		for (int i = 0; i < M; ++i) {
			char c; cin >> c;
			if (c == '!') {
				int a, b, w; cin >> a >> b >> w;
				a--; b--;
				uf.unionSet(a, b,w);
				
				
			}
			else {
				int a, b; cin >> a >> b;
				a--; b--;
				if (uf.root(a).first == uf.root(b).first) {
					int aa=uf.root(a).second - uf.root(b).second;
					cout << aa << endl;
				}
				else {
					cout << "UNKNOWN" << endl;
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 6668
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>

using namespace std;

int main()
{
	int N;
	cin>>N;
	int a[100], b[100], c[100];
	
	for (int i = 1; i<=N; i++) cin >> a[i];
	for (int i = 1 ; i<=N; i++) cin >> b[i];
	for (int i=1; i<=N-1; i++) cin >> c[i];
	
	int sum = 0; 
	
	for (int i = 1; i<=N; i++)
	{
		int t = a[i];
		sum = sum + b[t];
		if ((a[i+1]-a[i]) == 1)
		{
			sum = sum + c[a[i]];
		}
	}
	
	cout <<sum <<endl;
	
	
	
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

struct BipartiteMatching {
  vector<vector<int>> graph;
  vector<int> match,used;
 
  BipartiteMatching(int n):graph(n),used(n, 0),match(n, -1){}
 
  void add_edge(int u,int v){
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
 
  bool dfs(int now){
    used[now]=1;
    for(auto to:graph[now]){
      int to_match=match[to];
      if(to_match==-1||(!used[to_match]&&dfs(to_match))){
        match[now]=to;
        match[to]=now;
        return true;
      }
    }
    return false;
  }
 
  int bipartite_matching(){
    int res=0;
    for(int i=0;i<graph.size();++i){
      if(match[i]==-1){
        for(int j=0;j<graph.size();++j) used[j]=0;
        if(dfs(i)) ++res;
      }
    }
    return res;
  }
};

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

  int N,M;
  cin>>N>>M;
  vector<string> S(N);
  rep(i,N) cin>>S[i];

  BipartiteMatching graph(N*M);
  auto conv = [&](int a,int b){
      return a*M+b;
  };

  for(int i=0;i<N;i++) for(int j=0;j<M;j++){
      if(S[i][j]!='.') continue;
      if(i+1<N&&S[i+1][j]=='.') graph.add_edge(conv(i,j),conv(i+1,j));
      if(j+1<M&&S[i][j+1]=='.') graph.add_edge(conv(i,j),conv(i,j+1));
  }

  int V=graph.bipartite_matching();
  cout<<V<<"\n";
  vector<string> ans=S;
  for(int k=0;k<N*M;k++){
      int tar=graph.match[k];
      if(tar==-1) continue;
      if(tar<k) continue;

      int a=k/M,b=k%M;
      int c=tar/M,d=tar%M;
      if(a==c){
          ans[a][b]='>';
          ans[c][d]='<';
      }else{
          ans[a][b]='v';
          ans[c][d]='^';
      }
  }

  rep(i,N) cout<<ans[i]<<"\n";


  return 0;
}


Measured memory_bytes: 4392
#include <stdio.h>
char map[101][101];
int H,W;


void visit(int i,int j){
	char temp;
	temp=map[i][j];
	if(temp=='.'){
		printf("%d %d\n",j,i);
		return;
	}
	if(temp=='@'){
		printf("LOOP\n");
		return;
	}
	map[i][j]='@';
	if(temp=='>'){
		visit(i,j+1);
	}
	else if(temp=='<'){
		visit(i,j-1);
	}
	else if(temp=='^'){
		visit(i-1,j);
	}
	else if(temp=='v'){
		visit(i+1,j);
	}
}


int main(){
	char	x;
	int		i,j;
	
	while(1){
		scanf("%d %d",&H, &W);
		if(H==0&&W==0)break;
		for(i=0;i<H;i++){
			getchar();
			for(j=0;j<W;j++){
				scanf("%c",&x);
				map[i][j]=x;
			}
		}
		
		visit(0,0);
	}
	return 0;
}

Measured memory_bytes: 624
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
string bins(int x, int n) {
  string res;
  rep(i,n) res += "01"[x&1], x >>= 1;
  reverse(rng(res));
  return res;
}

const int n = 16;
const int n2 = 1<<n;

int c[n];
int dp[n2];
int ok[n2];

vi to[MX];
vi co[MX];

int dfs(int v, int p=-1) {
  int cur = 0, px = 0;
  rep(i,sz(to[v])) {
    int u = to[v][i];
    if (u == p) {
      px = co[v][i];
      continue;
    }
    int r = dfs(u,v);
    cur ^= r;
  }
  int now = cur^px;
  if (now) c[now]++;
  return cur^now;
}

int main() {
  int m;
  scanf("%d",&m);
  rep(i,m-1) {
    int a,b,x;
    scanf("%d%d%d",&a,&b,&x);
    to[a].pb(b); co[a].pb(x);
    to[b].pb(a); co[b].pb(x);
  }
  dfs(0);
  int s = 0, ans = 0;
  rep(i,n) {
    ans += c[i]/2;
    s |= (c[i]&1)<<i;
  }
  // cerr<<bins(s,n)<<endl;
  rep(i,n2) {
    int x = 0;
    rep(j,n) if (i>>j&1) x ^= j;
    ok[i] = !x;
  }
  rep(i,n2) dp[i] = -INF;
  dp[s] = 0;
  drep(i,n2) {
    if (dp[i] == INF) continue;
    for (int j = i; j; j = (j-1)&i) {
      if (ok[j]) maxs(dp[i^j], dp[i]+1);
    }
  }

  ans += pcnt(s)-dp[0];
  cout<<ans<<endl;
  return 0;
}






















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

const int SIZE=101;
using Field=array<array<int,SIZE>,SIZE>;
map<char,int> dmap={{'N',0},{'E',1},{'S',2},{'W',3}};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
Field create(int v=0){
    Field res;
    for(int i=0;i<SIZE;i++) fill(res[i].begin(),res[i].end(),v);
    return res;
}
int main(){
    int n,t,x0,y0;
    cin>>n>>x0>>y0>>t;
    x0*=2,y0*=2;
    Field f=create();
    for(int i=0;i<n;i++){
        int xs,ys,xe,ye;
        cin>>xs>>ys>>xe>>ye;
        xs*=2,ys*=2,xe*=2,ye*=2;
        if(xs>xe) swap(xs,xe);
        if(ys>ye) swap(ys,ye);
        for(int x=xs;x<=xe;x++){
            for(int y=ys;y<=ye;y++){
                f[x][y]=1;
            }
        }
    }
    vector<int> d(t);
    vector<int> c(t);
    for(int i=0;i<t;i++){
        char tmp;
        cin>>d[i]>>tmp;
        d[i]=d[i]*2;
        c[i]=dmap[tmp];
    }

    vector<Field> flag(4,create());
    vector<Field> mustGO(4,create(1));
    for(int i=0;i<4;i++) flag[i][x0][y0]=true;
    auto isRange=[](int x,int y){
        return 0<=x && x<SIZE && 0<=y && y<SIZE;
    };
    auto move=[&](){
        vector<Field> nex(4,create());
        vector<Field> nexm(4,create(1));
        for(int dir=0;dir<4;dir++){
            for(int i=0;i<SIZE;i++){
                for(int j=0;j<SIZE;j++){
                    if(!flag[dir][i][j]) continue;
                    for(int td=0;td<4;td++){
                        if(mustGO[dir][i][j] && dir!=td) continue;
                        if((td+2)%4==dir) continue;
                        int tox=i+dx[td],toy=j+dy[td];
                        if(isRange(tox,toy) && f[tox][toy]){
                            nex[td][tox][toy]=true;
                            nexm[td][tox][toy]=false;
                        }
                    }
                }
            }
        }
        flag=nex;
        mustGO=nexm;
    };
    auto judge=[&](int i,int j,char dir){
        int tox=i+dx[dir],toy=j+dy[dir];
        return flag[dir][i][j] || isRange(tox,toy) && (flag[(dir+1)%4][i][j] || flag[(dir+3)%4][i][j]) && f[tox][toy];
    };
    auto flesh=[&](int dir){
        for(int i=0;i<SIZE;i++){
            for(int j=0;j<SIZE;j++){
                if(flag[dir][i][j]){
                    for(int k=0;k<4;k++) flag[k][i][j]=false;
                    flag[dir][i][j]=true;
                }
                else if(judge(i,j,dir)){
                    for(int k=0;k<4;k++) flag[k][i][j]=false;
                    flag[dir][i][j]=true;
                    mustGO[dir][i][j]=true;
                }
                else{
                    for(int k=0;k<4;k++) flag[k][i][j]=false;
                }
            }
        }
    };
    for(int i=0;i<t;i++){
        for(int j=0;j<d[i];j++){
            move();
        }
        flesh(c[i]);
    }
    for(int ix=0;ix<SIZE;ix++){
        for(int j=0;j<SIZE;j++){
            if(flag[c.back()][ix][j]) cout<<ix/2<<" "<<j/2<<endl;
        }
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3692
S = input()
N = len(S)
ans = 0

for i in range(1, 2**(N-1)):
    tmp_S = ""
    checked_j = 0
    for j in range(N-1):
        if i >> j & 1:
            ans += int(S[checked_j:j+1])
            checked_j = j+1
            tmp_S = S[j+1:]
    if tmp_S:
        ans += int(tmp_S)

ans += int(S)
print(ans)


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

ll a, b, c, d;
int main(){
  cin.tie(0); ios_base::sync_with_stdio(0);
  cin >> a >> b >> c >> d;
  cout << max(max(a*c,a*d),max(b*c,b*d)) <<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,Y,a,b;
  cin>>N>>Y;
  bool f=false;
  for(a=0;a<N+1;a++){
    for(b=0;b<N+1;b++){
      if((a*10+b*5+N-a-b)==Y/1000&&(a+b)<=N){
        f=true;
        break;
      }
    }
    if(f)break;
  }
  if(f){
    cout<<a<<' '<<b<<' '<<N-a-b<<endl;
  }
  else cout<<"-1 -1 -1"<<endl;
}

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

using namespace std;
int cnt[102];

int main(){
   int n;
   cin>>n;
   for(int i=1;i<=n;i++){
      int j=i;
      while(j%2==0){
         j/=2;
         cnt[i]++;
      }
   }
   if(n==1){
      cout<<1<<endl;
      return 0;
   }
   cout<<max_element(cnt,cnt+n+1)-cnt<<endl;
}

Measured memory_bytes: 256
def sqrt(n):
    m = int(n**.5)
    return 1 if abs(m*m - n) < 1e-6 else 0

N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

ans = 0

for i in range(N-1):
    for j in range(i+1,N):
        d = 0
        for k in range(D):
            d += (X[i][k]-X[j][k])**2
        ans += sqrt(d)
        
print(ans)

Measured memory_bytes: 3064
n=int(input())
a=[input() for i in range(n)]
b=a.count("AC")
c=a.count("TLE")
d=a.count("WA")
e=a.count("RE")
print(f"AC x {b}")
print(f"WA x {d}")
print(f"TLE x {c}")
print(f"RE x {e}")




Measured memory_bytes: 16292
# -*- coding: utf-8 -*-
from bisect import bisect, bisect_left
def inpl(): return list(map(int, input().split()))
N, L, T = inpl()

Fants = []
Bants = []
A = [[0, 0] for _ in range(N)]
P = [-1]*N

for i in range(N):
    x, w = inpl()
    A[i] = (x, w)
    if w == 1:
        Fants.append(x)
        P[i] = (x+T)%L
    else:
        Bants.append(x)
        P[i] = (x-T)%L

B = Bants + [b+L for b in Bants] + [b+2*L for b in Bants]
F = [f-2*L for f in Fants] + [f-L for f in Fants] + Fants
d, m = divmod(T, L)
ans = [-1]*N

for i, (x, w) in enumerate(A):
    if w == 1: #forward
        j = i + 2*d*len(Bants) + (bisect(B, x+2*m) - bisect(B, x))
        ans[j%N] = P[i]
    else:
        j = i - 2*d*len(Fants) - (bisect_left(F, x) - bisect_left(F, x-2*m))
        ans[j%N] = P[i]    

print(*ans, sep="\n")

Measured memory_bytes: 30908
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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



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

  ll N,H; cin>>N>>H;
  vector<ll> a(N),b(N); rep(i,N) cin>>a[i]>>b[i];
  
  ll maxa=*max_element(a.begin(),a.end());
  sort(b.rbegin(),b.rend());
  
  ll ans=0,HP=H;
  for(int i=0;i<N&&b[i]>=maxa;i++){
    ans++;
    HP-=b[i];
    if(HP<=0) {cout<<ans<<endl; return 0;}
  }
  ans+=(HP+maxa-1)/maxa;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4772
n,m = map(int,input().split())
#包除定理で「少なくともk個値が一致する配列」を考える
#kこ選んでmPkで並べてここりのN-kをAとBに対してm-kPn-kで並べる
MOD = 10**9+7
size = 500001
frac = [1]*size
finv = [1]*size
for i in range(size-1):
    frac[i+1] = (frac[i]*(i+1))%MOD
finv[-1] = pow(frac[-1],MOD-2,MOD)
for i in range(size-2,-1,-1):
    finv[i] = (finv[i+1]*(i+1))%MOD
def comb(n,r):
    if n < r or r < 0:
    	return 0
    elif n == 0 or r == 0 or n == r:
        return 1
    else:
        return (frac[n]*finv[n-r]*finv[r])%MOD
def nPk(n,k):
    return frac[n]*finv[n-k]%MOD
ans = 0
for i in range(n+1):
    res = comb(n,i) * nPk(m,i) * (nPk(m-i,n-i)**2)
    res %=MOD
    if i%2: res*=-1
    ans += res
    ans %= MOD
# ans *= frac[m]*finv[m-n]
print(ans%MOD)

Measured memory_bytes: 103292
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <utility>
#include <numeric>
#include <iomanip>
#include <locale>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>
#include <cmath>

using namespace std;

string read();
string think(string);
void write(string);

int main(int argc, char* argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  auto input = read();
  auto output = think(input);
  write(output);

  return 0;
}

string read() {
  string buf;

  cin >> buf;
  return buf;
}

string think(string input) {
  for (int i = 0; i < 8; i++) {
    int sum = 0;
    auto bit = i;

    vector<string> signs;
    if (bit % 2 == 0) {
      signs.push_back("+");
      sum = (input.at(0) - '0') + (input.at(1) - '0');
    } else {
      signs.push_back("-");
      sum = (input.at(0) - '0') - (input.at(1) - '0');
    }
    bit /= 2;

    if (bit % 2 == 0) {
      signs.push_back("+");
      sum += (input.at(2) - '0');
    } else {
      signs.push_back("-");
      sum -= (input.at(2) - '0');
    }
    bit /= 2;

    if (bit % 2 == 0) {
      signs.push_back("+");
      sum += (input.at(3) - '0');
    } else {
      signs.push_back("-");
      sum -= (input.at(3) - '0');
    }

    if (sum == 7) {
      string buf = "";
      buf += input.at(0);
      buf += signs.at(0);
      buf += input.at(1);
      buf += signs.at(1);
      buf += input.at(2);
      buf += signs.at(2);
      buf += input.at(3);
      buf += "=7";
      return buf;
    }
  }
  return "";
}

void write(string output) {
  cout << output << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2); return sq*sq; } else { return N*RS(N, P - 1); } } //power(repeat-square,fast)
ll nPr(ll n, ll r) { ll ans = 1; rep(i, r) { ans = ans * (n - i); } return ans; } //permutation
ll nCr(ll n, ll r) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1); bunshi = bunshi * (n - i); } return bunshi / bunbo; } //combination
ll RS(ll N, ll P, ll Mod) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination


int main(void) {
  int N,A,B; cin >> N >> A >> B;
  int res = min(A*N,B);
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <time.h>
#include <complex>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;
using std::complex;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;
typedef complex<double> cd;

namespace MySpace{
    struct Small_Segment_Tree{
        vector<int> a;
        int l, r;

        private:
        int __summ(int L, int R, int l, int r, int v)
        {
            if (L <= l && r <= R)
                return a[v];
            if (R <= l || r <= L)
                return 0;
            int m = (l + r) / 2;
            return __summ(L, R, l, m, 2 * v + 1) + __summ(L, R, m, r, 2 * v + 2);
        }

        void __set(int P, int l, int r, int v, int V)
        {
            if (l + 1 == r)
            {
                a[v] = V;
                return;
            }
            int m = (l + r) / 2;
            if (P < m)
            {
                __set(P, l, m, 2 * v + 1, V);
                a[v] = a[2 * v + 1] + a[2 * v + 2];
            }
            else
            {
                __set(P, m, r, 2 * v + 2, V);
                a[v] = a[2 * v + 1] + a[2 * v + 2];
            }
        }

        public:
        int Summ(int L, int R)
        {
            if (R < L)
                return 0;
            return __summ(L, R + 1, l, r, 0);
        }

        void Set(int P, int V)
        {
            __set(P, l, r, 0, V);
        }

        Small_Segment_Tree(int _n)
        {
            a.resize(4 * _n);
            l = 0, r = _n;
        }
    };
    long long inq(long long x, long long q, long long MOD)
    {
        if (q == 0)
            return 1;
        long long l = inq(x, q / 2, MOD);
        if (q % 2)
            return l * l % MOD * x % MOD;
        return l * l % MOD;
    }
};


using namespace MySpace;

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

const ll MOD = 1e9 + 7;
ll cnt[500];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> cnt[i];
    int k = 0;
    for (int i = 1; i + 1 < n; i++) k += ((cnt[i] < cnt[i - 1]) && (cnt[i] > cnt[i + 1])) || ((cnt[i] > cnt[i - 1]) && (cnt[i] < cnt[i + 1]));
    cout << k;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define _ 0
#define INF 0x7fffffff
#define int long long
#define mod 1000000007
#define re register
#define drep(i ,l ,r) for(re int i = (r) ; i >= (l) ; -- i)
#define rep(i ,l ,r) for(re int i = l ; i <= r ; ++ i)
#define Next(u ,i) for(re int i = head[u] ; i ; i = e[i].next)
const int N = 1e6 + 1;
int n ,ans ,jc[N] = {1};
int qpow(int i,int j) {return j ? j & 1 ? qpow(i * i % mod ,j >> 1) * i % mod : qpow(i * i % mod ,j >> 1) : 1 ;}
int read() {
    char cc = getchar() ; int cn = 0 ,flus = 1;
    while(cc < '0' || cc > '9') {if(cc == '-') flus = - flus ; cc = getchar();}
    while(cc >= '0' && cc <= '9') cn = cn * 10 + cc - '0' ,cc = getchar();
    return flus * cn;
}
int c(int i,int j) {
	return jc[i] * qpow(jc[j] * jc[i - j] % mod ,mod - 2) % mod;
}
signed main()
{
	rep(i ,1 ,N - 1) jc[i] = jc[i - 1] * i % mod;
	n = read();
	rep(i ,2 ,n) ans = (ans + (mod + qpow(2 ,i) - 2) * qpow(8 ,n - i) % mod * c(n ,i)) % mod;
	printf("%lld" ,ans);
	return ~~(0^_^0);
}

Measured memory_bytes: 9408
//============================================================================
// Name        : hoba.cpp :)
// Author      : (O_O Diab) (Why_not) (el 3AQ)
// Version     :
// Copyright   : please, Don't touch me :(
// Description : problem in C++
// MAIN IDEA   : combinatorics NCR
//============================================================================
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define rw freopen("graphs_as_a_service.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define rep(i,a) lp(i,0,a-1)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define EPS 1e-6
// to convert string to number use int a = stoi(string);
// to convert number to string use string s = to_string(int);
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define clr(c,x) memset(c,x,sizeof(c));
using namespace __gnu_pbds;
using namespace std;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int N = 2e5 + 3, mod = (int) 1e9 + 7, INF = 0x3f3f3f3f;
ll a[N] = { }, XOR[N] = { };
int main() {
#ifdef ONLINE_JUDGE
	FAST
#endif
	int n;
	cin >> n;
	lp(i,1,n)
	{
		cin >> a[i];
		XOR[i] = (a[i] ^ XOR[i - 1]);
		a[i] += a[i - 1];
	}
	ll answer = 0;
	lp(i,1,n)
	{
		int l = i, r = n, ans = 0;
		while (l <= r) {
			int mid = (l + r) / 2;
			if ((a[mid] - a[i - 1]) == (XOR[mid] ^ XOR[i - 1])) {
				ans = mid;
				l = mid + 1;
			} else
				r = mid - 1;
		}
		answer += (ans - i + 1);
	}
	f(answer);
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,k;
  cin >> n >> k;
  string s; cin >> s;
  int score = 0;
  rep(i,n-1){
    if(s[i] == s[i+1]) score++;
  }
  int ans = min(score+k*2,n-1);
  cout << ans;
  
  return 0;
}


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

int main(){
  ll N; cin >> N;
  ll tmp = N, ket = 0, lst, ans = 0;
  while(tmp > 0){
    lst = tmp % 10;
    ans += lst;
    tmp /= 10;
    ket++;
  }
  
  cout << max(ans, (ket-1) * 9 + lst - 1) << endl;
}

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

#define ff first
#define ss second
//#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp make_pair
#define endl "\n"      // Comment in INTERACTIVE(there just use endl which flushes output , no need of fflush(sdtout)).
//  for counting setbits -> __builtin_popcountll(x)
// for counting zerobits -> __builtin_ctzll(x)
#define fastio() ios_base::sync_with_stdio(false);        cin.tie(NULL); //(unties i/o buffer).
            // DON'T USE SCANF/PRINTF WITH IT (c/c++ -> seperates buffer).

const int mod = 1000000007;
const int inf = 1000000009;
 const int N = (1e5) + 2;
 int arr[N][4];
 int dp[N][4];
 int memo[N][3];
 int memonew[N][3];
 int cnt;


 int profit(int i,int next ){
// memoized BUT DIFFICULT to do from recursion AS IN STATE VAR next -> DEPEND ON next STATE
    // Better if DEPENDENT ON OWN , THEN MORE CLEAR.
    if(i <= 0)
        return 0;
    if(memo[i][next] != -1)
        return memo[i][next];

    int c1 = (next +1)%3;
    int c2 = (next  +2)%3;
    return memo[i][next] = max(profit(i-1,c1) + arr[i][c1+ 1] , profit(i-1,c2) + arr[i][c2 + 1]);
 }

// ** BETTER MEMOISED SOLUTION AS in state -> ARGUMENTS CORRESPOND TO THAT STATE , better to relate.
 int profitnew(int i,int cur){    // here represent cur value (out of 3) , which can take next based on it.

    if(i <= 0)
        return 0;
    if(memonew[i][cur] != -1)
        return memonew[i][cur];
    int c1 = (cur +1)%3;
    int c2 = (cur + 2)% 3;

    // have cur , assign diff from it.
    // Here see PREVIOUS WITH DIFF char as present , find best and ADD CURR character.
    ++cnt;
    return memonew[i][cur] = max(profitnew(i-1, c1)  , profitnew(i-1,c2) ) + arr[i][cur + 1];
 }

int32_t main(){
    fastio();

    // #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    // #endif

     memset(memo, - 1, sizeof(memo));
     memset(memonew, - 1, sizeof(memonew));
     

     // ***** AC_chahiye EK BAR MEIN

     // BEGIN CODE HERE
    int n ;
    cin>>n;
    for(int i = 1;i <= n; ++i){
        cin>>arr[i][1]>>arr[i][2]>>arr[i][3];
    }
    dp[0][0] = dp[0][1] = dp[0][2] = dp[0][3] = 0;
    for(int i = 1;i <= n; ++i){
        for(int j = 1;j <= 3 ; ++j){
            int mx = 0;
            for(int k = 1;k <= 3; ++k){
                if(j != k)
                    mx = max(mx,dp[i - 1][k]);
            }
            dp[i][j] = mx + arr[i][j];
        }
    }
    // cout<<max({dp[n][1],dp[n][2],dp[n][3]})<<endl;

    // cout<<max({profit(n,0) , profit(n,1) , profit(n,2) })<<endl;

    cout<<max({profitnew(n,0) , profitnew(n,1)  , profitnew(n, 2)})<<endl;

    // for(int i = 1;i <= n; ++i){
    //     for(int j = 0;j < 3; ++j){
    //         cout<<memo[i][j]<<' ';
    //     }
    //     cout<<'\n';
    // }
    // for(int i = 1;i <= n; ++i){
    //     for(int j = 0;j < 3; ++j){
    //         cout<<memonew[i][j]<<' ';
    //     }
    //     cout<<'\n';
    // }

    // cout<<cnt<<endl;
    //getch();
}


Measured memory_bytes: 12032
#include <iostream>
#include <stack>

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

using namespace std;
using ll = long long;

int main()
{
    ll N;
    cin>>N;
    string alf = "abcdefghijklmnopqrstuvwxyz";
    stack<char> res;

    int v;
    while(N!=0){
        N--;
        res.push(alf[N%26]);
        N/=26;
    }

    while(!res.empty()){
        cout << res.top();
        res.pop();
    }
    cout << endl;
    

    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE 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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin >> n;
  vll a(n);
  REP(i, n)
    cin >> a[i];

  sort(a.begin(), a.end());
  cout << a[n-1] - a[0] << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	bool ok = false;
	string s;
	cin>>s;
	rep(i,s.size()){
		if(s.substr(i,2) == "AC") ok = true;
	}
	cout<<(ok?"Yes":"No")<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 764
#a, v = gets.split.map(&:to_i)

n = gets.to_i
as = gets.split.map(&:to_i)

hh = {}
sum = 0
as.each do |a|
    hh[a] = 0 if hh[a] == nil
    hh[a] += 1
    sum += a
end

q = gets.to_i
q.times do |i|
    b, c = gets.split.map(&:to_i)
    if hh[b] == nil
        puts sum
        next
    end
    cnt = hh[b]
    hh[b] = nil
    sum -= b*cnt
    sum += c*cnt
    if hh[c] == nil
        hh[c] = cnt
    else
        hh[c] += cnt
    end
    puts sum
end



Measured memory_bytes: 25704
#include <stdio.h>

/* prototype declaration */
void classify(double w);

int main(int argc, const char *argv[])
{
	double weight;
	while(scanf("%lf",&weight) != EOF)
		classify(weight);	
	return 0;
}

void classify(double w)
{
	if(w <= 48.00) printf("light fly\n");
	else if(w <= 51.00) printf("fly\n");
	else if(w <= 54.00) printf("bantam\n");
	else if(w <= 57.00) printf("feather\n");
	else if(w <= 60.00) printf("light\n");
	else if(w <= 64.00) printf("light welter\n");
	else if(w <= 69.00) printf("welter\n");
	else if(w <= 75.00) printf("light middle\n");
	else if(w <= 81.00) printf("middle\n");
	else if(w <= 91.00) printf("light heavy\n");
	else printf("heavy\n");
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll W;
ll dp[MAX_N];

void solve() {
	cin >> N >> W;
	rep(i, 1, 100000 + 1) dp[i] = linf;

	rep(i, 0, N) {
		ll w, v; cin >> w >> v;
		rer(j, 100000, 0) {
			if(j + v <= 100000) MIN(dp[j + v], dp[j] + w);
		}
	}
	int res = 0;
	rep(i, 0, 100000 + 1) {
		if(dp[i] <= W) res = i;
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

vector<long int> v;

void precompute(){
	v.push_back(1);
	for(long int i = 2; i <= 1000; i++)
		v.push_back(v.back() + i);
}



int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n;
   cin>>n;

   precompute();

   auto copy = n;
   n = sqrt(n);

   long int ans = 0;
   for(long int i = 2; i <= n; i++){
   		if(copy % i == 0){
   			long int cnt = 0;
   			while(copy && (copy % i == 0)){
   				copy /= i;
   				cnt++;
   			}
   			ans += (upper_bound(v.begin(),v.end(),cnt) - v.begin());
   		}
   }

   if(copy > 1)
   	ans++;

   cout<<ans;
   return 0;
}

Measured memory_bytes: 3716
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <bitset>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

template<class T>
inline bool chmin(T& a, const T b) { return a > b && (a = b, true); }

inline int popcount(lint n) {
	n = (n & 0x5555555555555555) + (n >> 1 & 0x5555555555555555);
	n = (n & 0x3333333333333333) + (n >> 2 & 0x3333333333333333);
	n = (n & 0x0f0f0f0f0f0f0f0f) + (n >> 4 & 0x0f0f0f0f0f0f0f0f);
	n = (n & 0x00ff00ff00ff00ff) + (n >> 8 & 0x00ff00ff00ff00ff);
	n = (n & 0x0000ffff0000ffff) + (n >> 16 & 0x0000ffff0000ffff);
	n = (n & 0x00000000ffffffff) + (n >> 32 & 0x00000000ffffffff);
	return n;
}

int main() {

	int N;
	cin >> N;

	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> B[i];

	int ans = INF;
	auto swap_count = [&](auto &svec) {

		DMP(svec);
		// buble sort
		int swaps = 0;
		for (int i = 0; i < N - 1; ++i) {
			for (int j = 0; j < N - i - 1; ++j) {
				if (svec[j].second > svec[j + 1].second) {
					swap(svec[j], svec[j + 1]);
					swaps++;
				}
			}
		}
		DMP(svec);

		return swaps;
	};

	for (int bit = 0; bit < (1 << N); bit++) {

		if (popcount(bit) & 1) continue;

		vector<pair<int, int>> odd, even;
		for (int i = 0; i < N; i++) {
			if (((bit >> i) & 1)) {
				if (i & 1) odd.emplace_back(B[i], i);
				else even.emplace_back(B[i], i);
			}
			else {
				if (i & 1) even.emplace_back(A[i], i);
				else odd.emplace_back(A[i], i);
			}
		}

		if (odd.size() == (N + 1) / 2 && even.size() == N / 2) {
			sort(odd.begin(), odd.end());
			sort(even.begin(), even.end());
			vector<pair<int, int>> vec(N);
			for (int i = 0; i < N; i++) {
				if (i & 1) vec[i] = even[i / 2];
				else vec[i] = odd[i / 2];
			}

			if (is_sorted(vec.begin(), vec.end(), [](auto& l, auto& r) { return l.first < r.first; })) {
				chmin(ans, swap_count(vec));
			}
		}
	}

	cout << (ans == INF ? -1 : ans) << "\n";

	return 0;
}



Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll s=a+b;
  ll ans=n/s*a+min(n%s,a);
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256