akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char *argv[])
{
	int n,m;
	cin >> n >> m;
	vector<PLL> vp(n);
	for (int i = 0; i < n; ++i) {
		int a,b;
		cin >> a >> b;
		vp[i] = {a,b};
	}
	SORT(vp);
	LL sum = 0;
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		cnt += vp[i].second;
		if (cnt >= m) {
			sum += (m - (cnt - vp[i].second)) * vp[i].first;
			break;
		}
		sum += vp[i].second * vp[i].first;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        while (a[i] % 2 == 0)
        {
            res++;
            a[i] /= 2;
        }
    }

    cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
def gcd(a,b): # 最大公約数を求める
  while b:
    a,b=b,a%b
  return abs(a)
  
def solve(A:int, B:int):
  a=gcd(A,B)
  ap=a
  ct=0
  x=2
  if a%x==0:
    ct+=1
    while a%x==0:
      a=a//x
  
  x=3
  while x*x<ap+1:
    if a%x==0:
      ct+=1
      while a%x==0:
        a=a//x
    x+=2
  
  if a!=1:
    ct+=1
  print(ct+1)
  
  return

def main():
  A,B=map(int,input().split())
  solve(A,B)

if __name__=="__main__":
  main()

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

const long long MOD = 1000000007;

void func(long long n, long long m, vi oks) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    vll dp(n + 1);
    dp[0] = 1;
    for (int now = 0; now < n; now++) {
        for (int next = now + 1; next <= min((int)n, now + 2); next++) {
            if (oks[next]) {
                dp[next] += dp[now];
                dp[next] %= mod;
            }
        }
    }
    cout << dp[n] << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    vi oks(N + 1, true);
    for (int i = 0; i < M; i++) {
        int a;
        cin >> a;
        oks[a] = false;
    }
    func(N, M, std::move(oks));
    return 0;
}


Measured memory_bytes: 1536
n, m = [int(i) for i in input().split()]
list_a = [[s for s in input().split()] for i in range(0, n)]
list_ans = [str(s) for s in range(1, m + 1)]
for i in range(0, n):
    for j in range(0, m):
        if list_ans[j] not in list_a[i][1:]:
            list_ans[j] = '0'
print(len([s for s in list_ans if s != '0']))

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

#define int long long

double prob[309][309][309];
double ev[309][309][309];

int n;

double dp(int a, int b, int c){
    if(a == 0 && b == 0 && c == 0){
        return 1;
    }
    if(prob[a][b][c] != -1) return prob[a][b][c];
    prob[a][b][c] = 0;
    if(a){
        prob[a][b][c] += dp(a-1,b,c)*(double)(a/((double)a+b+c));
        ev[a][b][c] += ev[a-1][b][c]*(double)(a/((double)a+b+c));
    }
    if(b){
        prob[a][b][c] += dp(a+1,b-1,c)*(double)(b/((double)a+b+c));
        ev[a][b][c] += ev[a+1][b-1][c]*(double)(b/((double)a+b+c));
    }
    if(c){
        prob[a][b][c] += dp(a,b+1,c-1)*(double)(c/((double)a+b+c));
        ev[a][b][c] += ev[a][b+1][c-1]*(double)(c/((double)a+b+c));
    }
    double prob_waste = ((double)(n-a-b-c))/(double)n;
    //cout << prob_waste << endl;
    double tot_waste = prob_waste/(1-prob_waste);
    //cout << tot_waste << endl;
    if(a+b+c < n)ev[a][b][c] += prob[a][b][c]*tot_waste;
    return prob[a][b][c];
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    vector<int> cnt(4,0);
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        cnt[a]++;
    }
    for(int i = 0; i < 309; i++){
        for(int j = 0; j < 309; j++){
            for(int k = 0; k < 309; k++){
                prob[i][j][k] = -1;
                //ev[i][j][k] = -1;
            }
        }
    }
    //ev[cnt[a]][cnt[b]][cnt[c]] = 1;
    double tot = 0;
    dp(cnt[1], cnt[2], cnt[3]);
    cout << fixed << setprecision(12) << (double)(ev[cnt[1]][cnt[2]][cnt[3]]+(cnt[1] + 2*cnt[2] + 3*cnt[3])) << endl;
    //cout << setprecision(12) << fixed << (double) << endl;// + (double)(cnt[1] + cnt[2] + cnt[3]) << endl;
}


Measured memory_bytes: 457216
from collections import defaultdict
import sys
N = int(input())
input = sys.stdin.readline

c = defaultdict(int)

maxC = 0

for _ in range(N):
    s = input().strip()
    c[s] += 1
    tmp = c[s]
    if tmp > maxC:
        maxC = tmp

ans = []

for k in c:
    if c[k] == maxC:
        ans.append(k)

ans.sort()

for a in ans:
    print(a)


Measured memory_bytes: 32480
import Control.Monad
import Control.Applicative
import Data.List

main = do
  xs <- input read :: IO [Int]
  mapM_ print $ solve xs

solve :: [Int] -> [Int]
solve = fmt . anf

anf :: [Int] -> [(Int,Int)]
anf = reverse . sort . map (\x -> (length x, head x)) . group . sort

fmt :: [(Int,Int)] -> [Int]
fmt [x] = [snd x]
fmt (x:xs) = sort $ map snd (x : filter (\y -> fst x == fst y) xs)

input :: (String -> a) -> IO [a]
input f = map f . lines <$> getContents 

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

using namespace std;

int main() {
	int n, sum = 0; cin >> n;
	for(int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int l = 1; l <= n; l++) {
				sum += __gcd(__gcd(i, j), l);
			}
		}
	}
	
	cout << sum;
}




Measured memory_bytes: 3636
def main():
    a, b, c, d, e, f = [int(i) for i in input().split()]
    #print(a, b, c, d, e, f)
    
    L_UNIT = 100
    result_sw, result_s = 0, 0
    ans = -10000.

    water_list = []
    sugar_list = []

    for t_a in range( int( f / (a * L_UNIT) ) + 1 ):
        #print("a")
        for t_b in range( int( f / (b * L_UNIT) ) + 1 ):
            #print("b")
            #sugar_lim = e * (a * t_a + b * t_b)
            if( (a * t_a * L_UNIT + b * t_b * L_UNIT) <= f ):
                water_list.append(a * t_a * L_UNIT + b * t_b * L_UNIT)
            
    for t_c in range( int( f / c ) + 1 ):
        #print("c")
        for t_d in range( int( f / d ) + 1 ):
            #print("d")
            if( (c * t_c + d * t_d) <= f):
                sugar_list.append( c * t_c + d * t_d )
            
    for water in water_list:
        for sugar in sugar_list:
            sugar_lim = e * (water / L_UNIT)
            if( sugar <= sugar_lim  and 0 < (water + sugar) and (water + sugar) <= f):
                noudo = 100 * sugar / (water + sugar)
                #print(noudo)
                if(ans < noudo):
                    ans = noudo
                    result_sw = sugar + water
                    result_s = sugar
    #print(ans)                    
    print( "{} {}".format(result_sw, result_s) )
    
if __name__=="__main__":
    main()

Measured memory_bytes: 12476
N = int(input())
S = []
ans = {"AC":0, "WA":0, "TLE":0,"RE":0}
i = 0
for i in range(N):
    S.append(input())

for i in range(N):
    ans[S[i]] +=1
for k, v in ans.items():
    print(k + " x " + str(v))

Measured memory_bytes: 16304
#define _GLIBCXX_DEBUG
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
//#include <bits/stdc++.h>

typedef long long ll;
const ll INF = 1e18 + 1;
const ll MOD = 1e9 + 7;

// print(x, y, z);
// print(va.begin(), va.end());
void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if (std::distance(begin, it) % 50 == 49) { std::cout << std::endl; }
  }
  std::cout << std::endl;
}

const ll MAX_N = 1e6;

int main(int argc, char* argv[])
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  std::vector< ll > va(MAX_N+1, 0LL);
  std::cin >> va[1];

  for (ll i = 1; i <= MAX_N; i++) {
    va[i+1] = va[i] % 2 == 0 ? (va[i]/2) : (3*va[i] + 1);
    for (ll j = 1; j <= i; j++) {
      if (va[i+1] == va[j]) {
	print(i+1);
	return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 8064
#include <iostream>

using namespace std;

int main()
{
	long long int a, b, x;
	long long int ans;
	long long int anum, bnum;
	
	cin >> a >> b >> x;
	
	bnum = b / x + 1;
	anum = (a - 1) / x + 1;
	
	if (a == 0) anum = 0;
	
	ans = bnum - anum;
	
	cout << ans << endl;
	
	return (0);
}

Measured memory_bytes: 256
import sys

N,K = map(int, sys.stdin.readline().split())

k = list(range(N))

for _ in range(K):
    d = map(int, sys.stdin.readline().split())
    A = map(int, sys.stdin.readline().split())
    for a in A:
        k[a-1] = ''

print(len([i for i in k if i != '']))


Measured memory_bytes: 65952
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int a,b,t,ans = 0;
    cin >> a >> b >> t;
    for(int i = 1;a * i <= t + 0.5;i++)
    {
        ans += b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String w=sc.next();
int[] a=new int[26];
    for (int i = 0; i < w.length(); i++) {
        int k=0;
        for (char j = 'a'; j <='z'; j++) {
         if(w.charAt(i)==j)a[k]++;
         k++;
        }
    }
    for (int i = 0; i < 26; i++) {
        if(a[i]%2==1){
            out.println("No");
            break;
        }
        if(i==25&&a[i]%2==0)out.println("Yes");
    }
}}

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

int main() {
  int64_t a, b, c;
  cin >> a >> b >> c;
  if ((a+b+1) >= c) {
    cout << b + c;
  }
  else {
    cout << a + b*2 +1;
  }
  cout << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> vec(h+2);
  rep(i,h) cin>>vec[i+1];
  vec[0] = string(w+2,'#');
  vec[h+1] =  string(w+2, '#');
  rep(i,h) vec[i+1] = "#" + vec[i+1] + "#";

  h+=2; w+=2;
  int sx,sy;
  rep(i,h)rep(j,w)if(vec[i][j]=='%') sx=i,sy=j;

  vector<vector<int>> d(h, vector<int>(w, -1));

  queue<int> x,y;
  x.push(sx); y.push(sy);
  while(!x.empty()){
    int i = x.front(); x.pop();
    int j = y.front(); y.pop();
    const int dx[] = {0,0,1,-1}, dy[]={1,-1,0,0};
    rep(k,4){
      int nx = i+dx[k], ny=j+dy[k];
      if(vec[nx][ny]=='#' || d[nx][ny]!=-1) continue;
      d[nx][ny] = d[i][j]+1;
      x.push(nx); y.push(ny);
    }
  }

  int p=0, s=INF;
  rep(i,h)rep(j,w){
    if(vec[i][j]=='@') p = d[i][j];
    if(vec[i][j]=='$') s = min(s,d[i][j]);
  }

  if(p < s) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3308
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,K;

signed main(){
	cin>>N>>K;
	int cnt=0;
	while(N>0){
		N/=K;
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>


static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }


int main() {
    int n;
    cin >> n;
    vector<vector<int>> v(n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        scanf("%d%d",&a, &b);
        v[a-1].emplace_back(b-1);
        v[b-1].emplace_back(a-1);
    }
    deque<int> Q;
    stack<int> s;
    int cnt = 0;
    vector<int> visited(n, 0), num(n);
    s.emplace(0);
    while(!s.empty()){
        int a = s.top(); s.pop();
        visited[a]++;
        num[a] = cnt++;
        Q.emplace_front(a);
        for (auto &&i : v[a]) {
            if(!visited[i]) s.emplace(i);
        }
    }
    auto dp = make_v(n, 2, -1LL);
    ll ans;
    while(!Q.empty()){
        int a = Q.front(); Q.pop_front();
        ll b = 1, w = 1;
        for (auto &&i : v[a]) {
            if(dp[i][0] != -1){
                (b *= dp[i][1]) %= MOD;
                (w *= (dp[i][0]+dp[i][1])) %= MOD;
            }
        }
        dp[a][0] = b, dp[a][1] = w;
        (ans = dp[a][0] + dp[a][1]) %= MOD;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0,flag=1;
    cin>>n;
    int x[n];
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        if(flag==1)
        {
            if(x[i]%2)flag=0;
        }
    }

    for(int i=1;flag;i++)
    {
        for(int j=0;j<n;j++)
        {
            x[j]/=2;
            if(flag==1 && x[j]%2)
            {
                flag=0;
                break;
            }
        }
        c++;
    }
      cout<<c<<endl;

    return 0;
}


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

#define endl "\n"
#define si(a) scanf("%d ",&a);
#define si2(a,b) scanf("%d %d ",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sll(a) scanf("%lld ",&a);
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sf(a) scanf("%f ",&a);
#define sd(a) scanf("%lf ",&a);
#define sc(a) scanf("%c ",&a);
#define ss(a) scanf("%s ",a);
#define sf2(a,b) scanf("%f %f ",&a,&b);
#define sd2(a,b) scanf("%lf %lf ",&a,&b);
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define LL long long int


using namespace std;

LL a, b, c, d, rect1, rect2;

void init(){
	sll(a);
	sll(b);
	sll(c);
	sll(d);
	rect1 = a * b;
	rect2 = c * d;
	LL res = max(rect1, rect2);
	printf("%lld\n", res);
}

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

Measured memory_bytes: 384
N=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
t=[]
a=0
for n in range(N):
  s=v[n]-c[n]
  t.append(s)
t=sorted(t)
for i in range(N):
  if t[i]>0:
    a=a+t[i]
print(a)
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll H,W;
  cin>>H>>W;
  vector<string> vec(H);
  for(ll i=0;i<H;i++) {
cin>>vec[i];
  }
  
  vector<vector<ll>> dp(H,vector<ll> (W,0));
  dp[H-1][W-1]=1;
  for(ll i=W-2;i>=0;i--) {
if(vec[H-1][i]=='#') {
dp[H-1][i]=0;
}
    else {
dp[H-1][i]=dp[H-1][i+1];
    }
  }
  
  
  for(ll i=H-2;i>=0;i--) {
    if(vec[i][W-1]=='#') {
dp[i][W-1]=0;
    }
    else {
dp[i][W-1]=dp[i+1][W-1];
    }
  }
  
  ll mod=1000000007;
  for(ll i=W-2;i>=0;i--) {
for(ll j=H-2;j>=0;j--) {
if(vec[j][i]=='#') {
dp[j][i]=0;
}
  else {
dp[j][i]=(dp[j+1][i]+dp[j][i+1])%mod;
  }
}
  }
  
  
cout<<dp[0][0]<<endl;


}
  

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

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

  if(a.size()>b.size())cout<<"GREATER"<<endl;
  else if(a.size()<b.size())cout<<"LESS"<<endl;
  else{
    int x=0;
    for(int i=0; i<a.size(); i++){
      if(a[i]>b[i]){
        x=1;
        break;
      }else if(a[i]<b[i]){
        x=-1;
        break;
      }
    }
    if(x==1)cout<<"GREATER"<<endl;
    else if(x==0)cout<<"EQUAL"<<endl;
    else cout<<"LESS"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pp long long int
#define pb push_back
pp a[1000005];
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL); 
    cout.tie(NULL);
   pp n,m; cin>>n>>m;
    pp a[m]; pp b[m];
    for(pp i=0;i<m;i++) cin>>a[i]>>b[i];
    pp min = *max_element(a,a+m);
    pp maxw = *min_element(b,b+m);
    pp ans = maxw-min+1;
    pp zeo = 0;
    pp ansf = max(ans,zeo);
    cout<<ansf<<"\n";
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#define MAX 100001
int partition(int *,int,int);
int main()
{
  int i,A[MAX],n,encloser;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&A[i]);
      if(A[i]<0 || A[i]>100000)
	i--;
    }
  encloser=partition(A,0,n-1);
   for(i=0;i<encloser;i++)
    {
      printf("%d ",A[i]);
    }
   printf("[%d] ",A[encloser]);
   for(i=encloser+1;i<n-1;i++)
    {
      printf("%d ",A[i]);
    }
   printf("%d\n",A[n-1]);
  return 0;
}

int partition(int *A,int p,int r)
{
  int x,i,j,regard;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++)
    {
      if(A[j]<=x)
	{
	  i=i+1;
	  regard=A[i];
	  A[i]=A[j];
	  A[j]=regard;
	}
    }
  regard=A[i+1];
  A[i+1]=A[r];
  A[r]=regard;

  return i+1;
}



Measured memory_bytes: 2188
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

int main ()
{
    int N,M; cin >> N >> M;
    vector < int > A(N);
    REP(i,N) cin >> A[i];

    map < int, int > cnt;
    vector < int > acc(N,0);
    int dup = 0;
    REP(i,N) {
        cnt[A[i]]++;
        int idx = A[i] - cnt[A[i]];
        if (idx < 0) idx = 0;
        if (acc[idx] > 0) dup++;
        acc[idx]++;
    }

    vector < int > ans;
    REP(i,M) {
        
        int X,Y; 
        cin >> X >> Y;
        
        int At = A[X - 1];
        int idx_f = At - cnt[At];
        if (idx_f < 0) idx_f = 0;
        if (acc[idx_f] > 1) dup--;
        acc[idx_f]--;
        cnt[At]--;
        
        cnt[Y]++;
        int idx_t = Y - cnt[Y];
        if (idx_t < 0) idx_t = 0;
        if (acc[idx_t] > 0) dup++;
        acc[idx_t]++;
        ans.push_back(dup);
        A[X - 1] = Y;
    }

    REP(i,ans.size()) cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 13440
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int maxn = 2e5 + 500;
bool vis[15], flag;
char str[15][15];
int marry[15];
int n, m;
bool check_c(int x, int y) {//判断这两列是否满足对称
	for (int i = 0; i < n; i++)
		if (str[marry[i]][x] != str[i][y])return false;
	return true;
}
bool check() {//在行全部随机匹配完成后进行判断是否满足通过列的随机配对得到中心对称的图像
	memset(vis, 0, sizeof(vis));
	for (int i = 0; i < m; i++)
	{
		if (vis[i])continue;
		for (int j = i + 1; j < m; j++)
			if (!vis[j] && check_c(i, j))
			{
				vis[i] = true;
				vis[j] = true;
				break;
			}
	}
	int x = -1;
	for (int i = 0; i < m; i++)
		if (!vis[i]) {
			if (m % 2 == 1 && x == -1 && check_c(i, i))
				x = i;
			else
				return false;
		}
	return true;
}
void dfs(int u) {
	if (u == n / 2) {//每次dfs随机匹配2行
		int x;
		if (n % 2 == 1) {//若是n为奇数则需要有一行自身匹配
			for (int i = 0; i < n; i++)
				if (marry[i] == -1)
					marry[i] = x = i;
		}
		if (check())
			flag = true;
		if (n % 2 == 1)marry[x] = -1;
		return;
	}
	for (int i = u; i < n; i++) {
		if (marry[i] != -1)continue;
		for (int j = i + 1; j < n; j++) {
			if (marry[j] == -1)
			{
				marry[i] = j;
				marry[j] = i;
				dfs(u + 1);
				if (flag)return;
				marry[i] = -1;//记得把之前的数据清空
				marry[j] = -1;//以便之后继续进行其他行的随机配对
			}
		}
	}
}
int main() {
	while (~scanf("%d%d", &n, &m)) {
		for (int i = 0; i < n; i++) {
			scanf("%s", &str[i]);
			marry[i] = -1;
		}
		flag = false;
		dfs(0);
		if (flag)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
typedef long long ll;
int n;
int a[maxn];
ll ans1, ans2;
bool all_neg = 1;
vector<int> s, o; 
void output()
{
	printf("%d\n", o.size());
	for(auto v : o) printf("%d\n", v);
}
void solve_all_neg()
{
	int Max = -1e9, pos;
	for(int i = 1; i <= n; ++i)
		if(a[i] >= Max)
			Max = a[i], pos = i;
	printf("%d\n", Max);
	for(int i = 1; i < pos; ++i) o.push_back(1);
	for(int i = n; i > pos; --i) o.push_back(i - pos + 1);
	output();
	exit(0);
}
int main()
{
	//freopen("rand_9.in", "r", stdin);
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%d", &a[i]);
		if(a[i] >= 0)
			all_neg = 0;
	}
	for(int i = 1; i <= n; ++i)
		if(i & 1)
			ans1 += max(a[i], 0);
		else
			ans2 += max(a[i], 0);
	if(all_neg) solve_all_neg();
	printf("%lld\n", max(ans1, ans2));
	int start;
	if(ans1 >= ans2) start = 1;
	else start = 2;
	for(int i = start, j = start; i <= n; i += 2, j += 2)
		if(a[i] < 0)
		{
			o.push_back(j);
			if(i > 1) j -= 2;
			else --j;
		}
		else
			s.push_back(i);
	if(s[0] > 1) o.push_back(1);
	for(int i = 0; i < s.size() - 1; ++i)
		o.push_back(2);
	if(s.back() < n)
		o.push_back(2);
	output();	
	return 0;
}

Measured memory_bytes: 256
import collections,itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)] #1_indexed
for i,j in itertools.product(range(1,N+1),range(W+1)):
    w,v = wv[i-1]
    if j-w>=0:
        dp[i][j] = max(dp[i][j],dp[i-1][j-w]+v)
    dp[i][j] = max(dp[i][j],dp[i-1][j])
print(dp[-1][-1])


Measured memory_bytes: 121200
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n,x,s=0;
        cin>>n;
        for(int i=0;i<n;i++)
        {
            cin>>x;
            s^=x;
        }
        if(s==0)
        cout<<"Yes";
        else
        cout<<"No";
    }
    
}

Measured memory_bytes: 256
use std::io::stdin;

fn main () {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut t = String::new();
    stdin().read_line(&mut t).unwrap();
    let s = s.trim();
    let t = t.trim();
    let slen = s.chars().count();
    let s: String = s.chars().cycle().take(slen * 2).collect();

    println!("{}", if s.contains(t) {"Yes"} else {"No"});
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}

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

typedef long long ll;
typedef long long int lli;
const int MOD = 1000000007;
#define rep(i,n) for (int i = 0; i < (n); i++)

using namespace std;

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

	double N,res; cin >> N;

	if((int)N%2==0){ res = (N / 2) / N; }
	else{ res = ((N+1) / 2) / N; }
	cout << res << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
char a[11][11];


int main () {
	SpeedForce;
	setIO();
	cin >> n >> m >> k;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			cin >> a[i][j];

	int ans = 0;
	for (int A = 0; A < (1<<n); ++A) {
		for (int B = 0; B < (1<<m); ++B) {
			int cnt = 0;
			for (int i = 0; i < n; ++i) if (!(A&(1<<i))) {
				for (int j = 0; j < m; ++j) if(!(B&(1<<j))) {
					cnt += a[i][j] == '#';
				}
			}
			ans += (cnt==k);
		}
	}
	cout << ans << '\n';
   	
	return Accepted;
}

// B...a

Measured memory_bytes: 3616
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;

long long solve(){
    int n;
    cin>>n;
    vector<int> t(n,0);
    int ans = 0;
    for(int i = 0;i<n;i++){
        cin>>t[i];
    }
    vector<int> tar(n,0);
    for(int i = 0;i<n;i++){
        cin>>tar[i];
    }
    auto check=[](vector<int> &a,vector<int> &b){
        int n = a.size();
        for(int i = 0;i<n;i++){
            if(a[i] != b[i]) return false;
        }
        return true;
    };
    vector<int> target(n,0);
    for(int i = 0;i<n;i++){
        target[i]=i+1;
    }
    int idx1 = 1;
    while(!check(target,t)){
        idx1++;
        next_permutation(target.begin(),target.end());
    }
    int idx2 = 1;
    for(int i=0;i<n;i++){
        target[i]=i+1;
    }
    while(!check(target,tar)){
        idx2++;
        next_permutation(target.begin(),target.end());
    }
    cout<<abs(idx1-idx2)<<endl;
    return 0;
}

int main(){
    int T = 1;
    while(T--){
        solve();
    }
    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		while(true) {
			int a=in.nextInt();
			String op=in.next();
			if(op.equals("?"))break;
			
			if(op.equals("+")) {
				out.println(a+in.nextInt());
			}
			else if(op.equals("-"))out.println(a-in.nextInt());
			else if(op.equals("*"))out.println(a*in.nextInt());
			else if(op.equals("/"))out.println(a/in.nextInt());
		}
		out.flush();
	}

}



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

#define INF INT_MAX/2
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

   string S,T;
   cin>>S>>T;
   string a = "abcdefghijklmnopqrstuvwxyz";
   vector<int>f(a.size(),-1);
   vector<int>g(a.size(),-1);
   for(int i=0;i<S.size();i++){
      int sc = S[i]-'a';
      int tc = T[i]-'a';
      if(f[sc] != -1&&f[sc] != tc){
         cout<<"No"<<endl;
         return 0;
      }
      f[sc] = tc;
      if(g[tc] != -1&&g[tc] != sc){
         cout<<"No"<<endl;
         return 0;
      }
      g[tc] = sc;
   }
   cout<<"Yes"<<endl;
   return 0;
}


Measured memory_bytes: 916
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if b-a > k or c-a > k or d-a > k or e-a > k or c-b > k or d-b > k or e-b > k or d-c > k or e-c > k or e-d > k:
  print(":(")
else:
  print("Yay!")

Measured memory_bytes: 9200
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var dep = new List<int>();
        var arr = new bool[n];
        for (int i = 0; i < m; i++)
        {
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line2[0])-1;
            var b = int.Parse(line2[1])-1;
            if (a == 0) dep.Add(b);
            else if (b == 0) dep.Add(a);
            if (a == n - 1) arr[b] = true;
            else if (b == n - 1) arr[a] = true;
        }
        foreach(var x in dep)
            if (arr[x]) { Console.WriteLine("POSSIBLE");  goto end; }
        Console.WriteLine("IMPOSSIBLE");
        end:;
    }
}

Measured memory_bytes: 16300
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();

		for (int i = 0; true; i++) {
			int cnt = 1 + (a - 1) * i;
			
			if (cnt >= b) {
				pr.println(i);
				break;
			}
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string s;
  cin >> s;
  cout << (s == "ABC" ? "ARC\n" : "ABC\n");
  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  string s; cin >> s;
  int N = s.size();
  int cnt = 0;
  rep(i,N-1){
    if (s[i]!=s[i+1]) cnt++;
  }
  cout << cnt << endl;
  
  // cout << fixed << setprecision(10);
  
  return 0;
}


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

typedef pair<int, int> P;

struct Centroid{
    vector<int> centroid;
    vector<int> sz;
    vector<int> esub;
    int N;

    void dfs(int i, int prev, const vector<P> G[]){
        sz[i] = 1;
        bool is_centroid = true;
        for(auto p : G[i]){
            int j = p.first, e = p.second;
            if(j == prev) continue;
            dfs(j, i, G);
            sz[i] += sz[j];
            if(sz[j] > N/2) is_centroid = false;
            esub[e] = min(sz[j], N-sz[j]);
        }
        if(N - sz[i] > N/2) is_centroid = false;
        if(is_centroid) centroid.push_back(i);
    }

    vector<int> calculate(int Nin, const vector<P> G[]){
        N = Nin;
        sz.resize(N);
        esub.resize(N-1);
        dfs(0, -1, G);
        return centroid;
    }
};

int main(){
    const int M = 100000;
    int N, A[M], B[M];
    int64_t C[M];
    vector<P> edges[M];
    cin >> N;
    for(int i=0; i<N-1; i++){
        cin >> A[i] >> B[i] >> C[i];
        A[i]--; B[i]--;
        edges[A[i]].push_back({B[i], i});
        edges[B[i]].push_back({A[i], i});
    }

    Centroid CT;
    auto ct = CT.calculate(N, edges);

    int64_t ans = 0;
    for(int i=0; i<N-1; i++){
        ans += min(2*CT.esub[i], N-1) * C[i];
    }
    if(ct.size() == 1){
        int64_t mn = 1e9;
        for(int i=0; i<N-1; i++) if(A[i]==ct[0] || B[i]==ct[0]) mn = min(mn, C[i]);
        ans -= mn;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	// your code goes here
	int cur_max = 0;
	int max_max = 0;
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) { 
	    if (s[i] == 'R') {
	        cur_max += 1;
	    } else {
	        cur_max = 0;
	    }
	    if (cur_max > max_max) {
	        max_max = cur_max;
	    }
    }
    cout << max_max;
	return 0;
}


Measured memory_bytes: 3592
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
const int N = 10 + 5;
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

ll dfs(ll x) {
    if (x == 0) return 0;
    if (x == 1) return 1;
    return 2 * dfs(x / 2) + 1;
}

int main() {
    ll x;
    cin >> x;
    printf("%lld\n", dfs(x));
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;

int main(){
	string s; int k; cin >> s >> k;
	vector<string> ss;
	int len = s.size();
	Rep(i, len){
		Rep(j, k){
			if(i+j < len){
				string l = s.substr(i, j+1);
				bool flag = find(ss.begin(), ss.end(), l) == ss.end();
				if(flag){
					ss.pb(l);
				}
			}
		}
	}
	sort(ss.begin(), ss.end());
	cout << ss[k-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
import math
n,d = map(int, input().split())

ans = 0

for i in range(n):
    x, y = map(int, input().split())
    kyori = math.sqrt(x*x+y*y)
    if kyori <= d:
        ans+=1
print(ans)



Measured memory_bytes: 9204
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;

const int N=55;
const int M=10005;
const int K=500005;
const ll inf=1ll<<60;
struct edge{
	int from,to,next;
	ll f,v;
}e[K];
int n,m,Q,SS,TT,nd,top;
int cnt[N],S[N][N],P[N][N],id[N][N];
int from[M],vis[M],q[M*50];
int head[M],tot=1;
ll C[N][N],dis[M],ans[K];
pll op[K],a[K];
void add(int x,int y,ll f,ll v){
	e[++tot]=(edge){x,y,head[x],f,v};
	head[x]=tot;
	e[++tot]=(edge){y,x,head[y],0,-v};
	head[y]=tot;
}
bool bfs(){
	For(i,1,nd) dis[i]=inf,vis[i]=0;
	int h=0,t=1; q[1]=SS; dis[SS]=0;
	while (h!=t){
		int x=q[++h]; vis[x]=0;
		for (int i=head[x];i;i=e[i].next)
			if (dis[e[i].to]>dis[x]+e[i].v&&e[i].f){
				dis[e[i].to]=dis[x]+e[i].v;
				from[e[i].to]=i;
				if (!vis[e[i].to]){
					vis[e[i].to]=1;
					q[++t]=e[i].to;
				}
			}
	}
	return dis[TT]!=inf;
}
void del(){
	ll f=inf;
	for (int i=from[TT];i;i=from[e[i].from])
		f=min(f,e[i].f);
	op[++top]=pll(f,dis[TT]);
	for (int i=from[TT];i;i=from[e[i].from])
		e[i].f-=f,e[i^1].f+=f;
}
int main(){
	#ifdef zyy
		freopen("1.in","r",stdin);
	#endif 
	scanf("%d",&n);
	For(i,1,n){
		scanf("%d",&cnt[i]);
		For(j,1,cnt[i]) scanf("%d%d%lld",&S[i][j],&P[i][j],&C[i][j]);
		For(j,1,cnt[i]) For(k,j+1,cnt[i])
			if (S[i][j]>S[i][k]){
				swap(S[i][j],S[i][k]);
				swap(P[i][j],P[i][k]);
				swap(C[i][j],C[i][k]);
			}
	}
	SS=++nd; TT=++nd;
	For(i,1,n){
		For(j,1,cnt[i]-1) id[i][j]=++nd;
		id[i][0]=SS; id[i][cnt[i]]=TT;
		For(j,1,cnt[i]){
			add(id[i][j],id[i][j-1],inf,0);
			add(id[i][j-1],id[i][j],inf,C[i][j]);
			add(id[i][j-1],id[i][j],P[i][j],0);
		}
	}
	scanf("%d",&m);
	For(i,1,m){
		int x,y,c;
		scanf("%d%d%d",&x,&y,&c);
		For(j,1,cnt[y]){
			int k=1;
			for (;k<=cnt[x]&&S[x][k]+c<S[y][j];++k);
			add(id[y][j-1],id[x][k-1],inf,0);
		}
	}
	for (;bfs();del());
	scanf("%d",&Q);
	For(i,1,Q) scanf("%lld",&a[i].fi);
	For(i,1,Q) a[i].se=i;
	sort(a+1,a+Q+1);
	int pos=1;
	ll slop=0;
	ll res=0;
	For(i,1,Q){
		res+=(a[i].fi-a[i-1].fi)*slop;
		for (;pos<=top&&op[pos].se<a[i].fi;++pos){
			slop+=op[pos].fi;
			res+=(a[i].fi-op[pos].se)*op[pos].fi;
		}
		//cout<<pos<<endl;
		if (slop>=1ll<<50)
			for (;i<=Q;i++) ans[a[i].se]=-1;
		else ans[a[i].se]=res;
	}
	For(i,1,Q)
		printf("%lld\n",ans[i]);
}
/*
min a[i] c[i]
a[i]-a[j]>=lim[ij]

id[i][j+1]-id[i][j]>=0
id[i][j]-id[i][j+1]>=-C[i][j]
id[vi][x]-id[ui][y]>=0

max -lim[ij] b[ij]
sum bij <=a[i]
*/

Measured memory_bytes: 13696
@D=map[glob<>],@@=0..$'-<>=~$";map{$j=0;for$x(split){$k=($i+$j++)%3;$$k[$_]+=$D[$x-1][$_]for@@}++$i}<>;$\=1e15;for$i(@@){for$j(@@){$\-=$-=$i-$j&&$i-$_&&$j-$_&&$\-$0[$i]-$1[$j]-$2[$_]for@@}}print

Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	vector<int>a(n);
	int tmp;
	rep(i,n){
		cin>>tmp;
		a[tmp-1]=i+1;
	}
	rep(i,n){
		cout<<a[i];
		if(i<n-1)cout<<" ";
		else cout<<"\n";
	}

	return 0;
}

Measured memory_bytes: 1152
const A: usize = 1e6 as usize;
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);

    let mut count = vec![0; A + 1];
    for i in 0..n {
        count[a[i]] += 1;
    }

    let primes = get_primes();
    let mut pair_wise = true;
    for &p in primes.iter() {
        let mut c = 0;
        let mut cur = p;
        while cur <= A {
            c += count[cur];
            cur += p;
        }
        if c >= 2 {
            pair_wise = false;
            break;
        }
    }

    if pair_wise {
        println!("pairwise coprime");
        return;
    }

    let mut set_gcd = a[0];
    for i in 1..n {
        set_gcd = gcd(set_gcd, a[i]);
    }

    if set_gcd == 1 {
        println!("setwise coprime");
        return;
    }

    println!("not coprime");
}

fn get_primes() -> Vec<usize> {
    let mut is_prime = vec![true; A + 1];
    is_prime[0] = false;
    is_prime[1] = false;
    for i in 2..=A {
        if !is_prime[i] {
            continue;
        }

        let mut cur = i * 2;
        while cur <= A {
            is_prime[cur] = false;
            cur += i;
        }
    }

    let mut primes = vec![];
    for i in 2..=A {
        if is_prime[i] {
            primes.push(i);
        }
    }
    primes
}

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write_all(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 15372