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

const ll MAX = 1e5+3;
ll n;

struct knap
{
    ll a,b;
}val[102];

ll dp[102][MAX];

int main()
{
    ll n,w;
    cin>>n>>w;
    for(int i=1;i<=n;i++)
    {
        cin>>val[i].a>>val[i].b;
    }
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(j>=val[i].a)
            {
                dp[i][j]=max(dp[i-1][j],max(dp[i][j-1],dp[i-1][j-val[i].a]+val[i].b));
            }
            else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    cout<<dp[n][w]<<endl;
}

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

int main(void) {
  string s;
  cin >> s;
  int size = s.size();
  string odd;
  for (int i = 1; i <= size; ++i) {
    if (i % 2 != 0) {
      odd += s[i - 1];
    }
  }

  cout << odd << endl;

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>

using namespace std;

int main()
{string S; long long K ; cin >> S ; cin >> K;
 char c = '1';
 for(int i = 0; i < min((long long)S.size(),K);i++)
 {if(S[i] != '1'){ c = S[i]; break;}}
 
 cout << c << 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> A(N);

    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    vector<int> B(A.back() + 1);
    for (int i = 0; i < N; i++)
    {
        if (B[A[i]] >= 1)
        {
            B[A[i]]++;
            continue;
        }
        
        for (int j = A[i]; j <= A.back(); j += A[i])
        {
            B[j]++;    
        }   
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        if (B[A[i]] == 1)
        {
            ans++;
        }
        
    }
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7896
#include<iostream>
#include<algorithm>
using namespace std;
#define INF (1<<29)

int N, M, R;
int d[201][201];
int r[9];
int A, B, C;
int res;
bool used[9];

void dfs(int p, int l, int dist) {
	if (p == R+1) {
		res = min(dist, res);
		return;
	}
	for (int i = 1; i <= R; i++) {
		if (!used[i]) {
			used[i] = true;
			if (l == -1) dfs(p + 1, i, 0);
			else dfs(p + 1, i, dist + d[r[i]][r[l]]);
			used[i] = false;
			
		}

	}

}


int main()
{
	cin >> N >> M >> R;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (i != j)d[i][j] = INF;
		}
	}

	for (int i = 1; i <= R; i++)cin >> r[i];

	for (int i = 1; i <= M; i++) {
		cin >> A >> B >> C;
		d[A][B] = d[B][A] = C;
	}

	for (int k = 1; k <= N; k++) {
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				if (d[i][j] > d[i][k] + d[k][j])
					d[i][j] = d[i][k] + d[k][j];
			}
		}
	}
	res = INF;
	dfs(1, -1, 0);
	cout << res;

    return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	answer := countItems(n)
	fmt.Println(answer)
}

func countItems(n int) int {
	var s string
	itemMap := make(map[string]int)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &s)
		itemMap[s]++
	}
	return len(itemMap)
}


Measured memory_bytes: 22140
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 2500;
const int K = 19;
int n, q;
int mod = 998244353;
int s1[N], s2[N], a[N], ans[N], f[N], invf[N], dp[N][N];
vector < pair < int, int > > v;
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int c(int n, int k){
    if (k < 0) return 0;
    return f[n] * invf[k] % mod * invf[n - k] % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    string s;
    cin >> s;
    int n = s.length();
    dp[0][0] = 1;
    f[0] = invf[0] = 1;
    for (int i = 1; i <= n + n; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 1; i <= n + n; i++) invf[i] = binpow(f[i], mod - 2);
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= i; j++){
            if (s[i - 1] == '0'){
                dp[i][j] = (dp[i][j] + dp[i - 1][j + 1]) % mod;
                dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
            } else
            if (s[i - 1] == '1'){
                dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
                dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % mod;
            } else
            if (s[i - 1] == '2'){
                dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % mod;
                dp[i][j] = (dp[i][j] + dp[i - 1][j - 2]) % mod;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= n; i++){
        ans = (ans + dp[n][i] * c(n, i)) % mod;
    }
    cout << ans;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,w;
const int V = 100025;
ll dp[V+1];

int main(){
  scanf("%d%d",&n,&w);
  fill(dp,dp+V+1,1ll<<60);
  dp[0] = 0;
  REP(i,n){
    int a,b;
    scanf("%d%d",&a,&b);
    FORR(j,0,V+1-b)CHMIN(dp[j+b],dp[j]+a);
  }
  ll ans = 0;
  REP(i,V+1)if(dp[i]<=w)ans = i;
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1024
using System;

namespace ABC097_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            int c = int.Parse(array[2]);
            int d = int.Parse(array[3]);
            int e = b - a;
            int f = c - b;
            int g = a - c;
            e = System.Math.Abs(e);
            f = System.Math.Abs(f);
            g = System.Math.Abs(g);
            if((e <= d) && (f <= d))
            {
                Console.WriteLine("Yes");
            }
            else if(g <= d)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11220
#include <atcoder/fenwicktree>
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    int N, Q;
    scanf("%d %d", &N, &Q);
    atcoder::fenwick_tree<ll> fw(N);
    for (int i = 0; i < N; i++) {
        ll a;
        scanf("%lld", &a);
        fw.add(i, a);
    }
    for (int z = 0; z < Q; z++) {
        int t;
        scanf("%d", &t);
        if (t == 0) {
            int p;
            ll x;
            scanf("%d %lld", &p, &x);
            fw.add(p, x);
        }else {
            int l, r;
            scanf("%d %d", &l, &r);
            printf("%lld\n", fw.sum(l, r));
        }
    }
}

Measured memory_bytes: 8220
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

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

    LL n;
    cin >> n;

    LL sum = 0;
    LL pos = 1;
    while( sum < n ) {
        sum += pos;
        ++pos;

    }

    for( int i = 1; i < pos; ++i ) {
        if( sum - n != i ) cout << i << endl;

    }


    return 0;
}



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


int main(){
	int h,w,n,cnt=0,cnt2=0;
	cin >> h >> w >> n;
	
	for(int i=1;i<=w;i++){
		if(h*i>=n){
			cnt=i;
			break;
		}
	}
	for(int i=1;i<=h;i++){
		if(w*i>=n){
			cnt2=i;
			break;
		}
	}
	
	cout << min(cnt,cnt2) << endl;
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

typedef long long llong;

const int INF = 2e9 + 999;
const llong LINF = 2e18 + 999;

void inv(bool e);
template<typename T> T sign(T a);
template<typename T> void die(T &a);
template<typename T> void umax(T &a, T b);
template<typename T> void umin(T &a, T b);

bool brute, alter;
int cnt_tests = 1;

// Improving csa rating

// Code below

llong a, b, c, d;

void inp() {
    cin >> a >> b >> c >> d;
}


void solve() {
    cout << max(0ll, min(b, d) - max(a, c));
}

void stress() {

}

void naive() {

}

void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("palindrome.in", "r", stdin);
            freopen("palindrome.out", "w", stdout);
        }
    #endif
    srand(time(0));
    #ifdef STRESS
        brute = true;
    #else
        brute = false;
    #endif

    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }
    cerr << endl << "Time: " << clock() / 1000.0 << " ms";
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
    cout << endl;
}

template<typename T>
void die(T &a) {
    cout << a;
    exit(0);
}

template<typename T>
T sign(T a) {
    if (a == 0)
        return 0;
    if (a < 0)
        return -1;
    return 1;
}

template<typename T>
void umax(T &a, T b) {
    if (b > a)
        a = b;
}

template<typename T>
void umin(T &a, T b) {
    if (b < a)
        a = b;
}

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[1000],b[1000],c[1000];
int main()
{
	long long i,n,ans;
	ans=0;
	cin>>n;
	for (i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for (i=0;i<n;i++)
	{
		cin>>b[i];
	}
	for (i=0;i<n-1;i++)
	{
		cin>>c[i];
	}
	for (i=0;i<n;i++)
	{
		ans+=(b[a[i]-1]);
	}
	//cout<<ans<<endl;
	for (i=0;i<n-1;i++)
	{
		if (a[i+1]-a[i]==1)
		{
			ans+=(c[a[i]-1]);
		}
	}
	cout<<ans<<endl;			
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n) ; i++)
typedef long long ll;

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

    if (N % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    rep(i, N / 2) {
        if (S[i] != S[i + N / 2]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int f(){
	int x,k,d;
	cin>>x>>k>>d;
	x = abs(x);
	int temp = x/d;
	if(k <= temp) return x - k*d;
	k -= temp;
	if(k % 2) return d - x%d;
	else return x % d;
}

int32_t main(){
    fast_io;
    show(f());
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    int k;
    cin>>s>>k;
    vector<int> a;
    int x=0, ones=0;
    for(char c:s) {
        if(c=='0') {
            a.push_back(x);
            x = 0;
        }
        else {
            ++x;
            ++ones;
        }
    }
    a.push_back(x);
    int n = a.size();
    k = min(k,ones);
    const ll MOD=998244353;
    vector<vector<ll>> dp(k+1,vector<ll>(ones+1));
    dp[0][0]=1;
    for(int i=n-1;i>0;--i) {
        // debug(a[i]);
        auto next = dp;
        rep(kk,0,k+1) {
            ll acc = 0;
            for(int j=ones;j>=0;--j) {
                next[kk][j]=(next[kk][j]+acc)%MOD;
                acc=(acc+dp[kk][j])%MOD;
            }
        }
        rep(l,1,a[i]+1) {
            for(int kk=k-l;kk>=0;--kk) {
                rep(j,0,ones+1-l) if(dp[kk][j]) {
                    next[kk+l][j+l] = (next[kk+l][j+l]+dp[kk][j])%MOD;
                }
            }
        }
        dp = move(next);
        // rep(kk,0,k+1) {
        //     rep(j,0,ones+1) cerr<<dp[kk][j]<<" ";
        //     cerr<<endl;
        // }
    }
    ll ans = 0;
    rep(kk,0,k+1) {
        rep(j,0,ones+1) {
            ans=(ans+dp[kk][j])%MOD;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4652
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] a = new int[N];
		
		for(int i=0;i<N;i++) {
			a[i] = sc.nextInt();
		}
		
		int ans = Integer.MIN_VALUE;
		
		for(int i=0;i<N-1;i++) {
			for(int j=i+1;j<N;j++) {
				ans = Math.max(ans, Math.abs(a[i]-a[j]));
			}
		}
		out.println(ans);
		
		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 21204
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>

using namespace std;

int main(void){
	long long int ans,ans2;
	int num[100001];
	int n,k;
	int a;
	while(1){
		scanf("%d%d",&n,&k);
		if(n==0 && k==0)break;
		ans=0;
		for(a=0;a<n;a++)scanf("%d",&num[a]);
		for(a=0;a<k;a++){
			ans+=num[a];
		}
		ans2=ans;
		for(a=k;a<n;a++){
			ans2+=num[a]-num[a-k];
			ans=max(ans,ans2);
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<bitset>
#define ll long long
using namespace std;
int read()
{
	char ch=getchar();int f=0,x=1;
	while(ch<'0'||ch>'9'){if(ch=='-') x=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){f=(f<<1)+(f<<3)+ch-'0';ch=getchar();}
	return f*x;
}
bitset<4000005> a;
bitset<4000005> b; 
int n,sum;
int main()
{
	a[0]=1;
	n=read();
	for(int i=1;i<=n;i++)
	{
		int x=read();
		b=a<<x;
		a=a|b;
		sum+=x;
	}
	for(int i=sum/2+(sum%2?1:0);i<=sum;i++)
	{
		if(a[i])
		{
			printf("%d",i);
			return 0;
		}
	}
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int f(int n) {
    if (n % 2) return 3 * n + 1;
    return n / 2;
}
signed main() {
    int s;
    cin >> s;

    vector<int> a(1000006);
    a[0] = s;
    REPF(i, 1, 1000006) a[i] = f(a[i - 1]);

    set<int> se;
    REP(i, 1000006) {
        if (CONTAIN(se, a[i])) {
            cout << i + 1 << endl;
            return 0;
        }
        se.insert(a[i]);
    }
    return (0^_^0);
}



Measured memory_bytes: 8064
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;

// 最大公約数を求める
template<typename T> T gcd(T a, T b)
{
	return b > 0 ? gcd(b, a % b) : a;
}

// 最小公倍数を求める
template<typename T> T lcm(T a, T b)
{
	return a / gcd(a, b) * b;
}

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

	vector<ll> a(n);
	for (ll i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	ll res = 1;
	for (ll i = 0; i < n; i++)
	{
		res = lcm(res, a[i]);
	}

	println(res);
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.numeric;

void main() {
    string x;
    scan(x);

    int st, ans;

    foreach (ch ; x) {
        if (ch == 'S') {
            st++;
        }
        else {
            if (st > 0) {
                st--;
            }
            else {
                ans++;
            }
        }
    }

    ans += st;
    writeln(ans);
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 764
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int S=stdIn.nextInt();
		int W=stdIn.nextInt();
		if(S<=W)
			System.out.println("unsafe");
		else
			System.out.println("safe");
	}
}


Measured memory_bytes: 35756
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

typedef std::pair<long, long> P;

std::vector<std::pair<long, long> > prime_factorize(long n){
    std::vector<std::pair<long, long> > ret;
    if(n < 2){
        printf("prime_factorize input invalid!\n");
        return ret;
    }
    for(long div = 2; div * div <= n; div++){
        std::pair<long, long> p(div, 0);
        while(n % div == 0){
            n /= div;
            p.second++;
        }
        if(p.second){
            ret.push_back(p);
        }
    }
    if(n != 1){
        ret.push_back(std::pair<long, long>(n, 1));
    }
    return ret;
}

long power(long a, long b){
	if(b == 0){
		return 1;
	}else if(b % 2 == 1){
		return a * power(a, b-1);
	}else{
		long r = power(a, b/2);
		return r*r;
	}
}

long n;

int main(){
    scanf("%ld", &n);
    long ans = 1;
    std::vector<P> vec = prime_factorize(n);
    for(int i = 0; i < vec.size(); i++){
        P p = vec[i];
        //printf("%ld^%ld\n", p.first, p.second);
        ans *= power(p.first, p.second - 1) * (p.first - 1);
    }
    printf("%ld\n", ans);
}



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

int main(){
  int N;
  cin >> N;
  double X[N];
  string U[N];
  
  for(int i=0;i<N;i++){
    cin>>X[i]>>U[i];
  }
  double total=0;
  
  for(int i=0;i<N;i++){
    if(U[i]=="JPY"){
      total=total+X[i];
    }
    else{total=total+X[i]*380000.0;
        }
  }
  
  cout<<total<<endl;

  return 0;
}
    

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
void dump(){cout<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cout<<h<<", ";dump(forward<Ts>(t)...);}
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}

void solve1();void solve2();
int main(){
  solve1();
  return 0;
}

void solve1(){

  ll n,t;
  cin>>n>>t;
  using pll = pair<ll,ll>;
  vector<pll> a(n);
  cin>>a;

  sort(a.begin(),a.end());
  auto dp = make_vector<ll>(6010,6010);
  rep(i,n){
    rep(j,t){
      if(i>0)chmax(dp[i][j],dp[i-1][j]);
      if(j>0)chmax(dp[i][j],dp[i][j-1]);
      if(i>0&&j>0)chmax(dp[i][j],dp[i-1][j-1]);
      chmax(dp[i+1][j+a[i].first],dp[i][j]+a[i].second);
    }
  }

  ll ans = 0;
  for(auto y:dp)for(auto x:y)chmax(ans,x);

  cout<<(ans)<<endl;

}


Measured memory_bytes: 282880
k, x =  list(map(int, input().split() ))
# 場合分け不要

a = range(x-k+1, x+k-1 + 1)
a = list(a)
a = map(str, a)
print(" ".join(a))
# for i in range(x-k+1, x+k-1 + 1):
# 	print(i)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll d, t, s;
  cin >> d >> t >> s;
  if (s*t >= d) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3620
h,w = map(int,input().split())
from copy import deepcopy
from collections import deque
a = [list(input()) for l in range(h)]
c = [[None for i in range(w)]for j in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] == '.':
            c[i][j] = -1
ans = 0
g = deque()
for l in range(h):
    for k in range(w):
        b = deepcopy(c)
        if a[l][k] == '.':
            b[l][k] = 0
            g.append((l,k))
            while len(g)>0:
                i,j = g.popleft()
                dis = b[i][j] 
                for dx,dy in ((1,0),(0,1),(-1,0), (0,-1)):
                    newi = i + dx
                    newj = j +dy
                    if newi < 0 or newi > h-1 or newj < 0 or newj > w-1:
                        continue
                    if b[newi][newj] == -1:
                        b[newi][newj] = dis + 1
                        ans = max(ans,dis+1)
                        g.append((newi,newj))
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getrnd(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

template <typename T1, typename T2>
bool relax(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T1, typename T2>
bool strain(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// :::::::::::::::::::::::::::::::

const int N = 405;
const ll INF = 1e15;

ll dp[N][N];

void solve() {
    int n;
    cin >> n;
    
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    
    vector<ll> pref(n + 1, 0);
    for (int i = 1; i <= n; ++i)
        pref[i] = pref[i - 1] + a[i - 1];
    
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            dp[i][j] = INF;
    
    for (int i = 0; i < n; ++i)
        dp[i][i] = 0;
    
    for (int len = 1; len <= n; ++len) {
        for (int l = 0; l + len < n; ++l) {
            int r = l + len;
            
            for (int i = l; i < r; ++i)
                relax(dp[l][r], dp[l][i] + dp[i + 1][r] + pref[r + 1] - pref[l]);
        }
    }
    
    cout << dp[0][n - 1] << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

int M;

void add(int& x, int y) {
  if ((x += y) >= M)
    x -= M;
}

void sub(int& x, int y) {
  if ((x -= y) < 0)
    x += M;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n >> M;

  vector<int> low(n), up(n * 2);
  for (int i = 0; i < n * 2; ++i)
    up[i] = sqrt(n * n * 4 - i * i);
  for (int i = 0; i < n; ++i)
    low[i] = ceil(sqrt(n * n - i * i)) - 1;
  up[0] = n * 2 - 1;
  int ans = 0;

  vector<vector<int>> pre(n, vector<int>(n));
  vector<int> pt(n);
  int ptr = n * 2 - 1;
  for (int i = n - 1; i >= 0; --i) {
    int qtr = ptr;
    while (qtr >= n && up[qtr] <= low[i]) --qtr;
    for (int j = 0; j < n - i; ++j) {
      int res = 1;
      for (int k = ptr; k > qtr; --k)
        res = res * (up[k] + 1LL - (n * 2 - k - 1 + j)) % M;
      pre[i][j] = res;
    }
    ptr = qtr;
    pt[i] = n * 2 - ptr - 1;
  }
  //cerr << up << '\n' << low << '\n';
  //cerr << "ptr " << ptr << '\n';
  for (int i = 0; i <= n; ++i) {
    vector<int> dp(i + 1);
    dp[0] = 1;
    for (int j = n - 1; j >= 0; --j) {
      for (int k = 0; k <= i; ++k)
        dp[k] = dp[k] * (ll)pre[j][k] % M;
      for (int k = i; k >= 0; --k) {
        dp[k] = dp[k] * (up[j] + 1LL - (n * 2 - j - 1 + i - k)) % M;
        if (k)
          add(dp[k], dp[k - 1] * (low[j] + 1LL - (pt[j] + (k - 1))) % M);
      }
    }
    int res = dp[i];
    //cerr << res << ' ';
    for (int j = n; j <= ptr; ++j)
      res = res * (up[j] + 1LL - (n * 2 - j - 1 + i)) % M;
    //cerr << i << ": " << res << '\n';
    if (i & 1)
      sub(ans, res);
    else
      add(ans, res);
  }
  cout << ans << '\n';

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main {
	static int out = 0;
	static boolean nF = false;
	static boolean nS = false;
	static boolean nT = false;
	static int A = 0;
	static boolean END = false;
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
			int n = stdIn.nextInt();
			for(int i = 0; i < n; i++) {
				out = 0;
				nF = false;
				nS = false;
				nT = false;
				A = 0;
				END = false;
				while(true) {
					if(END) break;
					String tmp = stdIn.next();
					if(tmp.equals("HIT")) hit();
					if(tmp.equals("OUT")) out();
					if(tmp.equals("HOMERUN")) homerun();
				}
				System.out.println(A);
		}
	}
	public static void hit() {
		if(!nF) {
			nF = true;
		}
		else if(!nS) {
			nS = true;
		}
		else if(!nT) {
			nT = true;
		}
		else {
			A++;
		}
	}
	
	public static void out() {
		out++;
		if(out > 2) {
			END = true;
		}
	}
	
	public static void homerun() {
		if(nT) {
			nT = nS = nF = false;
			A += 4;
		}
		else if(nS) {
			nS = nF = false;
			A += 3;
		}
		else if(nF) {
			nF = false;
			A += 2;
		}
		
		else {
			A += 1;
		}
	}
	
}

Measured memory_bytes: 17196
n = int(input())
A = list(map(int, input().split()))
checked = [False] * n
ans = 0
for i, a in enumerate(A):
    if checked[i]:
        continue
    if A[a - 1] - 1 == i:
        ans += 1
        checked[i] = True
        checked[a - 1] = True
print(ans)

Measured memory_bytes: 13880
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author david yepes buitrago
 * @date 01-08-2017
 * @time 0.000 ms
 */
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		for (String line; (line = in.readLine()) != null;) {
			StringTokenizer st = new StringTokenizer(line);
			long a = Long.parseLong(st.nextToken());
			long b = Long.parseLong(st.nextToken());
			long cont = 0;
			if (a == b) {
				out.println(0);
				continue;
			}
			if (a < b) {
				if (a < 0 && b > 0) {
					cont++;
				}
			} else {

				if (b > 0 && a > 0) {
					cont += 2;
				}
				if (b <= 0 && a >= 0) {
					cont++;
				}
				if (b < 0 && a < 0) {
					cont += 2;
				}
			}
			cont += Math.abs(Math.abs(a) - Math.abs(b));
			out.println(cont);
		}
		out.close();
	}
}


Measured memory_bytes: 20820
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():

    d,n=map(int,input().split())
    val=100**d
    if d==0 and n==100:
        print(101)
    elif d==1 and n==100:
        print(10100)
    elif d == 2 and n == 100:
        print(1010000)

    else:

        print(val*n)

resolve()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> C(N);
  vector<int> V(N);
  for(int i=0;i<N;i++){
    cin >> V.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> C.at(i);
  }
  
  int ans=0;
  
  for(int i=0;i<N;i++){
    if(V.at(i) > C.at(i)){
      ans = ans + V.at(i) - C.at(i);
    }
  }
  
  cout << ans << endl;
  
  
  
  
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=i+1
a=sorted(a)
def f(x):
    ans=0
    for i in range(n):
        ans+=abs(x-a[i])
    return ans

if n%2==0:
    m=n//2
else:
    m=(n+1)//2

print(f(a[m-1]))





Measured memory_bytes: 104428
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,x;
    
    cin>>n>>x;
    
    int L[n];
    int sum=0;
    
    for(int i=1; i<n+3; i++){
        cin>>L[i];
        //cout << sum << endl;
        sum=sum+L[i];
        if(sum>x){
            cout<<i;
            break;
        }
    }
}


Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	ll a, b, x;
	cin >> a >> b >> x;

	if (a == 0) {
		cout << b / x + 1 << endl;
	}
	else {
		cout << b/x-(a-1)/x<< endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>


using namespace std;


void solve2() {
	string input;
	string ans = "";
	cin >> input;
	for (int i = 0; i < input.size(); i++)
	{
		if (input[i] == '1')
			ans += "1";
		if (input[i] == '0')
			ans += "0";
		if (input[i] == 'B')
			ans = ans.substr(0, ans.size() - 1);
	}
	cout << ans << endl;
}

void solve1() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		ans += i;
	}
	cout << ans << endl;
}


int main() {
	solve2();
	return 0;
}

Measured memory_bytes: 256
#include <array>
#include <iostream>

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

	std::array<int, 26> count = {{0}};

	for (auto const c : S) ++count[c - 'a'];

	std::size_t i = 0;
	for (i = 0; i < 26; ++i) {
		if (!count[i]) break;
	}

	if (i == 26) {
		std::cout << "None" << std::endl;
	} else {
		std::cout << static_cast<char>('a' + i) << std::endl;
	}

	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int num =sc.nextInt();
		int n[]=new int[num];
		
		for(int i=0;i<num-1;i++) {
			int a=sc.nextInt()-1;
			n[a]+=1;
		}
		
		for(int i=0;i<num;i++) {
			System.out.println(n[i]);
		}
		sc.close();
		
	}

}

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


void solve(int N, std::string S){
    rep(i,S.length()){
        if(S[i]+N<(int)'Z'+1){
            S[i]+=N;
        }
        else{
            S[i]+=N-'Z'+'A'-1;
        }
    }
    cout<<S<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::cout<<std::fixed<<std::setprecision(10);//誤差小数10桁まで
    int N;
    scanf("%d",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


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

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

class RMQ {
private:
	int bottomSt, bottomEd;
	vector<int> a;
	vector<int> rs, re;
	vector<int> cand;
	int set(int n) {
		int left = 2 * n + 1;
		int right = 2 * n + 2;
		if (left <= a.size() - 1) {
			a[n] = min(set(left), set(right));
			rs[n] = rs[left];
			re[n] = re[right];
		}
		return a[n];
	}
	void search(int s, int t, int n) {
		if (s <= rs[n] && re[n] <= t) {
			cand.push_back(a[n]);
			return;
		}
		int left = 2 * n + 1;
		int right = 2 * n + 2;
		if (s <= re[left]) search(s, t, left);
		if (rs[right] <= t) search(s, t, right);
	}
public:
	RMQ(vector<int> &v) {
		bottomEd = 0;
		for (int i = 1, plus = 1; plus < v.size(); i++) {
			plus *= 2;
			bottomEd += plus;
		}
		a.resize(bottomEd + 1);
		rs.resize(bottomEd + 1);
		re.resize(bottomEd + 1);

		bottomSt = bottomEd / 2;

		for (int i = bottomSt; i <= bottomEd; i++) {
			int j = i - bottomEd / 2;
			a[i] = j < v.size() ? v[j] : LLONG_MAX;
			rs[i] = j;
			re[i] = j;
		}

		set(0);
	}

	void update(int index, int x) {
		int pt = bottomSt + index;
		a[pt] = x;
		while (pt > 0) {
			pt = (pt - 1) / 2;
			a[pt] = min(a[2 * pt + 1], a[2 * pt + 2]);
		}
	}

	int find(int s, int t) {
		cand.clear();
		search(s, t, 0);
		int ret = cand[0];
		for (int i = 1; i < cand.size(); i++) {
			ret = min(ret, cand[i]);
		}
		return ret;
	}
};

signed main() {
	int n, q;
	cin >> n >> q;

	vector<int> tmp(n, 2147483647);
	RMQ rmq(tmp);

	rep(lp, q) {
		int com, x, y;
		cin >> com >> x >> y;

		if (com == 0) {
			rmq.update(x, y);
		} else {
			cout << rmq.find(x, y) << endl;
		}
	}

    return 0;
}

Measured memory_bytes: 8132
from collections import Counter

n = int(input())
a = [int(_) for _ in input().split()]

odd = [a[i] for i in range(0,len(a),2)]
even = [a[i] for i in range(1,len(a),2)]

a_odd_most = Counter(odd).most_common()[:2]
a_even_most = Counter(even).most_common()[:2]

if a_odd_most[0][0] != a_even_most[0][0]:
    print(len(a) - a_odd_most[0][1] - a_even_most[0][1])
else:
    if len(a_odd_most) == 1 or len(a_even_most) == 1:
        a_odd_most.append((0,0))
        a_even_most.append((0,0))

    print(len(a) - max(a_odd_most[0][1]+a_even_most[1][1], 
                  a_odd_most[1][1]+a_even_most[0][1]))

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

# define ll long long

int main(){
 
  int n, capacity, late;
  cin >> n >> capacity >> late;
  
  int time[100005];
  for(int i=0; i<n; i++) cin >> time[i];
  sort(time, time+n);
  
  int ans = 1, currentCap = 1, firstPerson = time[0];
  for(int i=1; i<n; i++){
    if(currentCap + 1 <= capacity && time[i] <= firstPerson + late){
      currentCap++;
    } else {
      ans++;
      currentCap = 1;
      firstPerson = time[i];
    }
  }
  
  cout << ans << endl;
  
  return 0;
} 



Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    int a,b;
    cin>>a>>b;
    cout<<b*2-a<<endl;
    return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
#include<string.h>
#define M 1000000
#define NIL (-1)
#define L 14
char H[M][L];

int getChar(char ch){
  if(ch=='A')return 1;
  else if(ch=='C')return 2;
  else if(ch=='G')return 3;
  else if(ch=='T')return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0)return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key=getKey(str);
  for(i=0;;i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h],str)==0)return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i,n,h;
  char str[L],com[9];
  for(i=0;i<M;i++)H[i][0]='\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);

    if(com[0]=='i'){
      insert(str);
    }else{
      if(find(str)){
	printf("yes\n");
      }else{
	printf("no\n");
      }
    }
  }
  return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    char tmp = s[0];
    rep (i, s.size()) {
      if (tmp == s[i]) continue;
      tmp = s[i];
      ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

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

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

	int n, k;
	cin >> n >> k;
	
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	sort(a.begin(), a.end());
	if(a.back() < k){
		cout << "IMPOSSIBLE" << endl;
		return 0;
	}

	int g = a[0];
	rep(i, n - 1) g = gcd(g, a[i + 1]);

	if(k % g == 0){
		cout << "POSSIBLE" << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void){
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if(x+r<=W&&y+r<=H&&x-r>=0&&y-r>=0){
printf("Yes\n");
}else{
printf("No\n");
}
return 0;
}


Measured memory_bytes: 2096
# -*- coding: utf-8 -*-
import sys
from functools import lru_cache
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: print('Yes' if b else 'No')
YESNO=lambda b: print('YES' if b else 'NO')

def main():
    @lru_cache()
    def fib(n):
        if n==0 or n==1:
            return 1
        return fib(n-1)+fib(n-2)
    print(fib(int(input())))
        

if __name__ == '__main__':
    main()



Measured memory_bytes: 6292
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[200001];
long long int x,y,ans;
int main(){
  cin>>n;
  cin>>x;
  for(int i=1;i<n;i++){
    cin>>a[i];y+=a[i];
  }
  ans=abs(x-y);
  for(int i=1;i<n-1;i++){
    y-=a[i];x+=a[i];
    ans=min(ans,abs(x-y));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

const int MAX_V = 210;
int N;
int d[MAX_V][MAX_V];

void warshall()
{
    for (int k = 0; k < N; k++)
    {
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                chmin(d[i][j], d[i][k] + d[k][j]);
                
            }
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    for (int i = 0; i < R; i++)
    {
        cin >> r[i];
        r[i]--;
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (i == j)
            {
                d[i][j] = 0;
            }
            else
            {
                d[i][j] = INF;
            }
        }
    }
    for (int i = 0; i < M; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    sort(ALL(r));

    warshall();

    int ans = INF;

    do
    {
        int tmp = 0;
        // cout << "dbg:";
        for (int i = 0; i < R - 1; i++)
        {
            // cout << r[i] << ' ';
            tmp += d[r[i]][r[i + 1]];
        }
        // cout << r[R - 1] << endl;
        // cout << tmp << endl;
        chmin(ans, tmp);
    } while (next_permutation(ALL(r)));

    // for (int i = 0; i < N; i++)
    // {
    //     for (int j = 0; j < N; j++)
    //     {
    //         cout << d[i][j] << ' ';
    //     }
    //     cout << endl;
    // }

    cout << ans << endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using P   = pair<int, int>;
using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, a, b;cin >> n >> a >> b;
    int ans = 0;
    for(int i=0;i<n;i++){
        int t;cin >> t;
        if(t < a || b <= t) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256