akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define pb push_back
#define rng(a) a.begin(),a.end()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define sz(x) (i64)(x).size()
#define bit(n) (1LL<<(n))
#define fi first
#define se second
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

i64 pow_mod(i64 n, i64 k, i64 m){
  i64 r = 1;
  for(;k;k>>=1){
    if(k&1) r=(r*n)%m;
    n=(n*n)%m;
  }
  return r;
}

void Main()
{
  i64 n,k;
  cin >> n >> k;

  i64 x = 1;
  i64 ans = 0;
  while(n>=x){
    x *= k;
    ans++;
  }
  cout << ans << endl;

}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}


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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
	return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
	return a / gcd(a, b) * b;
}

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

int main()
{
    string s;
    ci >> s;

    int idx = 0;
    for(int i = 0; i < s.size(); i++) {
	if(s[i] == 'B') continue;
	cnt += i - idx;
	idx++;
    }

    co << cnt << en;
  
    return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li hon[10] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
map<li, li> m;

li dp[100100];

int main() {
    li n, k;
    cin >> n >> k;
    rep(i, k) {
        li a;
        cin >> a;
        a--;
        m[hon[a]] = max(m[hon[a]], a + 1);
    }

    dp[0] = 0;
    repp(i, 1, n + 1) {
        dp[i] = -1;
        for (auto && item : m) {
            if (i - item.F >= 0) {
                dp[i] = max(dp[i], dp[i - item.F] + 1);
            }
        }
    }

    li now = n;
    string res;
    while (now > 0) {
        li cand = -1;
        li step = -1;
        for (auto && item : m) {
            if (now - item.F >= 0 && dp[now] == dp[now - item.F] + 1 &&
                    cand <= item.S) {
                cand = item.S;
                step = item.F;
            }
        }
        //p3(now, cand, step);
        now -= step;
        res = res + to_string(cand);
    }
    cout << res << endl;
    //dump(dp, n + 1);

    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_129
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            var dict = new HashSet<int>();
            for(int i = 0; i < m; i++)
            {
                dict.Add(ReadInt());
            }

            var dp = new long[n+1];
            long mask = 1000000000 + 7;
            dp[0] = 1;
            for(int i = 0; i < n; i++)
            {
                if (dict.Contains(i))
                {
                    dp[i] = 0;
                    continue;
                }
                dp[i + 1] += dp[i];
                dp[i + 1] %= mask;
                if (i + 2 <= n)
                {
                    dp[i + 2] += dp[i];
                    dp[i + 2] %= mask;
                }
            }

            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            // Write output here
            WriteLine(dp[n]);
            Out.Flush();
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 18144
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(void){
    int N, M;
    ll X;
    cin >> N >> M >> X;
    vector<ll> C(N);
    vector<vector<ll>> A(N, vector<ll>(M));
    for(int i = 0; i < N; i++){
        cin >> C[i];
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }
    ll ans = 123456789LL;
    for(ll n = 0; n < (1LL << N); n++){
        ll nn = n;
        vector<ll> R(M, 0);
        ll cost = 0;
        for(int i = 0; i < N; i++){
            if(nn % 2 == 1){
                cost += C[i];
                for(int j = 0; j < M; j++){
                    R[j] += A[i][j];
                }
            }
            nn >>= 1;
        }
        for(int i = 0; i < M; i++){
            if(R[i] < X) goto next;
        }
        ans = min(ans, cost);
        next:;
    }
    if(ans == 123456789LL) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
b=input()
b=int(b)
a = input().split()
a=[int(i) for i in a]
a.sort()
c=0
d=99999999999999999
e=a[0]
f=a[b-1]
if e==f:
    d=0

else:
    for p in range (e,f):
        for x in range (0,b):
            c = c+(a[x]-p)**2
        if d>=c:
            d=c
            c=0

print(d)


Measured memory_bytes: 3064
a,b,c = map(int,input().split())
res = 0
while True:
    if a%2!=0 or b%2!=0 or c%2!=0:
        break
    elif a==b==c:
        res = -1
        break
    else:
        res += 1
        a,b,c = (b+c)//2, (c+a)//2, (a+b)//2
print(res)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int h[10000],w[10000],hh=-1,ww=-1,i=0,j,k,l;
    while (!(hh==0 && ww==0)){
        scanf("%d %d",&hh,&ww);
        h[i]=hh,w[i]=ww,i++;
    }
    for(j=0;j<i-1;j++){
        for(l=0;l<h[j];l++){
            for(k=0;k<w[j];k++){
                if (k==0 || k==w[j]-1 || l==0 || l==h[j]-1) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



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

int n, m;
int c[16], x[20001];


// dp[i][j] := X_i ?????¨??????y=j?????¨??????????????????????°?????
ll dp[20001][256];

ll rec(int p, int y) {
    if (dp[p][y] >= 0) return dp[p][y];

    if (p == n) return 0;

    ll ret=1e10;
    for (int i=0; i<m; ++i) {
        int ny=y+c[i];
        if (ny<0) ny=0;
        else if (ny>255) ny=255;
        ret = min(ret, rec(p+1, ny)+(ny-x[p])*(ny-x[p]));
    }

    return dp[p][y] = ret;
}

int main() {
    while (cin >> n >> m and (n or m)) {
        rep(i,m) cin >> c[i];
        rep(i,n) cin >> x[i];
        fill(dp[0], dp[20001], 1e10);

        dp[0][128] = 0;
        for (int p=0; p<n; ++p) {
            for (int y=0; y<256; ++y) {
                if (dp[p][y] != 1e10) {
                    for (int j=0; j<m; ++j) {
                        int yy = y + c[j];
                        if (yy > 255) yy = 255;
                        if (yy < 0) yy = 0;
                        dp[p+1][yy] = min(dp[p+1][yy], dp[p][y] + (x[p]-yy)*(x[p]-yy));
                    }
                }
            }
        }

        ll res = 1e10;
        rep(i, 256) {
            res = min(res, dp[n][i]);
        }

        cout << res << endl;
    }
}

Measured memory_bytes: 43080
// C++ program to demonstrate default behaviour of 
// sort() in STL. 
#include <bits/stdc++.h> 
using namespace std;

/*
long long int lcm(long long int a,long long int b){
	
	
     a = (a/(__gcd(a, b))) * (b/(__gcd(a, b))) * (__gcd(a, b));
    
    return a;
	
}
*/
  
int main() 
{ 

   int n,k,w;
   
   cin >> n;
   
   int a[n+50];
   
   for(int i = 0; i < n;i++){
   	
   	 cin >> k;
   	 a[k-1] = i+1;
   	
   }
   for(int i = 0; i < n;i++){
   	
   	cout << a[i] << " ";
   	
   }
  // cout << s;
    return 0; 
}


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

using namespace std;

// Function to solve the problem come here.

int main(int argc, char **argv)
{
    // The solution come here...
    int A, B;
    cin >> A >> B;

    if (A > 8 || B > 8)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;

    return 0;
}

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

int main(){
    long long a,b;
    cin>>a>>b;
    if(a==1 || b==1){
        cout<<1<<endl;
        return 0;
    }    
    long long res;
    res=ceil(a*(b/2.0));
    cout<<res<<endl;
    return 0;
}

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

int main(){
    int n, m, c;
    std::cin >> n >> m >> c;

    std::vector<int> b(m);
    for(int i = 0; i < m; ++i){
        std::cin >> b.at(i);
    }

    int counter = 0;
    int buf;
    int a;
    for(int i = 0; i < n; ++i){
        buf = c;
        for(int j = 0; j < m; ++j){
            std::cin >> a;
            buf += a * b.at(j);
        }

        if(buf > 0){
            ++counter;
        }
    }

    std::cout << counter << std::endl;

    return 0;
}


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

int main() {
  
  string S, T; cin >> S >> T;
  
  int count = 0;
  
  for (int i = 0; i < 3; i++) {
    if (S[i] == T[i]) {
      count++;
    }
  }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#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> ostream &operator << (ostream &_s,deque<_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

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
// const ll MAXN = 

ll n,l;
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n >> l;
    ll sum = 0;
    ll sm = INF;

    REP1 (i,n) {
        ll cur = l + i - 1;
        if (abs(cur) < abs(sm)) {
            sm = cur;
        }
        sum += cur;
    }

    cout << sum - sm << endl;
    return 0;
}


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

int main(){
    string s;
    while(cin >> s){
	int a[10];
	for(int i=0;i<10;i++){
	    a[i] = s[i] - (int)'0';
	}
	int n = 10;
	while(n>0){
	    for(int i=0;i<n-1;i++){
		a[i] = (a[i] + a[i+1])%10;
	    }
	    n--;
	}
	cout << a[0] << endl;
    }
   return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
  int N;
  cin>>N;
  char S[N];
  for(int i=0;i<N;i++){
    cin>>S[i];
  }
  int temp=0;
  int val=0;
  int leader=0;
  for(int i=0;i<N;i++){
    if(S[i]=='W')val+=1;
    else{
      val-=1;
      if(val<temp){
        temp=val;
        leader=i;
      }
    }
  }
  int answer=0;
  for(int i=0;i<leader;i++){
    if(S[i]=='W')answer+=1;
  }
  for(int i=leader+1;i<N;i++){
    if(S[i]=='E')answer+=1;
  }
  cout<<answer<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>

using namespace std;

typedef long long ll;

int main() {
    int K, X;
    cin >> K >> X;

    int min_val = max(X - K + 1, -1000000);
    int max_val = min(X + K - 1, 1000000);

    for(int i = min_val; i <= max_val; i++) {
        cout << i << " " ;
    }

    return 0;
}

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

using namespace std;

int main()
{
    int leng ,i,j,cnt=0;
//    char s[100005],t[100005];
string s,t;
//    scanf(" %s %s",s,t);
//    leng = s.size();
//    cout<<leng;
cin>>s>>t;
    for(i=0; i<(s.length()); i++)
    {
        if(s[i]!=t[i])
            cnt++;

    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

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

    if ((n + 1) / 2 >= k) {
        cout << "YES\n";
    }
    else {
        cout << "NO\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

#define bsf __builtin_ctzll
ll gcd(ll a, ll b) {
  // a = abs(a); b = abs(b);
  if (!a || !b) return a|b;
  int t = bsf(a|b); a >>= bsf(a);
  do { b >>= bsf(b); if (a > b) swap(a, b); b -= a;} while (b);
  return a << t;
}
ll lcm(ll x, ll y) { return x/gcd(x,y)*y;}


int main() {
  int n;
  scanf("%d",&n);
  vi a(n);
  cin>>a;
  vi l(n), r(n);
  rep(i,n-1) l[i+1] = gcd(l[i],a[i]);
  drep(i,n-1) r[i] = gcd(r[i+1],a[i+1]);
  ll ans = 1;
  rep(i,n) maxs(ans,gcd(l[i],r[i]));
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using s64 = int64_t;
using u64 = uint64_t;

int main() {

	u64 X;
	cin >> X;
	
	u64 ans = 0;
	
	if(X >= 500) {
		u64 t = X / 500;
		ans += t * 1000;
		X = X - t * 500;
	}
	if(X >= 5) {
		u64 t = X / 5;
		X = X - t * 5;
		ans += t * 5;
	}
	
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define lint long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD_Q 1e9 + 7
#define MOD_A 998244353

 #define int long long

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}


void solve()
{
 
  int N,L;
  cin>>N>>L;
  WeightedGraph<int> es(N);

  for (int i = 0; i < L; i++)
  {
    int A,B,C;
    cin>>A>>B>>C;
    A--;
    B--;
    es[A].emplace_back(A,B,C);
  }

  for (int i = 1; i < N - 1 ; i++)
  {
    es[i+1].emplace_back(i+1,i,0);
  }

  vector<int> path = dijkstra(es,0);

  if(path[N-1] == I64_MAX) cout<<-1<<endl;
  else if(path.empty()) cout<<-1<<endl;
  else
  {
    cout<<path[N-1]<<endl;
  }
  
  return;
}
 
int32_t main(int32_t argc, const char *argv[])
{
 
  solve();
 
  return 0;
}

Measured memory_bytes: 10620
K = int(input())
 
def f(n):
    return n / sum([int(s) for s in str(n)])

ans = [1]
for k in range(K - 1):
    min_f_val, next_snuke = float('inf'), None
    n = str(ans[-1] + 1)
    for i in range(len(n)):
        for x in range(int(n[i]), 10):
            X = n[:i] + str(x) + '9' * (len(n) - i - 1)
            f_val = f(int(X))
            if f_val < min_f_val:
                next_snuke = int(X)
                min_f_val = f_val
    ans.append(next_snuke)
print(*ans, sep='\n')

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

int main() {
  int x;
  cin >> x;
  int sum =0;
  while(x>=500){
    sum += 1000;
    x -= 500;
  }
  while(x>=5){
    sum += 5;
    x-= 5;
  }
  cout << sum << endl;
}

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

int main(){
    char c;
    cin >> c;
    if(c=='A'){
        cout << 'T' << endl;
    }else{
        if(c=='C'){
            cout << 'G' << endl;
        }else{
            if(c=='T'){
                cout << 'A' << endl;
            }else{
                cout << 'C' << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=100005;
int sz[N],n,a,b,c,rt,rt2;
vector<pii> e[N];
ll d[N];

void dfs(int u,int fa){
	int mx=0; sz[u]=1;
	for(auto v:e[u]){
		if(v.fi==fa) continue;
		dfs(v.fi,u);
		sz[u]+=sz[v.fi];
		mx=max(mx,sz[v.fi]);
	}
	mx=max(mx,n-sz[u]);
	if(mx*2<=n){
		if(!rt) rt=u;
		else rt2=u;
	}
}

void owo(int u,int fa){
	for(auto v:e[u]){
		if(v.fi==fa) continue;
		d[v.fi]=d[u]+v.se;
		owo(v.fi,u);
	}
}

void Case1(){
	owo(rt,0);
	ll ans=0,mn=1e9;
	rep(i,1,n) ans+=d[i]*2;
	for(auto v:e[rt]) mn=min(mn,d[v.fi]);
	cout<<ans-mn<<endl;
}

void Case2(){
	int len=0;
	for(auto v:e[rt])
		if(v.fi==rt2) len=v.se;
	owo(rt,rt2),owo(rt2,rt);
	ll ans=0;
	rep(i,1,n) ans+=d[i]*2;
	ans+=(ll)len*(n-1);
	cout<<ans<<endl;
}

int main(){
	read(n);
	rep(i,1,n-1){
		read(a),read(b),read(c);
		e[a].pb(mp(b,c));
		e[b].pb(mp(a,c));
	}
	dfs(1,0);
	if(!rt2) Case1();
	else Case2();
	return 0;
}

Measured memory_bytes: 13568
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int k = in.nextInt();
        long mn = 0;
        long mx = 0;
        for (int i = 0; i < k; ++i) {
            mn += i;
            mx += n - i;
        }
        long mod = 1_000_000_007;
        long ans = 0;
        for (int i = k; i <= n + 1; i++) {
            ans += mx - mn + 1;
            ans %= mod;
            mn += i;
            mx += n - i;
        }
        out.println(ans);
        out.close();
    }
}

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

char S[3][112];
int turn = 0, seek[3];

int main(void)
{
    scanf("%s%s%s", S[0], S[1], S[2]);

    while (true)
    {
        if (seek[turn] == strlen(S[turn]))
        {
            break;
        }
        ++seek[turn];
        switch (S[turn][seek[turn] - 1])
        {
        case 'a':
            turn = 0;
            break;

        case 'b':
            turn = 1;
            break;

        case 'c':
            turn = 2;
            break;
        }
    }

    switch (turn)
    {
    case 0:
        printf("A\n");
        break;

    case 1:
        printf("B\n");
        break;

    case 2:
        printf("C\n");
        break;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int a,p;
  cin >> a >> p;
  cout<< (a*3+p)/2 <<endl;
}


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

using namespace std;

int main()
{

    int w, h, n;

    cin >> w >> h >> n;

    int t = 0, d = h, l = 0, r = w;

    int x, y, a;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y >> a;
        switch (a)
        {
        case 1:
            l = max(l, x);
            break;
        case 2:
            r = min(r, x);
            break;
        case 3:
            t = max(t, y);
            break;
        case 4:
            d = min(d, y);
            break;
        }
    }

    cout << max(r - l, 0) * max(d - t, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const int INF = 0x3f3f3f3f;

int a[100001];

int mpow(int b, int e)
{
    int ret=1;
    for(int i=0; i<e; i++)
    {
        ret=ret*b%mod;
    }
    return ret;
}

int n, ma, mb;
int dp[401][401];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int a, b, c, ans=INF;
    cin >> n >> mb >> ma;
    for(int i=1; i<=400; i++)
    {
        for(int j=1; j<=400; j++)
            dp[i][j] = INF;
    }
    for(int i=0; i<n; i++)
    {
        cin >> a >> b >> c;
        for(int j=400-a; j; j--)
        {
            for(int k=400-b; k; k--)
            {
                dp[j+a][k+b]=min(dp[j+a][k+b], dp[j][k]+c);
            }
        }
        dp[a][b]=min(dp[a][b], c);
    }
    for(int i=1; i<=400; i++)
    {
        if((i*ma)%mb==0&&(i*ma)/mb<=400&&dp[i][(i*ma)/mb])
        {
            ans=min(ans, dp[i][(i*ma)/mb]);
        }
    }
    cout << ((ans==INF) ? -1 : ans);
}
//TODO: 54
//come back to 50D,


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
  static final char SEARCH_DONE = '.';
  static final int[] dx = { -1, 0, 1, 0 };
  static final int[] dy = { 0, 1, 0, -1 };
  static int h;
  static int w;
  static char[][] map;

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

    while (true) {
      h = sc.nextInt();
      w = sc.nextInt();
      if (h == 0 && w == 0) {
        break;
      }

      map = new char[h][];
      for (int i = 0; i < h; i++) {
        map[i] = sc.next().toCharArray();
      }

      int count = 0;
      for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
          char current = map[i][j];
          if (current != SEARCH_DONE) {
            depthFirstSearch(i, j, current);
            count++;
          }
        }
      }
      System.out.println(count);
    }
  }

  private static void depthFirstSearch(int y, int x, char target) {
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i];
      int ny = y + dy[i];

      if (nx < 0 || nx >= w || ny < 0 || ny >= h) {
        continue;
      }

      if (map[ny][nx] == target) {
        map[ny][nx] = SEARCH_DONE;
        depthFirstSearch(ny, nx, target);
      }
    }
  }
}

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

using namespace std;

typedef long long ll;

constexpr ll MOD = 998244353;

ll power(ll x, ll n){
    x %= MOD;
    ll res = 1;
    while(n > 0){
        if(n&1){
            res *= x;
            res %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return power(x, MOD-2);
}

int main(){
    ll n, k, a;
    cin >> n >> k >> a;
    vector<ll> dp(k+n+2,0);  // dp[i] = 得点iになる確率
    dp[0] = 1;
    for(int i=0;i<k;i++){
        ll p = dp[i] * mod_inv(n) % MOD;
        if(i>0) p *= a*mod_inv(100) % MOD;
        p %= MOD;
        dp[i+1] += p;
        dp[i+n+1] += MOD-p;
        if(i>0) dp[i+1] += dp[i];
        dp[i+1] %= MOD;
        dp[i+n+1] %= MOD;
    }
    ll ans = 0;
    for(int i=k;i<=k+n;i++){
        ans += dp[i];
        ans %= MOD;
        dp[i+1] = ((dp[i+1]+dp[i])%MOD+MOD)%MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4356
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
int n;
cin>>n;
char str[n];
cin>>str;
int ans=0;
for(int i=0;i<n;i++){
    int cnt=0;
    for(char c='a';c<='z';c++){
        bool left=false,right=false;
        for(int j=0;j<i;j++) if(str[j]==c) left=true;
        for(int j=i;j<n;j++) if(str[j]==c) right=true;
        if(left&&right) cnt++;
    }
    if(ans<cnt) ans=cnt;
}
cout<<ans;
return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))

for l in range(k):
    if a==[n]*n: 
        break
    imos = [0]*(n+1)
    for i in range(n):
        imos[max(0,i-a[i]) ]+=1
        imos[min(n-1,i+a[i])+1 ]-=1

    a=[0]*n
    a[0]=imos[0]
    for i in range(1,n):
        a[i] = a[i-1]+imos[i]

print(*a) 

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

using namespace std;
int grundy[100010];
int n, k;
vector<int> a;

void calc(){
    for(int i = 1; i <= k; i++){
        set<int> st;
        for(int j = 0; j < a.size(); j++){
            if(i - a[j] < 0) break;
            st.insert(grundy[i - a[j]]);
        }
        while(st.count(grundy[i]) > 0) grundy[i]++;
    }
}

int main(){
    cin >> n >> k;
    a = vector<int>(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(begin(a), end(a));
    calc();
    cout << (grundy[k] > 0? "First" : "Second") << endl;
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int [] line = Console.ReadLine().Trim().Split().Select(x => Int32.Parse(x)).ToArray();
            var A = line[0];
            var B = line[1];
            var C = line[2];
            var K = Int32.Parse(Console.ReadLine().Trim());

            if( A < B && B < C){
                Console.Write("Yes");
                return;
            }
            while ( K > 0 && A >= B ){
                B = B * 2;
                K--;
            }
            while ( K > 0 && B >= C){
                C = C * 2;
                K--;
            }
            Console.WriteLine( (A < B && B < C) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 19024
N = int(input())
A = input().split()

from collections import Counter
B=Counter(A)

ans=0
for c in B.values():
        ans+=c*(c-1)//2

for k in range(N):
    e=B[A[k]]
    ans_k=ans-e*(e-1)//2+(e-1)*(e-2)//2
    print(ans_k)

Measured memory_bytes: 26916
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).bigin(), (c).end())

typedef long long ll;
typedef long double ld;

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

int main()
{
    int t;
    ll a[310], b[310], c[310], d[310];

    cin >> t;
    REP(i, t)
    cin >> a[i] >> b[i] >> c[i] >> d[i];

    REP(i, t)
    {
        if (d[i] < b[i] || a[i] < b[i])
        {
            cout << "No" << endl;
            continue;
        }

        if (c[i] + 1 >= b[i])
        {
            cout << "Yes" << endl;
            continue;
        }

        ll g = gcd(b[i], d[i]);
        ll s = b[i] + a[i] % g - g;

        if (s > c[i])
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
'''
https://beta.atcoder.jp/contests/agc027/submissions/3202530
'''

N, X = map(int, input().split())
x = list(map(int, input().split()))

s = [0]  # 累積和
for i in range(N):
    s.append(s[-1] + x[i])

ans = float('inf')
for k in range(1, N + 1):
    cost = 0
    coef = 5
    coef_5_flg = True

    i = N
    while i > 0:
        if (i - k) < 0:
            cost += s[i] * coef
        else:
            cost += (s[i] - s[i - k]) * coef
        if coef_5_flg:
            coef_5_flg = False
        else:
            coef += 2
        if cost >= ans:
            break
        i -= k

    cost += (k + N) * X
    ans = min(ans, cost)

print(ans)

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

#define reb(i,b,n) for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n) reb(i,0,n)
#define rreb(i,b,n) for(int i = b-1; i >= n; i--)
#define rrep(i,n) reb(i,n,0)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v) for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vall(x) (x).begin(), (x).end()
#define rvall(x) (x).rbegin(), (x).rend()
#define vsort(v) sort(vall(v))
#define rvsort(v) sort(rvall(v))
#define len(array) (sizeof (array) / sizeof *(array))
#define aall(x) x, x+len(x)
#define asort(x) sort(aall(x))
#define rasort(a, type) sort(aall(a), greater<type>())
#define afill(a, v) fill(aall(a), v)
#define afill2(a, v, type) fill((type *)a, (type *)(a + len(a)), v)
#define sz(x) (int)(x).size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pb push_back
#define _USE_MATH_DEFINES
#define priArr(table, n) rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define priAr2(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;

using namespace std;
using std::stringstream;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class F, class T> inline void convert(const F &f, T &t){stringstream ss;ss<<f;ss>>t;}
template<class T> inline T sqr(T x) {return x*x;}

typedef long long ll; typedef unsigned long long ull;
typedef pair <int, int> P; typedef pair <int, P> PP;
typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<string> vs;
typedef vector<ll> vl; typedef vector<P > vP; typedef vector<char> vc;
typedef long double ld;

const static int INF = 0x3f3f3f3f;
const static ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const static double EPS = 1e-9;
const static ll MOD = 1000000007LL;

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

int main(int argc, char *argv[])
{
    ll N;
    cin >> N;
    string s;
    set<string> st;

    rep(i, N) {
        cin >> s;
        st.insert(s);
    }

    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 19180
//      0007	Debt Hell
//      2018.3.20

#include <stdio.h>
#include <math.h>

int
main (void)
{
  int n, i;
  int hensaigaku = 100000;
  double temp;

  scanf ("%d\n", &n);
  for(i = 1; i <= n; i++){
    temp = (double)hensaigaku * 1.05;
    hensaigaku = (int)(ceil(temp / 1000) * 1000);
  }
  
  printf ("%d\n", hensaigaku);
  
  return 0;
}



Measured memory_bytes: 1960
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <sstream>

using namespace std;
using ll = long long;
typedef long long ll;


int main() {
    int n;
    cin >> n;
    vector< vector<char> > v;
    v.push_back(vector<char>{'a'});

    while (n > 1) {
        vector< vector<char> > vv;
        for (const auto &chars : v) {
            char var = set<char>(chars.begin(), chars.end()).size();
            for (char i = 0; i < var + 1; i++) {
                vector<char> cc(chars);
                cc.push_back('a' + i);
                vv.push_back(cc);
            }
        }
        v = vv;

        n--;
    }

    for (const auto &chars : v) {
        string str;
        for (const auto &c : chars) {
            str += c;
        }
        cout << str << '\n';
    }

    return 0;
}


Measured memory_bytes: 12980
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

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


    return 0;
}

Measured memory_bytes: 3616
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] a = sc.nextLine().split(" ");
		// num of way
		int N = Integer.parseInt(a[0]);
		// limit
		int T = Integer.parseInt(a[1]);

		Map<Integer, Integer> map = new HashMap<>();
		//ways
		for (int i = 0; i < N; i++) {
			String[] tmp = sc.nextLine().split(" ");
			map.put(Integer.parseInt(tmp[0]), Integer.parseInt(tmp[1]));
		}

		ArrayList<Integer> b = new ArrayList<Integer>();
		for (Entry<Integer, Integer> entry : map.entrySet()) {
			if (entry.getValue() <= T) {
				b.add(entry.getKey());
			}
		}
		Collections.sort(b);

		if (b.isEmpty()) {
			System.out.println("TLE");
		} else {
			System.out.println(b.get(0));
		}

		sc.close();
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  LL a, b;
  cin>>a>>b;
  if(a==b){
    cout<<a<<endl;
    return 0;
  }
  --a;
  LL ansa=0, ansb=0;
  LL work, bit=1;
  while(bit<=a){
    work = a/(2*bit) * bit + max(a%(bit*2) - bit + 1, (LL)0);
    if(work%2==1) ansa += bit;
    bit*=2;
    //cout<<work<<" "<<ansa<<endl;
  }
  bit=1;
  while(bit<=b){
    work = b/(2*bit) * bit + max(b%(bit*2) - bit + 1, (LL)0);
    if(work%2==1) ansb += bit;
    bit*=2;
    //cout<<work<<" "<<ansb<<endl;
  }
  LL ans=ansa^ansb;
  //cout<<ansa<<" "<<ansb<<endl;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {
    static boolean arr[];

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int freq[] = new int[28];
        String word = s.next();
        for(int i=0;i<word.length();i++)freq[word.charAt(i)-'a']++;
        boolean flag = true;
        for(int i=0;i<28;i++)if(freq[i]%2==1)flag=false;
        System.out.println(flag?"Yes":"No");


    }


}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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

int main(void){
    int n;
    cin >> n;
    for(int i=0; i<3; i++){
        if((n/(int)pow(10, i))%10 == 1) n += 8*pow(10, i);
        else n -= 8*pow(10, i);
    }
    cout << n << endl;
}

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

int main() {
    int n,count=0;
    cin>>n;

    while (n >= 1) {
        if ((1 <= n && n <= 9) || (100 <= n && n < 1000) || (10000 <= n && n < 100000)) {
            count++;
        }
        n--;
    }
    cout<<count<<endl;
}


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

int main(){
	string s;
	cin>>s;
	
	
	string ans="AC";
	
	while(1){
		if(s[0]!='A'){
			ans="WA";
			break;
		}
		
		int cut=0;
		int point;
		for(int i=2;i<=s.size()-2;i++){
			if(s[i]=='C'){
				cut++;
				point=i;
			}
		}
		if(cut!=1){
			ans="WA";
			break;
		}
		
		for(int i=1;i<s.size();i++){
			if(i==point) continue;
			
			if(!('a'<=s[i]&&s[i]<='z')){
				ans="WA";
				break;
			}
		}
		
		break;
	}
	
	
	cout<<ans<<endl;
	
	
	return 0;
}		

Measured memory_bytes: 256
function partition(a,p,r){
    var x = a[r];
    var i = p - 1;
    for(var j = p;j < r;j++){
        if(a[j] <= x){
            i++;
            var b = a[i];
            a[i] = a[j];
            a[j] = b;
        }
    }
    b = a[i + 1];
    a[i + 1] = a[r];
    a[r] = b;
    return i + 1;
}

function Main(input){
    input = input.split("\n");
    var n = parseInt(input[0],10);
    input[1] = input[1].split(" ");
    var a = new Array(n);
    for(var i = 0;i < n;i++){
        a[i] = parseInt(input[1][i],10);
    }

    var j = partition(a,0,n - 1);

    for(var i = 0;i < n;i++)
        String(a[i]);
    var ans = a[0];
    for(var i = 1;i < n;i++){
        if(i == j)
            ans += " " + "[" + a[i] + "]";
        else
            ans += " " + a[i];
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

bool func(int x){
    int cnt=0;
    for(int i=1;i<=x;i++){
        if(x%i==0) cnt++;
    }
    if(cnt==8) return true;
    else return false;
}
int main(){
    int n;
    cin >> n;
    int ans=0;
    for(int i=1;i<=n;i+=2){
        if(func(i)) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;

void A() {
  char f, s, t;
  scanf("%c%c%c", &f, &s, &t);
  if (f == 'R' && s == 'R' && t == 'R') {
    printf("3");
  } else if (f == 'R' && s == 'R' || s == 'R' && t == 'R') {
    printf("2");
  } else if (f == 'R' || s == 'R' || t == 'R') {
    printf("1");
  } else {
    printf("0");
  }
  printf("\n");
}

void B() {
  int n;
  int sticks[100 + 2];
  scanf("%d", &n);
  for (auto i = 0; i < n; ++i) scanf("%d", &sticks[i]);
  ll triples = 0;
  for (auto i = 0; i < n; ++i) {
    for (auto j = i + 1; j < n; ++j) {
      if (sticks[i] == sticks[j]) continue;
      for (auto k = j + 1; k < n; ++k) {
        if (sticks[i] != sticks[k] && sticks[j] != sticks[k] &&
            sticks[i] + sticks[j] > sticks[k] &&
            sticks[i] + sticks[k] > sticks[j] &&
            sticks[j] + sticks[k] > sticks[i]) {
          ++triples;
        }
      }
    }
  }
  printf("%lld\n", triples);
}

void C() {
  ll x, k, d;
  scanf("%lld%lld%lld", &x, &k, &d);
  x = abs(x);
  ll applications = x / d;
  if (applications >= k) {
    x -= d * k;
    printf("%lld\n", abs(x));
  } else {
    x = x % d;
    ll rem_steps = (k - applications) % 2;
    printf("%lld\n", abs(min(x + d * rem_steps, x - d * rem_steps)));
  }
}

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


Measured memory_bytes: 3824
n, X = list(map(int, input().split()))
x = list(map(int, input().split()))
x.append(X)
x.sort()
s = [0 for i in range(n)]
for i in range(n):
  s[i] = x[i+1]-x[i]

def gcd(a, b):
  return gcd(b, a%b) if b else a

ans = s[0]
for i in range(n):
  ans = gcd(ans, s[i])
print(ans)

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

int main()
{
  int a;

  cin >> a;
  vector<int> vec(4);
  for (int i = 0; i < 4; i++)
  {
    vec.at(i) = (a / (int)pow(10, i)) % 10;
  }
  int flag = 0;
  for (int i = 0; i < 3; i++)
  {
    
    if (vec.at(i) == vec.at(i + 1))
    {
      flag = 1;
      
    }
  }
  if (flag)
  {
    cout << "Bad" << endl;
  }
  else
  {
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 512
N = int(input())
a = list(map(int, input().split()))
ans = [0 for i in range(N)]
ans2 = []
for i in range(N):
    p = N - 1 - i
    if a[p] != sum(ans[p::p + 1]) % 2:
        ans[p] = 1
        ans2.append(str(p + 1))
print(sum(ans))
print(" ".join(ans2))

Measured memory_bytes: 17204