akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

// const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);
const ll MD = 1000000007LL;
// fprintf(stderr, "%d %lld \n", x, xll);

class SegTree{

public:

	int n;
	vector<int> dat;
	vector<int> _kl;
	vector<int> _kr;

	int dummy = 2147483647;

	SegTree(int _n){
		init(_n);
	}

	void init(int n_){
		// set n
		n = 1;
		while(n < n_) n *=2;
		int n_cells = 2 * n - 1;

		// initialize vectors
		dat = vector<int>(n_cells);
		_kl = vector<int>(n_cells);
		_kr = vector<int>(n_cells);

		// initialize kl, kr
		rep(k, n_cells){
			if(is_root(k)){
				_kl[k] = 0;
				_kr[k] = n;
			}
			else{
				if(is_cl(k)) {
					_kl[k] = _kl[pa(k)];
					_kr[k] = (_kl[pa(k)] + _kr[pa(k)]) / 2;
				}
				else{
					_kl[k] = (_kl[pa(k)] + _kr[pa(k)]) / 2;
					_kr[k] = _kr[pa(k)];
				}
			}
		}

		// initialize values
		rep(k, n_cells) dat[k] = dummy;

		/*
		rep(k, n_cells){
			fprintf(stderr, "%d %d %d %d\n", k, _kl[k], _kr[k], dat[k]);
		}
		*/
	}

	int pos(int i){ return i + n - 1; }
	int pa(int k){ return (k - 1) / 2; }
	int cl(int k){ return k * 2 + 1; }
	int cr(int k){ return k * 2 + 2; }
	bool is_root(int k){ return k == 0; }
	bool is_cl(int k){
		if(is_root(k)) return false;
		return cl(pa(k)) == k;
	}

	void update(int i, int a){
		int k = pos(i);
		dat[k] = a;
		while(!is_root(k)){
			k = pa(k);
			dat[k] = min(dat[cl(k)], dat[cr(k)]);
		}
	}

	int query(int il, int ir){
		return _query(il, ir, 0);
	}

	int _query(int il, int ir, int k){
		int kl = _kl[k];
		int kr = _kr[k];
		if(kr <= il || ir <= kl) return dummy;
		if(il <= kl && kr <= ir) return dat[k];
		else{
			int vl = _query(il, ir, cl(k));
			int vr = _query(il, ir, cr(k));
			return min(vl, vr);
		}
	}
};

int N, Q;
int main() {
	cin >> N >> Q;

	SegTree ST(N);

	rep(q, Q){
		int c, x, y;
		cin >> c >> x >> y;

		if(c == 0){
			// update
			ST.update(x, y);
		}
		else{
			// find
			cout << ST.query(x, y+1) << endl;
		}
	}

}

Measured memory_bytes: 5884
#include <iostream>

int main ()
{
    int limit, total;

    while (std::cin >> limit >> total) {
        if (limit == 0 && total == 00) {
            break;
        }
        int num = 0;
        for (int i1 = 1; i1 <= limit - 2; i1++) {
            int remain1 = total - i1;
            for (int i2 = i1 + 1; i2 <= limit - 1; i2++) {
                int remain2 = remain1 - i2;
                if (remain2 <= limit && remain2 > i2) {
                    num++;
                }
            }
        }
        std::cout << num << '\n';
    }
}

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

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

  vector<string> W(N);

  cin >> W.at(0);

  for (int i = 1; i < N; i++)
  {
    cin >> W.at(i);

    // しりとり が成り立っているかどうか
    if (W.at(i - 1).back() != W.at(i).front())
    {
      cout << "No" << endl;
      return 0;
    }
  }

  // 配列重複削除
  sort(W.begin(), W.end());
  W.erase(unique(W.begin(), W.end()), W.end());

  // 同じ単語を使っているかどうか
  cout << (W.size() == N ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3616
#include <iostream>

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n, v, c;
    vector<int> cc;
    vector<int> vv;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> v;
        vv.push_back(v);
    }
    for(int i=0; i<n; i++){
        cin >> c;
        cc.push_back(c);
    }
    vector<int> diff;
    for(int i=0; i<n; i++){
        diff.push_back(vv[i] - cc[i]);
    }
    int sum = 0;
    for(int i=0; i<n; i++){
        if(diff[i]>0) sum += diff[i];
    }
    cout << sum << endl;
  return 0;
}

/*
13 21 6 19
11 30 6 15
*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    cin>>s;
    int i=1;
    for(int j=0;s[j]!='A';++j){
        ++i;
    }
    
    int n=s.size();
    int k=1;
    for(int l=0;s[n-l-1]!='Z';++l){
        ++k;
    }
    cout<<(n-k+1-i+1)<<endl;
    
    
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int count=0;
void liner_serch(int S[],int T[],int n,int q);
int main(void){
	int i,n;
	scanf("%d",&n);
	int S[n];
	for(i=0;i<n;i++){
		scanf("%d",&S[i]);
	}
	int q;
	scanf("%d",&q);
	int T[q];
	for(i=0;i<n;i++){
		scanf("%d",&T[i]);
	}
	
	liner_serch(S,T,n,q);
	printf("%d\n",count);
}


void liner_serch(int S[],int T[],int n,int q){
	int i,j;
	for(i=0;i<q;i++){
		for(j=0;j<n;j++){
			if(T[i]==S[j]){
				count++;
				break;
			}
		}
	}
}


Measured memory_bytes: 2088
#include <stdio.h>

int main(void)
{
    int S, h, m, s;
    scanf("%d", &S);
    h = S / 60 / 60;
    m = S / 60 % 60;
    s = S % 60;
    printf("%d:%d:%d\n", h, m, s);
    return (0);
}

Measured memory_bytes: 2728
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2e5+5;
int a[N],tot,n,res;
int main(){
	scanf("%d",&n);
	fp(i,1,n)scanf("%d",&a[i]);
	fp(i,1,n)if(a[i]!=a[i-1])a[++tot]=a[i];
	n=tot,res=1;
	for(R int l=1,r=2;r<=n;l=r++){
		if(a[l]<a[r])while(r<=n&&a[r]>a[r-1])++r;
			else while(r<=n&&a[r]<a[r-1])++r;
		if(r<=n)++res;
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h> 
using namespace std;
 
#define ll long long int
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);
#define MOD 998244353
#define ll_MAX 19223372036859
#define endl "\n"
inline ll absdiff(ll a,ll b){ return (a>b)?a-b:b-a;}
ll fast_expo(ll x,ll p){if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
ll gcd(ll a,ll b){if(a==0||b==0) return a+b;  else return gcd(b%a,a); }

int main()
{
    fast
    ll q;q = 1;
    // cin>>q;
    for (ll t = 0; t < q; ++t)
    {
        ll a,b;cin>>a>>b;
        cout<<6-a-b;
    }
    return 0;
}   

Measured memory_bytes: 256
n = int(input())
if n == 1:
  print('1')
elif 1 < n and n < 4:
  print('2')
elif 4 <= n and n < 8:
  print('4')
elif 8 <= n and n < 16:
  print('8')
elif 16 <= n and n < 32:
  print('16')
elif 32 <= n and n < 64:
  print('32')
else :
  print('64')

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
#define INF 1000000007

int d[201][201];
int N,M,R;
int r[8];
bool used[8];

int dfs(int c, int v){
  if(c == R){
    used[v] = false;
    return 0;
  }

  used[v] = true;
  int mn = INF;
  for(int i=0;i<R;i++){
    if(!used[i]){
      mn = min(mn, dfs(c+1,i)+d[r[v]][r[i]]);
    }
  }
  used[v] = false;
  return mn;
}

int main(){
  cin >> N >> M >> R;
  for(int i=0;i<R;i++){
    cin >> r[i];
    r[i]--;
  }

  fill(d[0],d[201],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;
  }
  for(int i=0;i<N;i++) d[i][i]=0;

  //ワーシャルフロイド
  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }

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

  fill(used,used+R,false);

  int mn = INF;
  for(int i=0;i<R;i++){
    //cout << "start" << r[i] << " " << dfs(1,i) << endl;
    mn = min(mn, dfs(1,i));
  }

  //cout << endl;
  cout << mn << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
pair<int64,int64> p[5];
void Solve() {
    int64 A,B;
    read(A);read(B);
    if(A == B) {puts("1");return;}
    int r = -1;
    for(int i = 59 ; i >= 0 ; --i) {
	if((A >> i & 1) != (B >> i & 1)) {r = i;break;}
    }
    int64 ans = 0;
    A &= (1LL << r + 1) - 1;
    B &= (1LL << r + 1) - 1;
    p[1] = mp((1LL << r) + A,(1LL << r + 1) - 1);
    int t = -1;
    for(int i = r - 1 ; i >= 0 ; --i) {
	if(B >> i & 1) {t = i;break;}
    }
    p[0] = mp(A,(1LL << r) + (1LL << t + 1) - 1);
    sort(p,p + 2);
    int64 rm = -1;
    for(int i = 0 ; i < 2 ; ++i) {
	if(p[i].se < rm) continue;
	else {
	    ans += p[i].se - max(rm,p[i].fi - 1);
	    rm = p[i].se;
	}
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


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

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll n,q;
ll a[200005];
map<ll,ll>map1;
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n;ll sum = 0;
		for(ll i=0;i<n;i++){cin>>a[i];map1[a[i]]++;sum+=a[i];}
		cin>>q;
		while(q--)
		{
			ll b,c;
			cin>>b>>c;
			ll d = c - b;ll times = map1[b];
			map1[c] += map1[b];map1[b] = 0;
			sum += times*d;
			cout<<sum<<endl;


		}





}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

    
}

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

int main() {
    int a,b;
    cin>>a>>b;
    int x=0;
    for(int i=1;i<4;i++){
        if(i!=a&&i!=b) x=i;
    }
    cout<<x<<endl;
}

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

const ll MAX = 1e9;

int main() {
  ll n, k, s;
  cin >> n >> k >> s;

  vector<ll> ans(n);
  for (int i = 0; i < k; i++) ans[i] = s;
  if (s == MAX) {
    for (int i = k; i < n; i++) ans[i] = s - 1;
  } else {
    for (int i = k; i < n; i++) ans[i] = s + 1;
  }

  for (int i = 0; i < n; i++) {
    printf("%ld ", ans[i]);
  }
  printf("\n");
}


Measured memory_bytes: 4008
#include <iostream>
#include<cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

typedef  long long ll;

using namespace std;

int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
    if((a == 5 && b == 5 && c == 7) || (b == 5 && c == 5 && a == 7) || (c == 5 && a == 5 && b == 7))
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll bitree[555555];

ll query(int x){
	ll v = 0ll;
	while(x){
		v += bitree[x];
		x -= (x&(-x));
	}
	return v;
}

void update(int x, ll v){
	++x;
	while(x<555555){
		bitree[x] += v;
		x += (x&(-x));
	}
}

int main(void){
	int n,q,i,t,l,r;
	ll a;
	std::cin >> n >> q;
	for(i=0; i<n; ++i){
		std::cin >> a;
		update(i,a);
	}
	for(i=0; i<q; ++i){
		std::cin >> t >> l >> r;
		if(t){
			std::cout << (query(r)-query(l)) << std::endl;
		}else{
			update(l,r);
		}
	}
	return 0;
}


Measured memory_bytes: 8244
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int N = 110;
int d[12][12], c[N][N], ma[12][12];

int main() {
    int a, b;
    cin >> a >> b;
    FOR(i,1,a) FOR(j,1,b){
        cin >> d[i][j];
        ma[i][j] = 1e9;
    }

    REP(cx,N) REP(cy,N) FOR(i,1,a) FOR(j,1,b){
        c[cx][cy] = max(c[cx][cy], d[i][j] - cx * i - cy * j);
    }

    REP(cx,N) REP(cy,N) FOR(i,1,a) FOR(j,1,b){
        ma[i][j] = min(ma[i][j], cx * i + cy * j + c[cx][cy]);
    }

    FOR(i,1,a) FOR(j,1,b){
        if (ma[i][j] != d[i][j]){
            cout << "Impossible" << endl;
            return 0;
        }
    }

    int m = 2 * (N-1) + N * N;

    cout << "Possible" << endl;
    cout << 300 << " " << m << endl;
    REP(i,N-1) cout << i+1 << " " << i+2 << " X" << endl;
    REP(i,N-1) cout << 299-i << " " << 300-i << " Y" << endl;
    REP(i,N) REP(j,N) cout << i+1 << " " << 300-j << " " << c[i][j] << endl;
    cout << "1 300" << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	string code[32] = {"00000", "00001", "00010", "00011", "00100", "00101", "00110", "00111", 
				   "01000", "01001", "01010", "01011", "01100", "01101", "01110", "01111",
				   "10000", "10001", "10010", "10011", "10100", "10101", "10110", "10111",
				   "11000", "11001", "11010", "11011", "11100", "11101", "11110", "11111"};
	string decode[32] = {"101", "000000", "000011", "10010001", "010001", "000001", "100101", "10011010",
					"0101", "0001", "110", "01001", "10011011", "010000", "0111", "10011000",
					"0110", "00100", "10011001", "10011110", "00101", "111", "10011111", "1000",
					"00110", "00111", "10011100", "10011101", "000010", "10010010", "10010011", "10010000"};
	char ch[6] = {' ', '.', ',', '-', '\'', '?'};
	char hc[6] = {' ', '\'', ',', '-', '.', '?'};
	string str;
	while(getline(cin, str)) {
		const char *c = str.c_str();
		string ret;
		for(int i = 0; c[i] != '\0'; i++) {
			if(isalpha(c[i])) {
				int a = c[i] - 'A';
				ret += code[a];
			} else {
				rep(j,6) {
					if(c[i] == ch[j]) ret+= code[26+j];
				}
			}
		}
		int len = ret.length();
		int i = 0;
		string ans;
		while(len > i) {
			bool f = 1;
			rep(j,32) {
				f = 1;
				rep(k,decode[j].length()) {
					if(decode[j][k] != ret[i+k]) {
						f = 0;
						break;
					}
				}
				if(f) {
					if(j < 6) ans += hc[j];
					else ans += (char)('A'+j-6);
					i += decode[j].length();
					break;
				}
			}
			if(!f) break;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;

long long cnt; //记录希尔排序次数值，可以和插入排序比较
vector<int> G;//希尔排序中的增量序列1，4，13，40，121，...
int n, a[1000005]; //入坑：大数组定义在main外部 

void insertSort2(int a[], int n, int g) {
	int i, j, tmp;
	for (i = g; i < n; i++) {
		tmp = a[i];
		for (j = i-g; j >=0 && a[j] > tmp; j = j - g) {
			a[j+g] = a[j];
			cnt++;
		}
		a[j+g] = tmp;
	}
}
void insertionSort(int a[] , int n , int g){
	for(int i =g ;i<n;i++){
		int v = a[i];
		int j=i-g;
		while(j>=0&&a[j]>v){
			a[j+g]=a[j];
			j-=g;
			cnt++;
		}
		a[j+g]=v;
	}
}
void shellSort(int a[], int n) {
	for (int h = 1;;) {
		if (h > n)break;
		G.push_back(h);
		h = 3 * h + 1; //这种增序列算法效率基本维持在O(N1.25)
	}
	for (int i = G.size() - 1; i >= 0; i--) {  //按逆序列指定G[i]=g
		insertSort2(a, n, G[i]);
	}
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
//		cin >> a[i];
		scanf("%d",&a[i]);
	shellSort(a, n);
	cout << G.size() << endl;
	for (int i = G.size() - 1; i >= 0; i--) {
		printf("%d", G[i]);
		if (i)printf(" ");
	}
	cout << endl;
	cout << cnt << endl;
	for (int i = 0; i < n; i++)
		printf("%d\n", a[i]);
}


Measured memory_bytes: 7192
N=int(input())
X=list(map(int,input().split()))
X_s=sorted(X)
can_m=X_s[ N//2-1 ]
can_M=X_s[ N//2 ]
for i in X:
    if i<=can_m:
        print(can_M)
    else:
        print(can_m)

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

int main()
{
    ll A,B,K;
    cin >> A >> B >> K;

    if(A>=K){
        A=A-K;
        cout << A << " " << B << endl;
        return 0;
    }else{
        K-=A;
        if(B>=K){
            B-=K;
            cout << 0 << " " << B << endl;
        }else{
            cout << 0 << " " << 0 << endl;
        }
    }

}

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

using namespace std;

int main() {
	int n, i, ab = 0, b = 0,a = 0, btoa = 0;
	string in;
	vector<string> s;

	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> in;
		s.push_back(in);
		if (*in.begin() == 'B' && (in[in.size() - 1] == 'A')) {
			b++;
			a++;
			btoa++;
		}
		else if (*in.begin() == 'B') {
			b++;
		}
		else if (in[in.size() - 1] == 'A') {
			a++;
		}

		for (int j = 0; j < (int)in.length()-1; j++) {
			if (in.substr(j, 2) == "AB") {
				ab++;
			}
		}
	}

	if (a == btoa && b == btoa) {
		a = max(a-1,0);
	}
	cout << ab + min(a, b) << endl;

	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

bool s[40]={};

ll md(ll a,ll m){
  return ((a%m)+m)%m;
}

int main(){
  ll n;
  cin>>n;
  if(n==0){cout<<0<<endl;return 0;}
  fr(i,40){
    s[i]=md(n,2);
    n+=(2*(i%2)-1)*md(n,2);
    n/=2;
  }
  bool f=0;
  ifr(i,40) if(f||s[i]){f=1;cout<<s[i];}
  cout<<endl;
}

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

signed main(){
       int n,k;
       cin >> n >> k;
       priority_queue<int> que[n];
       int t,d;
       for(int i=0;i<n;i++){
           cin >> t >> d;
           que[t-1].push(d);
       }
        priority_queue<int > quef;
        priority_queue<int> queq;
        for(int i=0;i<n;i++){
            if(!que[i].empty()){
                quef.push(que[i].top());
                que[i].pop();
            }
            while(!que[i].empty()){
                queq.push(que[i].top());
                que[i].pop();
            }
        }
        int ans[k]={};
        int a=0;
        
        for(int i=0;i<k&& !quef.empty() ;i++){
            a+=quef.top()+(2*i+1);
            ans[i]=a;
            quef.pop();
           
        }
        
        a=0;

         for(int i=k-2;i>=0&& !queq.empty() ;i--){
            a+=queq.top();
            ans[i]+=a;
            queq.pop();

        }
        sort(ans,ans+k,greater<int>());
        
        cout << ans[0];

    return 0;
}

Measured memory_bytes: 7796
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

using namespace std;

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

typedef long long ll;
typedef vector<vector<int> > Graph;

const int Mod = static_cast<int>(1e9 + 7);

int a[51], b[51], c[51], d[51];
int dp[51][11];

int main()
{
	int k, a, b;
	cin >> k >> a >> b;
	bool ans = false;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			ans = true;
			break;
		}
	}
	if (ans) {
		cout << "OK" << endl;
	}
	else {
		cout << "NG" << endl;
	}
}

Measured memory_bytes: 3636
import java.util.*;

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

        int count = 0;
        for(int i = L;i<=R;i++){
            if(i%d==0){
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35716
n=int(input())
h=list(map(int,input().split()))
h=h[::-1]
count=0
for i in range(1,n):
    if h[i]==h[i-1]+1:
        h[i]+=-1
        count=1
    elif h[i]<=h[i-1]:
        count=1
    
    elif h[i]>=h[i-1]+2:
        count=0
        break
    
print('Yes' if count==1 or n==1 else 'No')

Measured memory_bytes: 14228
#include<bits/stdc++.h>
using namespace std;
const int N=10005;
char s[N];int p[N];
signed main(){
	int n,K;
	long long res=1;
	cin>>n>>K;
	for(int i=2;i<=K;++i){
		res*=2;
		if(res>=n){
			res=n; break;
		}
	}
	cin>>(s+1);
	for(int i=n+1;i<=n+n;++i)
		s[i]=s[i-n];
	reverse(s+n+1,s+n+n+1);
	char ch=*min_element(s+1,s+n+1);
	int cnt=(s[1]==ch);
	for(int i=2;i<=n+n;++i)
		if(s[i]==ch && s[i]==s[i-1]) ++cnt;
		else p[i-1]=cnt,cnt=(s[i]==ch);
	p[n+n]=cnt;
	int mx=*max_element(p+n+1,p+n+n+1);
	res*=mx;
	if(res>=n){
		for(int i=1;i<=n;++i)
			cout<<ch;
		return 0;
	}
	string S="",tmp;
	for(int i=n+1;i<=n+n;++i)
		if(p[i]==mx){
			tmp="";
			for(int j=1;j<=res;++j)
				tmp+=ch;
			for(int j=i-p[i];j>i-p[i]-(n-res);--j)
				tmp+=s[j];
			if(S=="") S=tmp;
			else S=min(S,tmp);
		}
	cout<<S;
	return 0;
}

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

signed main(void)
{
	int n, ans;

	cin >> n;
	ans = 0;
	rep(i, n)
	{
		int l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

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

void solve() {
	int n; scanf("%d", &n);
	int d4 = 0, d2 = 0;
	for (int i = 0; i < n; ++i) {
		int a; scanf("%d", &a);
		if (a%4==0) ++d4;
		else if (a%2==0) ++d2;
	}
	n -= d4+d2;
	if ((d2 && d4 == n) || (!d2 && d4 >= n-1)) puts("Yes");
	else puts("No");
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


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

int main(){
    string s;
    cin>>s;
   int ans=0,res=0;
   s='0'+s;int len=s.size();
   for(int i=len-1;i>=1;i--){
       if(i==0) continue;
        if(s[i]>'5') {
            res+=10-(s[i]-'0');
            s[i]='0';
            s[i-1]++;
        }
        else if(s[i]=='5' && s[i-1]>='5'){
            res+=10-(s[i]-'0');
            s[i]='0';
            s[i-1]++;
        }
   }
   for(int i=0;i<len;i++)
    ans+=s[i]-'0';
   cout<<ans+res;
    return 0;
}


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


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

    long long int mod = 1e9 + 7;
    std::vector<long long int> sums(S);
    sums[0] = 0;
    sums[1] = 0;
    for (int i = 2; i < S; i++) {
        sums[i] = 1;
        for (int j = 0; j <= i - 3; j++) {
            sums[i] = (sums[i] + sums[j]) % mod;
        }
    }
    std::cout << sums[S - 1] << std::endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e6+5;
const long long inf=0x3f3f3f3f;
long long a[maxn],num;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long n;
	cin>>n;
	for(long long i=1;i<=n;i++)
	{
		cin>>a[i];
		num^=a[i];
	}
	for(long long i=1;i<=n;i++)
		cout<<(num^a[i])<<" ";
	return 0;
}




Measured memory_bytes: 5216
d=int(input())
c=list(map(int,input().split()))
c_days=[0]*26
s=[]
ans=0
for i in range(d):
    s.append(list(map(int,input().split())))
for i in range(d):
    n=int(input())-1
    ans+=s[i][n]
    c_days[n]=i+1
    for l in range(26):
        los=c[l]*(i+1-c_days[l])
        ans-=los
    print(ans)

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

int main() {
    long long S = 0;
    int n;
    cin >> n;
    
    long long minValue = 1000000;
    long long maxValue = -1000000;

    int i = 0;

    while ( i < n ){
        long long a;
        cin >> a;
        S += a;
        if ( a < minValue ) minValue = a;
        if ( a > maxValue ) maxValue = a;
        i++;

    }
    cout << minValue << " " << maxValue << " "<< S << endl;

    return 0;
}


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

using namespace std;

const int N = 1e2+7;

int n;
int vis1[10], vis2[10][10], vis3[10][10][10];
string s;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> s;
    for (int i = 0; i < n; ++i) {
        int x = s[i]-'0';
        for (int j = 0; j <= 9; ++j) {
            for (int k = 0; k <= 9; ++k) {
                if (vis2[j][k])
                    vis3[j][k][x] = 1;
            }
            if (vis1[j])
                vis2[j][x] = 1;
        }
        vis1[x] = 1;
    }
    int res = 0;
    for (int i = 0; i <= 9; ++i) {
        for (int j = 0; j <= 9; ++j) {
            for (int k = 0; k <= 9; ++k) {
                if (vis3[i][j][k])
                    ++res;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const ut INF=1LL<<30;
const int SIZE=5+1e5;
VI nums;
int N;

int main(){
	string s;
	cin >> s;
	VI vi;
	REP(i,s.size()){
		vi.PB(s[i]=='S');
		while(vi.size()>=2 && vi[vi.size()-2]==1 && vi[vi.size()-1]==0){
			vi.pop_back();
			vi.pop_back();
		}
	}
	cout << vi.size() << endl;
	 
	return 0;
}

Measured memory_bytes: 2552
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>

using namespace std;

/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
int s;
cin >> s;
int cnt = 1;
while(1){
    if(s==4 || s == 2 || s==1){
        cnt=cnt+3;
        cout << cnt << endl;
        return 0;
    }
    if(s%2==0){
        s /=2;
        cnt += 1;
    }
    else{
        s=3*s+1;
        cnt++;    
    }
}
}

Measured memory_bytes: 256
n=int(input())
a=[int(input()) for i in range(n)]


# 素数判定
# coding:utf8
import random

def is_prime3(q, k=50):
    q = abs(q)
    # 計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range (0,k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True

ans=0
for i in range(n):
    if is_prime3(a[i],50):
        ans+=1

print(ans)


Measured memory_bytes: 8532
#include<iostream>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include<math.h>
#define PI 3.14159265358979323846;
using namespace std;
int main(void){
    long long int n,m,s;
    cin >> n;
    cout << M_PI * n * 2  <<  endl;
} 

Measured memory_bytes: 3784
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main() {
    let l: i32 = read();
    let r: i32 = read();
    let d: i32 = read();
    let mut cnt = 0;
    for i in l..r + 1 {
        if i % d == 0 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2112
#include <stdio.h>
int main(void)
{
	int x, y, z;
	
	scanf("%d %d", &x, &y);
	
	if(x < y){
		z=x;
		x=y;
		y=z;
	}
	
	z=x%y;
	while(z!=0){
		x=y;
		y=z;
		z=x%y;
	}
	
	printf("%d\n", y);
	
	return 0;
}



Measured memory_bytes: 2036
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        print(*a)


Measured memory_bytes: 5980
using System;
using System.Collections.Generic;

class Program {
  static void Main(string[] args) {
    string line = Console.ReadLine();
    string[] elem = line.Split(' ');
    var stack = new Stack<string>();
    foreach (var e in elem) {
      int num;
      if (int.TryParse(e, out num)) {
        stack.Push(e);
      }
      else {
        int right = int.Parse(stack.Pop());
        int left  = int.Parse(stack.Pop());
        if(e == "+") {
          int ans = left + right;
          stack.Push(ans.ToString());
        }
        else if(e == "-") {
          int ans = left - right;
          stack.Push(ans.ToString());
        }
        else if(e == "*") {
          int ans = left * right;
          stack.Push(ans.ToString());
        }
      }
    }
    Console.WriteLine(stack.Pop());
  }
}

Measured memory_bytes: 5936
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s; cin >> s;
  int x = s.size(), y = -1;
  for(int i = 0; i < s.size(); i++) {
    if(s.at(i) == 'A') {
      x = min(x, i);
    } else if(s.at(i) == 'Z') {
      y = max(y, i);
    }
  }
  cout << (y - x + 1) << endl;
}


Measured memory_bytes: 640
def prim(p):
  if p == 2:
    return True
  else:
    flg = False
    count = 0
    for i in range(1, int(p ** 0.5) + 1):
      if p % i == 0:
        count += 1
    if count == 1:
      flg = True
    return flg
N = int(input())
if N == 1:
  print(1)
else:
  p_list = []
  for j in range(2, N + 1):
    if prim(j):
      p_list.append(j)
  l = []
  for p in p_list:
    k = 1
    add = 0
    while N // (p ** k):
      add += N // (p ** k)
      k += 1
    l.append(add + 1)
  ans = 1
  for r in l:
    ans *= r
    ans = ans % (10 ** 9 + 7)
  print(ans)


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

int main(){
    char N[3];
    int count=0;
    cin >> N;
    for(int i=0;i<3;i++){
        if(N[i]=='7'){
            count++;
        }
    }
    if(count==0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

}

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

int x(int i) {
  if (i % 10 != 0) {
    return i / 10 + 1;
  }
  else {
    return i / 10;
  }
}
int y(int i) {
  if (i % 10 != 0) {
    return i % 10;
  }
  else {
    return 10;
  }
}

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  int sum = 10 * (x(a) + x(b) + x(c)+x(d)+x(e))-10;
  int m = min(y(a), min(y(b), min(y(c), min(y(d), y(d)))));
  cout << sum + m <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k)
        cout << s << endl;
    else
        cout << s.substr(0, k) << "..." << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c;
    cin >> a >> b >> c;
    bool flag;
    if((c-a-b)>0){
    flag=4*a*b<(c-a-b)*(c-a-b);
    }else{
        cout << "No" << endl;
        return 0;
    }
    
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

type pair struct {
	a, b int
}

func f(x int) pair {
	s := strconv.Itoa(x)
	return pair{int(s[0] - '0'), int(s[len(s)-1] - '0')}
}

func main() {
	var n int
	fmt.Scan(&n)
	// 計算量的にO(N)をかけても良い
	// N以下の整数A,Bのうち、片方(A)を全列挙し、その先頭と末尾のペアの個数を数えておく
	freq := make(map[pair]int, 0)
	for i := 1; i <= n; i++ {
		freq[f(i)]++
	}
	// この時点で、あり得る全ての(先頭、末尾)のペアがfreqに入っている
	var ans int
	for i := 1; i <= n; i++ {
		p := f(i)                   //
		ans += freq[pair{p.b, p.a}] // 末尾と先頭を入れ替えたものがBとなる。そのようなペアが存在すれば、答えに足しこむ
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3200
#include <stdio.h>

int main(void)
{
    int a, b, c;

    scanf(" %d %d %d", &a, &b, &c);

    if (a > b){
        a ^= b;
        b ^= a;
        a ^= b;
    }
    if (b > c){
        b ^= c;
        c ^= b;
        b ^= c;
    }
    if (a > b){
        a ^= b;
        b ^= a;
        a ^= b;
    }

    printf("%d %d %d\n", a, b, c);

    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	sort(ALL(s));
	sort(ALL(t));
	reverse(ALL(t));
	if (s < t)cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
r = [0] * n
for i in range(n):
    r[a[i]-1] = i+1
for x in r:
    print(str(x) + " ", end="")
print()

Measured memory_bytes: 13876
def main():
    S = input().strip()
    aa = False
    for i in range(len(S)-1):
        if S[i] == "A" and S[i+1] == "A":
            aa = True
            break
    if not aa:
        if "KIH" in S:
            tmp = S.replace("A", "")
            if tmp == "KIHBR":
                print("YES")
                return
    print("NO")
    return



if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <stdlib.h>
#include <stdio.h>
#define P_KEY(i) (i / 2)
#define L_KEY(i) (i * 2)
#define R_KEY(i) (i * 2 + 1)

static void max_heapify(int *bh, int i, int n) {
  int l, r, m, tmp;

  l = L_KEY(i);
  r = R_KEY(i);
  m = i;
  if (l <= n && bh[l] > bh[i]) m = l;
  if (r <= n && bh[r] > bh[m]) m = r;
  if (m != i) {
    tmp = bh[i];
    bh[i] = bh[m];
    bh[m] = tmp;
    max_heapify(bh, m, n);
  }
}

int main(int argc, char **argv) {
  int n, i;
  int *bh;

  scanf("%d", &n);
  bh = (int *) malloc(sizeof(int) * (n + 1));
  for (i = 1; i <= n; ++i) scanf("%d", &bh[i]);
  for (i = n / 2; i > 0; --i) max_heapify(bh, i, n);
  for (i = 1; i <= n; ++i) printf(" %d", bh[i]);
  printf("\n"); free(bh); exit(0);
}


Measured memory_bytes: 3308
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n[28],count[30]={0};
  int p[2],r=0,i,j;
  for(int i=0;i<28;i++){
    cin>>n[i];
  }
  for(int i=1;i<=30;i++){
    for(int j=0;j<28;j++){
	  if(n[j]==i){
	    count[i]++;
	    break;
	  }
    }
    if(count[i]==0){
      p[r]=i;
      r++;
  }
  }
  for(i=0;i<2;i++){
    cout<<p[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
#define MAX 2000000
#define CMAX 10000

int main(){
  int n,a[MAX],c[CMAX],ans[MAX],i;
  int k=0;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a[i];
    if(a[i]>k)k=a[i];
  }
  for(i=0;i<=k;i++)c[i]=0;
  for(i=0;i<n;i++){
    c[a[i]]++;
  }

  for(i=1;i<=k;i++)c[i]=c[i]+c[i-1]; 
  for(i=n-1;i>=0;i--){
    ans[c[a[i]]]=a[i];
    c[a[i]]--;
  }

  for(i=1;i<=n;i++){
    cout<<ans[i];
    if(i!=n)cout<<" ";
    else cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 18728
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000007;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mmax=1000009;

int main(void){
    string s;
    cin>>s;
    int n=s.size();
    int p=0,g=0,ans=0;
    rep(i,n){
        if(p==g){
            g++;
            if(s[i]=='p') ans--;
        }
        else{
            p++;
            if(s[i]=='g') ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3756
# 2019-11-13 01:53:22(JST)
import sys
# import collections
import math 
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, k = [int(x) for x in sys.stdin.readline().split()]
        

    probability = 0
    for i in range(1, n + 1):
        if i < k:
            probability += (1 / n) * (1 / 2) ** math.ceil(math.log2(k / i))
        else:
            probability += 1 / n
    
    print(probability)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest 117：D - XXOR


N, K = [int(i) for i in raw_input().strip().split(' ')]
A = [int(i) for i in raw_input().strip().split(' ')]


def f(x):
    s = 0
    for n in A:
        s += x ^ n
    return s


def main():
    mlist = [0]*40
    for a in A:
        astr = ('0'*40 + bin(a)[2:])[-40:]
        for i in range(40):
            ass = astr[i]
            if ass == '0':
                mlist[i] += 1
    # print mlist
    cand = [0]*40
    for i in range(40):
        if mlist[i] > N/2:
            cand[i] = 1
    # print cand

    kbin = ('0'*40 + bin(K)[2:])[-40:]
    # print kbin
    maxbin = ['0']*40
    for i in range(40):
        if kbin[i] == '0':
            continue
        if cand[i] == 1:
            maxbin[i] = '1'
        else:
            break
    i += 1
    while i < 40:
        maxbin[i] = str(cand[i])
        i += 1
    maxx = int(''.join(maxbin), 2)
    print f(maxx)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12656
#include<stdio.h>
int main(void){
    int A,B;
    scanf("%d %d",&A,&B);
    if((A==2)&&(B==2)){
        printf("Yes");
    }else if(((A==4)||(A==6)||(A==9)||(A==11))&&((B==4)||(B==6)||(B==9)||(B==11))){
        printf("Yes");
    }else if(((A==1)||(A==3)||(A==5)||(A==7)||(A==8)||(A==10)||(A==12))&&((B==1)||(B==3)||(B==5)||(B==7)||(B==8)||(B==10)||(B==12))){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

struct card{
	char suit;
	int value;
};

int main(void)
{
	int n , i , j , minj , count = 0;
	scanf("%d",&n);
	struct card  c[n];
	struct card  b[n];
	struct card  tmp;
	
	for( i = 0; i < n; i++)
	{
		scanf(" %c%d",&c[i].suit,&c[i].value);
		b[i] = c[i];
	}
	for( i = 0; i < n; i++)//Bubblesort
	{
		for( j = n-1; j >= i+1; j--)
		{
			if(c[j].value < c[j-1].value)
			{
				tmp = c[j];
				c[j] = c[j-1];
				c[j-1] = tmp;
			}
		}
	}
	
	
	for(i = 0; i < n; i++)
	{
		if(i != n-1)
		{
			printf("%c%d ",c[i].suit,c[i].value);
		}
			else{printf("%c%d\n",c[i].suit,c[i].value);}
	}
	
	printf("Stable\n");

	for( i = 0; i <= n-1; i++)//SelectionSort
	{
		minj = i;
		for( j = i; j <= n-1; j++)
		{
			if(b[j].value < b[minj].value)
			{
				minj = j;
			}
		}
		tmp = b[i];
		b[i] = b[minj];
		b[minj] = tmp;
	}
	
	for(i = 0; i < n; i++)
	{
		if(i != n-1)
		{
			printf("%c%d ",b[i].suit,b[i].value);
		}
			else{printf("%c%d\n",b[i].suit,b[i].value);}
	}
	
	for( i = 0; i < n; i++)
	{
		if(b[i].suit!=c[i].suit)
		{
			count++;
		}
	}
	
	if(count == 0)printf("Stable\n");
		else{printf("Not stable\n");}
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

const int MAXN = 53;
pair<int, int> one[MAXN], two[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for(int i = 1; i <= n; i++) {
    cin >> one[i].F >> one[i].S;
  }
  for(int i = 1; i <= m; i++) {
    cin >> two[i].F >> two[i].S;
  }
  for(int i = 1; i <= n; i++) {
    int idx = -1, res = 1e9;
    for(int j = 1; j <= m; j++) {
      if(abs(two[j].F - one[i].F) + abs(two[j].S - one[i].S) < res) {
        res = abs(two[j].F - one[i].F) + abs(two[j].S - one[i].S);
        idx = j;
      }
    }
    cout << idx << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
a = []
for i in range(N):
  b = int(input())
  a.append(b)
a.sort()
c = []
for i in range(N-K+1):
  d = int(a[i+K-1]-a[i])
  c.append(d)
c.sort()
print(c[0])

Measured memory_bytes: 11288
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let mut ok: usize = (1 << m) - 1;
    for i in 0..n {
        let k = read::<usize>();
        let mut sum = 0;
        for j in 0..k {
            let v = read::<usize>() - 1;
            sum |= 1 << v;
        }
        ok &= sum;
    }
    println!("{:.8}", ok.count_ones());
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main() {
    long long l, r;
    long long ans = 2019;
    cin >> l >> r;
    for (long long i = l; i < r; i++) {
        for (long long j = i + 1; j <= r; j++) {
            ans = min(ans, (i * j) % 2019);
            if (ans == 0) goto last;
        }
    }
    last:
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 2e9
#define ll long long
#define MINUS(a) memset(a,0xff,sizeof(a))

int main(){
    string s;
    string t;
    cin>>s>>t;

    int ans = 0;
    for(int i=0; i<3; i++){
        if(s[i]==t[i]){
            ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 764
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
LL a[3030];
LL sum;
LL dp[3030][3030];
bool vis[3030][3030];

LL search(int l, int r, bool flg){
    if(vis[l][r])return dp[l][r];
    vis[l][r]  = true;
    auto &res = dp[l][r];

    if(l == r)return res = (flg ? a[l] : 0);

    if(flg)return res = max(a[l] + search(l + 1, r, false), a[r] + search(l, r - 1, false));

    else   return res = min(search(l + 1, r, true), search(l, r - 1, true));

}

int main(){
    cin >> n;
    REP(i, n)cin >> a[i], sum += a[i];
    cout << 2 * search(0, n - 1, true) - sum << endl;
}

Measured memory_bytes: 80384