akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  int n;
  cin>>n;

  ll ans=0;
  int amari=-5;
  rep(i,n){
    ll x;
    cin>>x;
    if(x>0 && amari+1==i) {
      ans++;
      x--;
    }
    ans+=x/2;
    if(x%2==1) amari=i;
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include<cstdio>
int main(void){
  int x,y,z;
  int m,k,n;
  scanf("%d %d %d",&x,&y,&z);
  scanf("%d",&k);
  m=0;
  n=0;
m=x;
  if(y>m){
    n+=m;
    m=y;
  }
  else{
    n+=y;
  }
   if(z>m){
    n+=m;
    m=z;
  }
  else{
    n+=z;
  }
 while(k>0){
   m=m*2;
   k--;
 }
  m+=n;
  printf("%d\n",m);
  return 0;
}

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

#define pb push_back
#define mp make_pair
#define ld long double
#define ll long long int
#define f(i,g,n) for(int i=g;i<=n;i++)
#define rf(i,g,n) for(int i=n;i>=g;i--)

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


	ll n,count=0;
	cin>>n;
	int A[n];
	for(int i=0;i<n;i++)
		cin>>A[i];
	sort(A,A+n);
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int sum=A[i]+A[j],l=j+1,r=n,ans=j;
			while(l < r)
			{
				int mid = (l+r)/2;
				if(A[mid] < sum)
				{
					ans = mid;
					l = mid+1;
				}
				else
					r = mid;
			}
			count += ans-j;
		}
	}
	cout<<count<<"\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const LL INF=1<<17;


vector<LL> fact;
vector<LL> inver(200001);
 
LL combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]%mod*inver[n-r]%mod*inver[r]%mod;
}
 
 
LL fpow(LL a, LL n){
    LL x = 1;
    while(n > 0){
        if(n&1){
            x=x*a%mod;
        }
        a=a*a%mod;
        n >>= 1;
    }
    return x;
}
 
void set_combi(){
    LL s=1;
    fact.push_back(1);
    for(int i=1;i<=200000;i++){
        s*=i;
        s%=mod;
        fact.push_back(s);
    }
    inver[200000]=fpow(fact[200000],mod-2);
    for(int i=199999;i>=0;i--){
        inver[i]=inver[i+1]*(i+1)%mod;
    }
}
 


int main(){
    set_combi();
    int H,W,N;cin >> H >> W >> N;
    H--,W--;
    vector<P> v;
    for (int i = 0; i < N; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        v.pb(P(x,y));
    }
    v.pb(P(0,0));
    v.pb(P(H,W));
    sort(ALL(v));
    vector<vector<LL>> dp(N+2,vector<LL> (2,0));
    dp[0][0] = 1;
    for (int i = 0; i < N+2; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = i+1; k < N+2; k++) {
                if(!i&&k==N+1) continue;
                int dx = v[k].fs - v[i].fs;
                int dy = v[k].sc - v[i].sc;
                dp[k][j^1] = (dp[k][j^1] + dp[i][j]*combi(dx+dy,dx))%mod;
            }
        }
    }
    cout << (combi(H+W,H) - dp[N+1][0] + dp[N+1][1] + mod)%mod << endl;
    return 0;
}


Measured memory_bytes: 3956
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int k;
  cin >> k;
  string s;
  cin >> s;
  if ((int) s.size() <= k) cout << s << endl;
  else cout << s.substr(0, k) + "..." << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  vector<pair<ll,ll>> xy(N); rep(i,N) cin >> xy[i].first >> xy[i].second;
  vector<pair<ll,ll>> AB(N);
  rep(i,N) {
    AB[i].first = xy[i].first-xy[i].second;
    AB[i].second = xy[i].first+xy[i].second;
  }
  vector<ll> a(N), b(N);
  rep(i,N) {
    a[i] = AB[i].first;
    b[i] = AB[i].second;
  }
  sort(all(a));
  sort(all(b));
  ll ans = max(abs(a[0]-a[N-1]),abs(b[0]-b[N-1]));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 12752
//
//  main.cpp
//  ProblemSolving
//
//  Created by Mac mini on 1/7/20.
//  Copyright © 2020 Mac mini. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <cstring>
using namespace std;
long long int  dp[51][51][1000];
int x[52], n, a;

long long int call(int idx, int cnt, int amount) {
	if(idx >= n) {
		if((double)amount / cnt == a)
			return 1;
		return 0;
	}

	if(dp[idx][cnt][amount] != -1) return dp[idx][cnt][amount];

	long long int  ret1 = 0, ret2 = 0;

	ret1 = call(idx + 1, cnt + 1, amount + x[idx]);
	ret2 = call(idx + 1, cnt, amount);

	dp[idx][cnt][amount] = ret1 + ret2;

	return dp[idx][cnt][amount];
}

int main() {
	cin >> n >> a;

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

	memset(dp, -1, sizeof(dp));

	cout << call(0, 0, 0) << "\n";

}


Measured memory_bytes: 23920
import java.util.Scanner;

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

        int x[] = new int[5];
        for(int i=0; i<5; i++){
            x[i] = in.nextInt();
            if(x[i] == 0)
                System.out.println(i+1);
        }
    }
}

Measured memory_bytes: 35400
#include <bits/stdc++.h>
#define dbg() cerr <<
#define name(x) (#x) << ": " << (x) << ' ' <<

using namespace std;

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

  int n; cin >> n;
  vector<pair<int, int>> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first;
    a[i].second = i;
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i].first;
    b[i].second = i;
  }
  if (n == 2) {
    bool x = a[0].first <= b[0].first, y = a[1].first <= b[1].first;
    cout << (x && y ? "Yes" : "No") << endl;
    return 0;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (int i = 0; i < n; ++i) {
    if (a[i].first > b[i].first) {
      cout << "No\n";
      return 0;
    }
  }
  for (int i = 0; i < n - 1; ++i) {
    if (a[i + 1].first <= b[i].first) {
      cout << "Yes\n";
      return 0;
    }
  }
  vector<int> nxt(n);
  for (int i = 0; i < n; ++i) {
    nxt[a[i].second] = b[i].second;
  }
  vector<bool> vis(n);
  int cnt_cycles = 0;
  for (int i = 0; i < n; ++i) {
    if (vis[i]) continue;
    int x = i;
    ++cnt_cycles;
    do {
      assert(!vis[x]);
      vis[x] = true;
      x = nxt[x];  
    } while (x != i);
  }
  cout << (cnt_cycles == 1 ? "No" : "Yes") << endl;
  

  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

Measured memory_bytes: 2176
n = int(input())
a = list(map(int, input().split())) 
b = list(map(int, input().split())) 
ans = 0
 
for i in range(n) :
  if b[i] >= a[i] :
    if a[i+1] >= (b[i]-a[i]) :
      a[i+1] = a[i+1] - (b[i]-a[i])
      ans += b[i]
    else :
      ans += a[i] + a[i+1]
      a[i+1] = 0
  else :
    ans += b[i]
    
print(ans)

Measured memory_bytes: 19156
#include<stdio.h>
#include<string.h>
char f[1000005];
int main(){
	int i,j,n,ans;
	memset(f,0,sizeof(f));
	for(i=2;i<=1000;i++){
		if(f[i]==0)for(j=2;i*j<=1000000;j++)f[i*j]=1;
	}
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		ans=0;
		for(i=2;i<=n/2;i++){
			if(f[i]==0 && f[n-i]==0)ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1)

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll arr[n],brr[n],c,p,d,sum,q,tot=0,ans;
    ll val[n+1]={0};
    for(ll i=0;i<n;i++)
    {
        cin>>arr[i];
        brr[i]=arr[i];
    }
    sort(brr,brr+n);
    c=1;
    for( p=1;p<n;p++){
       if(brr[p]==brr[p-1])
            c++;
        if(brr[p]!=brr[p-1])
        {
           val[brr[p-1]]=c;
           c=1;
        }
    }
    val[brr[n-1]]=c;
    d=brr[n-1];

    for(ll i=0;i<=d;i++){
       if(val[i]>0)
           tot+=((val[i]-1)*val[i])/2;
   }



    for(ll i=0;i<n;i++)
    {
        ans=tot+1-val[arr[i]];
        cout<<ans<<endl;
   }


   //checker
   // cout<<tot<<endl;
   // for(ll i=0;i<n;i++)
      //  cout<<val[i]<<" ";



return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define MAX_V 100005
 
 
struct myque{
  int l,r;
  int t[MAX_V];
  void clear(){l=r=0;}
  void pop(){l++;}
  void push(int x){t[r++]=x;}
  int front(){return t[l];}
  bool empty(){return (l==r);}
};
 
myque que;
int pa[MAX_V],de[MAX_V],sz[MAX_V];
int cd[MAX_V],mv[MAX_V],hl[MAX_V];
 
int V;
vector<int> G[MAX_V];
 
void HLD(int root=0){
  que.clear();
  for(int i=0;i<V;i++){
    sz[i]=1;
    pa[i]=cd[i]=mv[i]=i;
    hl[i]=G[i].size();
    if(i==root)continue;
    if(hl[i]!=1)continue;
    que.push(i);
  }
  // calc sz[] cd[] pa[]
  while(!que.empty()){
    int pos=que.front();que.pop();
    if(pos==root)continue;
    for(int i=0;i<(int)G[pos].size();i++){
      int to=G[pos][i];
      if(pa[to]==pos)continue;
      pa[pos]=to;
      sz[to]+=sz[pos];           
      if(cd[to]==to)cd[to]=pos;
      if(sz[cd[to]]<sz[pos])cd[to]=pos;
      hl[to]--;
      if(hl[to]==1)que.push(to);
    }
  }
 
  // calc hl[] de[] mv[]
  que.clear();
  que.push(root);
  de[root]=hl[root]=0;
  while(!que.empty()){
    int pos=que.front();que.pop();
    if(cd[pos]==pos)continue;
    mv[cd[pos]]=mv[pos];
    hl[cd[pos]]=hl[pos]+1;
    int sum=hl[pos]+1+sz[cd[pos]];
    for(int i=0;i<(int)G[pos].size();i++){
      int to=G[pos][i];
      if(to==pa[pos])continue;
      que.push(to);
      de[to]=de[pos]+1;
      if(to==cd[pos])continue;
      hl[to]=sum;
      sum+=sz[to];
    }
  }
}
 
int lca(int a,int b){
  while(mv[a]!=mv[b]){
    if(de[mv[a]]<de[mv[b]])swap(a,b);
    a=pa[mv[a]];
  }
  return (de[a]<de[b]?a:b);
}
 
void add_edge(int a,int b){
  G[a].push_back(b);
  G[b].push_back(a);
}
 
int main(){
  scanf("%d",&V);
 
  for(int i=0;i<V;i++){
    int size,ch;
    scanf("%d",&size);
    while(size--){
      scanf("%d",&ch);
      add_edge(i,ch);
    }
  }
  HLD(0);
  /*
  for(int i=0;i<V;i++){
    cout<< (char)('A'+i) <<endl;
    cout<<" hl = "<< hl[i] <<" , ";
    cout<<" sz = "<< sz[i] <<" , ";
    cout<<" de = "<< de[i] <<" , ";
    cout<<" pa = "<< (char)('A'+pa[i]) <<" , ";
    cout<<" cd = "<< (char)('A'+cd[i]) <<" , ";
    cout<<" mv = "<< (char)('A'+mv[i]) <<" , ";
    cout<<endl;
  }
  */
  int a,b,Q;
  scanf("%d",&Q);
  while(Q--){
    scanf("%d %d",&a,&b);
    printf("%d\n",lca(a,b));
  }
  return 0;
}

Measured memory_bytes: 9652
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    ll D;
    cin >> D;
    ll A;
    cin >> A;
    vector<P> vec(N);
    for(ll i=0;i<N;i++){
        ll x;
        cin >> x;
        ll h;
        cin >> h;
        vec[i]=P(x,h);
    ;}
    sort(vec.begin(), vec.end());
    vector<ll> until(N,INF);
    until[0]=0;
    for(ll i=0;i<N;i++){
        if(i>0){
            //既に爆破された回数
            ll b=until[i-1];
            if(vec[i].first>vec[0].first+2*D)
            b-=until[lower_bound(vec.begin(), vec.end(), P(vec[i].first-2*D,-INF))-1-vec.begin()];
            vec[i].second-=b*A;
            until[i]=until[i-1];
        }
        if(vec[i].second>0){
            until[i]+=vec[i].second/A;
            vec[i].second-=(vec[i].second/A)*A;
            if(vec[i].second>0){vec[i].second-=A;until[i]++;}
        }
    ;}
    cout<<until[N-1]<<endl;

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	string s;
	cin >> s;
	ll dp[100100][2] = {0};
	dp[0][0] = 1;
	rep(i,s.size())rep(k,2){
		int nd = s[i] - '0';
		rep(d, 3){
			int ni = i + 1, nk = k;
			int el_sum = (d > 0);
			if(k == 0){
				if(el_sum > nd)continue;
				if(el_sum < nd)nk = 1;
			}
			dp[ni][nk] += dp[i][k];
			dp[ni][nk] %= MOD;
		}
	}
	ll ans = dp[s.size()][0] + dp[s.size()][1];
	ans %= MOD;
	if(ans < 0)ans += MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5260
#include <iostream>
#include <map>
#include <string>
#include <string.h>

using namespace std;

int main(){
    char str[101];
    int i,len,sum;
    map<char,int> table;
 
table['I'] = 1;
table['V'] = 5;
table['X'] = 10;
table['L'] = 50;
table['C'] = 100;
table['D'] = 500;
table['M'] = 1000;



while(cin>>str){
	len = strlen(str) - 1;
	
	sum = 0;
	for(i = 0; i < len; i++){
	    if(table[str[i]] < table[str[i+1]]){
	    	sum -= table[str[i]];
	    }
	    else{
	        sum += table[str[i]];
	    }
	}
	cout<<sum+table[str[len]]<<endl;
}
    
 return 0;   
}



Measured memory_bytes: 2992
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<stdio.h>
#include<unordered_map>
#include<map>
#include<stack>
#include<queue>
#include<iterator>
#include<functional>
#include<climits>
#include<set>
#include<utility>

#define ll long long
#define MOD 1000000007

using namespace std;

void solve () {
	int n;
	cin >> n;
	int * arr = new int [n];
	for (int i = 0;i < n;++i) {
		cin >> arr[i];
	}
	int * dp = new int [n+1];
	fill(dp,dp+n+1,INT_MAX);
	dp[0] = dp[1] = 0;
	dp[2] = abs(arr[1]-arr[0]);
	for (int i = 3;i <= n;++i) {
		dp[i] = min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-1]-arr[i-3]));
	}
	int ans = dp[n];
	cout << ans << '\n';
	delete [] dp;
	delete [] arr;
	return;

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int n;
int a[202000];
bool m[202000];
vector<int> b;
int szb;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) m[i] = false;
    
    rrep(i, n) {
        int sum = 0;
        
        for(int ii = ((i + 1) * 2 - 1); ii < n; ii += (i + 1)) {
            sum += (m[ii] ? 1 : 0);
        }
        
        m[i] =  !((sum % 2) == a[i]);
        if (m[i]) b.push_back(i + 1);
    }
    
    int szb = sz(b);
    cout << szb << endl;
    
    rep(i, szb) {
        cout << b[i] << ((i == (szb - 1)) ? "\n" : " ");
    }
    
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
const ll MOD = 1000000007;

const int MAX = 2000005;
ll modFact[MAX];
ll modInv[MAX];
ll modFactInv[MAX];

// calc nCr % mod
ll comb(int n, int r) {
  return modFact[n] * (modFactInv[r] * modFactInv[n - r] % MOD) % MOD;
}

int main() {
  modFact[0] = modFact[1] = 1;
  modFactInv[0] = modFactInv[1] = 1;
  modInv[1] = 1;
  REP(i, 2, MAX) {
    modFact[i] = modFact[i - 1] * i % MOD;
    modInv[i] = MOD - modInv[MOD % i] * (MOD / i) % MOD;
    modFactInv[i] = modFactInv[i - 1] * modInv[i] % MOD;
  }

  int r1, c1, r2, c2;
  cin >> r1 >> c1 >> r2 >> c2;

  ll ans = 0;
  for (int i = c1; i <= c2; i++) {
    ans = (ans + comb(r2 + i + 1, i + 1)) % MOD;
    ans = (ans + MOD - comb(r1 - 1 + i + 1, i + 1)) % MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 47104
#include <iostream>
#include <map>
using namespace std;
using ll = long long;

int main(){
    int n,m; cin >> n >> m;
    int h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }

    // つながっているか？
    multimap<int, int> connected;
    int a,b;
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        connected.insert(make_pair(a-1,b-1));
        connected.insert(make_pair(b-1,a-1));
    }

    int ans = 0;
    bool continuable = false;
    for(int i = 0; i < n; i++){
        continuable = false;
        auto itr = connected.lower_bound(i);
        auto last = connected.upper_bound(i);
        while(itr != last){
            if(h[i] <= h[itr->second]){
                continuable = true;
                break;
            }
            ++itr;
        }
        if(continuable) continue;
        ans++;
    }
    cout << ans;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a.at(i);
  sort(a.begin(), a.end());
  cout << a.at(N-1)-a.at(0) << endl;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        string s;
        cin>>s;
        map<char,int> mp;
        mp['W'] = 0;
        mp['R'] = 1;
        int pre[n][2] = {};
        for(int i=0;i<n;i++)pre[i][mp[s[i]]]++;
        for(int i=1;i<n;i++)for(int j=0;j<2;j++)pre[i][j] += pre[i-1][j];

        int ans = min(pre[n-1][0],pre[n-1][1]);
        for(int i=0;i<n-1;i++)
        {
            int left_wc = pre[i][0];
            int right_rc = pre[n-1][1] - pre[i][1];
            int now = max(left_wc,right_rc);
            ans = min(ans,now);
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 6892
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def digit_sum(num:int, base:int) -> int:
    if num < base:
        return num
    else:
        return digit_sum(int(num/base), base) + (num % base)

def snuke(num: int):
    return num / digit_sum(num, 10)

k = ni()

snuke_nums = [i for i in range(1,10)]
res = 9
cur = 9

if k <= res:
    for s in snuke_nums[:k]:
        print(s)

else:
    while res != k:
        cur += 1
        
        cands = []
        for i in range(len(str(cur))):
            cands.append(int(str(cur)[:-i-1] + "9"*(i+1)))
            
        mi = float("inf")
        for c in cands:
            if snuke(c) < mi:
                cur = c
                mi = snuke(c)
                
        snuke_nums.append(cur)
        res += 1
        
    for s in snuke_nums:
        print(s)

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

int main() {
  int N;
  int Y=0;
  string S[101];
  cin >> N;
  for(int i=1; i<=N; i++){
    cin >> S[i];
    if(S[i]=="Y"){Y=1;}}
  cout << endl;
  if(Y==1){
    cout << "Four" << endl;}
  else if(Y==0){
    cout << "Three" << endl;}
}
  
  


Measured memory_bytes: 256
from math import log10
n, k = map(int, input().split())
a = list(map(int, input().split()))
MOD = 10**9+7
a.sort()

cnt_neg = 0
cnt_pos = 0
for i in a:
   if i <= 0:
      cnt_neg += 1
   else:
      cnt_pos += 1
is_minus = False
k_tmp = k
while k_tmp > 0:
   if k_tmp >= 2:
      if cnt_neg >= 2:
         cnt_neg -= 2
      elif cnt_pos >= 2:
         cnt_pos -= 2
      else:
         is_minus = True
         break
      k_tmp -= 2
   else:
      if cnt_pos > 0:
         cnt_pos -= 1
         k_tmp -= 1
      else:
         is_minus = True
         break

k_1 = k
ans1 = 1
l = 0
r = n - 1
if k_1 % 2:
   ans1 *= a[-1]
   r -= 1
   k_1 -= 1
while k_1 >= 2:
   if a[l] * a[l+1] > a[r-1] * a[r]:
      ans1 *= a[l] * a[l+1]
      l += 2
   else:
      ans1 *= a[r-1] * a[r]
      r -= 2
   k_1 -= 2
   ans1 %= MOD

a.sort(key=abs)
# print(a)
ans2 = 1
for i in a[:k]:
   ans2 *= i
   ans2 %= MOD

if is_minus:
   print(ans2)
else:
   print(ans1)


Measured memory_bytes: 105596
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


back = []


def backtrack(n, ml, mh, tmp=[]):
    if n == 0:
        back.append(tmp)
        return

    for i in range(ml, mh + 1):
        backtrack(n - 1, i, mh, tmp + [i])


def main():
    def count(carrer):
        ret = 0
        for a, b, c, d in abcd:
            if carrer[b - 1] - carrer[a - 1] == c:
                ret += d
        return ret
    N, M, Q = inpl()
    ans = 0
    abcd = [inpl() for _ in range(Q)]
    backtrack(N, 1, M)
    for carrer in back:
        # print(carrer)
        tmp = count(carrer)
        if tmp > ans:
            ans = tmp
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22944
<?php
list($x, $y) = ints();
if (abs($x) === abs($y)) exit('1');
$c = 0;
if ($x > 0 && abs($x) > abs($y)) {
    $c = 1;
    $x = -$x;
} elseif ($x < 0 && abs($x) < abs($y)) {
    $c = 1;
    $x = -$x;
}
$c += abs(abs($x) - abs($y));
$x += abs(abs($x) - abs($y));
if ($x !== $y) ++$c;
echo $c;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

int main(void)
{
	int H, W;
  	cin >> H >> W;
  	for (int i=0; i < W + 2; i++)
    	cout << '#';
  	cout << endl;
  	for (int i=0; i < H; i++)
    {
      string str;
      cout << '#';
      cin >> str;
      cout << str;
      cout << '#' << endl;
    }
    for (int i=0; i < W + 2; i++)
    	cout << '#';
   	cout << endl;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(){
    int n,y;
    cin>>n>>y;
    int s10k,s5000,s1000;
    int bal,satu;
    for(s10k= (y/1000)<=n ? y/1000 : n ; s10k >= 0; s10k-- ){
        bal=y-s10k*10000;
        satu=n-s10k;
        for(s5000 = (bal/5000)<=satu ? bal/5000 : satu ; s5000 >= 0; s5000-- ){
            s1000=satu-s5000;
            bal=y-s10k*10000-s5000*5000-s1000*1000;
            if(bal==0){
                goto FIN;
            }
        }
    }
    s10k = -1;
    s5000 = -1;
    s1000 = -1;
    FIN:
    printf("%d %d %d\n",s10k,s5000,s1000);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

main(void)
{
  int money,cake,donuts;
  int oturi=0;
  
  scanf("%d",&money);
  scanf("%d",&cake);
  scanf("%d",&donuts);
  
  oturi = money - cake;
  
  do{
    
    oturi = oturi - donuts;
    
  }while(oturi>=donuts);
  
  printf("%d",oturi);
  
  return 0;
}

Measured memory_bytes: 128
// 🐋💭 Walk on Multiplication Table
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}
// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

func main() {
    let n = readInt()
    let aryS = readLine()!.map { String($0) }
    var ans = n
    for i in 1..<n {
        if aryS[i - 1] == aryS[i] {
            ans -= 1
        }
    }
    print(ans)
}
main()

Measured memory_bytes: 13804
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x
  
using namespace std;
signed main()
{

  std::ios::sync_with_stdio(false);
  cin.tie(); cout.tie();
  string s;
  cin>>s;
  if(s[s.size()-1]=='s'){
    s+="es";
  }
  else{
    s+="s";
  }
  cout<<s;
  return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        
        if (A + B <= K) {
            System.out.println(0 + " " + 0);
        } else if (A > K) {
            System.out.println(A - K + " " + B);
        } else {
            System.out.println(0 + " " + (B - (K - A)));
        }
    }
}

Measured memory_bytes: 23380
/*
    Author : Wasi Ur Rahman
*/
#include <bits/stdc++.h>
using namespace std;
// defines
#define ll long long int
#define ull unsigned long long int
#define MOD 100000
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sc scanf
#define pf printf
#define min3(a, b, c) min(a, min(b, c))
#define min4(a, b, c, d) min(d, min(a, min(b, c)))
#define max3(a, b, c) max(a, max(b, c))
#define max4(a, b, c, d) max(d, max(a, max(b, c)))
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 3.141592653589793238462643
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;
#define elif else if
/* important funct */
ll Int()
{
    ll c;
    cin >> c;
    return c;
}
#define Int Int()
void sortString(string &str)
{
    sort(str.begin(), str.end());
}
bool isPrime(ll n)
{
    if (n <= 1)
        return false;
    for (ll i = 2; i < n; i++)
        if (n % i == 0)
            return false;
    return true;
}
ll ManualGcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll ManualLcm(ll a,ll b)
{
    return((a)*(b)/gcd(a,b));
}
ll fact(ll n)
{
    ll res = 1;
    for(ll i = n; i>=1; i--)
        res *= i;
    return res;
}
ll nCr(ll n,ll r)
{
    return (fact(n)/(fact(r)*fact(n-r)));
}
ll nPr(ll n,ll r)
{
    return fact(n)/fact(n-r);
}
// Main
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll t=Int;
    cout << pow(t,3) << endl;
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;
int C[51][51];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K, S, T;
	cin >> N >> K >> S >> T;
	vector<int> A(N);

	for (int i = 0; i <= 50; i++) {
		C[i][0] = 1;
		C[0][i] = 1;
	}
	for (int i = 1; i <= 50; i++) {
		for (int j = 1; j <= i; j++) {
			C[i][j] = C[i - 1][j - 1];
			if (i - 1 >= j) C[i][j] += C[i - 1][j];
		}
	}
	//cerr << C[5][2] << endl;
	//cerr << C[6][3] << endl;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	vector<int> B;
	int M = 0;
	for (int j = 0; j < 19; j++) {
		if (((1 << j) & ((~S) & T))) {
			M++;
		}
	}
	for (int i = 0; i < N; i++) {
		if ((A[i] & S) == S && (A[i] | T) == T) {
			int x = 0;
			for (int j = 0; j < 19; j++) {
				if (((1 << j) & ((~S) & T))) {
					x *= 2;
					x += ((A[i] >> j) & 1);
				}
			}
			B.push_back(x);
			//cerr << x << endl;
		}
	}
	A = B;
	N = A.size();
	//cerr << M << endl;
	int res = 0;
	int sm[51];
	for (int i = 0; i <= 50; i++) {
		sm[i] = 0;
		for (int k = 1; k <= K; k++) {
			if (i >= k) {
				sm[i] += C[i][k];
			}
		}
	}
	for (int i = 0; i < (1 << M); i++) {
		map<int, int> mp;
		int bit = 0;
		for (int j = 0; j < M; j++) {
			if (i & (1 << j)) bit ^= 1;
		}
		for (int j = 0; j < N; j++) {
			mp[A[j] & i]++;
		}
		int sum = 0;
		for (const auto &x : mp) {
			sum += sm[x.second];
		}
		if (bit == 0) {
			res += sum;
		} else {
			res -= sum;
		}
	}
	cout << res << endl;
}

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

int main() {
  int x;
  cin >> x;
  if(x < 1200) {
    cout << "ABC" << endl;
  } else {
    cout << "ARC" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
<?php 
  
  fscanf(STDIN, "%d", $n);
  $p = array();
  $q = array();
  $p = explode(" ", trim(fgets(STDIN)));
  $q = explode(" ", trim(fgets(STDIN)));
$str_p = 0;
$str_q = 0;

foreach($p as $val){
  $str_p .=$val;
}

foreach($q as $val){
  $str_q .=$val;
}

function pat($a, $s = '')
{
  $r = array();
  if (count($a) && is_array($a)) {
    //第1引数に文字の配列を渡されたらループして処理
    foreach ($a as $k => $v) {
      //文字の配列から1文字もらってこちらにくっつけて
      $_s = $s . $v;
      //もらった1文字を除いた文字の配列を作って
      $_a = $a;
      unset($_a[$k]);
      //再帰呼び出し
      $_r = pat($_a, $_s);
      //返り値にする変数に結果を追加
      $r = array_merge($r, $_r);
    }
  } else {
    $r[] = $s;
  }
  return $r;
}
$p_ans = pat($p);
$q_ans = pat($q);

sort($p_ans,SORT_NUMERIC);
sort($q_ans,SORT_NUMERIC);

$a=0;
$b=0;

foreach($p_ans as $key => $val){
 if($val == $str_p){
   $a = $key;
 }
}
   
foreach($q_ans as $key => $val){
 if($val == $str_q){
   $b = $key;
 }
}
echo abs($a-$b);


?>

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

int main(){
    int N; cin >> N;
    vector<int> A(N+1), B(N+1, 0), C; 
    for(int i = 1; i <= N; i++) cin >> A[i];
    //cout << "------------------------------" << endl;
    for(int i = N; i >= 1 ; i--){
        //cout << i << endl;

        if(i == 1){
            if(B[i] != A[i]){
                B[i] = (B[i] + 1) % 2;
                C.push_back(1);
                break;
            }
        }
        int number = i;
        //if(A[number] == 1) cout << "here! " << number << endl;
        if(A[number] != B[number]) {
            //cout << " y" << endl;
            //if(B[number] != 1){
                bool flag = false;
                for(int j = 1; j*j<= number; j++){
                    if(number % j == 0){
                        //cout << " " << j << " " << number/j << endl;
                        flag = true;
                        if(j*j == number){
                          B[j] = (B[j] + 1) % 2;
                          continue;
                        }
                        B[number/j] = (B[number/j] + 1) % 2;
                        B[j] = (B[j] + 1) % 2;

                    }
                }
                if(flag) C.push_back(number);
                //cout << B[1] << " " << B[9] << " " << B[27] << " " << B[81] << " " << B[135] << " " << B[405] << " " << B[1269] << " " << B[3807] << " " << B[6345] << " " << B[19035] << " " << endl;
                //for(int i = 1; i <= N; i++)  cout << B[i] << " "; cout << endl;
            //}
        }
      
    }
    
    sort(C.begin(), C.end());
    cout << C.size() << endl;
    if(C.size() != 0){
        for(int i = 0; i < C.size(); i++) cout << C[i] << " "; cout << endl;
    }
    //for(int i = 1; i <= N; i++)  cout << B[i] << " "; cout << endl;
}

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

#define ll long long
#define int long long

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define all(a) (a).begin(), (a).end()

const int M = 1e9 + 7;

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    map<char, int> ma;
    for (auto e : s) ma[e]++;
    int ans = 1;
    for (auto e : ma) ans = ans * (e.y + 1) % M;
    ans--;
    if (ans < 0) ans += M;
    cout << ans;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i=1;i<=N;i+=2){
        int cnt=0;
        for(int j=1;j<=i;j++){
            if(i%j==0) cnt++;
        }
        if(cnt==8) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll N,D; cin >> N >> D;
  vector<vector<ll>> X(N,vector<ll>(D));
  for(auto& vec:X) for(auto& in:vec) cin >> in;
  
  ll ans = 0;
  for(int i = 0; i < N;i++){
    for(int j = i+1; j < N;j++){
      ll T = 0;
      
      for(int k = 0; k < D;k++){
        T += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      }
      
      if(T == floor(sqrt(T))*floor(sqrt(T))) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
menu = [int(input()) for _ in range(5)]
menu = sorted(menu,key = lambda x:x%10)
flag = True
ans=0

for v in menu:
    if flag and v%10!=0:
        ans+=v
        flag=False
    else:
        if flag:
            ans+=v
        else:
            ans+= v + 10-(v%10)
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#define MAXN 200100
int a[MAXN];
int cnt[MAXN];
int n, k;
int solve(void) {
	int s = 0;
	int ans = 0;
	for(int i = 0; i < n; i++) cnt[a[i]]++;
	std::sort(cnt, cnt + MAXN);
	for(int i = 0; i < MAXN; i++)
		if(cnt[i] != 0) s++;
	for(int i = 0; i < MAXN; i++)
		if(cnt[i] != 0 && s > k)
			ans += cnt[i], s--;
	return ans;
}
int main(void) {
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	printf("%d\n", solve());
	return 0;
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}
 
mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,0,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

int main(){
  int x,y;
  cin >> x >> y;
  int a=max(x,y);
  int b=min(x,y);
  if(a>2*b){
    cout << 0 << endl;
    return 0;
  }
  if((a+b)%3!=0){
    cout << 0 << endl;
    return 0;
  }
  ll l=0;
  ll r=0;
  while(b>0){
    if(a==2*b) break;
    a-=3; b-=3;
    r+=1; l+=1;
  }
  r +=b;
  mint ans=choose(r+l,l);
  cout << ans.x << endl;

  return 0;
}


Measured memory_bytes: 3616
///who is the king ??? *** << t.mohammad >> *** ///
/*
                  00                                                                                                            00
                 00                               00                                                                           00
            0000000000                           00                                                                           00
           0000000000   000       000           00                        000       000  000       000                       00
              00       0000     0000           00         000000         0000     0000  0000     0000   000000              00
             00       00 00   00 00    000    00        00000000        00 00   00 00  00 00   00 00  00000000       00000000
            00       00  00 00  00   00000   000000    00    000       00  00 00  00  00  00 00  00  00    000     0000000000
           00       00   000   00  00   00  00000000  00    0000      00   000   00  00   000   00  00    0000    00     0000
          00       00         00  00   00  00    00  00    00 00     00         00  00         00  00    00 00   00     00 00
         00  00   00         00   00000   00    00  00000000  00    00         00  00         00  00000000  00  000000000  00
        00  00   00         00    000    00    00   000000    00   00         00  00         00   000000    00  0000000    00
*/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std ;
#define int long long int
typedef long double ld ;
#define ff first
#define ss second
#define setp(t) cout << setprecision(t) << fixed ;
const int N = 1e5 ;
int dp[N + 100] ;
int32_t main() {
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;
	fill(dp , dp + N + 100 , 1e18) ;
	int n , w ;
	cin >> n >> w ;
	dp[0] = 0 ;
	for(int i = 1 ; i <= n ; i++) {
		int x , y ;
		cin >> x >> y ;
		for(int j = N ; j >= y ; j--)
			dp[j] = min(dp[j] , x + dp[j - y]) ;
	}
	int fin = 0 ;
	for(int i = N ; i >= 0 ; i--)
		if(dp[i] <= w)
    		fin = max(fin , i) ;
	cout << fin ;
}


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


int main() {
    int N; cin >> N;
    string S; cin >> S;

    for (auto s : S) {
        int s_int = (int)s + N;
        if ((int)'Z' < s_int) s_int -= (int)'Z' - (int)'A' + 1;
        char a = (char)s_int;
        cout << a;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  vector<int> vc{};
  for (int i = 1; i <= 100000; i += 2) {
    if (isSosuu(i) && isSosuu((i+1) / 2)) {
      vc.push_back(i);
    }
  }
  set<int> s(vc.begin(), vc.end());
  int Q; cin >> Q;
  for (int _ = 0; _ < Q; ++_) {
    int l, r; cin >> l >> r;
    auto itrL = s.lower_bound(l);
    auto itrR = s.upper_bound(r);
    auto distance = std::distance(itrL, itrR);
    cout << distance << CRLF;
  }

  return;
}

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

  solve();

  return 0;
}


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

using namespace std;

typedef long long int LL;
typedef unsigned long long int ULL;
typedef pair<int, int> PII;
typedef map<int, int> MII;

const int SZ = 112345;
const int MOD = 1e9 + 7;

int main() {
  int h, a;
  cin >> h >> a;
  int ans = ceil((double)h / a);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

l = 0
r = 0
tmp = 0
ans = 0
while r < n do
    if tmp + a[r] == tmp ^ a[r]
#        printf("%d %d\n", l, r)
        tmp += a[r]
        ans += r - l + 1
        r += 1
    else
        tmp -= a[l]
        l += 1
    end
end

puts ans


Measured memory_bytes: 16644
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String a = scan.next();
    int b = a.length();
    int c = (int) (b-1)/2;
    int d = (int) (b+3)/2;

    boolean a1 = check(a,0,b-1);
    boolean a2 = check(a,0,c-1);
    boolean a3 = check(a,d-1,b-1);

    if ((a1 == false) || (a2 == false) || (a3 == false)){
      System.out.println("No");
    }
    else{
      System.out.println("Yes");
    }


  }

  public static boolean check(String a, int b, int c){
    for (int i=b;i<c;i++){
      if (a.charAt(i) != a.charAt(c-i)){
        return false;
      }
    }
    return true;
  }
}


Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string x;
    int n,s=0,t=0,minus=0;
    cin>>x;
    n=x.size();
    for(int i=0;i<n;i++){
        if(x[i]=='S'){s++;}
        else if(s>0){s--;minus+=2;}
    }
    cout<<n-minus;
}

Measured memory_bytes: 720
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define dump(o) { cerr << #o; for (auto e : (o)) cerr << " " << e; cerr << endl; }
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

//pair?????????
template<typename T1, typename T2>
ostream &operator << (ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << "," << p.second << ")"; return os; }

//??§?¨???§???
//v: ??§???????????§?¨??????? ????????????
template<typename T>
void compress(vector<T> &v) {
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
}

//??§?¨???§???(map)
//v: ??§???????????§?¨??????? ????????????
//?????????: zip[??§???????????§?¨?]:??§???????????§?¨? (zip.size()<=10^5?????????????????????)
template<typename T>
map<T, T> compressMap(vector<T> &v) {
	map<T, T> zip;
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	for (T i = 0; i < v.size(); i++) zip[v[i]] = i;
	return zip;
}

//??§???????????§?¨?
//index(??§???????????§?¨?, ??§???????????§?¨??????????(??????) )
template<typename T>
inline int index(vector<T> v, T i) { return lower_bound(v.begin(), v.end(), i) - v.begin(); }

//2?¬????imos???
class Imos {
public:
	using vvi = vector<vector<int> >;
	int X, Y;
	vvi s; //?´???????
	//f:field
	Imos(vvi &f) {
		X = f.size();
		Y = f[0].size();
		//one-based
		//(x,y)?????§????´??????????(x+1,y+1)
		s = vvi(X + 1, vector<int>(Y + 1));
		for (int y = 0; y < Y; y++)
			for (int x = 0; x < X; x++)
				s[x + 1][y + 1] += s[x + 1][y] + s[x][y + 1] - s[x][y] + f[x][y];
	}
	//[x1,x2)??????[y1,y2)???field??????????±???????
	//one-based????????????????§?
	int sum(int x1, int y1, int x2, int y2) { return s[x2][y2] - s[x2][y1] - s[x1][y2] + s[x1][y1]; }
};

int main() {
	int n, m; cin >> n >> m;
	vector<int> xs(n), ys(n);
	vector<int> x(n), y(n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &xs[i], &ys[i]);
		x[i] = xs[i]; y[i] = ys[i];
	}
	compress(x);
	compress(y);

	//map<int, int> zipx(compressMap(x));
	//map<int, int> zipy(compressMap(y));
	//dump(x);
	//dump(zipx);
	//dump(y);
	//dump(zipy);

	vector<vector<int> > f(x.size(), vector<int>(y.size()));

	for (int i = 0; i < n; i++) {
		int vx = index(x, xs[i]);
		int vy = index(y, ys[i]);
		f[vx][vy]++;
	}

	//for (int vx = 0; vx < x.size(); vx++) dump(f[vx]);

	Imos imos(f);

	for (int i = 0; i < m; i++) {
		int x1, y1, x2, y2;
		scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		x1 = index(x, x1);
		y1 = index(y, y1);
		x2 = index(x, x2 + 1); //Imos???sum???one-based?????????+1
		y2 = index(y, y2 + 1);
		cout << imos.sum(x1, y1, x2, y2) << endl;
	}
	return 0;
}


//Sample2
//https://gyazo.com/39c67d1abe7a6a686acb52285f8a0bc9

Measured memory_bytes: 198800
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S =sc.next();
        String spt[] =S.split("");
        
        switch(spt[spt.length-1]){
            case "0":
                System.out.println("pon");
                break;
            case "1":
                System.out.println("pon");
                break;
            case "2":
                System.out.println("hon");
                break;
            case "3":
                System.out.println("bon");
                break;
            case "4":
                System.out.println("hon");
                break;
            case "5":
                System.out.println("hon");
                break;
            case "6":
                System.out.println("pon");
                break;
            case "7":
                System.out.println("hon");
                break;
            case "8":
                System.out.println("pon");
                break;
            case "9":
                System.out.println("hon");
                break;
                
            
        }
        
        
	}
}

Measured memory_bytes: 35556