akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main()
{
    //データ定義
    string str;
    int i;

    //データ取得
    getline(cin, str);

    //大文字と小文字の入れ替え
    for(i = 0; i < str.size(); i++)
    {
        if('a' <= str[i] && str[i] <= 'z'){
            str[i] += 'A' - 'a';
        }
        else if ('A' <= str[i] && str[i] <= 'Z')
        {
            str[i] += 'a' - 'A';
        }
    }

    //結果出力
    cout << str << endl;

    return 0;
}


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

using namespace std;

int main() {
	int N, X, L;
	cin >> N >> X;
	int ans = 1, sum = 0;
	for (int i = 2; i <= N + 1; i++) {
		cin >> L;
		sum += L;
		if (sum <= X) ans = i;
	}		
	cout << ans << "\n";
}

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

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    ll n,m; cin>>n>>m;
    ll s[n+1]={};
    
    
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        if(b<a) swap(a,b);
        s[a]++;
        s[b]--;
    }
    for(int i=0;i<n;i++){
        s[i+1] += s[i];
    }
    
    for(int i=0;i<n;i++){
        //cerr<<s[i] <<" ";
        if(s[i]%2==1){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

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

}


Measured memory_bytes: 51944
n = int(input())
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b) 
A = sorted(A)
B = sorted(B, reverse = True)

ans = 0
ans += A[0]
for i in range(1, n):
    if(A[i] - A[i - 1] > B[i - 1] - B[i]):
        ans += B[i - 1] - B[i]
    else:
        ans += A[i] - A[i - 1]
ans += B[-1]
print(ans)


Measured memory_bytes: 12484
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    double p;
    vector<double> dp(n+1,0.0);
    dp[0]=1.0;
    for(int i=0;i<n;i++){
    	cin>>p;
    	for(int j=n-1;j>=0;j--){
    		dp[j+1]+=dp[j]*p;
    		dp[j]=dp[j]*(1.0-p);
    	}
    }
    double ans=0.0;
    for(int i=(n+2)/2;i<=n;i++){
    	ans+=dp[i];
    }
    doublecout(ans);
    return 0;
}


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

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (abs(C-A)<=D || (abs(B-A)<=D && abs(C-B)<=D)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int X = IN();
	cout << (X < 1200 ? "ABC" : "ARC") << endl;
}

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

#define int long long

const int N = 1e5 + 5, MOD = 1e9 + 7;

int32_t main(){

	int n; cin>>n;
	int a;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin>>a;
		if(i%2 and a%2){
			ans++;
		}
	}	    

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


Measured memory_bytes: 3600
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

ll N, ans;

int main() {
	rd(N);
	ll i = 1;
	while (1) {
		if (i*i > N) break;
		ans = i*i;
		i++;
	}
	wrln(ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

int main(){
  int n, r;
  while(scanf("%d%d", &n, &r) && n+r){
    vector<int>vi(n);
    int t = n;
    rep(i, n) vi[i] = t--;
    int p, c;
    while(r--){
      scanf("%d%d", &p, &c);
      p--;
      vector<int>tmp;
      rep(i, c){
	tmp.push_back(vi[p]);
	vi.erase(vi.begin()+p);
      }
      vi.insert(vi.begin(), tmp.begin(), tmp.end());
      /*      puts("");
      rep(i, n){
	printf("%d ", vi[i]);
	}*/
    }
    printf("%d\n", vi[0]);
  }
  return 0;
}

Measured memory_bytes: 1220
#include<queue>
#include<string>
#include<iostream>

#define	mp	make_pair

using namespace std;

typedef	pair<int,int>	pii;

bool isHomochrome(int stat,int len){
	int color=stat&3;
	for(int i=0;i<len;i++,stat>>=2)	if((stat&3)!=color)	return false;
	return true;
}

int getColor(int stat,int i){
	return (stat>>(2*i))&3;
}

void setColor(int &stat,int i,int c){
	stat&=~(3<<(2*i));
	stat|=c<<(2*i);
}

int main(){
	static int memo[1<<20];
	for(string worm;cin>>worm,worm!="0";){
		int len=worm.length();
		for(int i=0;i<(1<<(2*len));i++)	memo[i]=1<<30;

		int inistat=0;
		for(int i=0;i<len;i++){
			if(worm[i]=='r')	inistat=(inistat<<2)+0;
			if(worm[i]=='g')	inistat=(inistat<<2)+1;
			if(worm[i]=='b')	inistat=(inistat<<2)+2;
		}

		int ans=-1;
		memo[inistat]=0;
		queue<pii> qu;	qu.push(mp(0,inistat));
		while(!qu.empty()){
			pii a=qu.front();	qu.pop();
			int t=a.first,stat=a.second;
			if(isHomochrome(stat,len)){ ans=t; break; }
			for(int i=0;i<len-1;i++){
				int clr[]={getColor(stat,i),getColor(stat,i+1)};
				if(clr[0]!=clr[1]){
					int nextclr;
					for(int c=0;c<=2;c++)	if(clr[0]!=c && clr[1]!=c)	nextclr=c;
					int nextstat=stat;
					setColor(nextstat,i  ,nextclr);
					setColor(nextstat,i+1,nextclr);
					if(t+1<memo[nextstat]){
						qu.push(mp(t+1,nextstat));
						memo[nextstat]=t+1;
					}
				}
			}
		}

		if(~ans)	cout<<ans<<endl;
		else		cout<<"NA"<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int N, M;

int main() {
  cin >> N >> M;
  int a[100000] = {0};
  int b[100000] = {0};
  rep(i, M) {
    int temp;
    string res;
    cin >> temp >> res;
    temp--;
    if(res == "WA") {
      if(b[temp] == 0) {
        a[temp]++;
      }
    } else {
      if(b[temp] == 0) {
        b[temp] = 1;
      }
    }
  }
  int ans1 = 0, ans2 = 0;
  rep(i, N) {
    if(b[i] != 0) {
      ans1 += a[i];
    }
    ans2 += b[i];
  }
  cout << ans2 << " " << ans1 << endl;
  return 0;
}

Measured memory_bytes: 4440
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(void){
    int n;
    cin >> n;
    
    int i;
    
    string s;
    
    cin >> s;
    
    int countl=0;
    int countr=0;
    
    for(i=0;i<n;i++){
        if(s[i] == 'R'){
            countr++;
        }else{
            countl++;
        }
    }
    int num=0;
    for(i=0;i<countr;i++){
        if(s[i] == 'W'){
            num++;
        }
    }
    cout << num << endl;
}

Measured memory_bytes: 3728
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,k;cin>>n>>k;
  int a[20000];
  for(int i=1;i<=n;++i) cin>>a[i];
  sort(a+1,a+1+n);
  int ans=0;
  for(int i=1;i<=k;++i) ans+=a[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
typedef pair<ll,ll> Pair;
const ll inf =1000000007;

void solve(){
    ll n,k;
    cin >> n >>k;
    vector<ll> road;
    rep(i,n){
        ll a;
        cin >> a;
        road.pb(a);
    }
    isort(road);
    ll score=inf;
    for(ll i=0;i+k-1<n;i++){
        if(road[i]*road[i+k-1]<0){
            ll a=max(abs(road[i]),abs(road[i+k-1])),b=min(abs(road[i]),abs(road[i+k-1]));
            ll ans=a+b*2;
            score=min(score,ans);
        }
        else{
            ll ans=max(abs(road[i]),abs(road[i+k-1]));
            score=min(score,ans);
        }
    }
    kaku(score);
}

int main(){
    solve();
}




//




Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;
 
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
 
int n;
vector<int> g[202020];
bool fav[202020];
int far[202020];
int second_farthest[202020];
int closest[202020];
bool in_fav[202020];
long long ans = 0;
 
static const int INF = 0x3f3f3f3f;
 
void dfs1(int v, int prev) {
        if (fav[v]) in_fav[v] = true;
        for (auto u : g[v]) if (u != prev) {
                dfs1(u, v);
                in_fav[v] |= in_fav[u];
                far[v] = max(far[v], far[u] + 1);
        }
}
 
void dfs2(int v, int ma, bool par_fav, int prev) {
        vector<pair<pii, bool>> children;
        children.push_back(mp(mp(0, -1), false));
        for (auto u : g[v]) {
                if (u == prev) children.push_back(mp(mp(ma + 1, u), par_fav));
                else children.push_back(mp(mp(far[u] + 1, u), in_fav[u]));
        }
        vector<int> fav_children;
        for (auto c : children) if (c.second) fav_children.push_back(c.first.first);
        closest[v] = INF;
        for (int i = 0; i < fav_children.size(); i ++) closest[v] = min(closest[v], fav_children[i]);
        sort(all(children), greater<pair<pii, bool>>());
        second_farthest[v] = children[1].first.first;
        for (auto u : g[v]) if (u != prev) { 
                int maa = children[u == children[0].first.second ? 1 : 0].first.first;
                bool par_f = fav[v] || par_fav;
                if (!in_fav[u]) par_f |= !fav_children.empty();
                else par_f |= fav_children.size() > 1;
                ans += (maa < far[u] && par_f) || (maa > far[u] && in_fav[u]) || (maa == far[u] && (par_f || in_fav[u]));
                dfs2(u, maa, par_f, v);
        }
}
 
int main() {
        cin >> n;
        for (int i = 0; i < n - 1; i ++) {
                int a, b;
                cin >> a >> b;
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        string s;
        cin >> s;                                            
        for (int i = 0; i < n; i ++) fav[i] = s[i] == '1' ? true : false;
        dfs1(0, -1);
        dfs2(0, 0, fav[0], -1);
        for (int i = 0; i < n; i ++) {
                if (fav[i]) ans += 1 + second_farthest[i];
                else ans += max(0, 1 + (second_farthest[i] - closest[i]));
        }
        cout << ans << endl;
        return 0;
}


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

using namespace std;

const int mod = 1'000'000'007;

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

void sub(int &a, int b) {
  a -= b;
  if (a < 0) {
    a += mod;
  }
}

int mul(int a, int b) {
  return (int)(1LL * a * b % mod);
}

const long long inf = 1e18;
const int N = 200010;

int n;
vector < pair <int, int> > g[N];

void work(int from, vector <long long> &d, vector <int> &ways) {
  set < pair <long long, int> > s;
  for (int i = 0; i < n; ++i) {
    d[i] = inf;
    ways[i] = 0;
  }
  d[from] = 0;
  ways[from] = 1;
  s.emplace(0, from);
  while (!s.empty()) {
    int x = (s.begin())->second;
    s.erase(s.begin());
    for (auto e : g[x]) {
      int y = e.first;
      int c = e.second;
      if (d[x] + c < d[y]) {
        if (d[y] != inf) {
          s.erase(s.find({d[y], y}));
        }
        d[y] = d[x] + c;
        ways[y] = ways[x];
        s.emplace(d[y], y);
      } else
      if (d[x] + c == d[y]) {
        add(ways[y], ways[x]);
      }
    }
  }
}

int x[N];
int y[N];
int v[N];
bool bad[N];

int main() {
  int m, s, t;
  scanf("%d %d %d %d", &n, &m, &s, &t);
  --s; --t;
  for (int i = 0; i < n; ++i) {
    g[i].clear();
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d %d %d", x + i, y + i, v + i);
    --x[i]; --y[i];
    g[x[i]].emplace_back(y[i], v[i]);
    g[y[i]].emplace_back(x[i], v[i]);
  }
  vector <long long> ds(n);
  vector <int> ws(n);
  work(s, ds, ws);
  vector <long long> dt(n);
  vector <int> wt(n);
  work(t, dt, wt);
  memset(bad, false, sizeof bad);
  int ans = mul(ws[t], ws[t]);
  for (int i = 0; i < n; ++i) {
    if (i == s || i == t) {
      continue;
    }
    if (ds[i] + dt[i] == ds[t] && ds[i] == dt[i]) {
      int z = mul(ws[i], wt[i]);
      sub(ans, mul(z, z));
      bad[i] = true;
    }
  }
  for (int i = 0; i < m; ++i) {
    if (bad[x[i]] || bad[y[i]]) {
      continue;
    }
    if (ds[x[i]] + v[i] + dt[y[i]] == ds[t] && max(ds[x[i]], dt[y[i]]) - min(ds[x[i]], dt[y[i]]) <= v[i]) {
      int z = mul(ws[x[i]], wt[y[i]]);
      sub(ans, mul(z, z));
    } else
    if (ds[y[i]] + v[i] + dt[x[i]] == ds[t] && max(ds[y[i]], dt[x[i]]) - min(ds[y[i]], dt[x[i]]) <= v[i]) {
      int z = mul(ws[y[i]], wt[x[i]]);
      sub(ans, mul(z, z));
    }
  }
  printf("%d\n", ans);
}


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

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    double ans = sqrt((pow(x1-x2, 2)+pow(y1-y2, 2)));

    printf("%lf\n", ans);
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string str;
	cin>>str;
	if(str=="ABC")puts("ARC");
	else puts("ABC"); 
	return 0;
}


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

int main(){
  int a,b;
  cin>>a>>b;
  b*=2;
  cout<<max(0,a-b)<<endl;
  return(0);
}


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

int main(){
  int n;
  cin>>n;
  vector<int> t(n+1);
  vector<int> x(n+1);
  vector<int> y(n+1);
  rep(i,n) cin>>t[i+1]>>x[i+1]>>y[i+1];
  bool can = true;
  rep(i,n){
    int dt=t[i+1]-t[i];
    int dist = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    if(dt<dist) can = false;
    if(dist%2 != dt%2) can = false;
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {

	string s; cin >> s;
	int a = 0;
	int b = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') a++;
		if (s[i] == '1') b++;
	}
	cout << 2 * min(a, b) << endl;
	return 0;
}


Measured memory_bytes: 3732
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
int n,mod;
ll f[100100],g[100100];
vector<int> sq[100100];
vector<ll> pre[100100],suf[100100];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

void dfs1(int u,int fu)
{
	f[u]=1;int len=sq[u].size();
	rep(i,0,len-1)
	{
		int v=sq[u][i];
		if (v==fu)
		{
			pre[u].pb(1);suf[u].pb(1);
			continue;
		}
		dfs1(v,u);
		f[u]=f[u]*(f[v]+1)%mod;
		pre[u].pb(f[v]+1);suf[u].pb(f[v]+1);
	}
	rep(i,1,len-1) pre[u][i]=pre[u][i]*pre[u][i-1]%mod;
	per(i,len-2,0) suf[u][i]=suf[u][i]*suf[u][i+1]%mod;
}

void dfs2(int u,int fu)
{
	int len=sq[u].size();
	rep(i,0,len-1)
	{
		int v=sq[u][i];
		if (v==fu) continue;
		ll tmp=1;
		if (i) tmp=tmp*pre[u][i-1]%mod;
		if (i<len-1) tmp=tmp*suf[u][i+1]%mod;
		g[v]=(tmp*g[u]+1)%mod;
		dfs2(v,u);
	}
}

int main()
{
	n=read();mod=read();
	rep(i,1,n-1)
	{
		int u=read(),v=read();
		sq[u].pb(v);sq[v].pb(u);
	}
	dfs1(1,0);g[1]=1;dfs2(1,0);
	rep(i,1,n) printf("%lld\n",f[i]*g[i]%mod);
	return 0;
}


Measured memory_bytes: 27264
Scanf.scanf "%d %f %f" (fun n t a ->
    let h = Array.init n (fun _ -> Scanf.scanf " %f" (fun h -> h)) in
    let rec loop i dist di =
        if i = n then di + 1 else
            let v = t -. h.(i) *. 0.006 in
            let k = abs_float (a -. v) in
            if k < dist then loop (i + 1) k i
                        else loop (i + 1) dist di
    in
    loop 0 10000. 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int n;
	int a,b,c;
	int d,e,f;
	int s;
	int i;
	int cnt,cnt1,cnt2,cnt3;
	cnt=cnt1=cnt2=cnt3=0;
	
	while(scanf("%d %d %d",&a,&b,&c)!=EOF){
		//for(i=0;i<5;i++){
			d=a*a;
			e=b*b;
			f=c*c;
			if(c>=a && c>=b && c<a+b || b>=a && b>=c && b<c+a || a>=c && a>=b && a<b+c){
				cnt++;
				if(c>=a && c>=b){
					s=f-d-e;
					if(s==0){
						cnt1++;
					}
					else if(s<0){
						cnt2++;
					}
					else if(s>0){
						cnt3++;
					}
				}
				else if(b>=a && b>=c){
					s=e-d-f;
					if(s==0){
						cnt1++;
					}
					else if(s<0){
						cnt2++;
					}
					else if(s>0){
						cnt3++;
					}
				}
				else if(a>=c && a>=b){
					s=d-f-e;
					if(s==0){
						cnt1++;
					}
					else if(s<0){
						cnt2++;
					}
					else if(s>0){
						cnt3++;
					}
				}
			}
			else if(c>=a && c>=b && c>=a+b || b>=a && b>=c && b>=c+a || a>=c && a>=b && a>=b+c){
				break;
			}
		//}
	}
	printf("%d %d %d %d\n",cnt,cnt1,cnt2,cnt3);
	return 0;
}
	

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

typedef long long ll;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<ll>;
using vll = vector<vector<ll>>;

#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define MOD 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  char t;
  cin >> t;
  cout << (char)(t+1) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=64;
int N,nums[maxn];
int main()
{
    int cnt=0;
    scanf("%d",&N);for(int i=1;i<=N;i++)
    {
        scanf("%d",&nums[i]);
        if(nums[i]!=i) cnt+=1;
    }
    if(cnt==2||cnt==0) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
n = input()

"""max(n) = 100000"""
if len(n) == 6:
  res = 9 + 900 + 90000
  print(res)
elif len(n) == 5:
  res = 9 + 900 + (int(n) -9999)
  print(res)
elif len(n) == 4:
  res = 9 + 900
  print(res)
elif len(n) == 3:
  res = 9 + (int(n) - 99)
  print(res)
elif len(n) == 2:
  res = 9
  print(res)
else:
  res = int(n)
  print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
 
int main()
{
 
    int n;
    cin>>n;

    string s;
    cin>>s;

    string t;
    cin>>t;

    int cnt;
    int max_cnt=0;
    for(int i=0;i<n;i++){
        cnt=0;
        for(int j=0;j<n-i;j++){
            if(s.at(i+j)==t.at(j))
                cnt++;
        }
        max_cnt=max(max_cnt,cnt);
    }

    cout<<2*n-max_cnt;

    return 0;
}   

Measured memory_bytes: 256
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int> > matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};
map<string,int>kol;
string s[maxn];
vector<string>v;
int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n,mx=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
        kol[s[i]]++;
        mx=max(mx,kol[s[i]]);
    }
    for(int i=1;i<=n;i++){
        if(mx==kol[s[i]]){
            v.pb(s[i]);
        }
        kol[s[i]]=-1;
    }
    sort(all(v));
    for(auto i:v){
        cout<<i<<"\n";
    }
    exit(0);
}


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

using namespace std;

long long INF=1e15;

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

    int n;
    cin>>n;

    string s1,s2,s3,s4,s5,s6,s7,s8,s9;
    s1=".,!? ";s2="abc";s3="def";s4="ghi";s5="jkl";
    s6="mno";s7="pqrs";s8="tuv";s9="wxyz";
    
    for(int i=0;i<n;i++){
        string S;
        cin>>S;
        int sum=0;
        char c;
        string s;
        bool f=false;
        for(int j=0;j<S.size();j++){
            if(S[j]!='0'){
                f=true;
                c=S[j];
                sum++;
                if(c=='1')s=s1;if(c=='2')s=s2;if(c=='3')s=s3;
                if(c=='4')s=s4;if(c=='5')s=s5;if(c=='6')s=s6;
                if(c=='7')s=s7;if(c=='8')s=s8;if(c=='9')s=s9;
            }
            else{
                sum--;
                if(s==s1)sum%=5;
                else if(s==s7||s==s9)sum%=4;
                else sum%=3;
                if(f)cout<<s[sum];
                sum=0;
                f=false;
            }
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3136
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int num = 2000000;
int a[num];
int h;
inline int pa(int i) { return i / 2; }
void maxHeapify(int i) {
	int l = i*2;
	int r = i*2+1;
	int lg;
	if (l <= h && a[i] < a[l])
		lg = l;
	else lg = i;
	if (r <= h && a[lg] < a[r])
		lg = r;
	if (lg != i) {
		swap(a[i], a[lg]);
		maxHeapify(lg);
	}
}
inline void insert(int k) {
	h++;
	a[h] = k;
	int i = h;
	while (i > 1 && a[i] > a[pa(i)]) {
		 swap(a[i], a[pa(i)]);
		i = pa(i);
	}
}
inline void extract(){
	printf("%d", a[1]);
	printf("\n");
	a[1] = a[h];
	h--;
	maxHeapify(1);
}
int main() {
	char com[10];
	int key;
	for (int i = 1; ; i++) {
		scanf("%s", &com);
		if (com[0] == 'i') {scanf("%d", &key); insert(key);}
		else if (com[1] == 'x') extract();
		else break;
	}
	return 0;
}

Measured memory_bytes: 7024
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int N = 1e5+10;
int n;
char s[N];

int main(){
    scanf("%d%s",&n,s);
    int ans = 1;
    for(int i=1;i<n;++i){
        if(s[i]!=s[i-1])    ans++;
    }

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


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

using namespace std;
#define ll long long
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;
typedef pair<int,int>           PI;
typedef pair<ll,ll>             PL;
typedef vector<PI>               vip; 
typedef vector<int>             vi;
typedef vector<vi>              vvi;
typedef vector<ll>              vl;
typedef vector<vl>              vvl;








int main (){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    unordered_map<int, int> map;
    REP(i,n){
        ll a = 0;
        cin >> a;
        map[a]++;
    }

    int count = 0;
    for(auto e : map){
        if(e.second % 2 == 1) ++count;
    }


    cout << count << endl;



    return 0;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    char a[3];
    
    cin>>a;
    
    if(a[0]>a[1]){
        a[1]=a[0];
        a[2]=a[0];
    }
    if(a[0]==a[1]){
        if(a[1]>=a[2])a[2]=a[0];
        else{
            a[0]++;
            a[1]++;
            a[2]=a[0];
        }
    }
    else{
            a[0]++;
            a[1]=a[0];
            a[2]=a[0];
    }
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
/*Templates are for weak. -invictus_123*/
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 1;
int ans = 0, d[MAX];
bool v[MAX];
vector <int> g[MAX];
void dfs(int cur) {
	v[cur] = true;
	for(int x : g[cur]) {
		if(!v[x]) {
			dfs(x);
		}
		d[cur] = max(d[cur], d[x] + 1);
	}
	ans = max(ans, d[cur]);
}
int main() {
 	int n, m;
 	scanf("%d%d", &n, &m);
 	while(m --) {
 		int x, y;
 		scanf("%d%d", &x, &y);
 		g[x].push_back(y);
 	}
 	for(int i = 1; i <= n; i ++) {
 		if(!v[i]) {
 			dfs(i);
 		}
 	}
 	printf("%d", ans);
    return 0;
}

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

#define rep(i,n) for(signed i=0;i<n;++i)
#define int long long
#define str string
#define debg(a) cout<<#a<<":"<<a<<endl;
#define print(a) cout<<a<<endl;
#define end cout<<endl;
#define elif else if


int a,b,c,i,j,k,n,m,x,y,z;
str s,t;
vector<signed> v;

signed main(){
  
  int a,b,n;
  cin>>n>>a>>b;
  cout<<min(a,b)<<" ";
  if((a+b-n)<0)cout<<0;
  else cout<<(a+b-n);
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, W;
    cin >> n >> W;
    vector<long long> w(n + 1), v(n + 1);
    for (int i = 1; i <= n; i++) cin >> w[i] >> v[i];
    //long long dp[n + 1][W + 1];
    vector<long long>dp(W + 1, 0);
   // for (int i = 0; i <= n; i++) for (int j = 0; j<= W; j++) dp[i][j] = 0;
    // dp[i] la gia tri lon nhat tai i voi trong luong j
    //dp[0][w[0]] = v[0];
    for (int i = 1; i <= n; i++){
        for (int j = W - w[i]; j >= 0; j--){
            //dp[i][j] = max(dp[i][j], dp[i-1][j]);
            //if (j - w[i] >= 0){
                //dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
                dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
            //}

        }
    }

    //cout << dp[n][W];
    //for (int i = 0; i<= W; i++) cout << dp[i] << " ";
    //cout << dp[W];
    long long ans = 0;
    for (int i = 0; i<=W; i++) ans = max(ans, dp[i]);
    cout << ans;
}


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

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

    ll N;

    cin >> N;

    vector<ll> V(N);

    for (ll i=0; i<N; ++i)
    {
        cin >> V[i];
    }

    sort(V.begin(), V.end());

    V.erase(unique(V.begin(), V.end()), V.end());

    (V.size() == N) ? cout << "YES" : cout << "NO";

    return 0;
}

Measured memory_bytes: 1792
import queue
K=int(input())

q = queue.Queue()
for i in range(9):
    i+=1
    q.put(i)

tmp=9

while tmp<K:
    a=q.get()
    d=a%10
    if d != 0:
        hoge=a*10+(d-1)
        q.put(hoge)
        tmp+=1
        if tmp==K:
            break
    
    hoge=a*10+d
    q.put(hoge)
    tmp+=1
    if tmp==K:
        break

    if d != 9:
        hoge=(a*10)+(d+1)
        q.put(hoge)
        tmp+=1
        if tmp==K:
            break

if K <= 9:
    print(K)
else:
    print(hoge)

Measured memory_bytes: 53716
#include<stdio.h>
#include<math.h>
#include<stdlib.h>


int main(){
    char s[3];
    scanf("%s", s);
    if(s[1]=='B')
    	printf("ARC\n");
    else if(s[1]=='R')
    	printf("ABC\n");

    return 0;
}


Measured memory_bytes: 1640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll n;
string s;
cin>>n>>s;
ll cnt=0;
for(int i=0;i<n;i++){
    for(int j=1;j<n-i+1;j++){
        if(s.substr(i,j)=="ABC"){
            cnt++;
        }
    }
}
cout<<cnt;
}










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

int main(){
    ll a,b;
    cin>>a>>b;
    if(b>=a){
        cout<<a<<endl;
    }else{
        cout<<a-1<<endl;
    }
}

Measured memory_bytes: 256
from bisect import bisect_left
def main():
    n,c = map(int,input().split())
    xv = [tuple(map(int,input().split())) for _ in range(n)]
    xvr = []
    for i in range(n):
        j = n-i-1
        xvr.append((c-xv[j][0],xv[j][1]))
    xvv = [0]*n
    xvv[0] = xv[0]
    for i in range(1,n):
        xvv[i] = (xv[i][0],xvv[i-1][1]+xv[i][1])
    xvrv = [0]*n
    xvrv[0] = xvr[0]
    for i in range(1,n):
        xvrv[i] = (xvr[i][0],xvrv[i-1][1]+xvr[i][1])
    xvm = [(0,0)]
    xvmi = [0]
    for i in xvv:
        j = xvm[-1]
        if i[1]-i[0] >= j[1]-j[0]:
            xvm.append(tuple(i))
            xvmi.append(i[0])
    xvrm = [(0,0)]
    xvrmi = [0]
    for i in xvrv:
        j = xvrm[-1]
        if i[1]-i[0] >= j[1]-j[0]:
            xvrm.append(tuple(i))
            xvrmi.append(i[0])
    ans = max([xvm[-1][1]-xvm[-1][0],xvrm[-1][1]-xvrm[-1][0]])
    for i in xvm:
        t = c-i[0]
        idx = bisect_left(xvrmi,t)-1
        tans = xvrm[idx][1]-xvrm[idx][0]+i[1]-i[0]*2
        if tans > ans:
            ans = tans
    for i in xvrm:
        t = c-i[0]
        idx = bisect_left(xvmi,t)-1
        tans = xvm[idx][1]-xvm[idx][0]+i[1]-i[0]*2
        if tans > ans:
            ans = tans
    print(ans)
    
if __name__ == '__main__':
    main()

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n, m;
	string s, t;
	cin >> n >> m >> s >> t;

	ll l = lcm(n, m);
	ll add = lcm(l / n, l / m);
	for (ll i = 0; i < l; i += add) {
		if (s[i / (l / n)] != t[i / (l / m)]) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << l << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<Integer> set = new HashSet<>();
        for(int i = 0; i < n; i++) {
        	int num = sc.nextInt();
        	if(set.contains(num)) {
        		System.out.println("NO");
        		return;
        	}
        	set.add(num);
        }

        System.out.println("YES");
    }
}


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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v,n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vlint(v,n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v,n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v,n1,n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v,n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long int MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

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


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

  int n;
	string s, t;
	cin >> n >> s >> t;
	for(int i = n; i >= 0; i--){
		string tmps = s.substr(n - i, i);
		string tmpt = t.substr(0, i);
		if(tmps == tmpt){
			cout << s.length() + n - i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,k;
    cin>>n>>k;
    for(int i=n,j=1;i>=1;i--,j++){
        if(i==k){
            cout<<j<<endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long LL;
typedef long double LD;
int read() {
    char ch = getchar();
    int x = 0, flag = 1;
    for (;!isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
    for (;isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x * flag;
}
void write(int x) {
    if (x < 0) putchar('-'), x = -x;
    if (x >= 10) write(x / 10);
    putchar(x % 10 + 48);
}

const int Maxn = 109, Maxc = 1009;
const LL oo = 0x3f3f3f3f3f3f3f3f;
int n, weight[Maxn], val[Maxn], w;
LL dp[Maxc * Maxn];

void init() {
	n = read(); w = read();
	rep (i, 1, n) 
		weight[i] = read(), val[i] = read();
}

void solve() {
	clar(dp, 0x3f); dp[0] = 0;
	rep (i, 1, n)
		drep (j, (Maxc - 9) * Maxn, val[i]) 
			if (dp[j - val[i]] != oo) 
				dp[j] = min(dp[j - val[i]] + weight[i], dp[j]);

	drep (i, (Maxc - 9) * Maxn, 0) 
		if (dp[i] <= w) {
			printf("%d\n", i);
			return ;
		}
}

int main() {
//	freopen("e.in", "r", stdin);
//	freopen("e.out", "w", stdout);

	init();
	solve();

#ifdef Qrsikno
    debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
    return 0;
}



Measured memory_bytes: 1152
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_103_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(12).
    01 maxlen PIC 9(1)  VALUE 3.
    01 cur    PIC 9(12) VALUE 1.
    01 i      PIC 9(18) VALUE 1.
    01 j      PIC 9(18).
    01 len    PIC 9(12).
    01 ans    PIC X(3).
    01 A1.
        03 A11 OCCURS 3.
            05 A PIC 9(3).
    01 tmp    PIC 9(3).
    01 sm     PIC 9(4).

    01 ZS     PIC Z(4)9.
    01 DUMMY  PIC X(1).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    PERFORM maxlen TIMES

        PERFORM VARYING j FROM cur BY 1
            UNTIL INP(j:1) = SPACE
        END-PERFORM

        COMPUTE len = j - cur

        MOVE INP(cur:len) TO A(i)

        COMPUTE cur = j + 1

        ADD 1 TO i

    END-PERFORM.

    PERFORM VARYING i FROM 1 BY 1 UNTIL 3 < i
        ADD 1 TO i GIVING j
        PERFORM UNTIL 3 < j
            IF A(j) < A(i) THEN
                MOVE A(i) TO tmp
                MOVE A(j) TO A(i)
                MOVE tmp TO A(j)
            END-IF
            ADD 1 TO j
        END-PERFORM
    END-PERFORM.

    MOVE ZERO TO sm.
    SUBTRACT A(1) FROM A(2) GIVING tmp.
    ADD tmp TO sm.
    SUBTRACT A(3) FROM A(2) GIVING tmp.
    ADD tmp TO sm.

    MOVE sm TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 636
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<=(end);i++)
// #define REP(i, n) FOR(i,0,n)
// #define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
// #define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
using namespace std;
#define ll long long

bool is_prime(int k)
{
	for(int j=2;j*j<=k;j++){
		if(k%j==0) {
			return false;
		}
	}
    return true;
}

int main()
{
    stringstream ss;
    // 入力
    ll N,K;
    cin>>N>>K;
    ll A[N+1];
    A[0]=100001;
    FOR(i,1,N){
    	cin>>A[i];
    }
    int ans=0;
    int min=-1;
    FOR(i,1,N){
    	if(A[i]<min || min==-1) min=A[i];
    }
    ans++;
    FOR(i,K,N){
    	if(K==N) break;
    	// cout<<i<<endl;
    	if(A[i+1]!=min){
    		ans++;
    		i=i+K-1;
    		i--;
    	}

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

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll  A,B,C,D,E,F,G,H,K,L,M,N,P,Q,R,U,W,X,Y,Z;
string S,T;

int main(){
  cin >> S;
  cout << ((S[0]!=S[1]||S[1]!=S[2]) ? "Yes" : "No") << endl;
}


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

int main(){
	string s;
	int len, q; 
	cin >> len >> q ;
	cin >> s;
	int f[len];
	
	for (int i=0; i<len; ++i)  f[i] = 0;
	
	for (int i=1; i<len; i++){
		if (s[i]=='C' && s[i-1]=='A') 
		   f[i] = f[i-1]+1;
		else
		   f[i] = f[i-1];
	}
	
	int L, r;
	
	while(q--){
		cin >> L >> r;
		cout << f[r-1] - f[L-1] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
// created by himo.    
// フェネックの必殺技はどんなに体力が大きい相手でも一撃で倒すことが出来るため、
//最も体力の高いモンスター順に必殺技を使用していけばよい。
int  main(){
int monsters,skill;
cin >> monsters >> skill;
vector<int>a(monsters);//モンスターの体力を記録しておく。
for(int i=0;i<monsters;i++){
    cin >> a.at(i);
}
sort(a.begin(),a.end());//体力が小さい順にしてから。
reverse(a.begin(),a.end());//体力が大きい順にする。
long long  ans = 0;//答えを記録。
for(int i=skill;i<monsters;i++){// i=k とすることで、体力が大きい順から必殺技の回数分必殺技を使ったことになる。
    ans+=a.at(i);
}
cout << ans << endl;
}





Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if(b == 1) {
    cout << 0;
  } else if(a >= b) {
    cout << 1;
  } else {
    int temp = (b % a) == 0 ? 1 : (b % a);
    if(temp < (a / 2)) {
      cout << ((b - a) / (a - 1)) + 2;
    } else {
      cout << ((b - a) / (a - 1)) + 1;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  private static Scanner sc;

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


  private void solve() {
    int H = sc.nextInt();
    int W = sc.nextInt();

    char[][] grid = new char[H][W];
    for (int i = 0; i < H; i++) {
      grid[i] = sc.next().toCharArray();
    }

    boolean[] hasBlackH = new boolean[H];
    boolean[] hasBlackW = new boolean[W];

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (grid[i][j] == '#') {
          hasBlackH[i] = true;
          hasBlackW[j] = true;
        }
      }
    }

    for (int i = 0; i < H; i++) {
      StringBuilder sb = new StringBuilder();
      for (int j = 0; j < W; j++) {
        if (hasBlackH[i] && hasBlackW[j]){
          sb.append(grid[i][j]);
        }
      }
      if (!sb.toString().equals("")){
        System.out.println(sb.toString());
      }
    }
  }
}



Measured memory_bytes: 24748
A = [0] * 3
bingo = [0] * 3
for i in range(3):
    A[i] = list(map(int, input().split()))
    bingo[i] = [0, 0, 0]
N = int(input())
b = [0] * N
for k in range(N):
    b[k] = int(input())
for i in range(3):
    for j in range(3):
        for k in range(N):
            if A[i][j] == b[k]:
                bingo[i][j] = 1

vert = max([sum(bingo[i]) for i in range(3)])
hori = max([sum([bingo[i][j] for i in range(3)]) for j in range(3)])
cros = max(bingo[0][0]+bingo[1][1]+bingo[2][2], bingo[0][2]+bingo[1][1]+bingo[2][0])

if max(vert, hori, cros) == 3:
    print('Yes')
else:
    print('No')

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

int main(){
	int n;
	scanf("%d",&n);
	int A[n];
	for(int i=0;i<n;i++){
		scanf("%d",&A[i]);
		A[i]--;
	}
	int ans = 0;
	for(int i=0;i<n;i++){
		if(A[i]==i){
			int j = i;
			while(j<n && A[j]==j)
				j++;
			j--;
			ans += (j-i+2)/2;
			i = j;	
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 640
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

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

		PriorityQueue<Integer> p = new PriorityQueue<>(Collections.reverseOrder());
		for (int i = 0; i < n; i++) {
			p.add(sc.nextInt());
		}

		while (m > 0) {
			p.add(p.poll() / 2);
			m--;
		}

		long sum = 0;
		for (long num : p) {
			sum += num;
		}

		System.out.println(sum);

		sc.close();
	}
}


Measured memory_bytes: 57624