akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

bool vector_find(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}

int main(int argc, char *argv[]){
  ll result = 0;
  ll N;
  cin >> N;
  vector<ll> V;
  vector<ll> C;
  for(int i = 0; i < N; i ++){
    ll x;
    cin >> x;
    V.push_back(x);
  }
  for(int i = 0; i < N; i ++){
    ll x;
    cin >> x;
    C.push_back(x);
  }
  
  for(int i = 0; i < N; i ++){
    if(V[i] - C[i] > 0){
      result += V[i] - C[i];
    }
  }
  
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

vector<vector<int>> neighbor;
vector<bool> isVisited;
vector<int> length;

int dfs(int node)
{
    isVisited[node] = true;
    length[node] = 0;
    for (int nx : neighbor[node]) {
        if (!isVisited[nx]) {
            dfs(nx);
        }
        length[node] = max(length[node], length[nx] + 1);
    }

    return 0;
}

int main()
{
    int n, m;
    cin >> n >> m;

    neighbor.resize(n);
    isVisited.resize(n, false);
    length.resize(n);
    rep(i, m)
    {
        int x, y;
        cin >> x >> y;
        neighbor[x - 1].push_back(y - 1);
    }

    rep(i, n)
    {
        if (!isVisited[i]) {
            dfs(i);
        }
    }

    int result = 0;
    rep(i, n)
    {
        result = max(result, length[i]);
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
 
long long d[1010];
 
int main() {
	int n, m;
	std::cin >> n >> m;
 
	std::vector<int> us(m);
	std::vector<int> vs(m);
	std::vector<int> ws(m);
	for (int i = 0; i < m; i++) {
		std::cin >> us[i] >> vs[i] >> ws[i];
		us[i]--;
		vs[i]--;
	}
 
	const long long INF = 1e18;
	
	for (int i = 0; i < n; i++) d[i]=-INF;
	d[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			d[vs[j]] = std::max(d[vs[j]], d[us[j]] + ws[j]);
		}
	}
	long long ans1 = d[n - 1];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			d[vs[j]] = std::max(d[vs[j]], d[us[j]] + ws[j]);
		}
	}
	long long ans2 = d[n - 1];
	if (ans1 != ans2) {
		std::cout << "inf" << std::endl;
	} else {
		std::cout << ans1 << std::endl;
	}
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 2019;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


ll pmod(ll n, ll p) {
    ll m = n % mod;
    if (p == 0) return 1;
    ll rtn = pmod((m * m) % mod, p / 2) % mod;
    if (p % 2 == 1) rtn = rtn * m % mod;
    return rtn;
}

ll modinv(ll n) {
    return pmod(n, mod - 2);
}

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

    vector<int> X(S.size() + 1, 0);

    int tmp = 1;

    for(int i = S.size() - 1;i >= 0;i--)
    {
        int a = S[i] - '0';
        X[i] = (a * tmp + X[i + 1]) % mod;
        tmp *= 10;
        tmp %= mod;
    }

    vector<vector<int>> R(2019, vector<int>());

    rep(i, S.size())
    {
        R[X[i]].push_back(i);
    }

    ll count = 0;

    rep(i, S.size())
    {
        int idx = S.size() - i;

        int m = 0;
        if (idx < S.size()) m = X[idx];

        auto iter = lower_bound(all(R[m]), idx);

        count += distance(R[m].begin(), iter);
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 5688
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

    int ans = 0,bef = 0;
    for(int i = 0;i < N;i++) {
        int h;
        cin >> h;

        if(bef < h) {
            ans += h - bef;
        }

        bef = h;

    }

    cout << ans << endl;
}


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

int main() {
  using pii = pair<int, int>;
  int N;
  cin >> N;
  if(N<2 || N>100000){
    return 0;
  }
  vector<pii> A(N+1, pii(0, 0));
  for(int i=1; i<=N; ++i){
    int a;
    cin >> A.at(i).first;
  }
  A.at(2).second = 2; // 終点
  int times = 0;
  int position = 1;
  while(1){
    if(A.at(position).second==1){
      cout << -1 << endl;
      return 0;
    }
    else if(A.at(position).second==2){
      cout << times << endl;
      return 0;
    }
    else{
      times++;
      A.at(position).second = 1; // 到達した
      position = A.at(position).first;
    }
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  long long N, K;
  cin >> N >> K;

  long long ans = 0;
  FOR(b, K + 1, N)
  {
    ans += N / b * (b - K) + max(N % b - K + 1, (long long)0);
  }
  if(K == 0)
    ans -= N;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma region Library

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

using ll = long long int; // int_fast64_t;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
using vi = vt<int>;
using vvi = vvt<int>;
using vl = vt<ll>;
using vvl = vvt<ll>;

constexpr int INF = 1 << 30;  // 1073741824 2倍すると-2147483648
constexpr ll INFL = 1l << 62; // 4611686018427387904 2倍すると-0.9*10^18
constexpr int dx4[] = {0, 1, 0, -1};
constexpr int dy4[] = {1, 0, -1, 0};
constexpr int dx8[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy8[] = {0, -1, 0, 1, -1, -1, 1, 1};
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define RANGE(i, a, b) for (int i = (a); i <= (b); i++)
#define RANGER(i, a, b) for (int i = (b); i >= (a); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) RFOR(i, 0, (n))

#pragma endregion

int main() {
  int n, mx = 0, sum = 0;
  cin >> n;
  REP(i, n) {
    int l;
    cin >> l;
    mx = max(mx, l);
    sum += l;
  }
  // cout << mx << " " << sum;
  if (mx < sum - mx)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}


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

ans = []
i = 1

while True:
    """CHECK_NUM"""
    x = i
    if x % 3 == 0:
        ans.append(str(i))
    else:
        while True:
            """INCLUDE3"""
            if x % 10 == 3:
                ans.append(str(i))
                break

            x = int(x / 10)
            
            if x != 0: 
                continue
            else: 
                break
    i += 1
    if i <= n:
        continue
    else:
        break

print(" " + " ".join(ans))

Measured memory_bytes: 7364
n=int(input())
l=[]
for i in range(n):
    x,y=map(str,input().split())
    l.append([x,y,i+1])
l.sort()
flag=0
x=[]
for i in range(n-1):
    x.append([int(l[i][1]),int(l[i][2])])
    if l[i][0]==l[i+1][0]:
        pass
    else:
        x.sort()
        x.reverse()
        for j in range(len(x)):
            print(int(x[j][1]))
        x.clear()
x.append([int(l[n-1][1]),int(l[n-1][2])])
if x!=[]:
    x.sort()
    x.reverse()
    for j in range(len(x)):
            print(int(x[j][1]))
else:
    print(int(x[n-1][1]))

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> cities(N, 0);
  for (int i = 0; i < M; i++) {
    int r = 0;
    int c = 0;
    cin >> r >> c;
    cities[r-1]++;
    cities[c-1]++;
  }
  for (int i = 0; i < N; i++) {
    cout << cities[i] << endl;
  }
}

Measured memory_bytes: 256
Five = [a**5 for a in range(120)]
X = int(input())
clear = 0
for o in range(119):#i<j
    for p in range(o+1,120):
        i = Five[o]
        j = Five[p]
        if j - i == X:
            print(f"{p} {o}")
            clear = 1
        if not clear and j + i == X:
            print(f"{p} {-o}")
            clear = 1
    if clear:break

Measured memory_bytes: 63644
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main(){
  int n, d;
  cin >> n >> d;
  int ans=0;
  vector<pair<long long, long long>> p(n);
  double des=0.0;
  rep(i, n){
    cin >> p[i].first >> p[i].second;
    des = sqrt((p[i].first * p[i].first) + (p[i].second * p[i].second));
    if(des <= d) ans++;
    
  }
  cout << ans << endl;
}

Measured memory_bytes: 6484
/// You just can't beat the person who never gives up

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

#include<bits/stdc++.h>
using namespace std ;
const int N = 10 ;

int n ,m ,k ;
char str[N][N] ;
bool ok(int maskr,int maskc){
    int cnt = 0 ;
    for(int i=0;i<n;++i){
        if(maskr>>i&1) continue ;
        for(int j=0;j<m;++j){
            if(maskc>>j&1) continue ;
            cnt += str[i][j] == '#' ;
        }
    }
    return cnt==k ;
}
bool Never_give_up(){
    cin >> n >> m >> k ;
    for(int i=0;i<n;++i) cin >> str[i] ;
    int ans = 0 ;
    for(int maskr=0;maskr<(1<<n);++maskr){
        for(int maskc=0;maskc<(1<<m);++maskc){
            ans += ok(maskr,maskc) ;
        }
    }
    cout << ans << endl ;
    return 0 ;
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt" ,"r" ,stdin);
    freopen("output.txt" ,"w" ,stdout);
#endif
    int t = 1 ;
    //scanf("%d",&t);
    while(t--) Never_give_up();
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int n;
    cin>>n;
    n%=10;

    string ans;
    if(n==3)ans="bon";
    else if(n==0 || n==1 || n==6 || n==8)ans="pon";
    else ans="hon";

    cout<<ans<<"\n";

    return 0;

}

Measured memory_bytes: 3624
#!/bin/ruby

n = gets.chomp.to_i
hps = gets.chomp.split(" ").map(&:to_i)

(n-1).times do |i|
  a, b = [0, 0]
  if hps[i] < hps[i+1]
    b = hps[i+1]
    a = hps[i]
  else
    b = hps[i]
    a = hps[i+1]
  end

  ans = 0
  while true
    tmp = b % a
    if tmp == 0
      ans = a
      break
    else
      next_b = a
      next_a = b % a
      b = next_b
      a = next_a
    end
  end
  hps[i+1] = ans
end
puts hps[-1]




Measured memory_bytes: 9484
#include<stdio.h>

int main(void)
{

	int N, M;
	int A,sum=0;
	scanf("%d %d", &N,&M);
	for (int i = 0; i < M;i++) {
		scanf("%d",&A);
		sum += A;
	}
	N -= sum;
	if (N >= 0)
		printf("%d", N);
	else
		printf("-1");

	return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fore(b,c) for(int val0=b;val0<c;val0++)
#define forr(k,c,s) for(int k=c;k<s;k++)
#define pb push_back
#define mmp make_pair
#define oset(T) tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long double ld;
typedef vector<vii> al;
typedef vector<ll> vl;
typedef pair<ll,ll> pl;
const int INF = 1e9;
const ll INFL = 1LL<<61;
al g,h,rh;
vl d;
ll vs[100100],vt[100100];
const ll M = 1e9+7;
ll sv,tv;
ll dfa(int u) {
	if(u == sv) {return 1;}
	if(vs[u] != -1) return vs[u];
	ll res = 0;
	for(int i=0;i<rh[u].size();i++) {
		ll v = rh[u][i].first;
		res += dfa(v);
	}
	res %= M;
	return vs[u] = res;
}
ll dfb(int u) {
	if(u == tv) {return 1;}
	if(vt[u] != -1) return vt[u];
	ll res = 0;
	for(int i=0;i<h[u].size();i++) {
		ll v = h[u][i].first;
		res += dfb(v);
	}
	res %= M;
	return vt[u] = res;
}
int main() {
	ios::sync_with_stdio(0);cout.precision(20);cout.tie(0);cin.tie(0);
	int n,m;
	cin >> n >> m;
	int s,t;
	cin >> s >> t;
	s--;t--;
	sv = s;tv = t;
	memset(vs,-1,sizeof(vs));
	memset(vt,-1,sizeof(vt));
	g.assign(n,vii());
	d.assign(n,INFL);
	while(m--) {
		ll a,b,c;
		cin >> a >> b >> c;a--;b--;
		g[a].push_back({b,c});
		g[b].push_back({a,c});
	}
	priority_queue<pl,vector<pl>,greater<pl>> pq;
	pq.push({0,s});
	d[s] = 0;
	while(!pq.empty()) {
		ll u = pq.top().second,dist = pq.top().first;pq.pop();
		if(dist > d[u]) continue;
		for(int i=0;i<g[u].size();i++) {
			ll v = g[u][i].first;
			ll nd = dist+g[u][i].second;
			if(nd >= d[v]) continue;
			pq.push({nd,v});
			d[v] = nd;
		}
	}
	ll val = d[t];
	h.assign(n,vii());
	rh.assign(n,vii());
	bitset<100100> bs;
	for(int i=0;i<n;i++) {
		for(int j=0;j<g[i].size();j++) {
			int v = g[i][j].first;
			ll ev = g[i][j].second;
			if(d[v] == d[i]+ev) {
				h[i].push_back({v,ev});
				rh[v].push_back({i,ev});
			}
		}
	}
	ll tot = dfa(t);
	dfb(s);
	tot *= tot;
	tot %= M;
	for(int i=0;i<n;i++) {
		if(d[i]*2 == val) {
			ll ra = (dfa(i)*dfb(i))%M;
			tot -= ra*ra;
			tot = tot%M+M;
		}
		if(d[i]*2 < val) {
			for(int j=0;j<h[i].size();j++) {
				int v = h[i][j].first;
				if(d[v]*2 > val) {
					//cout << "choke " << i << " -> " << v << '\n';
					ll ra = (dfa(i)*dfb(v))%M;
					//cout << "funk " << ra << " ^2 " << '\n';
					tot -= ra*ra;
					tot = tot%M+M;
				}
			}
		}
	}
	tot = ((tot%M)+M)%M;
	cout << tot << '\n';
}

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

using namespace std;

int main() {
	
	long long a, b, c=0, d=0, f, n, m;
	
	while (cin >> a){
	c=0;
	for (int i=0; i <= 9; i ++){
		for (int j=0; j <= 9; j ++){
			for (int k=0; k <= 9; k ++){
				for (int l=0; l <= 9; l ++){
					if (i + j + k + l == a ){
						c ++;
					}
					
				}
			}	
		}
	}
	cout << c << endl;
	}
	return 0;
}


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

using namespace std;

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    long double prob = 0;
    for(int i=1; i<=n; i++){
        int cur = i;
        long double mul = 1;
        while(cur < k){
            cur *= 2;
            mul *= 0.5;
        }
        prob += 1. / n * mul;
    }
    printf("%.10Lf\n", prob);
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
    long long n,r=1,b=0;
    int k;
    cin >> n >>k;
    for(long long i = 0; i < 1000000000; i++){
        if(r<=n){
            r*=k;
            b=i;
        }
        else if(r>n){
            break;
        }
    }
    cout << b+1 << endl;
}

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

int main() {
  string s;
  cin >> s;
  
  string t = "CODEFESTIVAL2016";
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    ans += s[i] != t[i];
  }
  cout << ans << endl;
}

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

int main(){
  int a,b,c,d,save;
  cin>>a>>b>>c>>d;
  save=0;
  while(d>0){
    d--;
    if(a>0){
      save+=1;
      a--;
    }
    else if(b>0){
      save+=0;
      b--;
    }
    else if(c>0){
      save-=1;
      c--;
    }
  }
  cout<<save<<endl;
}

Measured memory_bytes: 3632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

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

	static class Task1 {
		public void solve(int testNumber, Scanner sc, PrintWriter out) {

			int x = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();

			x -= a;
			x %= b;

			out.println(x);

		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.buflen = 0;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) return true;
			else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) return false;
			}
			return true;
		}

		private byte readByte() {
			if (hasNextByte()) return buffer[ptr++];
			return -1;
		}

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
				ptr++;
			}
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			byte b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) throw new NumberFormatException();
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

	}
}



Measured memory_bytes: 21328
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdint.h>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

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

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

void solve(long long P, long long Q, long long R) {
  ll m = max(P, max(Q, R));
  std::cout << P + Q + R - m << std::endl;
}

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


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

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            String N;

            N = Console.ReadLine();

            if (N[0] == '9' || N[1] == '9')
                Console.WriteLine("Yes");

            else
                Console.WriteLine("No");

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 13140
using System;

namespace abc154_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string mojiU = Console.ReadLine();

            int l = mojiU.ToCharArray().Length;

            string output = "";

            for (int index = 0; index < l ;index++)
            {
                output += "x";
            }

 
            
            Console.WriteLine(output);
        }
    }
}


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

int n;
int Wsum[400000];
int ans = 1145140;

int main() {
    cin >> n;
    Wsum[0] = 0;
    for (int i = 1; i <= n; i++) {
        char c;
        cin >> c;
        Wsum[i] = Wsum[i - 1] + (c == 'W' ? 1 : 0);
    }
    for (int i = 1; i <= n; i++) {
        //cout << Wsum[i] << ' ';
        ans = min(ans, Wsum[i - 1] + (n - i) - (Wsum[n] - Wsum[i]));
    }

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

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

int power(int m, int n, int d)
{
    long long int tmp;

    if (n == 0) {
        return 1;
    }
    else {
        tmp = power(m, n / 2, d);
        if (n % 2 == 0) {
            tmp = (tmp * tmp) % d;
        }
        else {
            tmp = (((tmp * tmp) % d) * m) % d;
        }
    }
    return tmp;
}

int main()
{
    int m, n;

    cin >> m >> n;
    cout << power(m, n, 1000000007) << endl;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 1000000007
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 51;
ll pat[N],sze[N];

ll rec(int lvl, ll x){
	if(x == 0)return 0;
	if(lvl == 0)return 1;
	if(x == 1)return 0;
	if(x <= 1 + sze[lvl-1])return rec(lvl-1,x-1);
	if(x == 1 + sze[lvl-1] + 1)return pat[lvl-1] + 1;
	if(x <= 1 + 2 * sze[lvl-1] + 1)return pat[lvl-1] + 1 + rec(lvl-1,x - 2 - sze[lvl-1]);
	else return 2 * pat[lvl-1] + 1;
}

int main(){
	ll n,x;
	cin >> n >> x;
	pat[0] = sze[0] = 1;
	fu(i,1,n){
		pat[i] = 2 * pat[i-1] + 1;
		sze[i] = 2 * sze[i-1] + 3;
	}
	cout << rec(n,x) << '\n';
}


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

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

use std::cmp::min;

fn main() {
    let n = read::<usize>();
    let mut a = vec![0; n+2];

    for i in 1..n+1 {
        a[i] = read::<i64>();
    }

    let mut sum = 0;
    for i in 1..n+2 {
        sum += (a[i-1] - a[i]).abs();
    }

    for i in 1..n+1 {
        if (a[i-1] <= a[i] && a[i] <= a[i+1]) || (a[i+1] <= a[i] && a[i] <= a[i-1]) {
            println!("{}", sum);
        } else {
            println!("{}", sum - min((a[i] - a[i-1]).abs(), (a[i+1] - a[i]).abs()) * 2);
        }
    }
}

Measured memory_bytes: 5244
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import qualified Data.IntSet as S
import Data.Maybe
-- import Data.List
-- import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
-- import Debug.Trace
-- trace _ = id

solve :: Int -> Int -> [Int] -> String
solve bN bK as | S.member bK first = "First"
               | otherwise         = "Second"
  where
  first = foldl pFunc S.empty [0..bK]
  pFunc is x
    | S.member x is = is
    | otherwise =
      S.union is (S.fromDistinctAscList (takeWhile (<= bK) (map (+ x) as)))


readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> String
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bN,bs_bK]:remLines1 = remLines0
      bN = readBInt bs_bN
      bK = readBInt bs_bK
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve bN bK as

outAnswer :: String -> IO ()
outAnswer = putStrLn

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "YES" : "NO")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

template <class T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using ordered_multiset = tree <T, null_type, less_equal <T>, rb_tree_tag, tree_order_statistics_node_update>;

const int siz = 2e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "1";



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

//    freopen ((file + ".INP").c_str(), "r", stdin);
//    freopen ((file + ".OUT").c_str(), "w", stdout);

    string s;
    cin >> s;

    int cnt = 0, ans = 0;
    for (int i = 0; i < sz(s); i++) {
        if (s[i] == 'R') {
            cnt++;
        }
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);

    cout << ans;

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int X, N; cin >> X >> N;
	map<int, int>mp;
	int mx = 0;
	rep(i, 0, N) {
		int a; cin >> a;
		chmax(mx, a);
		mp[a]++;
	}
	int cnt = INF, ans = mx + 1;
	rREP(i, -100, 102) {
		if (!mp.count(i)) {
			if (cnt >= abs(i - X)) {
				ans = i;
				cnt = abs(i - X);
			}
		}
	}
	cout << ans << "\n";


	return 0;
}

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

Measured memory_bytes: 600
N, A, B = map(int, input().split())
S = input()

ac, bc = 0, 0
for s in S:
	if "a" == s:
		if (ac + bc) < (A + B):
			ac += 1
			print("Yes")
		else:
			print("No")
	elif "b" == s:
		if (ac + bc) < (A + B) and (bc < B):
			bc += 1
			print("Yes")
		else:
			print("No")
	else:
		print("No")


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

using namespace std;

typedef long long ll;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

const int K = 26;

set <int> pos[K];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) {
    pos[s[i] - 'a'].insert(i);
  }
  int q;
  cin >> q;
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int p;
      cin >> p;
      p--;
      char c;
      cin >> c;
      pos[s[p] - 'a'].erase(p);
      s[p] = c;
      pos[s[p] - 'a'].insert(p);
    } else {
      int l, r;
      cin >> l >> r;
      l--, r--;
      int res = 0;
      for (int i = 0; i < 26; i++) {
        auto it = pos[i].lower_bound(l);
        if (it != pos[i].end() && *it <= r) {
          res++;
        }
      }
      cout << res << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 24220
#include<bits/stdc++.h>
using namespace std;
queue <pair<int,int> > blocks;
int w,h,xs,ys,n,xg,yg,c,d,x,y,area[105][105];
bool flag=false;
void solve(int x,int y,int c);

int main(){
    while(1){
        cin >> w >> h;
        if(w==0&&h==0)break;
        cin >> xs >> ys >> xg >> yg >> n;
        for(int i=0;i<n;i++){
            cin >> c >> d >> x >> y;
            if(d==0){
            for(int j=y;j<y+2;j++){
                for(int k=x;k<x+4;k++){
                    area[k][j]=c;
                }
            }
            }else{
            for(int j=y;j<y+4;j++){
                for(int k=x;k<x+2;k++){
                    area[k][j]=c;
                    }
                }
            }
        }
        if(area[xs][ys]!=area[xg][yg]);
        else {
        blocks.push(make_pair(xs,ys));
        solve(blocks.front().first,blocks.front().second,area[xs][ys]);
        }
        if(flag==true)cout << "OK" << endl;
        else cout << "NG" << endl;
        flag=false;
        fill(area[0],area[104],0);
    }

return 0;
}

void solve(int x,int y,int c){
    if(!blocks.empty()){
    blocks.pop();
    if(x==xg&&y==yg){
        flag=true;
        while(!blocks.empty())blocks.pop();
    }else{
        area[x][y]=0;
        if(area[x-1][y]==c)blocks.push(make_pair(x-1,y));
        if(area[x][y-1]==c)blocks.push(make_pair(x,y-1));
        if(area[x+1][y]==c)blocks.push(make_pair(x+1,y));
        if(area[x][y+1]==c)blocks.push(make_pair(x,y+1));
        solve(blocks.front().first,blocks.front().second,c);
        }
    }
}

Measured memory_bytes: 1364
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;
typedef pair<double,P> PP;
 
#define EPS (1e-10)
 
class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}
  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(x*a,y*a);}
  double abs(){return sqrt(norm());}
  double norm(){return x*x+y*y;}
};
typedef Point Vector;
class Segment{
public:
  Point p1,p2;
  Segment(Point s=Point(),Point t=Point()):p1(s),p2(t){}
};
double norm(Vector a){return a.x*a.x + a.y*a.y;}
double abs(Vector a){return sqrt(norm(a));}
double getDistance(Vector a,Vector b){return abs(a-b);}
double dot (Vector a,Vector b){return a.x*b.x + a.y*b.y;}
double cross(Vector a,Vector b){return a.x*b.y - a.y*b.x;}
 
static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE=-1;
static const int ONLINE_BACK=2;
static const int ONLINE_FRONT=-2;
static const int ON_SEGMENT=0;
 
int ccw(Point p0,Point p1,Point p2){
  Vector a = p1-p0;
  Vector b = p2-p0;
  if ( cross(a, b) > EPS ) return COUNTER_CLOCKWISE;
  if ( cross(a, b) < -EPS ) return CLOCKWISE;
  if ( dot(a,b) < -EPS ) return ONLINE_BACK;
  if ( norm(a) < norm(b) ) return ONLINE_FRONT;
  return ON_SEGMENT;
}
 
bool isIntersect(Segment s1,Segment s2){
  Point p1=s1.p1, p2=s1.p2, p3=s2.p1, p4=s2.p2;
  return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0&&
      ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}
 
Point getCrossPoint(Segment s1,Segment s2){
 
  Vector base = s2.p2 - s2.p1;
  double d1 = abs(cross(base,s1.p1-s2.p1));
  double d2 = abs(cross(base,s1.p2-s2.p1));
  double t = d1/(d1+d2);
  return s1.p1+(s1.p2-s1.p1)*t;
}
 
 
int n,o,l;
Segment seg,input;
 
vector<PP> t;
 
int main(){
  int Tc;
  cin>>Tc;
  while(Tc--){
    t.clear();
    cin>>seg.p1.x>>seg.p1.y>>seg.p2.x>>seg.p2.y;
    cin>>n;
    for(int i=0;i<n;i++){
 
      cin>>input.p1.x>>input.p1.y>>input.p2.x>>input.p2.y;
      cin>>o>>l;
      //cout<<i<<' '<<o<<' '<<l<<endl;
       
      if(isIntersect(seg,input)==false)continue;
      Point a = getCrossPoint(seg,input);
      double b = getDistance(a,seg.p1);
       
      //cout<<input.p1.x<<' '<<input.p1.y<<endl;
      //cout<<input.p2.x<<' '<<input.p2.y<<endl;
       
      t.push_back(PP(b,P(o,l)));
    }
 
    if(t.size()<=1){cout<<"0"<<endl;continue;}
 
    sort(t.begin(),t.end());
    int ans=0,now;
    if(t[0].second.first==1)now=t[0].second.second;
    else now=1-t[0].second.second;
    for(int i=1;i<(int)t.size();i++){
      if(t[i].second.first==1){
    if(now!=t[i].second.second)ans++;
    now=t[i].second.second;
      }else if(t[i].second.first==0){
    if(now==t[i].second.second)ans++;
    now=1-t[i].second.second;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
typedef pair< int , int > Pi;
typedef long long int64;

int N;
Pi data[300000];

bool calc(int value){ //閉じこめられる微生物value

  priority_queue < Pi, vector< Pi >, greater< Pi > > que; //許容量が小さい順に取り出す(?)
  int64 sum = 0; //放出量の和

  for(int i = 0; i < value - 1; i++){ //人数分入れる
    sum += data[i].first;
    que.push( Pi( data[i].second, data[i].first)); //Pi( 許容量, 放出量)
  }

  for(int i = value - 1; i < N; i++){
    sum += data[i].first;
    que.push( Pi( data[i].second, data[i].first));
    while(!que.empty() && (int64)que.top().first * value < sum){
      sum -= que.top().second;
      que.pop();
    }
    if(que.size() >= value) return true;
  }
  return value == 0;
}



int main(){
  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    scanf("%d %d", &data[i].first, &data[i].second);
  }
  sort( data, data + N);

  //これわかんないな
  int row = 0, high = N;
  while(high != row){
    int mid = (row + high + 1) >> 1;
    if(calc(mid)) row = mid;
    else high = mid - 1;
  }
  printf("%d\n", high);
}

Measured memory_bytes: 10656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define fir first
#define sec second
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}
typedef double db;

const int N = 200010;
int n;
ll val[N];
int n2[N], n5[N], num[20][20];
int main() {
  db tmp;
  read(n);
  rep (i, 1, n) {
    scanf("%lf",&tmp);
    val[i] = (ll)(tmp * 1e9 + 0.5);
  }
  rep (i, 1, n) {
    while (val[i] % 2 == 0)
      ++ n2[i], val[i] /= 2;
    while (val[i] % 5 == 0)
      ++ n5[i], val[i] /= 5;
  }
  ll ans = 0;
  int mx2 = 0, mx5 = 0;
  rep (i, 1, n) {
    rep (a, 0, mx2) rep (b, 0, mx5) {
      if (a + n2[i] >= 18 && b + n5[i] >= 18)
        ans += num[a][b];
    }
    n2[i] = min(n2[i], 18);
    n5[i] = min(n5[i], 18);
    mx2 = max(n2[i], mx2);
    mx5 = max(n5[i], mx5);
    ++ num[n2[i]][n5[i]];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6840
def lcm(a, b):
    from fractions import gcd
    return (a * b) // gcd(a, b)


A, B, C, D = map(int, input().split())
A -= 1
LCM = lcm(C, D)

all_warikire = B - (B // C) - (B // D) + B // LCM
sub_warikire = A - (A // C) - (A // D) + A // LCM

print(all_warikire - sub_warikire)


Measured memory_bytes: 5044
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    string S;

    cin >> S;

    int n = S.length();

    int l = -1;
    int r = -1;
    for (int ch = 'a'; ch <= 'z'; ++ch) {
        map<int,int> M;
        int sum = 0;
        int pre = -1;
        for (int i = 0; i < n; ++i) {
            int cur = sum;
            if (S[i] == ch) {
                ++sum;
            } else {
                --sum;
            }
            // auto it = M.lower_bound(sum);
            // if (it != M.begin()) {
            //     --it;
            //     int len = i - (it->second);
            //     if (len >= 2) {
            //         l = it->second + 1;
            //         r = i;
            //         break;
            //     }
            // }
            auto it = M.begin();
            if (it != M.end() && it->first < sum) {
               l = it->second + 1;
               r = i;
               break;
            }
    
            if (M.count(cur) == 0) {
                M[cur] = i - 1;
            }
        }
        if (l >= 0) {
            break;
        }
    }

    if (l >= 0) {
        ++l, ++r;
    }
    cout << l << " " << r << "\n";


    return 0;
}

Measured memory_bytes: 8096
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() int {
	sc.Scan()
	val, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	return val
}

func main() {

	N := next()

	mod := N % 1000

	var result int
	if mod == 0 {
		result = 0
	} else {

		result = 1000 - mod
	}

	fmt.Println(result)
}

Measured memory_bytes: 1772
import java.io.*;

import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


 class Main {

    /*static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static final int mod = 1000000007;

    public static int gcd(int a, int b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }
    public static boolean isPalindrome(String str)
    {

        // Pointers pointing to the beginning
        // and the end of the string
        int i = 0, j = str.length() - 1;

        // While there are characters toc compare
        while (i < j) {

            // If there is a mismatch
            if (str.charAt(i) != str.charAt(j))
                return false;

            // Increment first pointer and
            // decrement the other
            i++;
            j--;
        }

        // Given string is a palindrome
        return true;
    }*/

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

        long h = sc.nextLong();
        int f = 1;
        long c = 1;
        long ans = 0;
        if (h == 1)
            System.out.println(1);
        else {
            while (f != 0) {
                h /= 2;
                ans+=c;

                c*=2;

                if (h == 1) {
                    ans+=c;

                    break;
                }



            }
            System.out.println(ans);
        }
    }
    }




Measured memory_bytes: 21844
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
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; }
template<class T> inline T int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
// sort(ALL(v), [](auto const& lhs, auto const& rhs) { return lhs > rhs; /* 左の方が大きい...というイメージ。*/ });
// --------------------------------------------------------------------------------------------- //

static const int MAX = 300101;
static const ll MOD = 1000000007;
ll dp[MAX];

using S = ll;
S op(S a, S b) { return max(a,b); } // a⊕b→c
S e() { return 0; }

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll N, K; cin >> N >> K;
	memr(dp, 0);
	ll ans = 0;
	vector<ll> v(N);
	rep(i, N){
		cin >> v[i];
	}
	segtree<S, op, e> seg(MAX);

	rep(i, N){
		dp[i] = seg.prod(max(0LL, v[i]-K), min(v[i]+K, 300000LL)+1) + 1;
		seg.set(v[i], dp[i]);
	}
	rep(i, MAX){
		chmax(ans, dp[i]);
	}
	cout << ans << endl;
	// cout << ans.size() << endl;
	// rep(i, ans.size()){
	// 	if(i) cout << " ";
	// 	cout << ans[i];
	// }
	// cout << endl;

	return 0;
}


Measured memory_bytes: 18548
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_158_b
    {

#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            long N, A, B;

            ReadLong(out N, out A, out B);

            long ans = N / (A + B) * A;
            long mod = Math.Min(N % (A + B), A);

            ans += mod;

            Write($"{ans}");
        }

        private static void ReadLong(out long a, out long b, out long c)
        {
            var ar = ReadLongArray();
            a = ar[0];
            b = ar[1];
            c = ar[2];
        }

        private static long[] ReadLongArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            long[] ar = new long[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = long.Parse(ss[i]);
            }
            return ar;
        }

        private static void Write(string s)
        {
            Console.WriteLine(s);
        }

#if !TEST
    }
}
#endif


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    string s;
    cin >>s;
    string ans;
    for(int i=0;i<3;i++){
        ans+=s.at(i);
    }
    cout<<ans<<endl;
}
    



Measured memory_bytes: 3624
import scala.io.StdIn.readLine

object Main extends App {

  val xs = {
    val lines = Iterator.continually(readLine())
    val xs    = for {
      line       <- lines
      Array(x, y) = line.split(" ").map { _.toInt }
    } yield (x, y)

    xs.takeWhile { _ != (0, 0) }
  }

  val results = xs.map {
    case (x, y) => if (x <= y) s"$x $y" else s"$y $x"
  }

  results.foreach(println)
}



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

a_sort = sorted(a, key=lambda x: x[1], reverse=True)

for i, val in a:
    if i == a_sort[0][0]:
        print(a_sort[1][1])
    else:
        print(a_sort[0][1])


Measured memory_bytes: 35020