akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

	int ans = 0;
	rep(i, N - 1) {
		if (S[i] != S[i + 1]) ++ans;
	}
	ans++;

	cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n-1){
        for(int j = 1;j<n;j++){
            string t = s.substr(0,i)+s.substr(j,n-1-j+1);
            if(t=="keyence"){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

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


using ll = long long;

const ll mod = 1e9+7;
int N;
map<int, int> mp; // map[x]: 素数が何個あるか？？？


int main(){
    cin >> N;
    
    // N,N-1,N-2,..について各素数の個数を求める
    for (int i = 2; i <= N; i++){
        
        int x = i; // iの値を変更してはならないから, 別の変数へ値をコピーする
        
         // 素数jの個数を求める
        for (int j = 2; j <= x; j++){
            while (x%j == 0){
                x /= j;
                mp[j]++;
            }
        }
        
    }
    
    
    ll ans = 1;
    
    for (auto x : mp){
        ans = ((ans%mod) * (x.second+1)%mod) % mod;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    S.reserve(1000000);
    cin >> S;
    int Q;
    cin >> Q;
    bool flg = true; //Tなら文字の先頭がはじめ.
    string ans = S;
    string mae="",ato="";
    mae.reserve(200005);
    ato.reserve(200005);
    int q;
    int f;
    string c;
    rep(i,Q){
        cin >> q;
        if(q==1){
            flg = !flg;
        }else{
            cin >> f;
            cin >> c;
            if(f==1){
                if(flg){
                    mae+=c;
                }else{
                    ato+=c;
                }
            }else{
                if(flg){
                    ato+=c;
                }else{
                    mae+=c;
                }
            }
        }
    }
    if(flg){
        ans+=ato;
        reverse(mae.begin(),mae.end());
        ans = mae+ans;
        cout << ans << endl;
        return 0;
    }
    ans += ato;
    reverse(ans.begin(),ans.end());
    ans+=mae;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1220
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
#define N 4005
#define INF 0x3f3f3f3f
#define MOD 924844033
int n,k;
bool vis[N][2],ed[N];
int tot;
int d[N][N][2],f[N],fac[N];
int rd()
{
	int f=1,x=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48); c=getchar();}
	return f*x;
}
int main()
{
	n=rd(),k=rd();
	for(int i=1;i<=n;i++)
		for(int j=0;j<=1;j++)
			if(!vis[i][j])
			{
				int len=0;
				for(int x=i,y=j;x<=n;x+=k,y^=1)
				{
					vis[x][y]=1;
					len++;
				}
				tot+=len;
				ed[tot]=1;
			 }
	ed[0]=1;
	d[0][0][0]=1;
	for(int i=0;i<2*n;i++)
		for(int j=0;j<=n;j++)
		{
			d[i+1][j][0]=(d[i][j][0]+d[i][j][1])%MOD;
			if(!ed[i])
				d[i+1][j+1][1]=d[i][j][0];
		}
	for(int i=0;i<=n;i++)
		f[i]=(d[2*n][i][0]+d[2*n][i][1])%MOD;
	fac[0]=1;
    for(int i=1;i<=n;i++)
        fac[i]=1ll*fac[i-1]*i%MOD;
    int ans=0;
    for(int i=0,j=1;i<=n;i++,j=-j)
        ans=((1ll*ans+1ll*j*fac[n-i]*f[i]%MOD)%MOD+MOD)%MOD;
    printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 124544
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int poi[200005][33];
int shigu[200005];

int main(){
    int N,C;
    cin >> N >> C;
    rep(i,N){
        int s,t,c;
        cin >> s >> t >> c;
        c--;
        s *= 2;
        t *= 2;
        poi[s-1][c]++;
        poi[t][c]--;
    }
    for(int i=0;i<200004;i++) rep(j,33) poi[i+1][j] += poi[i][j];
    for(int i=0;i<200005;i++){
        for(int j=0;j<33;j++){
            if(poi[i][j]>0) shigu[i]++;
        }
    }
    int mx = 0;
    rep(i,200005) mx = max(mx,shigu[i]);
    cout << mx << endl;
}


Measured memory_bytes: 26752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A.Pair
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            int Odd = 0;
            int Even = 0;
            int ans = 0;

            for (int i = 1; i <= K; i++)
            {
                if (i % 2 == 1)
                    Odd++;
                else
                    Even++;
            }

            ans = Odd * Even;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
N, M = map(int, input().split())
ans = 0
L_list = []
R_list = []

for _ in range(M):
    l, r = map(int, input().split())
    L_list.append(l)
    R_list.append(r)

L = max(L_list)
R = min(R_list)

for i in range(1, N+1):
    if L <= i <= R:
        ans += 1

print(ans)

Measured memory_bytes: 10996
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-7;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

double E() {
  int m;
  scanf("%*d %d", &m);
  double all = 0.0;
  double sum = 0.0;
  REP(i, m) {
    double v, p;
    scanf("%lf %lf", &v, &p);
    sum += v * p;
    all += p;
  }
  sum /= all;
  return sum;
}

int main() {
  int n;
  while (scanf("%d", &n) > 0) {
    double player = 0.0;
    REP(i, n) {
      double e = E();
      player = max(player, e);
    }
    double enemy = E();
    puts(player - enemy > EPS ? "YES" : "NO");
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

struct Node{
    string name;
    map<string,Node*> msn;
    Node *par;
    int num;
    Node(){
        num=0;
    }
};

int idx;


void parse(string s,Node *node){
    string name;
    string left;
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='/'){
            name=s.substr(0,i);
            left=s.substr(i+1);
            break;
        }
        else if(i==s.size()-1){
            name=s;
            break;
        }
    }
    if(node->msn.find(name)==node->msn.end()){
        Node *nd = new Node();
        nd->name=name;
        nd->par=node;
        node->msn[name]=nd;
        // t@CÉÍidðÂ¯Ä¯Ê
        if(left==""){
            //if(idx==3){
            //    cout<<endl;
            //}
            nd->num=idx++;
        }
    }
    // Ü¾¶ªcÁÄ¢êÎAÄA
    if(left!="")
        parse(left,node->msn[name]);
}

// ßêéæ¤Éem[hÖÌQÆàÁÄ¨­
int search(Node *node,string path){
    if(node==NULL)return 0;
    // t@CÌêÜÅB
    if(node->num!=0)
        return node->num;
    // ±±ÅpXªóÉÈÁ½
    if(path==""){
        // indexªºÉ é©Å»f
        if(node->msn.find("index.html")==node->msn.end())
            return 0;
        return node->msn["index.html"]->num;
    }
    string name;
    string left;
    bool isFile=false;
    for(int i = 0; i < path.size(); i++){
        if(path[i]=='/'){
            name=path.substr(0,i);
            left=path.substr(i+1);
            break;
        }
        else if(i==path.size()-1){
            isFile=true;
            name=path;
            break;
        }
    }
    if(!isFile&&node->msn.find(name)!=node->msn.end()&&node->msn[name]->num!=0){
        return 0;
    }

    // ÅºwÌfBNg é¢Ít@Cð¦·
    if(name=="..")
        return search(node->par,left);
    else if(name==".")
        return search(node,left);
    // ÄA
    if(node->msn.find(name)==node->msn.end())
        return 0;
    return search(node->msn[name],left);
}

int main(){

    int n,m;
    while(cin>>n>>m&&!(n==0&&m==0)){
        idx=1;
        Node *root = new Node();
        root->name+='/';
        root->par=NULL;
        for(int i = 0; i < n; i++){
            string s;
            cin>>s;
            parse(s.substr(1),root);
        }
        for(int i = 0; i < m; i++){
            string s1,s2;
            cin>>s1>>s2;
            int res1=search(root,s1.substr(1));
            int res2=search(root,s2.substr(1));
            if(res1==0||res2==0)cout<<"not found"<<endl;
            else if(res1==res2)cout<<"yes"<<endl;
            else cout<<"no"<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int64_t times(int64_t x, int64_t n) {
	int64_t output = 1;
	for (int64_t i = 0; i < n; i++) {
		output *= x;
	}
	return output;
}

int main() {
	//input
	int64_t X;
	cin >> X;

	vector<int64_t> baisuu(0);
	for (int64_t i = 1; i <= X; i++) {
		if (X % i == 0) {
			baisuu.push_back(i);
			for (int64_t A = 0; A <= 1000; A++) {
				int64_t B = A - i;
				if (times(A, 5) - times(B, 5) == X) {
					cout << A << " " << B << endl;
					return 0;
				}
			}
		}
	}


	int64_t min = 1000;
	int64_t max = 100000;
	while (true) {
		for (int64_t i = 0; i < baisuu.size(); i++) {
			for (int64_t A = min; A <= max; A++) {
				int64_t B = A - baisuu[i];
				if (times(A, 5) - times(B, 5) == X) {
					cout << A << " " << B << endl;
					return 0;
				}
			}
		}
		min = max;
		max *= 100;
	}

	//output
	cout << -99999 << endl;
	return 0;
}


Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main(){
  int A,min=1,j=0;
  cin>>A;
  int B[A],C[A];
  for(int i=0;i<A;i++){
  cin>>B[i];
  C[B[i]-1]=i+1;
  }
  for(int j=0;j<A;j++){
    cout<<C[j]<<" ";
  }
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<set<int>> nbs(n);
    rep(i,n-1) {
        int tmpa,tmpb;cin>>tmpa>>tmpb;
        tmpa--;tmpb--;
        nbs[tmpa].insert(tmpb);
        nbs[tmpb].insert(tmpa);
    }
    if(n==1){
        cout << "First" << endl;
        return 0;
    }
    function<pair<int,int>(int, int)> rec = [&] (int par, int now) {
        if(nbs[now].size()==1 && par != now) {return make_pair(0, now);}
        pair<int,int> res(-1,0);
        for(auto x: nbs[now]) {
            if(x == par) {continue;}
            auto tmp = rec(now, x);
            if(res.first < tmp.first) {
                res.first = tmp.first;
                res.second = tmp.second;
            }
        }
        res.first++;
        return res;
    };
    auto tmp = rec(0,0);
    DEBUG{
        printf("rec1 d:%d, cur:%d\n", tmp.first, tmp.second);
    }
    tmp = rec(tmp.second, tmp.second);
    DEBUG{
        printf("rec2 d:%d, cur:%d\n", tmp.first, tmp.second);
    }
    cout << (tmp.first %3 == 1 ? "Second" : "First") << endl;
    return 0;
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
long long int N, M; 
long long int A[114514] = {0}; 
long long int S[114514] = {0}; 
cin >> N >> M; 
for(int i = 1; i <= N; i++){
cin >> A[i]; 
S[i] = (S[i-1] + A[i]) % M; 
}
sort(S, S + (N + 1), greater<long long int>());

long long int ans = 0; 
long long int T[114514] = {0}; 
int type = 0; 
T[0] = 1; 
for(int i=1 ; i <=N ;i++){
if(S[i] != S[i-1]) {type ++; 
}
T[type] ++; 
}
for(int i=0 ; i < 114514 ;i++){
ans += T[i] * (T[i] - 1)/2; 
}
cout << ans << endl; 
}

Measured memory_bytes: 2944
n = int(input())
c = [-1,-1,-1]
a = 1
for i in map(int,input().split()):
  co = c.count(i-1)
  if co == 0:
    print(0)
    exit()
  a = a * co % 1000000007
  c[c.index(i-1)] = i
print(a)

Measured memory_bytes: 50544
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second

using namespace std;
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    ll num[n][n];

    fr(i, 0, n){
        ll nu = 0;
        fr(j, i, n){
            nu = nu * 10 + (int)(s[j] - '0');
            num[i][j] = nu;
        }
    }


    ll dp[n + 1];
    memset(dp, 0, sizeof(dp));

    ll cnt[n + 1];

    memset(cnt, 0, sizeof(cnt));

    cnt[0] = 1;

    ll ans = 0;
    fr(i, 1, n + 1){
        fr(j, 1, i + 1){
            dp[i] += dp[j - 1] + cnt[j - 1] * num[j - 1][i - 1];
            cnt[i] += cnt[j - 1];
        }
        ans += dp[i];

    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
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 str;
	int n, s, w, sum=0;
	while(cin >> n, n) {
		vector<pair<int, pair<int, string> > > v;
		rep(i,n) {
			cin >> str >> w >> s;
			v.push_back(make_pair(w, make_pair(s, str)));
			sum += w;
		}
		sort(v.begin(), v.end());
		vector<string> ret;
		while(!v.empty()) {
			for(int i = v.size()-1; i>=0; --i) {
				if(sum - v[i].first <= v[i].second.first) {
					ret.push_back(v[i].second.second);
					cout << v[i].second.second << endl;
					sum -= v[i].first;
					v.erase(v.begin() + i);
					break;
				}
			}
		}
	}
    return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define NIL -1
#define MAX 500000
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int n;
int root;
int *p = new int[MAX];       //    p---|  Unit
int *left2 = new  int[MAX]; // left2 --|--------> T
int *right2 = new int[MAX]; //right2---|
int *key = new int[MAX];     // key----|
   
void Init(){
  rep(i,MAX){
    p[i]=left2[i]=right2[i]=key[i]=NIL;
  }
}
   
bool SEARCH(int x,int k){
  if(k == key[x])return true;
  if(x == NIL)return false;
  if(k < key[x])return SEARCH(left2[x],k);
  else return SEARCH(right2[x],k);
}
  
   
void TREE_INSERT(int z){
  int y = NIL;
  int x = root;
   
  while(x != NIL){
    y = x;
    if(key[z] < key[x]){
      x = left2[x];
    }
    else x = right2[x];
  }
  p[z]=y;
  if(y == NIL){
    root = z;
  }
  else if(key[z] < key[y]){
    left2[y] = z;
  }else{
    right2[y] = z;
  }
   
}
   
void InorderTreeWalk(int x){
  if(x != NIL){
    InorderTreeWalk(left2[x]);
    printf(" %d",key[x]);
    InorderTreeWalk(right2[x]);
  }
}
   
void PreorderTreeWalk(int x){
  if(x != NIL){
    printf(" %d",key[x]);
    PreorderTreeWalk(left2[x]);
    PreorderTreeWalk(right2[x]);
  }
}
   
   
int main(){
  int val;
  string op;
  long long zr;                   
   
   
  scanf("%d",&n);
  Init();
  root = -1;
  zr=0;
  while(n-- > 0){
    cin >> op;
    if(op == "insert"){
      scanf("%d",&val);
      key[zr]=val;       
      TREE_INSERT(zr);
      zr++;
    }else if(op == "print"){
      InorderTreeWalk(root);
      printf("\n");
      PreorderTreeWalk(root);
      printf("\n");
    }
    else if(op == "find"){
      scanf("%d",&val);
      if(SEARCH(root,val)){
    printf("yes\n");
      }else{
    printf("no\n");
      }
         
   
    }
  }
   
  delete [] p;
  delete [] left2;
  delete [] right2;
  delete [] key;
  
  return 0;
}



Measured memory_bytes: 10736
N=int(input())
m=[]
for A in range(1,N):
  s=0
  B=N-A
  a="".join(str(A))
  b="".join(str(B))
  for x in range(0,len(a)):
    s+=int(a[x])
  for y in range(0,len(b)):
    s+=int(b[y])
  m.append(s)
print(min(m))

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define pll pair<ll,ll>
#define pii pair<int32_t,int32_t>
#define loop(i,n) for(int64_t i=0; i<n; i++)
#define loop1(i,a,b) for(int64_t i=a; i<=b; i++)
#define rloop(i,n) for(int64_t i=n-1; i>=0; i--) 
#define rloop1(i,a,b) for(int64_t i=a; i>=b; i--) 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define print(val) cout << #val << ": " << val << "\n";
#define print_c(a) cout<<#a<<": ";for(auto it=begin(a);it!=end(a);it++)cout<<*it<<" ";cout<<"\n";
#define fill(c,v) fill(begin(c),end(c),v);
template <typename T> T flip(T val) {reverse(begin(val),end(val)); return val;}

int main() {
  fast_io
  ll t=1; 
  while(t--) {
    int x; cin >> x; int n; cin >> n;
    map<int,int> mp;
    loop(i,n) {
      int temp; cin >> temp;
      mp[temp]++;
    }
    vector<int> vec; 
    loop1(i,0,101) {
      if(mp[i]==0) vec.push_back(i);
    }
    auto it2 = lower_bound(vec.begin(),vec.end(),x);
    int ans;
    auto it1 = --it2; it2++;
    if((x - *it1) <= (*it2 - x)) {
      ans = *it1;
    }
    else ans = *it2;
    cout << ans;
  }
}

Measured memory_bytes: 3612
import java.util.Scanner;

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

    int aPos = sc.nextInt();
    int aSpeed = sc.nextInt();
    int bPos = sc.nextInt();
    int bSpeed = sc.nextInt();
    int time = sc.nextInt();

    int diffSpeed = aSpeed - bSpeed; //if +, a is faster; if -, b is faster
    double diffPos = Math.abs( aPos - bPos );

    if( diffSpeed <= 0 ){ //if same speed or b is faster
      System.out.println("NO");
    }else{ //if a is faster
      if( (diffPos / time) <= diffSpeed ){ //if change in difference is greater than or equal to intial difference
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
    }

  }
}


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

int f(int x){
	return (x*x);
}

int main(){
	int d,s;

	while( cin >> d ){
		s = 0;
		for(int i=1 ; (d*i)<=(600-d) ; i++){
			s += f(d*i)*d;
		}
		cout << s << endl;
	}
}


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

int main(void) {
    int n;
    cin >> n;
    set<int> num;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (num.find(a) == num.end()) num.insert(a);
        else num.erase(a);
    }
    cout << num.size() << endl;
}


Measured memory_bytes: 4864
if __name__ == "__main__":
	S = input()
	if S == "SUN":
		print(7)
	elif S  == "MON":
		print(6)
	elif S == "TUE":
		print(5)
	elif S == "WED":
		print(4)
	elif S == "THU":
		print(3)
	elif S == "FRI":
		print(2)
	else:
		print(1)

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

bool isPrimeNumber(int value)
{
    if(value < 2 || 100000000 < value)      //2 <= value <= 10^8
    {
        return false;       // Invalid Value
    }
    else
    {
        if(value == 2)
        {
            return true;
        }
        
        if((value % 2) == 0)
        {
            return false;
        }
        
        for(int i = 3; i <= sqrt(value); i = (i + 2))
        {
            if((value % i) == 0)
            {
                return false;
            }
        }
    }
    return true;
}

int main(void)
{
    int number, value, count = 0;

    cin >> number;
	for(int i = 0; i < number; i++)
	{
		cin >> value;		// input
		if(isPrimeNumber(value) == true)
		{
		    count++;
		}
	}
	cout << count << endl;
	return 0;
}

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

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

  int N; cin >> N;

  string s; cin >> s;
  vector<set<int>> S(26);
  rep(i, N) {
    S[s[i] - 'a'].insert(i);
  }

  int Q; cin >> Q;

  rep(qi, Q) {
    int t; cin >> t;
    if(t == 1) {
      int l; cin >> l;
      char r; cin >> r;
      l--;

      S[s[l] - 'a'].erase(l);
      s[l] = r;
      S[r - 'a'].insert(l);
    } else {
      int l,r; cin >> l >> r;
      l--; r--;

      int ans = 0;
      rep(i, 26) {
        auto it = S[i].lower_bound(l);
        if(it == S[i].end()) continue;
        if(*it <= r) ans++;
      }

      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 24220
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<int,ll>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};

int main() {

	int k;
	cin>>k;
	string s;
	cin>>s;
	if(s.size()<=k)cout<<s<<endl;
	else{
		rep(i,k)cout<<s[i];
		cout<<"..."<<endl;
	}

	return 0;
}


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

using namespace std;
const int N=20;
const int INF=1e9+7;
struct stu{
	int weight;
	int A[20];
}arr[20];
int n,m,x;
int now[N];
int check(vector<int>a){
	int sum=0;
	memset(now,0,sizeof now);
	int pos= a.size(); 
	for(int i=0;i<pos;i++){
		sum+=arr[a[i]].weight;
		for(int j=1;j<=m;j++) now[j]+=arr[a[i]].A[j];
	}
	bool flag=0;
	for(int i=1;i<=m;i++){
		if(now[i]<x) {
			flag=1;
			break;
		}
	}
	if(flag) sum=INF;
	return sum;
}
int main(){ 
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>arr[i].weight;
		for(int j=1;j<=m;j++) cin>>arr[i].A[j];
	}
	vector<int>ve;
	int ans=INF;
	
	for(int i = 0; i < (1<<n); i++) {
        for(int j = 0; j < n; j++)
            if(i & (1 << j))
            	ve.push_back(j);
        ans=min(check(ve),ans);
        ve.clear(); 
    }
    if(ans==INF) cout<<-1<<endl;
	else cout<<ans<<endl; 
	return 0;
} 

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

using ll = long long int;

const int MAX_H = (int)(1e2 + 5);
const int MAX_W = (int)(1e1 + 5);
const ll MOD = (int)(1e9 + 7);

int h, w, k;

ll dp[MAX_H][MAX_W];
ll cf[MAX_H][MAX_W][3];

int main(void) {
    // Here your code !
    scanf("%d %d %d\n", &h, &w, &k);

    if (w == 1) {
      printf("%lld\n", 1);
      return 0;
    }

    for (int i = 0; i < h; ++i) {
      for (int bit = 0; bit < (1 << w - 1); ++bit) {
        if ((bit & (bit << 1)) != 0) continue;

        if (bit & (1 << 1 - 1)) {
          cf[i][1][2] += 1;
        }
        else cf[i][1][1] += 1;

        for (int j = 2; j <= w - 1; ++j) {
          if (bit & (1 << j - 1)) {
            cf[i][j][2] += 1;
          }
          else if (bit & (1 << j - 1 - 1)) {
            cf[i][j][0] += 1;
          }
          else cf[i][j][1] += 1;
        }

        if (bit & (1 << w - 1 - 1)) {
          cf[i][w][0] += 1;
        }
        else cf[i][w][1] += 1;
      }
    }

    dp[0][1] = 1;

    for (int i = 0; i < h; ++i) {
      dp[i + 1][1 + 1] += (cf[i][1][2] * dp[i][1]) % MOD;
      dp[i + 1][1 + 1] %= MOD;
      dp[i + 1][1 + 0] += (cf[i][1][1] * dp[i][1]) % MOD;
      dp[i + 1][1 + 0] %= MOD;

      for (int j = 2; j <= w - 1; ++j) {
        dp[i + 1][j + 1] += (cf[i][j][2] * dp[i][j]) % MOD;
        dp[i + 1][j + 0] += (cf[i][j][1] * dp[i][j]) % MOD;
        dp[i + 1][j + -1] += (cf[i][j][0] * dp[i][j]) % MOD;

        dp[i + 1][j + 1] %= MOD;
        dp[i + 1][j + 0] %= MOD;
        dp[i + 1][j + -1] %= MOD;
      }

      dp[i + 1][w + 0] += (cf[i][w][1] * dp[i][w]) % MOD;
      dp[i + 1][w + 0] %= MOD;
      dp[i + 1][w + -1] += (cf[i][w][0] * dp[i][w]) % MOD;
      dp[i + 1][w + -1] %= MOD;
    }

    /*
    for (int i = 1; i <= w; ++i) {
      printf("%lld\n", dp[h][i]);
    }
    */
    printf("%lld\n", dp[h][k]);

    return 0;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
if x==1 or x==2*n-1:
  print("No")
else:
  print("Yes")
  if x>n:
    for i in range(1,x-n+1):
      print(i)
    for i in range(3*n-x-1):
      print(2*n-1-i)
  elif x==n:
    for i in range(1,2*n):
      print(i)
  else:
    for i in range(n-x):
      print(2*n-1-i)
    for i in range(n+x-1):
      print(i+1)

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

using namespace std;

int main(void)
{
	long long a,b,x; cin>>a>>b>>x;
	long long c = b / x;
	long long d = a / x;
	if(a%x == 0) c++;
	cout<<c-d<<endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define INT_MAX (1<<31) - 1

using namespace std;
typedef long long ll;

const int MAX_N = 1 << 17;

class LazySegTree{
private:
    ll dat[2*MAX_N - 1];
    ll lazy[2*MAX_N - 1];
public:
    int n;
    LazySegTree(int n);
    void add(int a, int b, int k, int l, int r, int x);
    ll sum(int a, int b, int k, int l, int r);
};

LazySegTree::LazySegTree(int n_){
    n = 1;
    // 葉の数 n を2のべき乗にする
    while(n < n_) n *= 2;
    for(int i=0; i<2*n-1; i++){
        dat[i] = 0;
        lazy[i] = 0;
    }
}

// 配列arrの[a, b)の値にxを加算
void LazySegTree::add(int a, int b, int k, int l, int r, int x){
    if (a <= l && r <= b){
        // 一様に加算する区間
        lazy[k] += x;
    }else if (l < b && a < r){
        // 一様に加算されない区間
        // min(b, r) - max(a, l) : 重なっている区間の数
        dat[k] += (min(b, r) - max(a, l)) * x;
        //
        add(a, b, 2*k+1, l, (l+r)/2, x);
        add(a, b, 2*k+2, (l+r)/2, r, x);
    }
}

// [a, b) の和を求める
ll LazySegTree::sum(int a, int b, int k, int l, int r){
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b){
        // 一様に計算できる区間
        return dat[k] + lazy[k] * (min(b, r) - max(a, l));
    }else{
        // 一様に計算できない区間
        // min(b, r) - max(a, l) : 重なっている区間の数
        ll res = lazy[k] * (min(b, r) - max(a, l));
        // vl:左の子の和, vr:右の子の和 をそれぞれ再帰的に求める
        ll sum_l = sum(a, b, 2*k+1, l, (l+r)/2);
        ll sum_r = sum(a, b, 2*k+2, (l+r)/2, r);
        res += sum_l + sum_r;
        return res;
    }
}

int main(){
    int n, q; cin >> n >> q;
    LazySegTree lst(n);
    for(int i=0; i<q; i++){
        int com; cin >> com;
        if (com == 0){
            int s, t, x; cin >> s >> t >> x;
            lst.add(s-1, t, 0, 0, lst.n, x);
        }else{
            int s, t; cin >> s >> t;
            cout << lst.sum(s-1, t, 0, 0, lst.n) << endl;
        }
    }
}



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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  if(a+1==b){
    cout << "Borys" << endl;
  }
  
  for(int i=0; i<103; i++){
    a++;
    if(a+1==b){
      cout << "Alice" << endl;
    }
    b--;
    if(b-1==a){
      cout << "Borys" << endl;
    }
  }
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[7][7];
char b[7][7];
int n,m,x,y,k;

void swap_matrix()
{

    for(x=0;x<n;x++)
    {

        for(y=0;y<m;y++)
        {
            b[x][y]=a[x][y];
        }
    }
 return;
}
void Anika_colour(int i,int j)
{

    for(x=0;x<n;x++)
    {
        if(i & (1<<x))
        {
          // cout<<"C"<<endl;
            for(y=0;y<m;y++)
            {
                b[x][y]='$';
            }
        }
    }
    for(x=0;x<m;x++)
    {
        if(j & (1<<x))
        {
           // cout<<"p"<<endl;
            for(y=0;y<n;y++)
            {
                b[y][x]='$';
            }
        }
    }
    return;

}
bool is_it_fine()
{
   int d=0;
    for(x=0;x<n;x++)
    {
       // cout<<"l"<<endl;
        for(y=0;y<m;y++)
        {
            if(b[x][y]=='#')
                d++;
        }
    }
    if(d==k)
        return true;
    else
        return false;
}
int main()
{
    int i,j,l,p,s;
    cin>>n>>m>>k;
    int t=0;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    for(i=0;i<(1<<n);i++)
    {
        for(j=0;j<(1<<m);j++)
        {
            swap_matrix();
            Anika_colour(i,j);
            if(is_it_fine())
            {
               // cout<<"x"<<endl;
                t++;
            }
        }
    }
    cout<<t<<endl;
}


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

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    boolean approved = true;
    for (int i = 0; i < n; i++) {
      int a = Integer.parseInt(sc.next());
      approved = approved && isApproved(a);
      if (!approved) {
        break;
      }
    }
    pw.println(approved ? "APPROVED" : "DENIED");
  }

  static boolean isApproved(int a) {
    if (a % 2 == 1) {
      return true;
    }
    return a % 3 == 0 || a % 5 == 0;
  }
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

char buf[256];

int main() {
    memset(buf,0,sizeof(buf));
    scanf("%s",buf);
    buf[5]=buf[13]=' ';
    printf("%s\n",buf);
}

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

using namespace std;

const int MAX_D = 80 * 80 * 2;

int main()
{
	int H, W;
	cin >> H >> W;

	vector<vector<int>> A(H, vector<int>(W));
	vector<vector<int>> B(H, vector<int>(W));

	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> B[i][j];
		}
	}

	vector<vector<int>> S(W, vector<int>(MAX_D, 0));
	vector<vector<int>> T(W, vector<int>(MAX_D, 0));

	S[0][abs(A[0][0] - B[0][0])] = 1;
	
	for (int j = 1; j < W; ++j) {
		for (int k = 0; k < MAX_D; ++k) {
			if (S[j - 1][k]) {
				int d = abs(A[0][j] - B[0][j]);
				S[j][abs(k + d)] = 1;
				S[j][abs(k - d)] = 1;
			}
		}
	}

	for (int i = 1; i < H; ++i) {
		for (int k = 0; k < MAX_D; ++k) {
			if (S[0][k]) {
				int d = abs(A[i][0] - B[i][0]);
				T[0][abs(k + d)] = 1;
				T[0][abs(k - d)] = 1;
			}
		}
		for (int j = 1; j < W; ++j) {
			int d = abs(A[i][j] - B[i][j]);
			for (int k = 0; k < MAX_D; ++k) {
				if (T[j - 1][k]) {
					T[j][abs(k + d)] = 1;
					T[j][abs(k - d)] = 1;
				}
			}
			for (int k = 0; k < MAX_D; ++k) {
				if (S[j][k]) {
					T[j][abs(k + d)] = 1;
					T[j][abs(k - d)] = 1;
				}
			}
		}
		for (int j = 0; j < W; ++j) {
			S[j] = move(T[j]);
			T[j].clear();
			T[j].resize(MAX_D, 0);
		}
	}
	int ans = 1 << 30;
	for (int k = 0; k < MAX_D; ++k) {
		if (S[W - 1][k]) {
			ans = min(ans, k);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 8320
var
i,j,c,d,e,b,n,a:longint;
s,s1,s2,s3:string;
begin
readln(a,b);
readln(s);
if s[a+1]<>'-' then begin writeln('No');exit;end;
for i:=1 to length(s) do
if not(s[i] in ['0'..'9']) then inc(e);
if e>=2 then writeln('No')
else
writeln('Yes');
end.


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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
	ll n;
	cin>>n;
	Array w(n),s(n),v(n);
	REP(i,n) cin>>w[i]>>s[i]>>v[i];
	Array o(n);
	REP(i,n) o[i]=i;
	sort(all(o),[&](ll i,ll j){
		return min(s[i]-w[j],s[j]) > min(s[j]-w[i],s[i]);
	});

	ll sn=20101;
	Matrix dp(n+1,Array(sn,-1));
	dp[0][sn-1]=0;
	REP(i,n){
		REP(j,sn){
			if(dp[i][j]==-1) continue;
			ll next = min(j-w[o[i]],s[o[i]]);
			if(next>=0) chmax(dp[i+1][next],dp[i][j]+v[o[i]]);//のっける
			chmax(dp[i+1][j],dp[i][j]);//のっけない
		}
	}

	ll ans=0;
	REP(i,sn) chmax(ans,dp[n][i]);
	cout<<ans<<en;
}

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

    solve();
    return 0;
}


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

int main()
{
  int N;
  cin>>N;
  int a[N+1];
  for(int i=1; i<=N; i++) cin>>a[i];

  int answ = 0;

  for(int i=1; i<=N; i++)
   if(i == a[a[i]])
    answ++;

  cout<<answ/2;
  return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <math.h>
#include <string.h>

#define N	(600000)

char isPrime[N];

int makePrime(void)
{
	int i, j;
	int lim;

	memset(isPrime, 0, sizeof(isPrime));

	lim = sqrt(N);
	for (i = 2; i < lim; i++){
		for (j = i * i; j < N; j += i){
			isPrime[j] = 1;
		}
	}
	return (0);
}

int main(void)
{
	int q;
	int i;

	makePrime();
	while (~scanf("%d", &q)){
		for (i = -1; isPrime[q + i]; i--);
		printf("%d ", q + i);
		for (i = 1; isPrime[q + i]; i++);
		printf("%d\n", q + i);
	}
	return (0);
}

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

int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<"\n";
    return 0;
}



Measured memory_bytes: 3176
from collections import deque

N, M = map(int, input().split())
v = [[] for _ in range(N)]
for _ in range(M) :
    A, B = map(int, input().split())
    v[A-1].append(B-1)

def bfs(i) :
    dist = [float('inf')] * N
    pre = [-1] * N
    
    queue = deque([(i, 0)])
    while queue :
        cur, cost = queue.popleft()
        if dist[cur] < cost :
            continue
        for nex in v[cur] :                
            if cost + 1 < dist[nex] :
                dist[nex] = cost + 1
                pre[nex] = cur
                queue.append((nex, cost + 1))
    
    return dist[i], pre

mi = -1
mv = float('inf')
mp = []
for i in range(N) :
    m, pre = bfs(i)
    if m < mv :
        mi, mv, mp = i, m, pre

if mi >= 0 :
    print(mv)
    cur = mi
    while mp[cur] != mi :
        print(cur + 1)
        cur = mp[cur]
    print(cur + 1)
else :
    print(-1)

Measured memory_bytes: 51176
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto data = readln.split;
	auto N = data[0].to!long, M = data[1].to!long;
	Tuple!(long, long)[] AB;
	foreach (i; 0 .. N) {
		data = readln.split;
		
		AB ~= tuple(data[0].to!long, data[1].to!long);
	}
	AB = AB.sort!((a,b) => a[0] < b[0]).array;
	long ans, num;
	foreach (i; 0 .. N) {
		if (num + AB[i][1] < M) { ans += AB[i][0]*AB[i][1]; num += AB[i][1]; }
		else { ans += (M-num)*AB[i][0]; break; }
	}
	writeln(ans);
	
}

Measured memory_bytes: 5116
#include<iostream>
#include<cstdio>
 
using namespace std;
 
int n,x[101],minn=100000,maxn=-1,cnt;
 
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",x+i);
        maxn=max(maxn,x[i]);
        minn=min(minn,x[i]);
    }
    if(minn!=(maxn+1)/2){
        puts("Impossible");
        return 0;
    }
    cnt=0;
    for(int i=1;i<=n;++i)if(x[i]==minn)++cnt;
    if(cnt>1+(maxn&1)){
        puts("Impossible");
        return 0;
    }
    for(int i=minn+1;i<=maxn;++i){
        cnt=0;
        for(int j=1;j<=n;++j)if(x[j]==i)++cnt;
        if((i==minn&&cnt>1)||(i!=minn&&cnt<2)){
            puts("Impossible");
            return 0;
        }
    }
    puts("Possible");
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b;
	cin >> a >>b;
	
	if(a > b){
		cout << a-1 <<"\n";
	}else cout << a <<"\n";
	
	return 0;
}


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

typedef long long ll;
typedef long double lg;
using namespace std;

int main(){

 long long h;
 cin>>h;

 long long cnt=0;

 while(h>1){
    h /=2;
    cnt++;
 }

 long long ans=0,now=1;

 for(int i=0;i<cnt+1;i++){
    ans += now;
    now *= 2;
 }

 cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

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

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

    ll n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    ll sum[n + 1];
    sum[0] = 0;
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + (i >= 2 && s[i - 2] == 'A' && s[i - 1] == 'C');
    }

    rep(i, q) {
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l] << endl;
    }

    return 0;
}


Measured memory_bytes: 1872
loop do
    a, l = gets.split.map(&:to_i)
    break if a == 0 && l == 0
    i = 0
    hash = {a => 0}
    loop do
        i += 1
        ary = sprintf("%0#{l}d", a).split("").sort
        a = ary.reverse.join.to_i - ary.join.to_i
        if j = hash[a]
            puts [j, a, i - j] * ' '
            break
        end
        hash[a] = i
    end
end

Measured memory_bytes: 9596
n, k = map(int, input().split())
s = input()
cnt = 0
if s[0] == "0":
	cnt += 1
for i in range(1, n):
	if s[i-1] == "1" and s[i] == "0":
		cnt += 1
if cnt <= k:
	print(n)
else:

	one_left, one_right = [], []
	#if s[0] == "1":
	one_left.append(0)
	for i in range(1, n):
		if s[i-1] == "0" and s[i] == "1":
			one_left.append(i)
		if s[i-1] == "1" and s[i] == "0":
			one_right.append(i)
	#if s[-1] == "1":
	one_right.append(n)
	if s[0] == "1":
		one_right.pop(0)
	if s[-1] == "1":
		one_left.pop(-1)
	#print(one_left)
	#print(one_right)
	ans = 0
	for i in range(min(len(one_left), len(one_right)-k+1)):
		ans = max(ans, one_right[i+k-1] - one_left[i])
	print(ans)

Measured memory_bytes: 7208
N = int( input() )

def make_divisors( n ) :
   res = []
   for i in range(1, int(n**0.5)+1) :
       if n%i == 0 :
          res.append(i)
          res.append(int(n/i))
   return res

divs = make_divisors( N )
#print(divs)
#print( max( divs[len(divs)-1],divs[len(divs)-2] ) )
print( len( str( max( divs[len(divs)-1],divs[len(divs)-2] ) ) ) )

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	long long a,b,x;
	cin>>a>>b>>x;

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



Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
int n1,count=0;

int binarySearch(int *A,int key);
int main(){
  int n2;
  int *A,*B;
  int i,j;
   
  scanf("%d",&n1);


   A  = (int *)malloc(n1 * sizeof(int));
   
  for(i=0;i<n1;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&n2);

  B  = (int *)malloc(n2 * sizeof(int));
   
    
    for(i=0; i<n2; i++){
      scanf("%d",&B[i]);
    }

    
    for(i=0;i<n2;i++){
      binarySearch(A,B[i]);
    }	 
	   
    printf("%d\n",count);

    return 0;
}


binarySearch(int *A,int key){
 int left = 0;
 int right;
 int mid;
  right = n1;
  
  while(left<right){
    mid = (left + right)/2;
    if(key == A[mid]){
      count++;
      return mid;
    }
    if(key >A[mid]){
      left = mid + 1;
    }
    else if(key < A[mid]){
      right = mid;
    }
  }
    return NULL;
  }
    



Measured memory_bytes: 2332
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n - 1):
        for m in range(s + 1, n):
            for e in range(m + 1, n + 1):
                if x == sum([s, m, e]):
                    count += 1

    print(count)

Measured memory_bytes: 7728
#include <bits/stdc++.h>
//#define ll long long int
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=55;
int a[MAX];
vector<pii>ans;
int maxi=-1,pos=-1;
int32_t main()
{
  BOOST;
	int n;
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
		if (abs(a[i])>maxi)maxi=abs(a[i]),pos=i;
	}
	//3
	//1000 -1000 0
  if (a[pos]<0){
		for (int i=1;i<=n;i++) if (i!=pos)ans.pb(mp(pos,i));
		for (int i=n-1;i>=1;i--)ans.pb(mp(i+1,i));
	}
	else{
		for (int i=1;i<=n;i++) if (i!=pos)ans.pb(mp(pos,i));
		for (int i=2;i<=n;i++)ans.pb(mp(i-1,i));
	}
	
	cout<<sz(ans)<<"\n";
	for(auto it:ans)cout<<it.st<<" "<<it.nd<<"\n";
  return 0;
}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long int ll;
int n;
const int maxn=200005;
ll aa[maxn];
ll su[maxn];
ll yh[maxn];
int main(){
	scanf("%d",&n);
	rep(i,1,n)scanf("%lld",aa+i);
	rep(i,1,n)su[i]=su[i-1]+aa[i];
	rep(i,1,n)yh[i]=yh[i-1]^aa[i];
	//rep(i,1,n)cout<<su[i]<<" "<<yh[i]<<endl;
	ll cnt=0;
	int l=1,r=1;
	while(l<=n&&r<=n){
		while(l<=r&&su[r]-su[l-1]!=(yh[r]^yh[l-1]))l++;
		if(l<=r)cnt+=r-l+1;
		r++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
int main(void){
   int n,i,j;
   scanf("%d",&n);
   int a[100]={};
   for(i=0;i<n;i++){
       scanf("%d",&a[i]);
   }
   for(j=n-1;j>=0;j--){
       printf("%d",a[j]);
       if(j!=0){
           printf(" ");
        
       }
       else{
           printf("\n");
       }
   }
   return 0;
}   


Measured memory_bytes: 2084
x = int(input())
A = []
for i in range(1,1005):
    A.append([100*i, 105*i])

ans = 0
for i in range(len(A)):
    if A[i][0] <= x <= A[i][1]:
        ans = 1
if ans==1:
    print(1)
else:
    print(0)

Measured memory_bytes: 38384