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

int main(){
    int N;
    cin>>N;
    if(__builtin_popcount(N)==1){
        cout<<"No"<<endl;
        return 0;
    }else{
        cout<<"Yes"<<endl;
    }
    cout<<1<<' '<<2<<endl;
    for(int i=2;i<N;i+=2){
        cout<<i<<' '<<i+1<<endl;
        cout<<i+1<<' '<<1+N<<endl;
        cout<<1+N<<' '<<i+N<<endl;
        cout<<i+N<<' '<<i+1+N<<endl;
    }
    if(N%2==0){
        int y=1;
        while(y<=N)y<<=1;
        y>>=1;
        int x=N^y^1;
        cout<<x<<' '<<N<<endl;
        cout<<y+N<<' '<<2*N<<endl;
    }
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>

# define REP(i,n) for(int i=0; i<n;i++)

using namespace std;

int main(){
	
	string s;
	cin >> s;
	
	REP(i,s.length()){
		if (s[i]=='A' && i<s.length()-1){
			if (s[i+1]=='C'){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
 
#define pi 3.1415926535

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

  int ans = 0, tmp = 0;
  for(int i = 0; i < N; i++){
    cin >> tmp;
    if(i % 2 == 0){
      if(tmp % 2){
        ans++;
      }
    }
  }

  cout << ans;

  return 0; 
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define N_MAX 1000001
struct MOD{
  ll fac[N_MAX+1], inv[N_MAX+1], finv[N_MAX+1];
  constexpr MOD():fac(), inv(), finv(){
    fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
    for(int i = 2; i <= N_MAX; i++){
      fac[i] = (fac[i-1]*i)%P;
      inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
      finv[i] = (finv[i-1]*inv[i])%P;
    }
  }
  constexpr ll comb(ll n, ll k){
    if(n<0||k<0||n<k) return 0;
    return (((fac[n]*finv[n-k])%P)*finv[k])%P;
  }
  constexpr ll pp(ll a, ll b){
    return (a * b)%P;
  }
};

int main(int argc, char const *argv[]) {
  constexpr MOD mod = MOD();
  ll x, y;scanf("%lld %lld", &x, &y);
  if((x+y)%3!=0||(max(x, y)>2*min(x, y))) {
    printf("0\n");
    exit(0);
  }
  ll num = (x+y)/3;
  ll ooi = max(x, y) - min(x, y);
  ll a = num - ooi;
  if(a%2!=0) {
    printf("0\n");
    exit(0);
  }
  a/=2;
  ll X = mod.finv[a];
  ll Y = mod.fac[num];
  ll Z = mod.finv[num - a];
  //cout << X << " " << Y << " " << Z << endl;
  ll ans = ((X*Y)%P*Z)%P;
  std::cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 23680
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll i,j,k,n,d;
   string s,t;
    cin>>s>>t;
   ll ind=0,len=t.length(),cnt=INT_MAX;
   for(i=0;i<=s.length()-t.length();i++)
   {
       ll tmp=0;
       //cout<<i<<endl;
           ind=i;
           for(j=0;t[j];j++)
           {
            if(s[ind]!=t[j]) tmp++;
               ind++;
           }
           cnt=min(tmp,cnt);
   }


    cout<<min(cnt,len)<<endl;



    return 0;
}





Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(const auto& x : c )cout << x << " "; cout << "\n";
#define ol(c, s, e) for(int pos=s; pos<e; pos++)cout << c[pos] << " ";cout <<"\n";
#define PI acos(-1LL)



#ifndef CF
string to_string(const string& s){
    return '"' + s + '"';
}
string to_string(const char* s) {
    return to_string((string) s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename T>
string to_string(vector<T> v){
    bool first = true;
    string res = "{";
    for(const auto& x: v){
        if(!first) res+=", ";
        first = false;
        res+=to_string(x);
    }
    res+="}";
    return res;
}
void bug() { cerr << endl; }
template<typename Head, typename... Tail>
void bug(Head H, Tail... T) {
    cerr << " " << to_string(H);
    bug(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__);
#endif


const int M = 1000000007;
const int N = 2e5 + 5;
const long long INF = 1e9 + 12;

void solve(){
    string s;
    cin >> s;
    if(s.length() == 3){
        if(s[0] == '4' || s[0] == '5'){
            cout << "8";
        }
        else if(s[0] == '6' || s[0] == '7'){
            cout << "7";
        }
        else{
            cout << "6";
        }
    }
    else{
        if(s[1] == '0' || s[1] == '1'){
            cout << "5";
        }
        else if(s[1] == '2' || s[1] == '3'){
            cout << "4";
        }
        else if(s[1] == '4' || s[1] == '5'){
            cout << "3";
        }
        else if(s[1] == '6' || s[1] == '7'){
            cout << "2";
        }
        else{
            cout <<"1";
        }
    }

}


signed main(){
    FAST
    int tc = 1;
//    TODO: check for tc
//    cin >> tc;
    for (int t = 1; t <= tc; t++) {
//        cout << "Case #" << t << ": ";
        solve();
    }
}


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

#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9, MOD = 1e6 + 7;
 
/////////////////////////////////////////////////////////////////////
 
const int N = 1e5 + 5, LOG = 20;

int n, l, X[N], PAR[N][LOG];

int main() {
 
	sync;

	cin >> n;
	for (int i = 0; i < n; i++) cin >> X[i];
	cin >> l;
	for (int i = 0; i < n; i++) PAR[i][0] = upper_bound(X, X + n, X[i] + l) - X - 1;
	for (int pw = 1; pw < LOG; pw++) for (int i = 0; i < n; i++) PAR[i][pw] = PAR[PAR[i][pw - 1]][pw - 1];
	int q; cin >> q;
	while (q--) {
		int l, r; cin >> l >> r; l--, r--;
		if (l > r) swap(l, r);
		int ans = 0;
		for (int pw = LOG - 1; pw >= 0; pw--) if (PAR[l][pw] < r) l = PAR[l][pw], ans += (1 << pw);
		cout << ans + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <vector>

using namespace std;
int main(int argc, char* argv[]) {
	int n, m; cin >> n >> m;
	vector<int> a, b;
	for (int i = 0; i < m; i++) {
		int aa, bb; cin >> aa >> bb;
		a.push_back(aa);
		b.push_back(bb);
	}
	vector<int> ans;
	for (int i = 0; i < n; i++) {
		ans.push_back(0);
	}
	for (int i = 0; i < m; i++) {
		ans[a[i] - 1]++;
		ans[b[i] - 1]++;
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,M;cin>>N>>M;
    int a,b;a=0,b=N;
    for(int i=0;i<M;i++){
        int n,m;cin>>n>>m;
        a=max(a,n);
        b=min(b,m);
    }
    //cout<<a<<" "<<b<<endl;
    if(b<a)cout<<0<<endl;
    else cout<<b-a+1<<endl;
}

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

int main (){
    long long N, K;
    cin >> N >> K;
    long long ans = N;
    if(N > K) {
        ans = min(N%K,K - N%K);
    } else if(N == K) {
        ans = 0;
    } else {
        ans = min(N, K - N);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
import numpy as np
import fractions
import sys
readline = sys.stdin.readline
read = sys.stdin.read

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

N = II()
A = LII()

b = min(A)
for a in A:
    b = fractions.gcd(a, b)
print(b)

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

int main(){
	char s[1000000+2];
	scanf("%s",&s);
	int l=0,j=0,o=0,i=0,ans=0;
	while(s[l]!='\0')l++;
	for(int k=0;k<l;k++){
		if(s[k]=='J'){
			if(o==0)j++;
			if(o!=0){j=1;o=0;i=0;}
		}
		if(s[k]=='O'){
			if(i==0)o++;
			if(j<o||i!=0){j=0;o=0;i=0;}
		}
		if(s[k]=='I'){
			if(o==0){j=0;o=0;i=0;}
			if(o!=0){
				i++;
				if(o==i){
					if(ans<i)ans=i;
					j=0;o=0;i=0;
				}
			}
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 2100
n = int(input())

one = n % 10
hund = n // 100
thou = n // 1000
cnt = 0

if  n < 10:
    cnt += n

elif 100 > n >= 10:
    cnt += 9

elif 1000 > n >= 100:
    cnt += (n - 99) + 9

elif 10000 > n >= 1000:
    cnt += 909

elif 100000 > n >= 10000:
    cnt += (n - 9999) + 909

elif n == 100000:
    cnt += 90909

print(cnt)



Measured memory_bytes: 3060
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
#include<atcoder/dsu>
using namespace std;
using namespace atcoder;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n = 0, q = 0, ch = 0, x = 0, y = 0;
	cin >> n >> q;
	dsu v(n);
	for (int i = 0; i < q; ++i)
	{
		cin >> ch >> x >> y;
		if (ch == 0)
			v.merge(x, y);
		else
		{
			if (v.same(x, y))
				cout << "1\n";
			else
				cout << "0\n";
		}
	}
}

Measured memory_bytes: 3980
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,m;
    cin>>n>>m;
    vi x(m);
    rep(i,m)cin>>x[i];
    SORT(x);
    vi v;
    rep(i,m-1)v.pb(x[i+1]-x[i]);
    RSORT(v);
    int ans=0;
    REP(i,n-1,m-1)ans+=v[i];
    cout<<ans<<endl;
}

Measured memory_bytes: 2168
#include<stdio.h>
int main(){
    int k,i,j,n,m,x,y,A=0;
    int num[101][6];
    scanf("%d",&k);
    for(i=0;i<k;i++){
        for(j=0;j<6;j++){
        scanf("%d",&num[i][j]);
        }
    }
    for(m=0;m<k;m++){
        for(i=0;i<6;i++){
            if(i>0 && i<5){
                n=num[m][1];
                num[m][1]=num[m][3];
                num[m][3]=num[m][4];
                num[m][4]=num[m][2];
                num[m][2]=n;
                if(i==4){
                    n=num[m][0];
                    num[m][0]=num[m][1];
                    num[m][1]=num[m][5];
                    num[m][5]=num[m][4];
                    num[m][4]=n;
                }
            }else if(i==5){
                n=num[m][0];
                num[m][0]=num[m][5];
                num[m][5]=n;
                n=num[m][1];
                num[m][1]=num[m][4];
                num[m][4]=n;
            }
            for(j=0;j<4;j++){
                for(x=0;x<k;x++){
                    for(y=0;y<k;y++){
                        if(x<y && num[x][0]==num[y][0] && num[x][1]==num[y][1] && num[x][2]==num[y][2] && num[x][3]==num[y][3] && num[x][4]==num[y][4] && num[x][5]==num[y][5]){
                            A=1;
                            break;
                        }
                    }
                    if(A==1){
                        break;
                    }
                }
                if(A==1){
                    break;
                }
                n=num[m][0];
                num[m][0]=num[m][2];
                num[m][2]=num[m][5];
                num[m][5]=num[m][3];
                num[m][3]=n;
            }
            if(A==1){
                break;
            }
        }
    if(A==1){
        break;
    }
    }
    
    if(A==1){
        printf("No\n");
    }else{
        m--;
        printf("Yes\n");
    }
    return 0;
}   


Measured memory_bytes: 2104
#include<iostream>
using namespace std;
int main()
{
long double v,n;
long long int N;
while(cin>>v)
{
n=(4.9*((v/9.8)*(v/9.8)))/5+1;
N=n*100000000000000;	
if(N%100000000000000==0)
{
	cout<<N/100000000000000<<endl;
}
else if(N%100000000000000!=0)
{
	cout<<N/100000000000000+1<<endl;
}
}
return 0;
}

Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[][][] people = new int[4][3][10];
		
		for(int i = 0; i < n; i++) {
			int b = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			int v = scan.nextInt();
			people[b-1][f-1][r-1] += v;
		}
		
		for(int i = 0; i < 4; i++) {
			for(int j = 0; j < 3; j++) {
				for(int k = 0; k < 10; k++) {
					System.out.print(" " + people[i][j][k]);
				}
				System.out.println();
			}
			if(i != 3) System.out.println("####################");
		}
			
		
		
	}

}



Measured memory_bytes: 30028
#include"bits/stdc++.h"
#define F(i,j,n) for(register int i=j;i<=n;i++)
#define D(i,j,n) for(register int i=j;i>=n;i--)
#define ll long long
#define P 998244353
using namespace std;
namespace io{
	const int L=(1<<19)+1;
	char ibuf[L],*iS,*iT,c;int f;
	char gc(){
		if(iS==iT){
			iT=(iS=ibuf)+fread(ibuf,1,L,stdin);
			return iS==iT?EOF:*iS++;
		}
		return*iS++;
	}
	template<class I>void gi(I&x){
		for(f=1,c=gc();c<'0'||c>'9';c=gc())if(c=='-')f=-1;
		for(x=0;c<='9'&&c>='0';c=gc())x=x*10+(c&15);x*=f;
	}
};
using io::gi;
using io::gc;
char s[2010];int n,a[4010],b[4010],f[4010][4010];
void add(int&a,int b){a=a+b<P?a+b:a+b-P;}
int main(){
	#ifdef JHR
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
	#endif
	scanf("%s",s+1);
	n=strlen(s+1);
	F(i,1,n)a[i]=a[i-1]+s[i]-'0',b[i]=2*i-a[i];
	F(i,n+1,n*2)a[i]=a[i-1],b[i]=b[i-1];
	F(i,1,n)a[i]-=(s[i]=='2'),b[i]-=(s[i]=='0');
	f[0][0]=1;
//	F(i,1,n*2)printf("%d %d\n",a[i],b[i]);
	F(i,1,n*2)F(j,max(0,i-b[i]),a[i]){
		int k=i-j;
//		printf("%d %d\n",j,k);
		if(j)add(f[j][k],f[j-1][k]);
		if(k)add(f[j][k],f[j][k-1]); 
	}
	printf("%d\n",f[a[n+1]][b[n+1]]);
	return 0;
}



Measured memory_bytes: 61056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RREP(i,n) for (int i=n-1;i>=0;i--)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=5e3+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
ll sum[MAXn];
int main(){
    IOS();
    ll k,q;
    cin >> k >> q;
    REP1 (i,k) {
        cin >> d[i];
    }
    while (q--) {
        ll n,x,m;
        cin >> n >> x >> m;
        ll nn = n;
        n--;
        ll cur = x % m;
        ll cnt = 0;
        REP1 (i,k) {
            sum[i] = d[i] % m;
            if (sum[i] == 0) cnt++;
            sum[i] += sum[i-1];
        }
        cur += (n/k) * sum[k] + sum[n%k];
        int cc = 0;
        REP1 (i,n%k) {
            if (d[i] % m == 0) cc++;
        }
        cur /= m;
        debug(cur,sum[k]);
        cout << n - cur - (n/k)*cnt - cc << endl;
    }
}


Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
m = max(a)
a.remove(m)
l = 10**9
t = a[0]
for i in range(n-1):
  if abs(m/2-a[i]) < l:
    l = abs(m/2-a[i])
    t = a[i]

print(m, t)


Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int MN = 200200;
const int A = 26;
deque<int> v[A];
bitset<A> bs;
bitset<MN> us,rs;
int ft[MN];
int sz;
int lso(int n) {
	return n&(-n);
}
void up(int a, int val) {
	for(;a<MN;a+=lso(a)) {
		ft[a] += val;
	}
}
int rq(int a) {
	int res = 0;
	for(;a>0;a-=lso(a)) {
		res += ft[a];
	}
	return res;
}
int main() {
	memset(ft,0,sizeof(ft));
	ios::sync_with_stdio(0);cin.tie(0);
	string s;
	cin >> s;
	sz = s.size();
	for(int i=0;i<s.size();i++) {
		int id = s[i]-'a';
		v[id].push_back(i);
		bs[s[i]-'a'] = !bs[s[i]-'a'];
	}
	if(bs.count()>1) {cout << "-1\n";return 0;}
	for(int i=0;i<sz;i++) {
		up(i+1,1);
	}
	ll tot = 0;
	int rs = sz;
	for(int i=0;i<s.size();i++) {
		if(us[i]) continue;
		int id = s[i]-'a';
		if(v[id].size() == 1) break;
		int co = v[id].back();
		tot += rs-rq(co+1);
		v[id].pop_back();
		v[id].pop_front();
		us.set(i);
		us.set(co);
		up(i+1,-1);
		up(co+1,-1);
		rs -= 2;
	}
	for(int i=sz-1;i>=0;i--) {
		if(us[i]) continue;
		int id = s[i]-'a';
		if(v[id].size() == 1) break;
		int co = v[id].front();
		tot += rq(co);
		v[id].pop_back();
		v[id].pop_front();
		us.set(i);
		us.set(co);
		up(i+1,-1);
		up(co+1,-1);
		rs -= 2;
	}
	cout << tot << '\n';
}

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


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


def main():
    N = int(input())
    ans = 0
    for i in range(1, N + 1):
        n = N // i
        ans += n * (n + 1) * i // 2
    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 63148
#include <iostream>
#include <vector>
#include <random>
using namespace std;
typedef long long ll;
int D;
int v=27;
vector<int> c(v,0);
vector<vector<int>> s;
vector<int> t;
vector<int> last(v,0);

void init(){
    cin >> D;
    s.resize(D+1);
    t.resize(D+1);
    for(int i=0;i<D+1;i++){
        s[i].resize(v);
    }

    for(int i=1;i<27;i++){
        cin >> c.at(i);
    }
    for(int i=1;i<D+1;i++){
        for(int j=1;j<27;j++){
            cin >> s.at(i).at(j);
        }
    }
/*
    for(int i=1;i<D+1;i++){
        cin >> t.at(i);
    }
*/

}

void init_last(){
  for(int i=0;i<v;i++){
    last.at(i) = 0;
  }
}

ll calc(){
    ll ans=0;
    init_last();
    for(int i=1;i<D+1;i++){
        ans += s.at(i).at(t.at(i));
        last.at(t.at(i)) = i;
        for(int j=1;j<v;j++){
            ans -= c.at(j) * (i - last.at(j));
        }
    }
    return ans;
}

int main(){
    init();

    std::random_device rd;

    std::mt19937 mt(rd());

    for(int i=1;i<D+1;i++){
        t.at(i) = mt() % 26 + 1;
    }

    ll sol = calc();
    ll trial = 10;
    for(int i=0;i<trial;i++){
        int d,q;
        d = mt()%365 + 1;
        q = mt()%26 + 1;
        int old = t.at(d);
        t.at(d) = q;
        if(sol > calc()){
            t.at(d) = old;
        }
    }

    for(int i=1;i<D+1;i++){
        cout << t.at(i) << endl;
    }
  
  	return(0);
}

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

int ans, n;
string s;

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

    cin >> n >> s;

    int L = 0, R = n-1;
    while (L <= R) {
        if (s[L] == 'W') {
            while (L <= R) {
                if (s[R] == 'R') {
                    ans++;
                    swap(s[L], s[R]);
                    R--;
                    break;
                }

                R--;
            }
        }

        L++;
    }

    cout << ans << '\n';

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];

    int ans = 1, u = 0;
    rep(i, n - 1) {
        if (a[i + 1] == a[i]) {
            if (i == u) u++;
            continue;
        }
        if (a[i + 1] > a[i] != a[u + 1] > a[u]) {
            ans++;
            u = i + 1;
        }
    }

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


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

using namespace std;

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

const double PI = 3.1415926535897932384626433832795;

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

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

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

	int n, k;
	cin >> n >> k;

	vector<int> h(n);
	for (auto &v : h) {
		cin >> v;
	}

	sort(begin(h), end(h));

	int ans = INT_MAX;
	for (int i = 0; i <= n - k; i++) {
		ans = min(ans, abs(h[i + k - 1] - h[i]));
	}

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


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<deque>
#define ll long long
#define mp make_pair
using namespace std;
int n;
int a[100005];
int main(){
	cin>>n;
	int i,j;
	for(i=0;i<n;++i) cin>>a[i];
	sort(a,a+n);
	cout<<a[n/2]-a[n/2-1]<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;
typedef long long ll;

int main()
{
	std::ios::sync_with_stdio(false);

	ll res = 0;
	ll x;
	cin >> x;

	ll bal = 100;

	while (bal < x)
	{
		res++;

		double dbal = (double)bal * 1.01;

		bal = dbal;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int n = scan.nextInt();
			int[]v = new int[n];
			for(int i = 0;i<n;i++)v[i] = scan.nextInt();
			
			Map<Integer,Integer> O = new TreeMap<Integer,Integer>();
			Map<Integer,Integer> E= new TreeMap<Integer,Integer>();
			
			for(int i = 0;i<n;i++) {
				if(i%2==1) {//偶数
					if(E.containsKey(v[i])) E.put(v[i], E.get(v[i])+1);
					else E.put(v[i], 1);
				}else{//奇数
					if(O.containsKey(v[i])) O.put(v[i], O.get(v[i])+1);
					else O.put(v[i], 1);
				}
			}
			
			for(Integer key:O.keySet()) 
				O.put(key, n/2-O.get(key));
			for(Integer key:E.keySet()) 
				E.put(key, n/2-E.get(key));
			
			ArrayList<Entry<Integer,Integer>> olist = new ArrayList<Entry<Integer,Integer>>(O.entrySet());
			ArrayList<Entry<Integer,Integer>> elist = new ArrayList<Entry<Integer,Integer>>(E.entrySet());
			Comparator<Entry<Integer,Integer>> com = new COMP();
			
			Collections.sort(olist,com);
			Collections.sort(elist,com);
			
			for(Entry<Integer,Integer> ent:olist) {
				//System.out.print(ent.getKey());
				//System.out.print(" ");
				//System.out.println(ent.getValue());
			}
			
			//System.out.println();
			
			for(Entry<Integer,Integer> ent:elist) {
				//System.out.print(ent.getKey());
				//System.out.print(" ");
				//System.out.println(ent.getValue());
			}
			
		
			int el = elist.get(0).getKey();
			int ol = olist.get(0).getKey();
			
			if(el!=ol) {
				System.out.println(elist.get(0).getValue()+olist.get(0).getValue());
			}else{
				if(elist.size()==1&&olist.size()==1) {
					System.out.println(n/2);
					
				}else if(elist.size()==1) {
					System.out.println( elist.get(0).getValue()+olist.get(1).getValue());
					
				}else if(olist.size()==1) {
					System.out.println(elist.get(1).getValue()+olist.get(0).getValue());
				
				}else {
				int N = elist.get(0).getValue()+olist.get(1).getValue();
				int S= elist.get(1).getValue()+olist.get(0).getValue();
				
				if(N>=S) {
					System.out.println(S);
				
				}else {
					System.out.println(N);
				
				}
				}
			}
			
		
			
			
			
			
		}
		
		
	}
	
	
	
	static class COMP implements Comparator<Entry<Integer,Integer>>{
		public int compare(Entry<Integer,Integer> x,Entry<Integer,Integer> y) {
			return x.getValue().compareTo(y.getValue());
		}
		}
		

}


Measured memory_bytes: 55256
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T &a){int t = 0;for(auto itr :a){if(t++)cout << " "; cout << itr;} cout <<endl; }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    cin >> H >> W;
    vector<vector<int>>c(10,vector<int>(10,INF));
    rep(i,10)rep(j,10) cin >> c[i][j];
    rep(k,10)rep(i,10)rep(j,10)cmin(c[i][j],c[i][k] + c[k][j]);
    int ans = 0;
    rep(i,H)rep(j,W){
        int t; cin >> t;
        if(t == 1 or t == -1)continue;
        ans += c[t][1];
    }
    cout << ans << endl;
}




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

int main() {
    int a,b;
    cin >> a >> b;
    string o;
    if (a == b) o = "a == b";
    else if (a < b) o = "a < b";
    else o = "a > b";
    cout << o << endl;
    return 0;
}

Measured memory_bytes: 3168
import java.util.*;

public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = a*b;
      if(c % 2 == 0){
      	System.out.println("Even");
      }else{
      	System.out.println("Odd");
      }
    }
}


Measured memory_bytes: 21588
H, W = map(int, input().split())
while 1:
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if i == 0 and j == 0:
                print("#", end = "")
            elif i % 2 == 0 and j % 2\
            or i % 2 and j % 2 == 0:
                print(".", end = "")
            else:
                print("#", end = "")
            if j == W - 1:
                print()
    print()
    H, W = map(int, input().split())

Measured memory_bytes: 8956
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

N, M = map(int,input().split())
uf = UnionFind(N)
l = []
count=0
for i in range(M):
    a, b = map(int,input().split())
    l.append([a, b])
    
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        if i != j:
            uf.union(l[j][0], l[j][1])
    if not uf.same_check(l[i][0],l[i][1]):
        count+=1
print(count)

Measured memory_bytes: 41584
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            byte X = Byte.parseByte(in.next());
            if (X >= 30)
                out.println("Yes");
            else
                out.println("No");
        }

    }
}

Measured memory_bytes: 35648
n = int(input())
X = list(map(int,input().split()))
X_sorted = sorted(X)
med_low = X_sorted[n//2-1]
med_high = X_sorted[n//2]
for i in range(n):
    if X[i] <= med_low:
        print(med_high)
    else:
        print(med_low)

Measured memory_bytes: 25228
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;

struct team{
	long long int id,ac[15]={},tim[15]={},sumtime=0,sumac=0;
};

long long int M,T,P,R;

bool cmp(team x,team y){
	
	if(x.sumac!=y.sumac){
		return y.sumac<x.sumac;
	}
	else if(x.sumtime!=y.sumtime){
		return x.sumtime<y.sumtime;
	}else{
		return y.id<x.id;
	}
}
bool samecmp(team x,team y){
	
	if(x.sumac!=y.sumac){
		return false;
	}
	else if(x.sumtime!=y.sumtime){
		return false;
	}else{
		return true;
	}
}
int main() {
	
	cout << fixed << setprecision(18);
	cin>>M>>T>>P>>R;
	while(M!=0){
		team te[55];
		for(int i=1;i<=T;i++){te[i].id=i;}
		for(int i=0;i<R;i++){
			long long int m,t,p,j;
			cin>>m>>t>>p>>j;
			if(j==0){te[t].ac[p]=1;te[t].tim[p]+=m;}
			else{te[t].tim[p]+=20;}
		}
		
		for(int i=1;i<=T;i++){
			for(int v=1;v<=P;v++){
				te[i].sumac+=te[i].ac[v];
				te[i].sumtime+=te[i].ac[v]*te[i].tim[v];
			}
		}
		sort(te+1,te+T+1,cmp);
		cout<<te[1].id;
		for(int i=2;i<=T;i++){
			if(samecmp(te[i],te[i-1])){
				cout<<"="<<te[i].id;
			}else{
				cout<<","<<te[i].id;
			}
		}
		cout<<endl;
		cin>>M>>T>>P>>R;
	}

} 


Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define pii pair<int, int>
using namespace std;
const int MAXN = 1e6 + 7;
const int INF = 1e9;
vector<pii>vec;
char s[MAXN];
stack<char>stk;
int N, a[MAXN], v[MAXN];
    
#define lson (rt << 1)
#define rson (rt << 1 | 1)
struct node{int val, pos;} T[MAXN << 2];
node merge(node &x, node &y) {
    if (x.val > y.val) return x;
    else return y;
}
void pushup(int rt) {T[rt] = merge(T[lson], T[rson]);}
void build(int rt, int l, int r) {
    if (l == r) {T[rt] = {v[l], l}; return;}
    int mid = (l + r) >> 1;
    build(lson, l, mid);
    build(rson, mid + 1, r);
    pushup(rt);
}
void update(int rt, int l, int r, int pos, int v) {
    if (l == r) {T[rt] = {v, l}; return;}
    int mid = (l + r) >> 1;
    if (pos <= mid) update(lson, l, mid, pos, v);
    else update(rson, mid + 1, r, pos, v);
    pushup(rt);
}
node query(int rt, int l, int r, int L, int R) {
    if (L <= l && r <= R) return T[rt];
    int mid = (l + r) >> 1;
    node resl = {-INF, -1}, resr = {-INF, -1};
    if (L <= mid) resl = query(lson, l, mid, L, R);
    if (mid <  R) resr = query(rson, mid + 1, r, L, R);
    return merge(resl, resr);
}
    
int main() {
    int n; scanf("%d", &n);
    int sum1 = 0, sum2 = 0;
    for (int k = 1; k <= n; k++) {
        scanf(" %s", s);
        int len = strlen(s);
        for (int i = 0; i < len; i++) {
            if (s[i] == '(') stk.push(s[i]);
            else {
                if (stk.size() && stk.top() == '(') stk.pop();
                else stk.push(s[i]);
            }
        }
        pii item = {0, 0};
        while (stk.size()) {
            if (stk.top() == '(') item.second++;
            else item.first++;
            stk.pop(); 
        }
        if (item.first == 0) sum1 += item.second;
        else if (item.second == 0) sum2 += item.first;
        else vec.push_back(item);
    }
    sort(vec.begin(), vec.end());
    N = vec.size();
    for (int i = 1; i <= N; i++) {
        a[i] = vec[i - 1].first;
        v[i] = vec[i - 1].second - vec[i - 1].first;
    }
    if (N > 0) build(1, 1, N);
    for (int i = 1; i <= N; i++) {
        int p = upper_bound(a + 1, a + 1 + N, sum1) - a - 1;
        if (!p) {puts("No"); return 0;}
        node res = query(1, 1, N, 1, p);
        if (res.pos == -1 || sum1 < a[res.pos]) {puts("No"); return 0;}
        sum1 += v[res.pos];
        update(1, 1, N, res.pos, -INF);
    }
    sum1 == sum2 ? puts("Yes") : puts("No");
    return 0;
}

Measured memory_bytes: 10456
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
	int n,d[100],ans=1;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&d[i]);
	sort(d,d+n);
	for(int i=1;i<n;i++){
		if(d[i]>d[i-1]) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9+7;
ll dp[1<<13][1005];
ll val;
vector<ll> a;
vector<vector<ll>> v;
int main()
{
	//freopen("test.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m;
	cin>>n>>m;
	a.clear();
	v.resize(m);
	for(ll i=0;i<m;i++)
	{
		ll x,y;
		cin>>x>>y;
		a.push_back(x);
		
		for(ll j=0;j<y;j++)
		{
			ll p;
			cin>>p;
			v[i].push_back(p);
		}
	}
	val = (1<<n);
	for(ll i=0;i<(1<<13);i++)
	{
		for(ll j=0;j<(1005);j++){
			dp[i][j]=1e15;
		}
	}

	for(ll i=0;i<m;i++)
		dp[0][i]=0;
	ll ans=1e15;

	for(ll i=0;i<val;i++)
	{
		ll cost = dp[i][0];
		for(ll j=0;j<m;j++)
			cost = min(cost,dp[i][j]);
		//cout<<cost<<endl;

		for(ll j=0;j<m;j++)
		{
			ll mask=i;
			ll temp=cost+a[j];
			for(ll k=0;k<v[j].size();k++)
			{
				//cout<<j<<" "<<v[j][k]<<endl;
				mask = mask | (1<<(v[j][k]-1));
			}
			//cout<<mask<<" "<<temp<<endl;
			dp[mask][j+1]=min(dp[mask][j+1],temp);
			if(mask == (val-1))
				ans = min(ans,dp[mask][j+1]);
		}
	}
	if(ans==1e15)
		cout<<-1<<"\n";
	else
		cout<<ans<<"\n";

}

Measured memory_bytes: 64768
import math

N = int(input())
Xi = list(map(int, input().split(" ")))

Xi_min = min(Xi)
Xi_max = max(Xi)

ans = 999999999
for i in range(Xi_min, Xi_max+1):
    tmp = 0
    for j in range(N):
        tmp += pow(Xi[j] - i, 2)
    if tmp < ans:
        ans = tmp

print(ans)

Measured memory_bytes: 3064
import sys

def aa097():
    a,b,c,d = list(map(int, input().split()))
    if abs(a-c) <= d:
        print('Yes')
        sys.exit()

    if abs(a-b) <= d and abs(b-c) <= d:
        print('Yes')
        sys.exit()

    print('No')

aa097()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif

    string s;
    cin >> s;
    int n = s.size();
    for (int c = 0; c < 26; ++c)
    {
        vector<int> pref(n + 1, 0);
        int mn = 0;
        int mni = 0;
        for (int i = 0; i < n; ++i)
        {
            if (s[i] - 'a' == c)
            {
                pref[i + 1] = pref[i] + 1;
            }
            else
            {
                pref[i + 1] = pref[i] - 1;
            }
            if (i >= 1 && pref[i + 1] - mn > 0)
            {
                cout << mni + 1 << ' ' << i + 1 << '\n';
                return 0;
            }
            if (i >= 0 && chkmin(mn, pref[i])) mni = i;
        }
    }
    cout << "-1 -1\n";

    return 0;
}



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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N), S(N + 1);
    S[0] = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        S[i + 1] = S[i] + A[i];
    }

    long long ans = LLONG_MAX;
    for (int i = 1; i < N; ++i) {
        long long left = S[i];
        long long right = S[N] - S[i];
        ans = min(ans, abs(left - right));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define rd(a) cin>>(a)
#define RD(a,b) cin>>(a)>>(b)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int ans=0;

void solve(int k, int n, int p) {
  if(n==0 && k==0) ans++;
  if(k<0 || n==0) return;
  rrep(i,p) solve(k-i-1,n-1,i);
}
int main() {
  int n,m,k;
  while(cin >> n >> m >> k && (n||m||k)) {
    ans=0;
    solve(k,m,n);
    pr(ans);
  }
  return 0;
}


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

using namespace std;
using ll = long long;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N){
  string s = "";
  while(N!=0) {
    if(N%2!=0) {
      N--;
      s = '1'+s;
    } else
      s = '0'+s;
    N/=-2;
  }
  if(s=="") s = '0';
  std::cout << s << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char s[110][11000];
char temp[11000];
int main(){
	int n,l;
	while(~scanf("%d%d",&n,&l)){
		for(int i=0;i<n;i++){
			scanf("%s",s[i]);
		}
		for(int i=0;i<n-1;i++){
			for(int j=0;j<n-1-i;j++){
				if(strcmp(s[j],s[j+1])>0){
					memset(temp,'\0',sizeof(temp));
					strcpy(temp,s[j]);
					strcpy(s[j],s[j+1]);
					strcpy(s[j+1],temp);
				}
			}
		}
		
		for(int i=0;i<n;i++)
			printf("%s",s[i]);
		printf("\n");
	}
} 

Measured memory_bytes: 640
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#include <boost/lexical_cast.hpp>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

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

  int answer = numeric_limits<int>::max();
  for (int i = 0; i < S.size() - 2; i++) {
    const auto sub = S.substr(i, 3);
    answer = min(answer, abs(753 - boost::lexical_cast<int>(sub)));
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3584
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));


int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cin.tie(0);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);


    int n;
    cin >> n;

    vector<vector<int>> layers;
    for (int i = 1; i + i <= n; ++i) {
        vector<int> cur = {i, n - i + 1 - n % 2};
        layers.push_back(cur);
    }
    if (n%2)
        layers.push_back({n});

    vector<pair<int,int>> edges;
    for (int i = 1; i < layers.size(); ++i) {
        for (int x : layers[i - 1])
        for (int y : layers[i])
            edges.emplace_back(x, y);
    }

    if (layers.size() > 2) {
        for (int x : layers.back())
        for (int y : layers[0])
            edges.emplace_back(x, y);
    }

    cout << edges.size() << endl;
    for (const auto& pa : edges)
        cout << pa.first << ' ' << pa.second << '\n';
}


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

int main() {
  long X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;

  vector<long> p, q, r;
  for (long i = 0; i < A; i++)
    {
      long pi;
      cin >> pi;
      p.emplace_back(pi);
    }
  for (long i = 0; i < B; i++)
    {
      long qi;
      cin >> qi;
      q.emplace_back(qi);
    }
  for (long i = 0; i < C; i++)
    {
      long ri;
      cin >> ri;
      r.emplace_back(ri);
    }

  sort(p.rbegin(), p.rend());
  sort(q.rbegin(), q.rend());

  p.erase(p.begin() + X, p.end());
  q.erase(q.begin() + Y, q.end());

  r.insert(r.end(), p.begin(), p.end());
  r.insert(r.end(), q.begin(), q.end());
  sort(r.rbegin(), r.rend());
  r.erase(r.begin() + X + Y, r.end());
  
  cout << accumulate(r.begin(), r.end(), 0LL) << endl;
}


Measured memory_bytes: 5988
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll N,X;
    cin >> N >> X;
    ll ans = 0;
    ans += N;
    if(3*X == N){
        ans += N;
        cout << ans << "\n";
        return 0;
    }
    N -=X;
    ll tmp;
    while(X > 0){
        if(N < X){
            tmp = X;
            X = N;
            N = tmp;
        }
        tmp = N % X;
        ans += (2*(N/X))*X;
        N = X;
        X = tmp;
    }
    ans -= N;
    cout << ans << "\n";
    return 0;
    
}


Measured memory_bytes: 256
n = gets.chomp.to_i
ans = 0
n.times do |i|
    x, u = gets.chomp.split(" ")
    if u == "BTC"
        x = x.delete(".")
        x = x.to_i * 380000.0
    else
        x = x.to_i
        x = x * 100000000
    end
    ans += x
end
puts ans / 100000000

Measured memory_bytes: 14208
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000009
using namespace std;
int main(){
	int n;
	cin>>n;
	double sum=0.0;
	vector<int> a;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	sort( a.begin(), a.end() );
	sum = 0.5 * (a[0]+a[1]);
	for(int i=2;i<n;i++){
		sum = 0.5 * (sum + a[i]);
	}
	cout<<sum<<endl;
	return 0;
}

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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

string s4[4] = {"aabd",
                "ccbd",
                "efgg",
                "efhh"};

string s5[5] = {"aabbc",
                "hii.c",
                "h..jd",
                "g..jd",
                "gffee"};

string s6[6] = {"aa.ccd",
                "..bf.d",
                "..bfee",
                "ccdaa.",
                "f.d..b",
                "fee..b"};

string s7[7] = {"gghhii.",
                "aa.cc.j",
                "..b..ej",
                "..b..ek",
                "cc.aa.k",
                "..d..bl",
                "..d..bl"};

char s[1002][1002];

void gao(int x,string *p,int t) {
    for(int i=0;i<t;i++)
        for(int j=0;j<t;j++)
            s[x+i][x+j]=p[i][j];
}

int main() {
    int n;read(n);
    if(n==2) return puts("-1"),0;
    if(n==3) {
        puts("aa.\n..b\n..b");
        return 0;
    }
    int x=n/4;if(n%4!=0) x--;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++) s[i][j]='.';
    for(int c=0;c<x;c++) gao(c*4+1,s4,4);
    int y=n-x*4;
    if(n%4!=0) gao(x*4+1,y==5?s5:(y==6?s6:s7),y);
    for(int i=1;i<=n;i++) printf("%s\n",s[i]+1);
    return 0;
}


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

int n, temp;

int main() {
  cin >> n;
  vector<P> a;
  rep (i, n) {
    cin >> temp;
    a.push_back(make_pair(temp, i + 1));
  }
  sort(a.begin(), a.end());
  rep (i, n - 1) {
    cout << a.at(i).second << " ";
  }
  cout << a.at(n - 1).second << endl;
  return 0;
}


Measured memory_bytes: 1780
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>

using namespace std;

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

#define pb push_back
#define ld long double
#define int long long
#define mp make_pair

const int MOD = 1e9 + 7;

mt19937 rnd(51);

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	int ans = 0, sum = 0, sum1 = 0;
	for (int i = 0; i < k; i++){
        sum += i, sum1 += n - i;
	}
	for (int i = k; i <= n + 1; i++){
        ans += sum1 - sum + 1;
        sum += i, sum1 += n - i;
	}
	cout << ans % MOD;
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; i++) cin >> p[i];
    sort(p.begin(), p.end());
    int S = 0;
    for (int i = 0; i < K; i++) S += p[i];
    cout << S << endl;
}

Measured memory_bytes: 3640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  if(S[2] == S[3] && S[4] == S[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256