akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    long double N, K; cin >> N >> K;
    long double ans = 0;
    REP(i, N+1) {
        int a = i;
        long double count = 0;
        res(j, 0) {
            if (a >= K) {
                count = j;
                break;
            }
            a *= 2;
        }
        ans += (1.0 / N) * pow(0.5, count);
    }
    cout << fixed << setprecision(100) << ans << endl;
}

Measured memory_bytes: 3752
#include <iostream>

using namespace std;

int cnt[100001];

int main(){
    int N;
    int ans = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        if(a > N) ans++;
        else{
            cnt[a]++;
        }
    }
    for(int i = 1; i <= N; i++){
        if(cnt[i] >= i) ans+= cnt[i]-i;
        else ans += cnt[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int M[3][3], O[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			scanf("%d", &M[i][j]);
		}
	}
	int N, X;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &X);
	    for (int i = 0; i < 3; i++) {
		    for (int j = 0; j < 3; j++) {
		        if (M[i][j] == X) {
		        	O[i][j] = 1;
	            }
            }
		}
	}
	
	if (O[0][0] + O[1][1] + O[2][2] == 3 || O[0][2] + O[1][1] + O[2][0] == 3) {
		printf ("Yes\n");
		return 0;
	}
	for (int i = 0; i < 3; i++) {
		if (O[i][0] + O[i][1] + O[i][2] == 3 || O[0][i] + O[1][i] + O[2][i] == 3) {
			printf ("Yes\n");
			return 0;
		}
	}
	printf ("No\n");
	return 0;
}

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

int main(void){
	int n, m, mul=0;
	int **A, *B;

	cin >> n >> m;
	A = new int*[n];
	B = new int[m];
	for (int i = 0; i < n; i++){
		A[i] = new int[m];
	}
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < m; i++){
		cin >> B[i];
	}

	for (int i = 0; i < n; i++){
		mul = 0;
		for (int j = 0; j < m; j++){
			mul += A[i][j] * B[j];
		}
		cout << mul << "\n";
	}

	delete[] A[0];
	delete[] A,B;

	return 0;
}

Measured memory_bytes: 1232
import os
H, W = map(int, input().split())
s = ["." + input() + "." for _ in range(H)]

s.insert(0, "."*(W+2))
s.insert(H+1, "."*(W+2))

for i in range(1, H+1):
    for j in range(1, W+1):
        target = s[i][j]
        if target == ".":
            continue
        l = s[i][j-1]
        r = s[i][j+1]
        u = s[i-1][j]
        d = s[i+1][j]
        if "#" not in [l, r, u, d]:
            print("No")
            os.sys.exit()

print("Yes")


Measured memory_bytes: 3188
n=int(input())
k=0
for i in range(1,10):
  checklist=set()
  checklist.add(n//i)
  if checklist.issubset({1,2,3,4,5,6,7,8,9}) and n%i==0:
      k=k+1
if k!=0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18
const int N = 100010;//10^5+10

const int MAX_N = 2000;
int a[MAX_N], n, x;
int f[MAX_N][MAX_N];

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

	vector<int> a(n);
	vector<int> b(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}

	vector<int> pat(n, 0);

	int L = -INF;
	//高さの変更があった点は、確定のはず。
	for (int i = 0; i < n; i++) {
		if (L < a[i]) {
			pat[i] = 1;
			L = a[i];
		}
	}

	int R = -INF;
	for (int i = n - 1; i >= 0; i--) {
		if (R < b[i]) {
			if (pat[i] && a[i] != b[i]) { cout << 0 << endl; return 0; }
			pat[i] = 1; R = b[i];
		}
		else {
			if (pat[i] && a[i] > b[i]) { cout << 0 << endl; return 0; }
		}
	}

	LL ans = 1;

	for (int i = 0; i < n; i++) {
		if (!pat[i])pat[i] = min(a[i], b[i]);
		(ans *= pat[i]) %= MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1e6+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
const int maxn = 1e6+5;
int n, m;
struct node {
    int to, next, w;
    bool operator < (const node& a) const {
        return w > a.w;
    }
} e[maxn<<1];
int cnt, head[maxn];
void add(int u, int v, int w) {
    e[cnt] = node{v, head[u], w};
    head[u] = cnt++;
}
bool vis[maxn];
int dis[maxn];
void dij(int st, int ed) {
    priority_queue<node> q;
    memset(dis,INF,sizeof(dis));
    dis[st] = 0;
    q.push(node{st, 0, 0});
    while (!q.empty()) {
        node u = q.top();
        q.pop();
        if(vis[u.to]) continue;
        vis[u.to] = 1;

        for (int i = head[u.to]; ~i; i = e[i].next) {
            int to = e[i].to;
            if (dis[to] > dis[u.to] + e[i].w) {
                dis[to] = dis[u.to] + e[i].w;
                q.push(node{to, 0, dis[to]});
            }
        }
    }
    printf("%d\n", dis[ed] == INF?-1:dis[ed]/2);
}
map<int, int>mp[maxn];
void init() {
    cnt = 0;
    memset(head,-1,sizeof(head));
    for (int i = 1 ; i <= n ; i ++) {
        mp[i].clear();
    }
}
int getid(int x, int y) {
    if (!mp[x][y]) mp[x][y] = ++n;
    return mp[x][y];
}
int main() {
    while(~scanf("%d%d", &n, &m)) {
        init(); int ed = n;
        for (int i = 1 ; i <= m ; i ++) {
            int u, v, c;
            scanf("%d%d%d", &u, &v, &c);
            int uc = getid(u, c);
            int vc = getid(v, c);
            add(uc, vc, 0); add(vc, uc, 0);
            add(u, uc, 1); add(uc, u, 1);
            add(v, vc, 1); add(vc, v, 1);
        }
        dij(1, ed);
    }
    return 0;
}


Measured memory_bytes: 93812
a,b,c = list(map(int,input().split()))


if c - b >= 0:
    ans = 2*b
    if c -b - a > 0:
        ans += a + 1
    elif c-b-a == 0:
        ans += a
    else:
        ans += c-b

else:
    ans = b+c

print(ans)

Measured memory_bytes: 3060
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { cin, nCin, biCin } = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return { cin: cin, nCin: () => Number(cin()), biCin: () => BigInt(cin()) };
})();

const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);

type Color = "Black" | "White";
type Grid = Color[][] & {
  height: number;
  width: number;
};
type PickData = {
  index: number;
  isPicked: boolean;
};

const getBlackCnt = (hPicks: PickData[], wPicks: PickData[], grid: Grid) =>
  hPicks
    .filter(({ isPicked }) => isPicked)
    .map(({ index }) => {
      const cs = grid[index];
      return wPicks
        .filter(({ isPicked }) => isPicked)
        .map(({ index }) => (cs[index] === "Black" ? 1 : 0) as number)
        .reduce((acc, x) => acc + x, 0);
    })
    .reduce((acc, x) => acc + x, 0);

const wPickFn = (K: number, grid: Grid, hPicks: PickData[], initialBlackCnt: number) => {
  const wPickFn = (n: number, wPicks: PickData[]): number =>
    n >= grid.width
      ? (() => {
          const hCnt = getBlackCnt(
            range(grid.height).map((i) => ({ index: i, isPicked: true })),
            wPicks,
            grid
          );
          const wCnt = getBlackCnt(
            hPicks,
            range(grid.width).map((j) => ({ index: j, isPicked: true })),
            grid
          );
          const hwCnt = getBlackCnt(hPicks, wPicks, grid);
          return initialBlackCnt - (hCnt + wCnt - hwCnt);
        })() === K
        ? 1
        : 0
      : wPickFn(n + 1, wPicks) +
        wPickFn(
          n + 1,
          wPicks.map(({ index, isPicked }) =>
            index === n ? { index: index, isPicked: true } : { index: index, isPicked: isPicked }
          )
        );
  return wPickFn(
    0,
    range(grid.width).map((j) => ({ index: j, isPicked: false }))
  );
};

const hPickFn = (grid: Grid, K: number) => {
  const initialBlackCnt = getBlackCnt(
    range(grid.height).map((i) => ({ index: i, isPicked: true })),
    range(grid.width).map((j) => ({ index: j, isPicked: true })),
    grid
  );
  const hPickFn = (n: number, hPicks: PickData[]): number =>
    n >= grid.height
      ? wPickFn(K, grid, hPicks, initialBlackCnt)
      : hPickFn(n + 1, hPicks) +
        hPickFn(
          n + 1,
          hPicks.map(({ index, isPicked }) =>
            index === n ? { index: index, isPicked: true } : { index: index, isPicked: isPicked }
          )
        );
  return hPickFn(
    0,
    range(grid.height).map((i) => ({ index: i, isPicked: false }))
  );
};

const getCnt = (K: number, grid: Grid) => hPickFn(grid, K);

{
  const [H, W, K] = [nCin(), nCin(), nCin()];
  const grid: Grid = (() => {
    const grid: Color[][] = range(H).map(() =>
      cin()
        .split("")
        .map((c) => (c === "#" ? "Black" : "White") as Color)
    );
    return { ...grid, height: H, width: W };
  })();
  const cnt = getCnt(K, grid);
  console.log(cnt);
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N; cin >> N;
  ll a[N]; rep(i,N) cin >> a[i];
  ll x = 0; rep(i,N) x ^= a[i];
  ll result[N]; rep(i,N) result[i] = x^a[i];
  debug(result,result+N);
  return 0;
}

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

int main(){
long long a,d,e,s,sum;
cin>>a;
s=sqrt(a)/1;
sum=0;
  for(int i=1;i<s+1;i++){
    if((a-i)/i<=i){
      continue;
    }
    if((a-i)%i==0){
      sum+=(a-i)/i;
    }
      
    
    }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#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")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    /*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int a,b;
    cin>>a>>b;
    cout<<(a*b);

    printclock;
    return 0;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  int n, k; cin >> n >> k;
  long res = 0;
  for (int i = k; i <= n + 1; i++){
    long l = 1ll * i * (i - 1) / 2;
    long r = 1ll * (2 * n - i + 1) * i / 2;
    res += (r - l + 1); res %= MOD;
  }
  cout << res;
  return 0;
}

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

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

    static class A_FallingAsleep {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int N = Integer.parseInt(in.next());
            String s[] = new String[N];
            int t[] = new int[N];
            for (int i = 0; i < N; i++) {
                s[i] = in.next();
                t[i] = Integer.parseInt(in.next());
            }
            String X = in.next();
            int ans = 0;
            int pt = 0;
            int t2[] = new int[N];
            for (int i = 0; i < N; i++) {
                ans += t[i];
                t2[i] = ans;
                if (X.equals(s[i])) {
                    pt = i;
                }
            }

            ans = ans - t2[pt];
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21844
#include <cstdio>
#include <algorithm>
#include <cmath>

int d[1005];

int main()
{
    int n;
    while(scanf("%d ", &n) && n > 0)
    {
        for(int i = 0; i < n; ++i)
        {
            scanf("%d ", &d[i]);
        }

        int min = 1 << 30;
        for(int i = 0; i < n; ++i)
        {
            for(int j = 0; j < n; ++j)
            {
                if(i == j)
                {
                    continue;
                }
                else
                {
                    min = std::min(min, std::abs(d[i] - d[j]));
                }
            }
        }
        printf("%d\n", min);
    }
    return 0;
}


Measured memory_bytes: 2716
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int):

    if N%2 != 0:
        print(0)
        exit()

    ans = 0
    i = 1
    while(5 ** i <= N):
        ans +=  (N//2)//(5**i)
        i += 1
    
    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define N 501
int n, m, a[N][N], b[N][N];
int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            char c = getchar();
            if (c == '\n') c = getchar();
            a[i][j] = b[i][j] = c == '#';
        }
    for (int i = 1; i <= n; i++) {
        a[i][1] = b[i][m] = 1;
        if (i & 1)
            for (int j = 1; j < m; j++) a[i][j] = 1;
        else
            for (int j = 2; j <= m; j++) b[i][j] = 1;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) putchar(a[i][j] ? '#' : '.');
        putchar('\n');
    }
    putchar('\n');
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) putchar(b[i][j] ? '#' : '.');
        putchar('\n');
    }
}

Measured memory_bytes: 2688
import math
N=int(input())
A=list(map(int,input().split()))

B=[A[i]-(i+1) for i in range(N)]
B.sort()
temp=0

if N%2==0:
  ans = B[N//2]
  ans2= B[N//2 -1]
  temp=0
  for j in range(N):
    temp+= abs(B[j] - ans)
  temp2=0
  for j in range(N):
    temp2+= abs(B[j] - ans2)
  ans= min(temp,temp2)
else:
  ans = B[N//2]
  temp=0
  for j in range(N):
    temp+= abs(B[j] - ans )
  ans=temp
print(ans)



Measured memory_bytes: 26608
//abc105_a.cpp
//Sat Aug 18 12:07:15 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INF 100000000
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (n%k==0){
		cout << 0 << endl;
	}else {
		cout << 1 << endl;
	}
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

const int N=2e5+19;

map<pii,int> sz;
int fa[N],Fa[N];
int n,k,l,x,y;

int getf(int x){
	return fa[x]==x?x:fa[x]=getf(fa[x]);
}
int getF(int x){
	return Fa[x]==x?x:Fa[x]=getF(Fa[x]);
}
void Union(int x,int y){
	x=getf(x),y=getf(y);
	if (x!=y) fa[x]=y;
}
void Merge(int x,int y){
	x=getF(x),y=getF(y);
	if (x!=y) Fa[x]=y;
}

int main(){
	n=IN(),k=IN(),l=IN();
	For(i,1,n+1) fa[i]=Fa[i]=i;
	For(i,0,k) Union(IN(),IN());
	For(i,0,l) Merge(IN(),IN());
	For(i,1,n+1) sz[mp(getf(i),getF(i))]++;
	For(i,1,n+1) printf("%d ",sz[mp(getf(i),getF(i))]);
	puts("");
}

Measured memory_bytes: 13568
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,m,n) for(int i = m; i < n; ++i)
#define RFOR(i,m,n) for(int i = n - 1; i >= m; --i)
#define CIN(a) cin >> a
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a << endl
#define COUT2(a, b) cout << a << " " << b << endl
#define COUT3(a, b, c) cout << a << " " << b << " " << c << endl
#define pb push_back
#define PB push_back
#define VINT(v, n) vector<int> v(n); REP(i, n) { v[i] = 0 }
#define VINT2(v, n, m) vector<vector<int> > v(n, vector<int>(m)); REP(i, n) { REP(j, m) { v[i][j] = 0 } }
#define VCHAR(v, n) vector<char>v(n)
#define KIRIAGE(a, b) a += (b - a % b) % b
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef long long ll;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
	string s, ans;
	CIN(s);
	REP(i, s.size()) {
		if(s[i] == '0') ans += '0';
		else if(s[i] == '1') ans += '1';
		else if(s[i] == 'B' && ans.size()) {
			ans.erase(ans.size() - 1, 1);
		}
	}
	COUT(ans);
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner (System.in)){
			String clock = sc.nextLine();
			String target = sc.nextLine();
			int pointer = 0;
			boolean result = false;

			for (int i=0; i<clock.length(); i++) {
				String s = "";
				pointer = i;
				for (int j=0; j<target.length(); j++) {
					s += clock.substring(pointer,pointer+1);
					pointer++;
					if (pointer==clock.length()) pointer = 0; //最後になったら最初に戻る
				}
			//	System.out.println(s);
				if (s.equals(target)) {  //作成したものがターゲットと一致したら
					result = true;
					break;
				}
			}
			if (result) System.out.println("Yes");
			else System.out.println("No");
		}
	}
}


Measured memory_bytes: 26972
n=int(input())
a,b=map(int,input().split())
x=list(map(int,input().split()))
t=0
u=0
v=0
for i in x:
  if i<=a:
    t+=1
  elif i<=b:
    u+=1
  else:
    v+=1
print(min(t,u,v))

Measured memory_bytes: 3316
n, c, k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()
cnt = 1
buss = 0
fir = t[0]
for i in range(1, n):
    if fir <= t[i] and t[i] <= fir + k and cnt < c:
        cnt += 1
    else:
        buss += 1
        cnt = 1
        fir = t[i]
if cnt >= 1:
    buss += 1
print(buss)

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

int main() {
  long long N, W;
  cin >> N >> W;
  vector<vector<long long>> dp(N + 1, vector<long long>(W + 1, 0));

  for (long long i = 1; i <= N; i++) {
  	int w, v;
  	cin >> w >> v;
  	for (long long j = 0; j <= W; j++) {
      if (j < w) {
        dp[i][j] = dp[i - 1][j];
      }
      else{
        dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v);
  	  }
//  	  cout << "w: " << w <<  " v:" << v << endl;
//  	  cout << "    i, j: " << i << "," << j <<  " dp:" << dp[i][j] << endl;
    }
  }
  
  long long ans = 0;
  for (long long j = 0; j <= W; j++) {
    if (ans < dp[N][j]) {
      ans = dp[N][j];
    }
  }
  cout << ans << endl;
}


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

int main(){
	int c1,c5,c10,c50,c100,c500;
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
	int total = c1 + c5*5 + c10*10 + c50*50 + c100*100 + c500*500;
	cout << ((total>=1000) ? (1):(0)) << '\n';
	return 0;
}

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

using namespace std;

int main(){
    int H, W; cin >> H >> W;
    bool x[H], y[W];
    fill(x, x + W, false);
    fill(y, y + H, false);
    char c[H][W];
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < H; ++i){
        bool isWhite = true;
        for(int j = 0; j < W; ++j){
            if(c[i][j] == '#') isWhite = false;
        }
        y[i] = isWhite;
    }
    for(int i = 0; i < W; ++i){
        bool isWhite = true;
        for(int j = 0; j < H; ++j){
            if(c[j][i] == '#') isWhite = false;
        }
        x[i] = isWhite;
    }
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            if(x[j] || y[i]) continue;
            cout << c[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())
ans = 0

if A + B <= 2*C:
    ans = A*X + B *Y
    
else:
    ans += C*2*min(X, Y)
    nokori = max(X, Y)-min(X, Y)
    
    if X > Y:
        if A >= 2*C:
            ans += 2*C*nokori
        else:
            ans += A*nokori
    
    elif X < Y:
        if B >= 2*C:
            ans += 2*C*nokori
        else:
            ans += B*nokori

print(ans)

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

int main(){
  int n;
  map<int, int> A; 
  cin >> n;
  for(int i = 0; i < n; ++i){
    int a;
    cin >> a;
    if(!A.count(a))A[a] = 1;
    else ++A[a];
  }

  int ans = 0;
  for(auto a : A){ 
    if(a.second % 2)++ans;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4992
n = int(input())
l = [int(x) for x in input().split()]

for i in range(n):
    a = l[i]
    j = i - 1

    while j >= 0 and l[j] > a:
        l[j+1] = l[j]
        j = j - 1

    l[j+1] = a
    print(*l)

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    string A,B,C; cin >> A >> B >> C;

    if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0]) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;

}

Measured memory_bytes: 256
#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;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
ll n,w,val[200],wgh[200],dp[105][100004];
ll recurs(int pos,int v)
{
	if(pos>=n)
	{
		if(v==0) return 0;
		else return (w+5);
	} 
	//return 0;
	if(dp[pos][v]!=-1) return dp[pos][v];
	dp[pos][v]=min(wgh[pos]+recurs(pos+1,v-val[pos]),recurs(pos+1,v));
	return dp[pos][v];
}
int main()
{
    ios_base::sync_with_stdio(false);//this works only
    cin.tie(NULL);// when first all inputs are from user
    cout.tie(NULL);//you will see all outputs afterwards
    cin>>n>>w;
    ll v=0;
    memset(dp,-1,sizeof(dp));
    for (int i = 0; i < n; ++i)
    {
    	cin>>wgh[i]>>val[i];
    	v+=val[i];
    }
    for (int i = v; i >=0; --i)
    {
    	ll check=recurs(0,i);
    	if(check<=w)
    	{
    		cout<<i<<endl;
    		break;
    	}
    }
    return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    int v[51];
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    int ans = 0;
    for(int l = 0; l <= n; l++){
        for(int r = n - 1; r >= l - 1; r--){
            if(l + n - 1 - r > k) continue;
            if(l == 0 && r == n - 1) continue;
            vector<int> vec;
            for(int i = 0; i < l; i++){
                vec.push_back(v[i]);
            }
            for(int i = n - 1; i > r; i--){
                vec.push_back(v[i]);
            }
            sort(vec.begin(), vec.end(), greater<int>());
            int nok = k - (l + n - 1 - r);
            int nag = vec.size();
            for(int i = 0; i < nag; i++){
//                cout << vec[i] << " ";
            }
//            cout << "     ";
            int i = nag - 1;
            while(vec[i] < 0 && nok > 0){
                vec.pop_back();
                i--;
                nok--;
            }
            nag = vec.size();
            for(int i = 0; i < nag; i++){
//                cout << vec[i] << " ";
            }
//            cout << "     ";
            int sum = 0;
            for(int i = 0; i < nag; i++){
                sum += vec[i];
            }
//            cout << l << " " << r << " " << sum << endl;
            ans = max(sum, ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		String N = stdIn.nextLine();
		int sum = 0;
		for(int i = 0; i < N.length(); i ++) {
			sum += Integer.parseInt(N.substring(i, i + 1));
		}
		if(sum % 9 == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 50416
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define PI 3.141592653589793
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, K;
  cin >> N >> K;
  vll A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    A.at(i)--;
  }
  vll time(N, -1);
  map<ll, ll> city;
  ll now = 0;
  time.at(0) = 0;
  city[0] = 0;
  ll x = INF;
  ll one = INF;
  
  while(true){
    ll next = A.at(now);
    if(time.at(next) == -1){
      time.at(next) = time.at(now) + 1;
      city[time.at(next)] = next; 
      now = next;
    }
    else{
      x = time.at(next);
      one = time.at(now) + 1 - time.at(next);
      break;
    }
  }

  if(K <= x) cout << city.at(K)+1 << endl;
  else{
    ll ans = (K - x) % one;
    cout << city.at(x + ans) + 1 << endl;
  }

  /*cout << x << endl;
  cout << one << endl;
  cout << city[2] << endl;*/
}

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

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

typedef long long LL;

int uf[100000];
set<int> K[100000];
set<int> P[100000];

int Find(int num){
  if(uf[num]==num){
    return num;
  }else{
    uf[num]=Find(uf[num]);
    return uf[num];
  }
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
    p[i]--;
  }
  for(int i=0;i<n;i++){
    uf[i]=i;
  }
  int x,y;
  for(int i=0;i<m;i++){
    cin >> x >> y;
    x--;
    y--;
    x=Find(x);
    y=Find(y);
    uf[x]=y;
  }
  for(int i=n;i>=0;i--){
    Find(i);
  }
  for(int i=0;i<n;i++){
    K[uf[i]].insert(i);
    P[uf[i]].insert(p[i]);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    for(set<int>::iterator itr=K[i].begin();itr!=K[i].end();itr++){
      if(P[i].find((*itr))!=P[i].end()){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

// 0-based index
// tree size: 2 * NN - 1
// leaves indices: [NN - 1, 2 * NN - 1)
template<class T>
struct SegTree {
    int NN;
    T default_value;
    vector<T> data;

    T aggr(T a, T b) {
        return max(a, b);
    }

    SegTree(int N, T val) {
        default_value = val;
        NN = 1; while (NN < N) NN <<= 1;
        data = vector<T>(2 * NN, val);
    }

    SegTree(const vector<T> v, T val) {
        default_value = val;
        int N = v.size();
        NN = 1; while (NN < N) NN <<= 1;
        data = vector<T>(2 * NN, val);
        copy(v.begin(), v.end(), data.begin() + (NN - 1));
        build(0, 0, NN);
    }

    void build(int u, int l, int r) {
        if (r - l == 1) return;
        int m = (l + r) / 2;
        build(u * 2 + 1, l, m);
        build(u * 2 + 2, m, r);
        data[u] = aggr(data[2 * u + 1], data[2 * u + 2]);
    }

    T query(int a, int b, int u, int l, int r) {
        if (l >= b || r <= a)
            return default_value;
        if (l >= a && r <= b)
            return data[u];
        int m = (l + r) / 2;
        T res1 = query(a, b, u * 2 + 1, l, m);
        T res2 = query(a, b, u * 2 + 2, m, r);
        return aggr(res1, res2);
    }

    void update_value(int idx, T x, int u, int l, int r) {
        if (idx < l || idx >= r)
            return;
        if (idx == l && r - l == 1) {
            data[u] = x;
            return;
        }
        int m = (l + r) / 2;
        update_value(idx, x, u * 2 + 1, l, m);
        update_value(idx, x, u * 2 + 2, m, r);
        data[u] = aggr(data[2 * u + 1], data[2 * u + 2]);
    }

    void update_delta(int idx, T x, int u, int l, int r) {
        update_value(idx, data[NN - 1 + idx] + x, u, l, r);
    }
};

template <class T>
ostream & operator << (ostream &out, const SegTree<T> &seg) {
    out << "SegTree(NN=" << seg.NN << ", ";
    for (int u = seg.NN - 1, sz = seg.NN; sz >= 1; u /= 2, sz /= 2) {
        out << "[ ";
        for (int i = 0; i < sz; i++) {
            out << seg.data[u + i] << " ";
        }
        out << "]";
    }
    out << ")";
    return out;
}

int solve() {
    int H, W, M;
    cin >> H >> W >> M;

    auto cntR = vector<int>(H, 0);
    auto cntC = vector<int>(W, 0);
    auto t = vector<vector<int>>(H, vector<int>());
    for (int i = 0; i < M; i++) {
        int r, c; 
        cin >> r >> c;
        r--; c--;
        cntR[r]++;
        cntC[c]++;
        t[r].push_back(c);
    }

    auto seg = SegTree<int>(cntC, 0);
    // cout << seg << endl;
    int ans = -1;
    for (int r = 0; r < H; r++) {
        for (auto c : t[r]) {
            seg.update_delta(c, -1, 0, 0, seg.NN);
        }
        // cout << seg << endl;
        int val = cntR[r] + seg.query(0, W, 0, 0, seg.NN);
        ans = max(ans, val);
        for (auto c : t[r]) {
            seg.update_delta(c, +1, 0, 0, seg.NN);
        }
    }
    return ans;
}

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

    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 27208
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
//#define P pair<int, int>

using namespace std;
using ll = __int64_t;

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

void solve(){
  int n;
  cin >> n;
  ll a[n], ans1, ans2 = INF;
  rep(i, n) cin >> a[i];
  sort(a, a+n);
  ans1 = a[n-1];
  rep(i, n){
    if(abs(ceil((double)ans1/2)-a[i]) < abs(ceil((double)ans1/2)-ans2)){
      ans2 = a[i];
    }
  }
  cout << ans1 << " " << ans2 << endl;
}

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


Measured memory_bytes: 1024
import fractions
from functools import reduce

def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)

def lcm_for_lst(lst):
  return reduce(lcm, lst)

n = int(input())
lst = []
for i in range(n):
  t = int(input())
  lst.append(t)
print(lcm_for_lst(lst))

Measured memory_bytes: 5076
#include<iostream>
#include<math.h>
using namespace std;
int main(){
  long int N;
  cin >> N;
  long int min=N+1-2;
  for(long int i=2;(double)i<=sqrt(N);i++){
    if(N%i==0){
      if(N/i+i-2<min){
        min=N/i+i-2;
      }
    }
  }
  cout << min;
  return 0;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
  char b;
  cin >> b;

  if(b == 'A') cout << "T" << endl;
  if(b == 'T') cout << "A" << endl;
  if(b == 'C') cout << "G" << endl;
  if(b == 'G') cout << "C" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
#include <stdio.h>
using namespace std;
int N, M, Q; 
vector<int> E[100010]; 
int V[100010]; 
int D[100010]; 
int C[100010]; 
int ans[100010]; 
int memo[100010]; // これ未満の値が来たら打ち切ってよい
void bfs(int i){
	if(memo[V[i]] > D[i]) return; 
	queue<int> que;
	int dist[100010] = {}; 
	que.push(V[i]); 
	dist[V[i]] = D[i] + 1; 
	memo[V[i]] = D[i] + 1; 
	if(!ans[V[i]]) ans[V[i]] = C[i]; 
	while(que.size()){
		int p = que.front(); que.pop(); 
		if(dist[p] <= 1) break; 
		for(int j = 0; j < E[p].size(); j++){
			int q = E[p].at(j); 
			if(memo[q] < dist[p] - 1 && dist[q] == 0){
				que.push(q);
				dist[q] = dist[p] - 1;
				memo[q] = dist[q]; 
				if(!ans[q]) ans[q] = C[i];
			}
		}
	}
	return; 
}
int main(){
	cin >> N >> M; 
	fill(memo, memo+100010, -1); 
	for(int i = 0; i < M; i ++){
		int a, b; 
		scanf("%d%d", &a, &b); 
		a--; b--; 
		E[a].push_back(b); 
		E[b].push_back(a); 
	}
	cin >> Q; 
	for(int i = 0; i < Q; i++){
		scanf("%d%d%d", &V[i], &D[i], &C[i]);
		V[i] --; 
	}
	for(int i = Q-1; i >= 0; i--){
		bfs(i); 
	}
	for(int i = 0; i < N; i++){
		printf("%d\n", ans[i]);
	}
}

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define com(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define pri(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<endl;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
/*__builtin_clz();
__builtin_ctz();
__builtin_popcount();*/
int main()
{
    speed;
    ll h;
    cin>>h;
    ll k=0;
    ll sum=0;
    while(h>0)
    {
        k++;
        h=h/2;
        sum= pow(2,k);
    }
    cout<<sum-1<<"\n";
    cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
}
 
 
 
 
 
// bool prime[100000];
 
// // int gcdExtended(int a, int b, int *x, int *y) ;
// ll modInverse(int a, int m) 
// { 
//     int x, y; 
//     int g = gcdExtended(a, m, &x, &y); 
//     // if (g != 1) 
//     //     cout << "Inverse doesn't exist"; 
//     // else
//     // { 
//         // m is added to handle negative x 
//         int res = (x%m + m) % m; 
//         return res; 
//     // } 
// } 
  
// // // C function for extended Euclidean Algorithm 
// int gcdExtended(int a, int b, int *x, int *y) 
// { 
//     // Base Case 
//     if (a == 0) 
//     { 
//         *x = 0, *y = 1; 
//         return b; 
//     } 
  
//     int x1, y1; // To store results of recursive call 
//     int gcd = gcdExtended(b%a, a, &x1, &y1); 
  
//     // Update x and y using results of recursive 
//     // call 
//     *x = y1 - (b/a) * x1; 
//     *y = x1; 
  
//     return gcd; 
// } 
// ll modu(ll x)
// {
//     if(x<0)
//     {
//         x+=mod;
//     }
//     else 
//     {
//         x=x%mod;
//     }
//     return x;
// }
 
// void SieveOfEratosthenes(int n) 
// { 
//     // Create a boolean aay "prime[0..n]" and initialize 
//     // all entries it as true. A value in prime[i] will 
//     // finally be false if i is Not a prime, else true. 
     
//     memset(prime, true, sizeof(prime)); 
  
//     for (int p=2; p*p<=n; p++) 
//     { 
//         // If prime[p] is not changed, then it is a prime 
//         if (prime[p] == true) 
//         { 
//             // Update all multiples of p greater than or  
//             // equal to the square of it 
//             // numbers which are multiple of p and are 
//             // less than p^2 are already been marked.  
//             for (int i=p*p; i<=n; i += p) 
//                 prime[i] = false; 
//         } 
//     } 
//     prime[1]=false;
  
//     // Print all prime numbers 
//     // for (int p=2; p<=n; p++) 
//     //    if (prime[p]) 
//     //       cout << p << " "; 
// } 
// ll power(ll x, unsigned ll y, ll p) 
// { 
//     ll res = 1;      // Initialize result 
  
//     x = x % p;  // Update x if it is more than or  
//                 // equal to p 
  
//     while (y > 0) 
//     { 
//         // If y is odd, multiply x with result 
//         if (y & 1) 
//             res = (res*x) % p; 
  
//         // y must be even now 
//         y = y>>1; // y = y/2 
//         x = (x*x) % p;   
//     } 
//     return res; 
// } 


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
using namespace std;

int V;
vector<int> G[2000];
int match[2000];
bool used[2000];

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v]=true;
  for(int i=0;i<(int)G[v].size();i++){
    int u=G[v][i],w=match[u];

    if( w<0 || !used[w] && dfs(w) ){

      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res=0;
  memset(match,-1,sizeof(match));
  for(int v=0;v<V;v++){
    if(match[v]<0){
      memset(used,0,sizeof(used));
      if(dfs(v)){
	res++;
      }
    }
  }
  return res;
}


int m,n;
int b[500],r[500];

int main(){
  while(cin>>m>>n){
    if(m==0&&n==0)break;

    for(int i=0;i<m;i++)cin>>b[i];
    for(int i=0;i<n;i++)cin>>r[i];

    for(int i=0;i<2000;i++)G[i].clear();

    //for(int i=0;i<m;i++)add_edge(n+m,i);
    //for(int i=0;i<n;i++)add_edge(m+i,n+m+1);

    for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
	if( __gcd(b[i],r[j])> 1 )add_edge(i,m+j);
      }
    }

    V=m;
    cout<<bipartite_matching()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX 20

int h,w;
char ss[MAX][MAX];

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

int bfs(int s, int t){
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<P> que;
	que.emplace(s, t);
	dist[s][t] = 0;
	while(que.size()){
		P p = que.front();
		que.pop();
		REP(i,4){
			int ny = p.first + dy[i], nx = p.second + dx[i];
			if(0 <= ny && ny < h && 0 <= nx && nx < w && ss[ny][nx] != '#' && dist[ny][nx] == INF){
				que.push(P(ny, nx));
				dist[ny][nx] = dist[p.first][p.second] + 1;
			}
		}
	}
    int res = 0;
    REP(i,h){
        REP(j,w){
            if(dist[i][j] != INF){
                res = max(res, dist[i][j]);
            }
        }
    }
    return res;
}

signed main(){
    cin >> h >> w;
    REP(i,h){
        REP(j,w){
            cin >> ss[i][j];   
        }
    }
    vector<P> cand;
    REP(i,h){
        REP(j,w){
            if(ss[i][j] == '.'){
                cand.emplace_back(i, j);
            }
        }
    }
    int ans = 0;
    int n = cand.size();
    for(int i = 0; i < n; i++){
        ans = max(ans, bfs(cand[i].first, cand[i].second));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool check(string sub, int n) {
	for (int i=0; i<(int)n/2; i++) {
		if (sub[i] != sub[n/2+i]) return false;
	}
	return true;
}
int main () {
	string s;
	cin >> s;
	int l = s.size()-1;
	if (l%2!=0) l--;
	while (l>0) {
		string sub=s.substr(0, l);
		if (check(sub, l) == true) {
			cout << l; 	
			return 0;
		}
		l-=2;
	}
	cout << 0;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main(){
  int m,n;
  cin>>m>>n;
  char arr[m][n];
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      cin>>arr[i][j];
    }
  }
  vector<vector<int>>dp(m,vector<int>(n,0));
  for(int i=0;i<m;i++){
    if(arr[i][0]=='#')break;
    dp[i][0]=1;
  }
  for(int j=0;j<n;j++){
    if(arr[0][j]=='#')break;
    dp[0][j]=1;
  }
  for(int i=1;i<m;i++){
    for(int  j=1;j<n;j++){
      if(i==0||j==0){
        if(arr[i][j]=='#')dp[i][j]=0;
        else{
          dp[i][j]=1;
        }
      }
      else{
        if(arr[i][j]=='#'){
          dp[i][j]=0;
        }
        else dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
      }

    }
  }
  cout<<dp[m-1][n-1]<<endl;
}

Measured memory_bytes: 8504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  if (op == '+') cout << a+b << endl;
  else cout << a - b << endl;
}


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

int main() {

	int k, a, b;
	cin >> k >> a >> b;
	

	string ans = "NG";

	if ((a-1) / k < b / k) {
		ans = "OK";
	}

	cout << ans << endl;

	cin >> a;

	return 0;


}

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

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a, b, c;

            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            c = (x - a) % b;
            Console.WriteLine(c);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092