akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <list>
#define forn(n) for(int i=0; i<n; i++)
#define ll long long
#define ull unsigned long long
#include <stack>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#define pi 3.14159265
#define MAX 1e7
#define fijar(n) cout<<fixed<<setprecision(n);

//const int modulo = 1e6
//const double EPSILON=0.0000000001;
//const bool Is_Triangle = a+b>c && a+c>b && b+c>a;
//Semiperimetro_triangulo s=(a+b+c)/2.0;
//#define area_triangle sqrt(s*((s-a)*(s-b)*(s-c))))

using namespace std;
int main(int argc, char *argv[])
{
	ios_base::sync_with_stdio(false); 
    cin.tie(0); 
	list<int> l;
	string op;
    int n,input,k;
    cin>>n;
    while(n--){
    	cin>>op;
    	if(op=="insert"){
    		cin>>input;
    		l.emplace_front(input);
    	}else if(op=="delete"){
    		cin>>input;
    		  for(list<int>::iterator it=l.begin(); it!=l.end(); it++){
    		 	if(*it==input){
    		 		l.erase(it);
    		 		 break;
    		 	}
    		 }
    	}else if(op=="deleteFirst")
    		l.pop_front();
    	else
    		l.pop_back();
    }
    k=0;
    for(list<int>::iterator it=l.begin(); it!=l.end(); it++){
    	if(k) cout<<" ";
    	cout<<*it;
    	k++;
    }
    cout<<"\n";
    
	return 0;
}


Measured memory_bytes: 34468
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int a, b;
    cin >> a >> b;
    cout << ((a + b < 10) ? to_string(a + b) : "error") << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAX 100000
using namespace std;

int A[MAX],n;


int partition(int p,int r){
	int x,i,j,t;
	x=A[r];
	i=p-1;
	for ( j = p; j < r; ++j) {
		if(A[j]<=x){
			i++;
			swap(A[i],A[j]);
		}
	}
	swap(A[i+1],A[r]);
	return i+1;
}
int main()
{int i,q;
scanf("%d",&n);
for (int i = 0; i < n; ++i) {
	scanf("%d",&A[i]);
}
q=partition(0,n-1);
for (int i = 0; i < n; ++i) {
	if(i)printf(" ");
	if(i==q)printf("[");
	printf("%d",A[i]);
	if(i==q)printf("]");
}
printf("\n");

return 0;
}

Measured memory_bytes: 3552
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int3(int *a1, int *a2, int *a3) {
  scanf("%d %d %d", a1, a2, a3);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 2000
// 2048
#define INF ((1e+9)+1)

enum type {
    TURN_X,
    TURN_Y,
};

int main(void) {
    int num, xscore, yscore;
    get_int3(&num, &xscore, &yscore);
    static int arr[NUM_MAX];
    fget_array(arr, num);
    int ans = 0;
    if(num == 1) {
        ans = abs(arr[num-1]-yscore);
    } else {
        ans = max(abs(arr[num-1]-yscore), abs(arr[num-2]-arr[num-1]));
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
def calcPairOddAndEven(num):
    if num % 2 == 0:
        return int((num / 2))**2
    else:
        return int(num / 2)*int(num / 2 + 1)


def main():
    numArray = [3, 6, 11, 50]
    for num in numArray:
        print(num, ":", calcPairOddAndEven(num))


def contest():
    print(calcPairOddAndEven(int(input())))

if __name__ == '__main__':
    contest()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n - 1));
    rep(i, n) {
        rep(j, n - 1) {
            cin >> a[i][j];
            --a[i][j];
        }
        reverse(a[i].begin(), a[i].end());
    }

    vector<pair<int, int>> q;
    auto check = [&](int i) {
        if (a[i].size() == 0) return;
        int j = a[i].back();
        if (a[j].size() == 0) return;
        if (a[j].back() == i) {
            pair<int, int> p(i, j);
            if (p.second < p.first) swap(p.first, p.second);
            q.push_back(p);
        }
    };
    rep(i, n) {
        check(i);
    }
    int day = 0;
    while(q.size() > 0) {
        day++;
        sort(q.begin(), q.end());
        q.erase(unique(q.begin(), q.end()), q.end());
        vector<pair<int, int>> prevQ;
        swap(prevQ, q);
        for (pair<int, int> p : prevQ) {
            int i = p.first;
            int j = p.second;
            a[i].pop_back();
            a[j].pop_back();
        }
        for (pair<int, int> p : prevQ) {
            int i = p.first;
            int j = p.second;
            check(i);
            check(j);
        }
    }

    rep(i, n) {
        if (a[i].size() != 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << day << endl;

    return 0;
}

Measured memory_bytes: 4224
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
using namespace std;
#define int long long
int canv[10000];
int cans[10000];
signed main() {

	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	canv[0] = 1;
	cans[0] = 1;
	int ansf = -1, anss = -1;
	for (int i = 0; i <= f; ++i) {
		canv[i + a * 100] |= canv[i];
	}
	for (int i = 0; i <= f; ++i) {
		canv[i + b * 100] |= canv[i];
	}
	for (int i = 0; i <= f; ++i) {
		cans[i + c] |= cans[i];
	}
	for (int i = 0; i <= f; ++i) {
		cans[i + d] |= cans[i];
	}
	for (int i = 1; i <= f; ++i) {
		for (int j = 0; j <= f; ++j) {
			if (!canv[i] || !cans[j] || i + j > f) continue;
			if (j * (e + 100) > e * (i + j)) continue;
			if (ansf == -1 || j * ansf > (i + j) * anss) {
				ansf = i + j;
				anss = j;
			}
		}
	}
	cout << ansf << ' ' << anss << endl;
}

Measured memory_bytes: 256
m = gets.to_i
numbers = Array.new
m.times do
  numbers << gets.split.map(&:to_i)
end
digit = numbers.inject(0) { |res, num| res + num[1] }
sum = numbers.inject(0) { |res, num| res + num[0] * num[1] }
count = (sum - 1) / 9
puts digit - 1 + count


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MOD 2019
i64 L, R;


i64 solve() {
  if (R - L >= MOD) {
    return 0;
  }

  i64 minv = 100000;
  for (i64 l = L % MOD; l < R % MOD; l = (l + 1) % MOD) {
    for (i64 r = (l + 1) % MOD; r <= R % MOD; r = (r + 1) % MOD) {
      i64 v = (l * r) % MOD;
      if (v < minv) {
        minv = v;
      }
      if (v == 0) return minv;
    }
  }

  return minv;
}


int main() {
  cin >> L >> R;
  assert(L < R);

  i64 minv = solve();
  cout << minv << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

bool c[1000001];

int main(){
    int x;
    cin >> x;
    for(int i=1;i<=x;i++){
        int t=i*i;
        while(t<=x&&!c[t]){
            c[t]=true;
            t*=i;
        }
    }
    for(int i=x;i>=0;i--){
        if(c[i]){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define M 2005
#define N 200005
#define mo 1000000007
#define inv2 500000004
using namespace std;
int n,a[N],b[N],maxa,maxb,dp[M<<1][M<<1],fac[N],inv[N],ans;
bool vis[M<<1][M<<1];
int DP(int x,int y)
{
    if (x<-maxa||y<-maxb) return 0;
    if (vis[x+M][y+M]) return dp[x+M][y+M];
    vis[x+M][y+M]=1;
    return dp[x+M][y+M]=(dp[x+M][y+M]+DP(x,y-1)+DP(x-1,y))%mo;
}
void pre(int m)
{
    fac[0]=1;
    for (int i=1;i<=m;i++) fac[i]=(ll)fac[i-1]*i%mo;
    inv[1]=1;
    for (int i=2;i<=m;i++) inv[i]=(ll)(mo-mo/i)*inv[mo%i]%mo;
    inv[0]=1;
    for (int i=1;i<=m;i++) inv[i]=(ll)inv[i]*inv[i-1]%mo;
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        maxa=max(maxa,a[i]);
        maxb=max(maxb,b[i]);
        dp[-a[i]+M][-b[i]+M]++;
    }
    pre(maxa+maxb<<1);
    for (int i=1;i<=n;i++) ans=(ans+DP(a[i],b[i]))%mo;
    for (int i=1;i<=n;i++)
    ans=(ans-(ll)fac[a[i]+b[i]<<1]*inv[a[i]<<1]%mo*inv[b[i]<<1]%mo+mo)%mo;
    printf("%d",(ll)ans*inv2%mo);
    return 0;
}

Measured memory_bytes: 82176
#include<bits/stdc++.h>
#define ls rt<<1
#define rs rt<<1|1
#define lson rt<<1,l,M
#define rson rt<<1|1,M+1,r
#define PI acos(-1)
#define MM int M=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define fh(i,be,e) for(int i=head[be];~i;i=e[i].next)
#define fa(i,V) for(auto i:V)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
#define umap unordered_map
#define P pair<int,int>
#define SET set<int>
#define mp map<int,int>
#define mk make_tuple
#define low lower_bound
#define upp upper_bound
#define yn(key) out(key?"YES":"NO")
#define in(i) i+1,i+1+n
#define im(i) i+1,i+1+m
#define bffs(i) __builtin_ffs(i)
#define bcount(i) __builtin_popcount(i)
#define bone(i) ((1<<i)-1)
#define got(container,num) get<num-1>(container)
using namespace std;
const int INF=LLONG_MAX/2;
const int dx[]={0,0,-1,1},dy[]={-1,1,0,0};//up down left right
const int maxn=1e6+1e5;
const int mo_num=1e9+7;
int n,m,t,a[maxn],b[maxn],ans;

main()
{
    IOS
    cin>>m>>n;
    fun(i){
        int x;
        cin>>x;
        a[x]=1;
    }
    int num=INF;
    fd(i,101,0)
    {
        if(!a[i])
        {
            if(num>=abs(i-m)){
                num=abs(i-m);
                ans=i;
            }
        }
    }
    out(ans)
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  string n; cin >> n;
  int cnt = 0;
  rep(i,n.size()){
    cnt += n[i]-'0';
    cnt %= 9;
  }
  if(cnt == 0) cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 3736
#include<iostream>
using namespace std;
int a[200000];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
int min=a[0];
int maxn=a[1]-a[0];
for(int j=1;j<n;j++)
{
    if(a[j]-min>maxn)
        maxn=a[j]-min;
    if(a[j]<min)
        min=a[j];
}
cout<<maxn<<endl;

}

Measured memory_bytes: 3868
#include<iostream>
#include<string>
using namespace std;
const string hr = "HOMERUN";
const string h = "HIT";
const string o = "OUT";
int main() {
	int n;
	cin >> n;
	int point[100];
	for (int j = 0; j < n; j++){
		string s;
		int bs = 0, p = 0;
		for (int i = 0; i < 3;){
			cin >> s;
			if (s == o)i++;
			else if (s == h){
				if (bs == 3)p += 1;
				else bs += 1;
			}
			else if (s == hr){
				p += bs + 1;
				bs = 0;
			}
		}
		point[j] = p;
	}
	for (int i = 0; i < n; i++){
		cout << point[i] << endl;
	}
	char c;
	cin >> c;
	return 0;
}

Measured memory_bytes: 3068
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] s = in.next().toCharArray();
            StringBuilder sb = new StringBuilder();
            for (int i = 1; i < s.length + 1; i++) {
                if (i % 2 == 1) {
                    sb.append(s[i - 1]);
                }
            }
            out.println(sb);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (this.numChars == -1) {
                throw new InputMismatchException();
            } else {
                if (this.curChar >= this.numChars) {
                    this.curChar = 0;

                    try {
                        this.numChars = this.stream.read(this.buf);
                    } catch (IOException ex) {
                        throw new InputMismatchException();
                    }

                    if (this.numChars <= 0) {
                        return -1;
                    }
                }

                return this.buf[this.curChar++];
            }
        }

        public String next() {
            int c;
            while (isSpaceChar(c = this.read())) {
                ;
            }

            StringBuilder result = new StringBuilder();
            result.appendCodePoint(c);

            while (!isSpaceChar(c = this.read())) {
                result.appendCodePoint(c);
            }

            return result.toString();
        }

        public static boolean isSpaceChar(int c) {
            return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
        }

    }
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793


   
int main(){
  int n;
  cin >> n;
  vector<ll> t(n);
  rep(i,n){
    cin >> t.at(i);
  }
  sort(t.begin(),t.end());
  rep(i,n-1){
    for(int j=i+1;j<n;j++){
      if(t.at(j)%t.at(i)==0){
        t.at(i)=1;
        break;
      }
    }
  }
  ll ans=1;
  rep(i,n){
     ans=ans/__gcd(ans,t.at(i))*t.at(i);
  }
  cout << ans << endl;
}

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

using namespace std;
int a[100010];
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a + n);
	int j = n - 1,k = 1;
	while(j>0 && a[j - 1]>=k + 1){
		j--; k++;
	}
	int x = a[j] - k + 1,y = 1;
	for(i=j-1;i>=0;i--){
		if(a[i]==k) y++;
	}
	if(x&1 && y&1){
		cout << "Second" << endl;
	}else{
		cout << "First" << endl;
	}
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    ll x;
    cin >> x;
    ll y=0;
    for(int a=0;a<1000;a++){
        for(int b=-999;b<1000;b++){
            y=pow(a,5)-pow(b,5);
            if(x==y){
                cout<<a<<' '<<b<<endl;
                return 0;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 4076
import numpy

n,d = map(int, input().split())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
count = 0
#print(x) [0, -2, 3, 4]
#print(y) [5, 4, 4, -4]

for i in range(n):
  if numpy.sqrt(x[i]**2+y[i]**2) <= d:
    count += 1
  else:
    count += 0
print(count)

Measured memory_bytes: 134384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MOD 1000000007LL

long long dp[410][410]={{0}};
long long prod[410][410]={{0}};

int main() {
	int C, i, j, k, N;
	int A[410], B[410];
	long long p;
	scanf("%d%d", &N, &C);
	for (i=0;i<N;i++) {
		scanf("%d", &A[i]);
	}
	for (i=0;i<N;i++) {
		scanf("%d", &B[i]);
	}

	for (i=0;i<N;i++) {
		for (j=A[i];j<=B[i];j++) {
			p = 1;
			for (k=0;k<=C;k++) {
				prod[i][k] = (prod[i][k] + p) % MOD;
				p = (p*j) % MOD;
			}
		}
	}
	
	dp[0][0] = 1;
	for(i=0;i<N;i++) {
		for (j=0;j<=C;j++) {
			for (k=0;k<=j;k++) {
				dp[i+1][j] = (dp[i+1][j] + dp[i][j-k]*prod[i][k]) % MOD;
			}
		}
	}

	printf("%lld\n", dp[N][C]);

	return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

int main(){

    string s,t;    
    cin >>s>>t;
    int a,b;
    cin >>a>>b;    
    string u;
    cin >> u;

    if(s==u){
        a--;
    }else{
        b--;
    }

    cout << a<<" "<<b;


    return 0;
}

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

int main() {
	double a, b, d, r, f;
	cin >> a >> b;
	d = (a - ((int)a % (int)b)) / b;
	r = (int)a % (int)b;
	f = a / b;
	cout << (int)d << " " << (int)r << " " << flush;
	cout << fixed << setprecision(5) << f << endl;
	return 0;
}

Measured memory_bytes: 3284
import sys
from collections import Counter
readline = sys.stdin.readline

class UF():
    def __init__(self, num):
        self.par = [-1]*num
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            stack = []
            while self.par[x] >= 0:
                stack.append(x)
                x = self.par[x]
            for xi in stack:
                self.par[xi] = x
            return x
    
    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx != ry:
            if self.par[rx] > self.par[ry]:
                rx, ry = ry, rx
            self.par[rx] += self.par[ry]
            self.par[ry] = rx
            return True
        else:
            return False


N, M = map(int, readline().split())

AB = [tuple(map(int, readline().split())) for _ in range(N)]
AB.sort()

A, B = map(list, zip(*AB))
Sw = [0]*N
push = 0

for i in range(N):
    Sw[i] = B[i]^push
    push ^= Sw[i]

Code = Counter()
Edge = []
for m in range(M):
    l, r = map(int, readline().split())
    r += 1
    
    ng = -1
    ok = N
    while abs(ok-ng) > 1:
        med = (ok+ng)//2
        if l <= A[med]:
            ok = med
        else:
            ng = med
    
    L = ok
    
    ng = -1
    ok = N
    while abs(ok-ng) > 1:
        med = (ok+ng)//2
        if r <= A[med]:
            ok = med
        else:
            ng = med
    
    R = ok
    if L == R:
        continue
    if L == N or R == 0:
        continue
    if (L, R) in Code:
        continue
    Edge.append((L, R))
    Code[(L, R)] = m+1
    Code[(R, L)] = m+1
    
UE = [[] for _ in range(N+1)]

T = UF(N+1)

for l, r in Edge:
    if T.union(l, r):
        UE[l].append(r)
        UE[r].append(l)

seen = set()
stack = []

for i in range(N, -1, -1):
    ri = T.find(i)
    if ri not in seen:
        stack.append(i)
        seen.add(ri)
        

used = set(stack)
Lord = []
par = [-1]*(N+1)
while stack:
    vn = stack.pop()
    Lord.append(vn)
    for vf in UE[vn]:
        if vf not in used:
            used.add(vf)
            stack.append(vf)
            par[vf] = vn
Col = Sw[:] + [0]
anse = []

for l in Lord[::-1]:
    p = par[l]
    if p == -1:
        continue
    if Col[l]:
        Col[l] = 0
        Col[p] ^= 1
        anse.append(Code[(l, p)])


if any(Col[:-1]):
    print(-1)

else:
    anse.sort()
    print(len(anse))
    print(*anse)

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

#define FOR(i,a,b)  for(int i = a; i < b; ++i)
#define FORR(i,a,b) for(int i = a; i <= b; ++i)
//#define LOCAL_DEFINE
using namespace std;

#define maxn 1234
double dist[maxn];
map<string, int>mp;
struct Edge {
    int src, dest;
    double weight;
};

struct Graph {
    int V, E;
    struct Edge* edge;
};

struct Graph* createGraph(int V, int E){
    struct Graph* graph = new Graph;
    graph->V = V;
    graph->E = E;
    graph->edge = new Edge[E];
    return graph;
};

bool flag;

bool BellmanFord(Graph* graph, int src){
    for (int i = 0; i <= graph->V - 1; ++i) {
        for (int j = 0; j < graph->E; ++j) {
            if(dist[graph->edge[j].src] * graph->edge[j].weight > dist[graph->edge[j].dest])
            dist[graph->edge[j].dest] = dist[graph->edge[j].src] * graph->edge[j].weight;
        }
    }
    for (int j = 0; j < graph->E; ++j) {
        if(dist[graph->edge[j].src] * graph->edge[j].weight > dist[graph->edge[j].dest])
            //cout << "exist negative weight cycle" <<endl;
            return true;
    }
    return false;
}

char uppper(char c){
    if(c >= 'a' && c <= 'z')return c - 'a' + 'A';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //cin.precision(10);
    //cout << fixed;g

#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif
    string a, b, c;
    cin>>a>>b>>c;
    string s = "";
    s += uppper(a[0]);
    s += uppper(b[0]);
    s += uppper(c[0]);
    cout << s << '\n';

    return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    ll max_number = 55555;
    vector<bool> era(max_number+1, true);
    era.at(0) = false;  era.at(1) = false;
    for(i = 2;i <= max_number;++i){
        if(era.at(i)){
            for(j = 2*i;j <= max_number;j += i){
                era.at(j) = false;
            }
        }
    }
    ll num = 0;
    ll now = 1;
    while(num < n){
        if(era.at(now) && (now%5 == 1)){
            cout << now << endl;
            ++num;
        }
        ++now;
    }
    return 0;
}

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

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  writeln(s[0] == s[2] ? "Yes" : "No");
}


Measured memory_bytes: 256
program main
  implicit none
  integer(8) :: n, i, blacks, res
  character(200000) :: s
  read (*, *) s
  n = len(trim(s))
  res = 0
  blacks = 0
  do i = 1, n
    if (s(i:i) == "B") then
      blacks = blacks + 1
    else
      res = res + blacks
    end if
  end do
  write (*, "(i0)") res
end program main


Measured memory_bytes: 1084
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <map>
using namespace std; typedef long long ll; const int INF=1e9;
typedef pair<int,int> P;

int main() {
  int n; cin>>n;
  ll a[n]; for(int i=0;i<n;i++) cin>>a[i];
  ll an=0; map<ll,ll> mp; mp[0]=1;
  ll sm=0;
  for(int i=0;i<n;i++) {
    sm += a[i];
    an += mp[sm]; mp[sm]++;
    //for(P x:mp) cout<<"("<<x.first<<","<<x.second<<") "; cout<<endl;
  }
  cout<<an<<endl;
}

Measured memory_bytes: 14336
from itertools import accumulate
def resolve():
    def ev(x):
        return (x*(x+1)//2)/x

    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    E = [0]+[ev(a) for a in A]
    E = list(accumulate(E))
    ans = 0
    for i in range(N-K+1):
        if ans < E[i+K] - E[i]:
            ans = E[i + K] - E[i]
    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 34124
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def check1(I, J, L):
    res = 0
    res += I - I%2
    res += J - J%2
    res += L - L%2
    return res

def check2(I, J, L):
    res = 0
    if I > 0 and J > 0 and L > 0:
        res += 3
        I -= 1
        J -= 1
        L -= 1
    res += I - I%2
    res += J - J%2
    res += L - L%2
    return res

I, O, T, J, L, S, Z = MAP()

ans = O
ans += max(check1(I, J, L), check2(I, J, L))
print(ans)


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N, K, Q;
	
	cin >> N >> K >> Q;
	
	int A[Q];
	int count[N] = {};
	
	rep(i, Q){
		cin >> A[i];
		A[i]--;
		count[A[i]]++;
	}
	
	rep(i, N){
		if(K - (Q - count[i]) > 0){
			cout << "Yes" << endl;
		}else
			cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1408
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/4;
    public static final int inf = Integer.MAX_VALUE/4;

    static void solve(InputReader in, PrintWriter out){
        String s = in.ns();
        long k = in.nl();
        if(s.charAt(0)=='1'){
            int count = 0;
            char ans = '1';
            for (int j = 0; j < s.length(); j++) {
                if(s.charAt(j)=='1') count++;
                else {
                    ans = s.charAt(j);
                    break;
                }
            }
            if(count<k)out.println(ans);
            else out.println('1');
        }else{
            out.println(s.charAt(0));
        }
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <cstdlib>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <string>

using namespace std;
const long long MOD = 1e9+7;

long long fp(long long base, long long n){
    long long ret = 1;
    for(long long i = 0; i < n; i++){
        ret = ret * base % MOD;
    }
    return ret;
}

int main()
{
    long long n;
    cin >> n;
    long long ans = (fp(10, n) - fp(9, n) - fp(9, n) + fp(8, n)) % MOD;
    ans += MOD;
    ans %= MOD;
    cout << ans << endl;
}

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

ll N;
ll memo[90] = {0};

ll Luca(ll N) {
    if (N == 0) {
        return 2;
    }else if (N == 1) {
        return 1;
    }else{
        if (memo[N] == 0) {
            ll num = Luca(N-1) + Luca(N-2);
            memo[N] = num;
            return num;
        }else{
            return memo[N];
        }
    }
}

int main() {
    cin >> N;
    ll ans = Luca(N);
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	x := -1
	h := -1
	for {
		fmt.Scan(&x)
		fmt.Scan(&h)
		if x == 0 && h == 0 {
			return
		}

		f_x := float64(x) / 2.0

		sya := math.Sqrt(f_x*f_x + float64(h*h))
		fmt.Println(float64(x*x) + float64(x)*sya*2.0)

	}
}



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

const int N = 100005;

int n, m;
vector<int> L[N], R[N];
int cnt[N], ans[N];
int d[N];
vector<int> dvs[N];
int T[N];

void prepare() {
	d[0] = d[1] = 1;
	for (int i = 2; i <= m; ++i) if (!d[i]) {
		for (int j = i; j <= m; j += i) d[j] = i;
	}

	for (int i = 1; i <= m; ++i) {
		dvs[i].push_back(1);
		int tmp = i;
		while(tmp > 1) {
			int x = d[tmp], c = 0;
			while(tmp % x == 0) tmp /= x, ++c;

			int pw = 1, sz = dvs[i].size();
			for (int j = 1; j <= c; ++j) {
				pw *= x;
				for (int k = 0; k < sz; ++k) {
					dvs[i].push_back(dvs[i][k] * pw);
				}
			}
		}
	}
}

void upd(int x, int v) { for (; x <= m; x += x & -x) T[x] += v; }
int get(int x) { int res = 0; for (; x > 0; x -= x & -x) res += T[x]; return res; }

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		int l, r; cin >> l >> r; ++r;
		L[l].push_back(r - l);
		R[r].push_back(r - l);
		cnt[r - l]++;
	}
	prepare();
	
	for (int i = 1; i <= m; ++i) {
		for (int j : L[i]) upd(j, +1);
		for (int j : R[i]) upd(j, -1);
		for (int j : dvs[i]) {
			ans[j] += get(j - 1);
		}
	}

	for (int i = m; i >= 1; --i) {
		cnt[i] += cnt[i+1];
		ans[i] += cnt[i];
	}

	for (int i = 1; i <= m; ++i) printf("%d\n", ans[i]);
}

Measured memory_bytes: 21760
package main

import (
	"fmt"
)

func main() {
	var N, K int

	fmt.Scanf("%d %d\n", &N, &K)
	if N%K == 0 {
		fmt.Println(0)
		return
	}
	x1 := N % K
	x2 := x1 - K
	if x2 < 0 {
		x2 = -x2
	}

	if x1 > x2 {
		fmt.Println(x2)
	} else {
		fmt.Println(x1)
	}
}


Measured memory_bytes: 512
# AOJ 1156: Twirling Robot
# Python3 2018.7.15 bal4u

mv = [[-1,0,],[0,1],[1,0],[0,-1]]

INF = 0x7fffffff
import heapq
def dijkstra(h, w, cost):
	Q = []
	node = [[[INF for d in range(4)] for c in range(w)] for r in range(h)]
	node[0][0][1] = 0
	heapq.heappush(Q, (0, 0, 0, 1))
	while Q:
		t, r, c, d = heapq.heappop(Q)
		if r == h-1 and c == w-1: break
		for i in range(4):
			nd = (d+i)%4
			nr, nc = r + mv[nd][0], c + mv[nd][1]
			if nr < 0 or nr >= h or nc < 0 or nc >= w: continue
			nt = node[r][c][d]
			if arr[r][c] != i: nt += cost[i]
			if nt < node[nr][nc][nd]:
				node[nr][nc][nd] = nt
				heapq.heappush(Q, (nt, nr, nc, nd))
	return node[h-1][w-1][d]
	
while True:
	w, h = map(int, input().split())
	if w == 0: break
	arr = [[] for r in range(h)]
	for r in range(h): arr[r] = list(map(int, input().split()))
	cost = list(map(int, input().split()))
	print(dijkstra(h, w, cost))



Measured memory_bytes: 5936
#include<stdio.h>

int main(void){

    long int N,K,Q,A[100001],point[100001],i,result;

    scanf("%ld %ld %ld",&N,&K,&Q);
    for(i = 0;i < Q;i++){
        scanf("%ld",&A[i]);
    }

    for(i = 0;i < N;i++){
        point[i] = K;
    }

    for(i = 0;i < Q;i++){
        point[A[i]-1] += 1;
    }

    for(i = 0;i < N;i++){
        result = point[i] - Q;
        if(result > 0){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
    }

    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::cin;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::set;
using std::unordered_set;
using std::multiset;

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; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	ll k = 1;
	FOR(i, 2, b + 1) {
		k *= i;
		k %= MOD;
	}
	c *= pow(k, MOD - 2);
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}

int main() {
	int a, b;
	cin >> a >> b;

	int ca = 0;
	int cb = 0;
	cout << 100 << " " << 100 << endl;
	REP(i, 100) {
		REP(j, 100) {
			if (i < 50) {
				if (i % 2 && j % 2 && ca < a - 1) {
					cout << ".";
					++ca;
				} else {
					cout << "#";
				}
			} else {
				if (i % 2 && j % 2 && cb < b - 1) {
					cout << "#";
					++cb;
				} else {
					cout << ".";
				}
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
s = input()
S = input()
ans = 3
i = 0
if s[i] == S[i]:
    ans *= 1
    i += 1
else:
    ans *= 2
    i += 2
while i < n:
    if s[i] == S[i]:
        if s[i-1] == S[i-1]:ans *= 2;i += 1
        else:ans *= 1;i += 1
    else:
        if s[i-1] == S[i-1]:ans *= 2;i += 2
        else:ans *= 3;i += 2
print(ans % (10**9+7))

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

int main(){

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

    long long cnt = 0;
    long long current_hight = A[0];

    for(int i=1; i<N; ++i){
        if(current_hight >= A[i]){
            cnt += current_hight - A[i];
        }else{
            current_hight = A[i];
        }

    }

    cout << cnt << endl;


}

Measured memory_bytes: 4832
#include<bits/stdc++.h>
using namespace std;
int w,h,mp[50][50],
	dy[8]={-1,-1,0,1,1,1,0,-1},
	dx[8]={0,1,1,1,0,-1,-1,-1};
void func(int x,int y){
	mp[y][x]=0;
	for(int i=0;i<8;i++){
		int xx=x+dx[i],yy=y+dy[i];
		if(xx>=0&&xx<w&&yy>=0&&yy<h&&mp[yy][xx]) func(xx,yy);
	}
}
int main(void){
	while(1){
		cin>>w>>h;
		if(w==0&&h==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++) cin>>mp[i][j];
		}
		int cnt=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(mp[i][j]==1){
					cnt++;
					func(j,i);
				}
			}
		}
		cout<<cnt<<endl;
	}
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define nrep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin>>n;
	vi a;
	rep(i,3*n){
		int t;cin>>t;
		a.push_back(t);
	}
	sort(a.begin(),a.end(),greater<int>());
	ll ret=0;
	rep(i,2*n){
		if(i%2)ret+=a[i];
	}
	cout<<ret<<endl;
	return 0;
}



Measured memory_bytes: 2420
#include <stdio.h>
#include <string.h>
int n, r[128]; bool used[22370000]; char com[7], s[13];
int main() {
	scanf("%d", &n); r[65] = 1, r[67] = 2, r[71] = 3;
	for(int i = 0; i < n; i++) {
		scanf("%s %s", com, s);
		int h = 0, l = strlen(s);
		for(int j = 0; j < l; j++) h = h * 4 + r[s[j]];
		h += (1 << (2 * l));
		if(com[0] == 'i') used[h] = true;
		else puts(used[h] ? "yes" : "no");
	}
}

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

#define endl "\n"
#define ioss ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
//#define int long long

typedef  long long ll;

using namespace std;
ll ans=0;ll nm=1;
void kill(ll h)
{
    if(h==1){ans=ans+nm;}
  else
  {
    ans=ans+nm;nm=nm*2;
     kill(h/2);
     //<<ans<<endl;
  }
}

int main()
{
    ioss
    ll h;cin>>h;
  //kill(h);
    ll answ=0;ll i=0;
    for( i=0;;i++)
    {
        if(pow(ll(2),i)>h)break;
    }
    i--;
    cout<<ll(pow(ll(2),i))*2-1<<endl;
 // cout<<answ<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int judge(string s){
  int l = s.length();
  bool par = true;
  if(l == 2){
      if(s[0] != s[1]) par = false;
  }
  else if(l != 1){
  for(int i=0;i<(l-1)/2;i++){
    if(s[i] != s[l-i-1]) par = false;
  }
  }
  return par;
}

int main(void){
  string s;
  cin >> s;
  
  int n = s.length();
  
  bool ans = true;
  string p;
  if(!judge(s)) ans = false;
  p = s.substr(0,n/2);
  if(!judge(p)) ans = false;
  p = s.substr((n+3)/2-1, n-(n+3)/2+1);
  if(!judge(p)) ans = false;
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n);
	std::string s; cin >> s;

	const int MOD = 1e9 + 7;
	
	i64 ans = 1, tmp = 0;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'W') {
			if(tmp % 2 == 0) {
				(ans *= (i64)tmp) %= MOD;
				tmp--;
			} else tmp++;
		} else {
			if(tmp % 2 == 1) {
				(ans *= (i64)tmp) %= MOD;
				tmp--;
			} else tmp++;
		}
		if(tmp < 0) ans = 0;
	}
	if(tmp != 0) ans = 0;
	for(i64 i = 1; i <= n; i++) (ans *= i) %= MOD;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 640
L = int(input())
A, N, D = [(1<<i) for i in range(21)], L.bit_length(), []
for i in reversed(range(1,N)):
    D += [(i,i+1,0),(i,i+1,A[N-1-i])]
P = A[N-1]
for i in range(2,N+1):
    s = N-i
    if (L>>s)&1==1:
        D += [(1,i,P)]
        P += A[s]
print(N,len(D))
for x,y,c in D:
    print(x,y,c)

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


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



int main() {

	int w, a, b;
	cin >> w >> a >> b;

	if (a + w < b) {
		cout << b - (a + w) << endl;
	}
	else if (b <= a + w && a + w <= b + w) {
		cout << 0 << endl;
	}
	else {
		cout << a - (b + w) << endl;
	}
	
	return 0;
}


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



int main() {
    string S;
    cin>>S;
    if(S=="AAA" || S=="BBB"){cout<<"No"<<endl;}
    else{cout<<"Yes"<<endl;}
}

Measured memory_bytes: 256
import bisect

n,m = map(int,input().split())

Q = []
P = [[] for _ in range(n)]
for i in range(m):
    p,y = map(int,input().split())
    Q.append([p,y])
    P[p-1].append(y)

P_1 = [sorted(l) for l in P]

for p,y in Q:
    a = str(p).zfill(6)
    b = str(bisect.bisect(P_1[p-1], y)).zfill(6)
    print(a+b)

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

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

  for(int i = 1; i <= 9; ++i) {
    for(int j = 1; j <= 9; ++j) {
      if(N == i * j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

using namespace std;

#define INF 1e9

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

    int n;
    cin>>n;

    int ans[100010]={};

    for(int i=0;i<6;i++)ans[i]=i;

    for(int i=6;i<=n;i++){
        int t=INF,p=1;

        for(int j=0;i-p>=0;j++){
            t=min(t,ans[i-p]+1);
            p*=9;
        }
        p=1;
        for(int j=0;i-p>=0;j++){
            t=min(t,ans[i-p]+1);
            p*=6;
        }
      
      ans[i]=t;

    }

    cout<<ans[n]<<endl;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int dfscnt(vector<vector<int>> tree,vector<int> color,int v)
{
    color[v] = 1;
    int sum = 0;
    REP(i, tree[v].size())
    {
        if(color[tree[v][i]] == 0){
            sum += dfscnt(tree, color, tree[v][i]);
        }
    }
    bool flag = true;
    REP(i, color.size())
    {
        if(color[i] == 0){
            flag = false;
        }
    }
    if(flag){
        return sum + 1;
    }
    else{
        return sum;
    }
}

int main(void)
{
    int n,m;
    cin >> n >> m;
    vector<vector<int>> tree(n);
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    cout << dfscnt(tree, vector<int>(n, 0), 0);

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
d=defaultdict(int)
N,K=map(int,input().split())
A=[0]+list(map(int,input().split()))
S=[None]*(N+1)
S[0]=0
cnt=0
d[0]=1
for i in range(1,N+1):
  S[i]=(S[i-1]+A[i]-1)%K
for i in range(1,N+1):
  if i-K>=0:
    d[S[i-K]]-=1
  cnt+=d[S[i]]
  d[S[i]]+=1
print(cnt)

Measured memory_bytes: 41064
//template code, C343, 2019
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;
import java.util.*;
class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	
	
	
	public void printDistance() {
		int[] distTo = new int[totalVertex];
		distTo[0]=0;
		for(int i=1; i<totalVertex;i++) {
			distTo[i]=-1;
		}
		LinkedList<Integer> q = new LinkedList<Integer>();
		q.add(0);
		ArrayList<Integer> seen = new ArrayList<>();
		seen.add(0);
		
		int incrementTimer=1;
		while(q.peek()!=null) {
			
			int cur=q.poll();
			for(int i =0; i<adjList.get(cur).size();i++) {
				
				if(!seen.contains(adjList.get(cur).get(i))){
					distTo[adjList.get(cur).get(i)]=distTo[cur]+1;
					seen.add(adjList.get(cur).get(i));
					q.add(adjList.get(cur).get(i));
				}
			}
		}
		
		for(int i=0; i<totalVertex;i++) {
			System.out.print((i+1)+" "+distTo[i]);
			if(i!=totalVertex) {
				System.out.println();
			}
		}
		
	}
	
	
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		//complete the following
		
		
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printDistance();
	}
}


Measured memory_bytes: 28832