akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

ll A[200000] = {};
ll B[200003] = {};

int main(void) {

	ll N;
	cin >> N;
	FOR(i, N)
		cin >> A[i];

	for (int r = 0; r < N; r++) {
		B[r + 1] = A[r] + B[r];
		//cerr << B[r + 1] << endl;
	}

	B[N + 1] = 10000000000000000LL;
	sort(B, B + N + 2);

	ll answer = 0;

	for (int i = 0; i < N + 2; i++) {
		//cout << B[i] << " " << upper_bound(B, B + N + 2, B[i]) - B - ( i + 1 ) << endl;
		answer += (ll)(upper_bound(B, B + N + 2, B[i]) - B) - (i + 1);
	}

	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<limits.h>

using namespace std;

int main () {
    int n;
    long c, m = LONG_MAX, M = LONG_MIN, t = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> c;
        if (c < m) {
            m = c;
        }
        if (c > M) {
            M = c;
        }
        t += c;
    }
    cout << m << " " << M << " " << t << endl;

    return 0;
}

Measured memory_bytes: 1168
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto Q = readln.chomp.to!int;
    auto pqmin = new BinaryHeap!(Array!long, "a < b");
    auto pqmax = new BinaryHeap!(Array!long, "a > b");
    long seppen = 0;
    long left = 0;
    long right = 0;
    int cnt = 0;

    while (Q--) {
        auto s = readln.split.map!(to!long);
        if (s[0] == 1) {
            auto a = s[1];
            auto b = s[2];
            seppen += b;
            if (!pqmin.empty && a >= pqmin.front) {
                pqmax.insert(a);
                right += a;
            } else {
                pqmin.insert(a);
                left += a;
            }
            while (pqmax.length.to!int - pqmin.length.to!int > 1) {
                pqmin.insert(pqmax.front);
                left += pqmax.front;
                right -= pqmax.front;
                pqmax.removeFront;
            }
            while (pqmin.length.to!int - pqmax.length.to!int > 1) {
                pqmax.insert(pqmin.front);
                right += pqmin.front;
                left -= pqmin.front;
                pqmin.removeFront;
            }
        } else {
            long ans;
            long l = left;
            long r = right;
            long lcnt = pqmin.length.to!long;
            long rcnt = pqmax.length.to!long;
            if (pqmax.length == pqmin.length) {
                ans = pqmin.front;
                l -= pqmin.front;
                lcnt -= 1;
            } else if (pqmax.length > pqmin.length) {
                ans = pqmax.front;
                r -= pqmax.front;
                rcnt -= 1;
            } else {
                ans = pqmin.front;
                l -= pqmin.front;
                lcnt -= 1;
            }
            writeln(ans, " ", ans * lcnt - l - ans * rcnt + r + seppen);
        }
    }
}

Measured memory_bytes: 4852
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N =  1e5 + 10;
std::vector<int> gr[N];
int h[N];
int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i++){
		scanf("%d", &h[i]);
	}
	int x, y;
	for(int i = 1; i <= m; i++){
		scanf("%d %d", &x, &y);
		gr[x].push_back(y);
		gr[y].push_back(x);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		bool io = true;
		for(auto it: gr[i]){
			if(h[i] <= h[it])
			{
				io = false; 
				break;
			}
		}
		if(io) ans++;
	}
	printf("%d", ans);


}

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

using namespace std;

int main() {
	int a, b, c, k, x, y, z;

	cin >> a >> b >> c >> k;

	x = max({ a,b,c });
	z = min({ a,b,c });
	y = (a + b + c) - (x + z);

	for (int i = 0; i < k; i++) {
		x *= 2;
	}

	cout << x + y + z << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int ar[10],r[3],t=10;
	for(int i=0;i<10;i++)
		cin>>ar[i];
	for(int i=0;i<10;i++)
		for(int j=0;j<9;j++)
		if(ar[i]>ar[j]){
			int t;
			t=ar[i];
			ar[i]=ar[j];
			ar[j]=t;
		}
	for(int i=0;i<3;i++)
		cout<<ar[i]<<endl;
	return 0;
}


Measured memory_bytes: 3100
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int N;ll A[1<<20], K;

ll part(ll a, ll b) {
  if(a%b == 0) return a/b-1;
  return a/b;
}

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

 int lo = 1, hi = 0;
 cin>>N>>K;
 rep(i,N) {cin>>A[i];hi = max(1LL*hi, A[i]);}

 // debug(lo);debug(hi);
 int mid = (lo+hi)/2;
 int ans = 0;
 while(lo <= hi) {

   ll cnt = 0;
   rep(i, N) {
     if(A[i] > mid) cnt += part(A[i], mid);
   }
   if(cnt <= K) {
     hi = mid-1;
     ans = mid;
   } else {
     lo = mid+1;
   }

   mid = (lo+hi)/2;
 }


 cout << ans << endl;



 return 0;
}


Measured memory_bytes: 5180
import bisect,collections,copy,itertools,math,numpy,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
N = I()
kouho = []
for i in range(1,N+1):
    if i%3 and i%5:
        kouho.append(i)
print(sum(kouho))


Measured memory_bytes: 48104
N = gets.to_i
D = gets.split.map(&:to_i)

if D[0] != 0
  puts 0
  exit 0
end

count_table = Hash.new { 0 }
D.each do |d|
  count_table[d] += 1
end

vn = 0
count_table.keys.sort.each do |n|
  if n != vn
    puts 0
    exit 0
  end
  vn += 1
end

if count_table[0] > 1
  puts 0
  exit 0
end

MOD = 998244353
parent_count = 1
ans = 1
count_table.size.times do |i|
  next if i == 0
  count = count_table[i]
  ans = (ans * (parent_count ** count)) % MOD
  parent_count = count
end
puts ans

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

int main(void) {
    int n, m;
    cin >> n >> m;
    vector<int> a;

    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a.push_back(t);
    }

    int m_count = 0;
    int sum = accumulate(a.begin(), a.end(), 0);
    for (auto vote : a) {
        if ((double)vote < ((double)sum / (4 * m))) {
            continue;
        }
        m_count++;
    }

    if (m_count >= m) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())

if n>2 and m>2:
      print((n-2)*(m-2))
      exit()
if n==2 or m==2:
      print(0)
      exit()
if n==1 and m>2:
      print(m-2)
      exit()
if n>2 and m==1:
      print(n-2)
      exit()
if n==1 and m==1:
      print(1)
      exit()


Measured memory_bytes: 2940
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  set<string> se;
  bool flag = true;
  char c;
  REP(i,n) {
    string s;
    cin >> s;
    if(!se.empty() && s[0] != c) flag = false;
    se.insert(s);
    c = s[s.size()-1];
  }
  if(n != se.size()) flag = false;
  YesorNo(flag);
  return 0;
}
//templete by private_yusuke

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

int main(){
	string word;
	
	for (int i=0; i<6; i++){
		cin >> word[i];
	}
	if(word[2]==word[3]&&word[4]==word[5]){
		cout << "Yes";
	}
	else 
			cout << "No";
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef long long int ll;
typedef pair<ll, ll> P;

int toPM(int a) {
    return a == 1 ? 1 : -1;
}

int main() {
    ll a, b;
    cin >> a >> b;
    vector<ll> c,d,e;
    c.resize(a);
    d.resize(a);
    e.resize(a);
    REP(i, a) {
        cin >> c[i] >> d[i] >> e[i];
    }
    ll ans = 0;
    REP(i, 2) {
        REP(j, 2) {
            REP(k, 2) {
                ll thisAns = 0;
                vector<ll> f;
                f.resize(a);
                REP(l, a){
                    f[l] = toPM(i) * c[l] + toPM(j) * d[l] + toPM(k) * e[l];
                }
                sort(ALL(f), greater<ll>());
                REP(l, b) thisAns += f[l];
                ans = thisAns > ans ? thisAns : ans;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
class WeightedUnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n + 1)]
        self.rank = [0 for _ in range(n + 1)]
        self.weight = [0 for _ in range(n + 1)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            y = self.find(self.parent[x])
            self.weight[x] += self.weight[self.parent[x]]
            self.parent[x] = y
            return y

    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            if w != self.diff(x, y):
                print("No")
                exit()

        if self.rank[rx] < self.rank[ry]:
            self.parent[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        else:
            self.parent[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


N, M = map(int, input().split())
w_union_find = WeightedUnionFind(N)
for i in range(M):
    l, r, d = map(int, input().split())
    w_union_find.union(l, r, d)
print("Yes")


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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 61;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

llong dp[1100][5000];

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

    int n, m;
    cin >> n >> m;
    vector<int> A(m), B(m);
    vector<vector<int> > C(m, vector<int>());
    rep(i, m) {
        cin >> A[i] >> B[i];
        rep(j, B[i]) {
            int c;
            cin >> c;
            --c;
            C[i].push_back(c);
        }
    }

    vector<vector<int> > dp(m + 1, vector<int>(1 << n, inf)); 
    dp[0][0] = 0;
    rep(i, m) {
        rep(j, 1 << n) {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            int mask = j;
            rep(k, B[i]) mask |= 1 << C[i][k];
            dp[i + 1][j | mask] = min(dp[i + 1][j | mask], dp[i + 1][j] + A[i]);
        }
    }

    if (dp[m][(1 << n) - 1] == inf) cout << -1 << endl;
    else cout << dp[m][(1 << n) - 1] << endl;
    
    return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  char tmp;
  string s;
  for (int i = 0; i < n; i++){
    cin >> tmp;
    if (i + 1 == k){
      tmp += 32;
    }
    s += tmp;
  }
  
  cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.141592653589793238
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007
int main ()
{
      FastIO
      lld n, k;
      cin >> n;
      cin >> k;
      lld i, s;
      lld p, q;
      lld c, j;
      p = 0;
      q = 0;
      c = 0;
      i = 0;
      j = n;
      while (c < k)
      {
      	p += i%MOD;
      	p %= MOD;
      	i += 1;
      	q += j%MOD;
      	q %= MOD;
      	j -= 1;
      	c += 1;
      }
      s = (q - p+1)%MOD;
      s%= MOD;
      while (k < n+1)
      {
      	p += i%MOD;
		p %= MOD;
      	i += 1;
      	q += j%MOD;
      	q %= MOD;
      	j -= 1;
      	s += (q-p+1)%MOD;
      	s %= MOD;
      	k += 1;
      }
      if (s < 0)
    	cout << (MOD+s);
      else
    	cout << s;
      return 0;
}

Measured memory_bytes: 3648
def Two_Anagrams(s , t):

    ans = ""
    s.sort()
    t.sort(reverse=True)

    for i in range(min(len(s) , len(t))):
        if s[i] > t[i]:
            ans = "No"
            break
        elif s[i] < t[i]:
            ans = "Yes"
            break

    if not ans and len(s) >= len(t):
        ans = "No"
    elif not ans:
        ans = "Yes"

    return ans

def main():
    s = list(str(input()))
    t = list(str(input()))
    print(Two_Anagrams(s , t))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
int n,k,x[100010];
int solve(int l,int r){
	if(l<0&&r<0)	return -l;
	if(l>0&&r>0)	return r;
	return r-l+min(-l,r);
}
int ans=1e9;
int main(){
	cin>>n>>k;k--;
	rep(i,1,n)	scanf("%d",x+i);
	rep(i,1,n-k){
		ans=min(ans,solve(x[i],x[i+k]));	
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
int a[100001];
bool check = false;
int main(){
    int n;
    cin >> n;
    int temp;
    for(int i=0;i<n;++i){
        cin >> temp;
        if(temp!=0)a[temp-1]++;
        a[temp]++;
        a[temp+1]++;
    }
    int max = -1;
    for(int i=0;i<100000;++i){
        if(max<a[i]){
            max = a[i];
        } 
    }
    cout << max << endl;
    return 0;
}

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

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  int x[N],s=0;
  for(int i=1;i<=N;i++){
  x[i]=i/10000+i%10000/1000+i%1000/100+i%100/10+i%10;
  if(A<=x[i]&&x[i]<=B) s+=i;
  }
  cout<<s<<endl;
}
  

Measured memory_bytes: 256
//
//  main.cpp
//  ervb
//
//  Created by Kanak Gautam on 21/04/20.
//  Copyright © 2020 Kanak Gautam. All rights reserved.
//
 
 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <utility>
#define pb push_back
#define mk make_pair
#define endl "\n"
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef long double ld;
priority_queue <lli, vector<lli>, greater<lli> > ti;
vector <lli> p[200005],h,b(200005,0),f(200005,0);
lli vis[200005];
map <pair<lli,lli>,lli> mp;
set<pair<lli, lli> > s;
set<lli> st;
map<lli,lli> np,v;
queue<lli> qy;
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
lli bpow(lli a, lli b) {
    lli res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res%mod;
}
lli fact(lli i)
{
    f[0]=1;
    for(lli k=1;k<=i;k++)
    {
        (f[k]=f[k-1]*k)%=mod;
    }
    return f[i];
}
lli isprime(lli n)
{
    if(n==1)
        return 0;
    for(lli i=2;i<=sqrt(n);i++)
        if(n%i==0)
            return 0;
    return 1;
}
bool cmp(lli i,lli j)
{
    return p[i].size()<p[j].size();
}
/*void sieve()
{
    for(lli i=2;i<=5000000;i++)
    {
        if(b[i]==0)
        {
        for(lli j=2;i*j<=5000000;j++)
        {
            b[i*j]=1;
        }
        }
    }
}*/
int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    float n,x,t;
    cin>>n>>x>>t;
    float g=n/x;
    g=ceil(g);
    lli h=g*t;
    cout<<h<<endl;
}



Measured memory_bytes: 10984
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	string s; cin >> s;
	REP(i, s.size())
	{
		if (i % 2 == 0) cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
using namespace std;
typedef long long ll;

int main(){
    ll h; cin>>h;
    ll ans=0;
    for(int i=0;i<=log2(h);i++){
        ans+=pow(2,i);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

vector<int> to[100005];
const int INF = 1000000;

int main(){
  int n,m;
  cin >> n >> m;
  int a,b;
  rep(i,m){
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;
  q.push(0);
  vector<int> dist(n,INF);
  vector<int> pre(n,-1);
  dist[0] = 0;

  while(!q.empty()){
    int v = q.front(); q.pop();
    for(auto x: to[v]){
      if(pre[x] != -1) continue;
      pre[x] = v;
      q.push(x);
    }
  }

  printf("Yes\n");
  for(int i = 1; i < n; i++){
    int ans = pre[i];
    ans++;
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 10676
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    int l[N], r[N];
    for (int i = 0; i < N; i++) {
        cin >> l[i] >> r[i];
    }

    int sum = 0;

    for (int i = 0; i < N; i++) {
        sum += r[i] - l[i] + 1;
    }

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

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

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

    int ans = 0;

    while (true)
    {
        n -= 1000;
        if (n <= 0)
        {
            ans = -1 * n;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <stdio.h> 
 #include <ctype.h> 
 #include <string.h> 
 
 
 int main(){ 
     char search[21], word[21]; 
     int count=0; 
     int i; 
      
     scanf("%s", search); 
         while(1){ 
         scanf(" %s", word); 
         if(strcmp(word, "END_OF_TEXT")==0)break; 
         for(i=0;word[i]!='\0';i++){ 
             word[i]=tolower(word[i]); 
         } 
         if(strcmp(word, search)==0){ 
             count++; 
         } 
     } 
     printf("%d\n", count); 
 
 
     return 0; 
 } 



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

int main()
{
  ll N;cin>>N;
  vector<ll> A(N+1);
  map<ll,ll> m;
  for (ll i=1;i<=N;i++)
  {
    cin>>A[i]; 
    m[A[i]]++;
  }
  
  ll count=0;
  for (auto i=m.begin();i!=m.end();i++)
  {
    if ((i->second) %2==1)
      count++;
  }
  cout<<count<<endl;
}

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

const int N = 5e5 + 10, mod = 1e9 + 7;

char s[N];
int len;
int ne[N], rne[N];
int ans;

void kmp(int *Next)
{
    for (int i = 2, j = 0; i <= len; i ++ )
    {
        while(j && s[j + 1] != s[i]) j = Next[j];
        if(s[j + 1] == s[i]) j ++;
        Next[i] = j;
    }
}

int main()
{
    scanf("%s", s + 1);
    len = strlen(s + 1);
    kmp(ne);
    reverse(s + 1, s + 1 + len);
    kmp(rne);
    // cout << lenS << ' ' << strlen(rs + 1) << endl;

    if(ne[len] && len % (len - ne[len]) == 0)
    {
        if(ne[len] == len - 1) 
        {
            printf("%d\n%d", len, 1);
            return 0;
        }
        puts("2");
        int ans = 0;
        for (int i = 1; i < len; i ++ )
        {
            int k = len - i;
            ans = (ans + (!(ne[i] && i % (i - ne[i]) == 0) && !(rne[k] && k % (k - rne[k]) == 0))) % mod;
        }
        cout << ans << endl;
    }
    else cout << 1 << endl << 1 << endl;
    
    return 0;
}

Measured memory_bytes: 8164
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            int N = int.Parse (Console.ReadLine ());
            int K = int.Parse (Console.ReadLine ());

            int n = 1;
            for (int i = 0; i < N; i++)
            {
                n = Min (2 * n, n + K);
            }

            Console.WriteLine (n);
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
char dice[8][5][5];
int i,j,res,flag1,flag2;
int MIN(int x,int y){ return x<y?x:y; }
int input()
{
    for(i=1;i<=6;i++)
        for(j=2;j>=0;j--)
        {
            scanf("%s",dice[i][j]);
            if(i==1&&j==2&&dice[i][j][0]=='#') return 0;
        }
    return 1;
}
void f1(int a,int b)
{
    for(flag1=i=0;i<3;i++) if(dice[a][b][i]=='*') flag1=1;
}
void f2(int a,int b)
{
    for(flag2=i=0;i<3;i++) if(dice[a][b][i]=='*') flag2=1;
}
void f3(int a,int b)
{
    for(flag1=i=0;i<3;i++) if(dice[a][i][b]=='*') flag1=1;
}
void f4(int a,int b)
{
    for(flag2=i=0;i<3;i++) if(dice[a][i][b]=='*') flag2=1;
}
void C(int x)
{
    if(flag1&&flag2) res=MIN(res,x);
}
int main()
{
    while(input())
    {
        res=9;

        f1(1,0),f2(3,0),C(0);
        f1(1,2),f2(3,2),C(2);
        f3(1,0),f4(3,2),C(1);
        f3(1,2),f4(3,0),C(1);

        f1(2,0),f2(4,0),C(3);
        f1(2,2),f2(4,2),C(3);
        f3(2,0),f4(4,2),C(2);
        f3(2,2),f4(4,0),C(2);

        f1(5,0),f2(6,2),C(1);
        f1(5,2),f2(6,0),C(1);
        f3(5,0);
        for(flag2=i=0;i<3;i++) if(dice[6][2-i][0]=='*') flag2=1;
        C(2);
        f3(5,2);
        for(flag2=i=0;i<3;i++) if(dice[6][2-i][2]=='*') flag2=1;
        C(2);

        printf("%d\n",res);
    }
}

Measured memory_bytes: 536
t = []
ans = 0
for i in range(5):
    a = int(input())
    if a%10 == 0:
        ans += a
        t.append(0)
    
    else:
        x = 10-a%10
        ans += a + x
        t.append(x)
    
ans -= max(t)
print(ans)

Measured memory_bytes: 3060
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

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

    int H = scanner.nextInt();
    int W = scanner.nextInt();

    char[][] graph = new char[H][W];
    int white = 0;
    for (int i = 0; i < H; i++) {
      graph[i] = scanner.next().toCharArray();
      for (int j = 0; j < W; j++) {
        if (graph[i][j] == '.') white++;
      }
    }

    int d = bfs(graph, H, W);
    if (d < 0) {
      System.out.println("-1");
    } else {
      System.out.println(white - d);
    }
  }

  private static int bfs(char[][] graph, int H, int W) {
    final Queue<Cell> queue = new LinkedList<>();
    final boolean[][] visited = new boolean[H][W];
    queue.offer(new Cell(0, 0, 0));
    visited[0][0] = true;

    int[][] ds = new int[][] {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
    while (!queue.isEmpty()) {
      final Cell c = queue.poll();
      if (c.i == H - 1 && c.j == W - 1) {
        return c.level + 1;
      }
      for(int[] d : ds) {
        int i = c.i + d[0];
        int j = c.j + d[1];
        if (i >= 0 && i < H && j >= 0 && j < W && graph[i][j] == '.' && !visited[i][j]) {
          visited[i][j] = true;
          queue.offer(new Cell(i, j, c.level + 1));
        }
      }
    }
    return -1;
  }

  private static class Cell {
    public final int i;
    public final int j;
    public final int level;

    private Cell(int i, int j, int level) {
      this.i = i;
      this.j = j;
      this.level = level;
    }
  }
}


Measured memory_bytes: 23252
#include<stdio.h>
int main(){
    int h,m,s,t;
    scanf("%d",&t);
    h=t/3600;
    m=(t-(3600*h))/60;
    s=(t-(3600*h)-(60*m));
    printf("%d:%d:%d\n",h,m,s);
    return 0;

    
}


Measured memory_bytes: 2744
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = myconv(next(),1);
  var output = 0;
  var a = 0;
  var b = 0;
  var ab = 0;
  for(var i = 0; i < N; i++){
    var s = next();
    for(var j = 0; j < s.length - 1; j++){
      if(s[j] == "A" && s[j + 1] == "B"){
         output++;
      }
    }
    if(s[0] == "B" && s[s.length - 1] == "A"){
       ab++;
    }else if(s[0] == "B"){
       b++;
    }else if(s[s.length - 1] == "A"){
       a++;
    }
  }
  myerr(output);
  myerr(a);
  myerr(b);
  myerr(ab);
  if(a > 0 || b > 0){
     output += Math.min(a,b);
     output += ab;
  }else{
     if(ab > 0){
        output += (ab - 1);
     }
  }
  myout(output);
}


Measured memory_bytes: 7756
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==v.size()?"":" ");
    return os;
}


signed main(){
    int h,w,k;cin>>h>>w>>k;
    string s[h];
    rep(i,h) cin>>s[i];
    int ans=0;
    rep(bh,1<<h){
        rep(bw,1<<w){
            char m[h][w];
            rep(i,h)rep(j,w)m[i][j]=s[i][j];

            rep(i,h){
                if((bh>>i)&1){
                    rep(j,w)m[i][j]='?';
                }
            }

            rep(j,w){
                if((bw>>j)&1){
                    rep(i,h)m[i][j]='?';
                }
            }
            int cnt=0;
            rep(i,h){
                rep(j,w){
                    cnt+=(int)(m[i][j]=='#');
                }
            }
            ans+=int(cnt==k);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

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

	int a, b, c; cin >> a >> b >> c;
	int x = -1000;
	int s[3][3];
	while(true){
		s[0][0] = a, s[0][1] = b; s[0][2] = x;
		s[1][0] = 2 * x + b - 2 * c; s[1][1] = c; s[1][2] = a + c - x;
		s[2][0] = 2 * c - x; s[2][1] = x + a - c; s[2][2] = b - c + x;
		int total = a + b + x;
		bool flag = true;
		for(int i = 0; i < 3; i++){
			int tate = 0, yoko = 0;
			for(int j = 0; j < 3; j++){
				tate += s[j][i]; yoko += s[i][j];
			}
			if(tate != total || yoko != total) flag = false;
		}
		int naname1 = s[0][0] + s[1][1] + s[2][2], naname2 = s[2][0] + s[1][1] + s[0][2];
		if(naname1 != total || naname2 != total) flag = false;
		if(flag){
			for(int i = 0; i < 3; i++){
				for(int j = 0; j < 3; j++){
					cout << s[i][j];
					if(j < 2) cout << " ";
				}
				cout << endl;
			}
			return 0;
		}
			x++;
	}
	return 0;	
}

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


int main() {

  int N,M;
  cin >> N >> M;

  vector<pair<int,bool>> B(N,make_pair(1,false));
  B.at(0) = make_pair(1,true);

  for(int i = 0;i < M;i++) {
    int x,y;
    cin >> x >> y;
    x--;
    y--;
    B.at(x).first--;
    B.at(y).first++;
    if(B.at(x).second) B.at(y).second = true;
    if(B.at(x).first == 0) B.at(x).second  = false; 
  }

  int ans = 0;
  for(int i = 0;i < N;i++) {
    if(B.at(i).second) ans++;
  }

  cout << ans << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<int>> cho(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char s;
      cin >> s;
      cho[i][j] = s - '0';
    }
  }

  int m = 1100;
  for (int bit = 0; bit < (1<<h-1); bit++) {
    bool FF = 1;
    vector<bool> f(h-1, 0);
    int count = 0;
    for (int i = 0; i < h-1; i++) {
      if (bit & (1<<i)) {
        f[i] = 1;
        count++;
      }
    }

    vector<vector<int>> CH(h-count, vector<int>(w, 0));
    for (int i = 0; i < w; i++) CH[0][i] = cho[0][i];

    int p = 0;
    for (int i = 0; i < h-1; i++) {
      if (f[i]) {
        for (int j = 0; j < w; j++) {
          CH[p][j] += cho[i+1][j];
        }
      }
      else {
        p++;
        for (int  j = 0; j < w; j++) {
          CH[p][j] += cho[i+1][j];
        }
      }
    }
    
    /*for (int i = 0; i < h - count; i++) {
      for (int x : CH[i]) cout << x;
      cout << ' ' << i <<endl;
    }*/

    vector<int> sum(h-count, 0);
    int c = 0;
    int bun = h-count-1;
    for (int i = 0; i < w; i++) {
      bool F = 0;
      for (int j = 0; j < h-count; j++) {
        sum[j] += CH[j][i];
        c++;
        if (sum[j] > k) F = 1;
      }
      if (F) {
        if (c == 1) {
          FF = 0;
          break;
        }
        else {
          bun++;
          for (int j = 0; j < h - count; j++) {
            sum[j] = CH[j][i];
            if (sum[j] > k) {
              FF = 0;
            }
          }
        }
      }
    }
    if (FF) {
      m = min(m, bun);
    }
  }
  cout << m << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n,k; cin>>n>>k;
    if((n+1)/2>=k){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
int m=(s[0]-'0')*10+(s[1]-'0');
int q=(s[2]-'0')*10+(s[3]-'0');

if(m>=1&&m<=12){
    if(q>=1&&q<=12)
        cout<<"AMBIGUOUS";
    else
        cout<<"MMYY"<<endl;
}
else {
    if(q>=1&&q<=12)
        cout<<"YYMM"<<endl;
    else
        cout<<"NA"<<endl;
}
}


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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n;
    cin>>n;
    string s;
    int ans = 0;
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=="E869120") ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3196
#include <stdio.h>
#include <stdlib.h>
int main(){
  long int X,i,money;
  scanf("%ld",&X);
  money=100;
  i=0;
  while(money<X){
    money=money+money/100;
    i++;
  }
  printf("%d",i);
  return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<string.h>
using namespace std;

int main(){
    char s[15];
    cin>>s;
    int len=strlen(s);
    int tmp=10000;
    int n;

    for(int i=0;i<len-2;i++){
        n=0;
        for(int j=i;j<i+3;j++){n*=10; n+=s[j]-'0'; }

        if(tmp>abs(n-753))tmp=abs(n-753);
    }
    cout<<tmp<<endl;
}

Measured memory_bytes: 256
N, L = list(map(int, input().split()))
letters = []
nums = []
for i in range(N):
    n = []
    for j in range(L):
        n.append(0)
    nums.append(n)


for i in range(N):
    S = []
    s = input()
    for j in range(L):
        S.append(s[j])
    letters.append(S)

def letter(let):
    if let == "a":
        nums[i][j] = 1
    elif let == "b":
        nums[i][j] = 2
    elif let == "c":
        nums[i][j] = 3
    elif let == "d":
        nums[i][j] = 4
    elif let == "e":
        nums[i][j] = 5
    elif let == "f":
        nums[i][j] = 6
    elif let == "g":
        nums[i][j] = 7
    elif let == "h":
        nums[i][j] = 8
    elif let == "i":
        nums[i][j] = 9
    elif let == "j":
        nums[i][j] = 10
    elif let == "k":
        nums[i][j] = 11
    elif let == "l":
        nums[i][j] = 12
    elif let == "m":
        nums[i][j] = 13
    elif let == "n":
        nums[i][j] = 14
    elif let == "o":
        nums[i][j] = 15
    elif let == "p":
        nums[i][j] = 16
    elif let == "q":
        nums[i][j] = 17
    elif let == "r":
        nums[i][j] = 18
    elif let == "s":
        nums[i][j] = 19
    elif let == "t":
        nums[i][j] = 20
    elif let == "u":
        nums[i][j] = 21
    elif let == "v":
        nums[i][j] = 22
    elif let == "w":
        nums[i][j] = 23
    elif let == "x":
        nums[i][j] = 24
    elif let == "y":
        nums[i][j] = 25
    elif let == "z":
        nums[i][j] = 26

for i in range(N):
    for j in range(L):
        letter(letters[i][j])

letters = sorted(letters)

ans = ""

for i in range(N):
    for j in range(L):
       ans += letters[i][j]

print(ans)








Measured memory_bytes: 3316
s=input()
n=len(s)
jj=((n-1)//2)
t=s[0:jj]
kk=((n+3)//2)-1
tt=s[kk:n+1]
if(t==t[::-1] and tt==tt[::-1] and s==s[::-1]):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = line[0];
    let c = line[1];
    let mut memo = vec![vec![0i32; 200_010]; 30];
    for _ in 0..n {
        let line: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
        let s = line[0] * 2 - 1;
        let e = line[1] * 2;
        let c = line[2] - 1;
        memo[c][s] += 1;
        memo[c][e] -= 1;
    }
    for i in 0..memo.len() {
        for j in 0..memo[i].len()-1 {
            memo[i][j+1] += memo[i][j];
        }
    }
    let mut ans = 0;
    for j in 0..memo[0].len() {
        let mut tmp = 0;
        for i in 0..memo.len() {
            tmp += cmp::min(1, memo[i][j]);
        }
        ans = cmp::max(ans, tmp);
    }

    println!("{}", ans);
}


Measured memory_bytes: 35068
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,x;
    cin >> n >> k;
    int cnt = 0;
    rep(i,n){
        cin >> x;
        cnt += min(2*(k-x),2*x);
    }
    PRINT(cnt);
}


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

int main(void){
    long long x,i=1,count=0;
    cin>>x;
    if(x%2==1){
        count=0;
    }else{
        x/=2;
        while(x>5){
            x/=5;
            count+=x;
            i*=2;
        }
        if(x==5) count++;
    }
    cout<<count<<endl;
}


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

using namespace std;

const unsigned long long int MAXN = 1000001L;
int preffix_L[MAXN], preffix_R[MAXN], suffix_L[MAXN], suffix_R[MAXN], ans[MAXN];

int main() {
    string S;
    cin >> S;
    int N = S.size();

    // sum of preffixes
    for(int i = 0; i < N; ++i) {
        if('L' == S[i]) {
            preffix_L[i] = preffix_L[i-1]+1;
            preffix_R[i] = 0;
        } else {
            preffix_R[i] = preffix_R[i-1]+1;
            preffix_L[i] = 0;
        }
    }

    // sum of suffixes
    for(int i = N; i >= 0; --i) {
        if('L' == S[i]) {
            suffix_L[i] = suffix_L[i+1]+1;
            suffix_R[i] = 0;
        } else {
            suffix_R[i] = suffix_R[i+1]+1;
            suffix_L[i] = 0;
        }
    }

    for(int i = 0; i < N-1; ++i) {
        if('R' == S[i] and 'L' == S[i+1]) {
            ans[i] = (preffix_R[i]+1)/2 + suffix_L[i+1]/2;
            ans[i+1] = preffix_R[i]/2 + (suffix_L[i+1]+1)/2;
        }
    }

    for(int i = 0; i < N; ++i)
        cout << ans[i] << " ";
    cout << endl;

    return 0;
}

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

int main()
{
  int N ;
  cin>>N ;
  int A[N] ;
  for(int i=0;i<N;i++) cin>>A[i] ;
  
  int count=0 ;
  for(int i=0;i<N;i++){
    if(A[i]%2!=0) break ;
    A[i]/=2 ;
    if(i==N-1){
      i=-1 ;
      count++ ;
    }
  }
  cout<<count<<endl ;
  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int MAX = 999999999;

int main(){
    vector<int> nums(3);
    rep(i, 3) cin >> nums[i];

    int k;
    cin >> k;

    rep(i, k){
        auto max_place = max_element(all(nums));
        *max_place *= 2;
    }

    cout << accumulate(all(nums), 0) << endl;
}

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

int main() {

	double a, b, x;
	cin >> a >> b >> x;

	double pi = acos(-1.0);

	double theta = 0.0;

	if (x >= (a * a * b) / 2.0) {
		theta = 180.0 * atan(2.0 * (a * a * b - x) / (a * a * a)) / pi;
	}
	else {
		theta = 90 - 180.0 * atan(2.0 * x / (a * b * b)) / pi;
	}

	cout << fixed;
	cout << setprecision(8) << theta << endl;

	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

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

int main(){
  long ii,jj,kk;
  vector<int> a;
  int S;
  cin >> S;
  int h,m,s;
  h = S/3600;
  m = (S % 3600) / 60;
  s = (S % 60);

  cout << h <<":" << m <<":"<< s << endl;
  
  return 0;
}



Measured memory_bytes: 3084
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
 
//  int a, b, c, d, e, X, Y;
  int a, b, c,  d, e,f;
  //  double  c;
//  long long  A[1000001]={};
  int  A[2000001]={};
  int  B[2000001]={};
  int  ans[100003]={};
  int  sum[100003]={};
  int  cnt_flag[100003]={};

  int  L[1003]={};


//  long long  a, b, c, d, X, Y;
//  long long   d, X, Y;
  long long JPY;
  double BTC;
  char s[200001]={};
  char t[200001]={};
  char u[200001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  int flag=0;
//  int flag[10000003]={};
  int tmp=0;
//  int min=1000000;
  long long min=10000000001;
  int len=0;
  int cnt=0;
  int cnt0=0;
  int cnt1=0;
  int num=0;
//  double ans=0.0;
//  long long ans=0;
  int max=0;
//  int sum=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);

  if(e-a<=f)printf("Yay!\n");
  else printf(":(\n");
/*    
    for(j=0;j<b;j++){
      if( i==A[j][0])
        ans[j]=-sum[i];
      else if(i==A[j][1])
        ans[j]=ans[j]+sum[i];
      printf("%d\n",ans[j]);
    }
    */

//  printf("%s\n",s);
//    else  
  
return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

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

vector<P> p;
multiset<int> pos;


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

    for(int i = 0; i < N; i++){
        int x;
        cin >> x;
        p.emplace_back(P(x, i+1));
    }

    sort(p.begin(), p.end());

    pos.insert(p[N-1].sc);
    pos.insert(0);
    pos.insert(0);
    pos.insert(N+1);
    pos.insert(N+1);

    ll res = 0;
    for(int i = N-2; i >= 0; i--){
        int x = p[i].sc;
        auto itr = pos.lower_bound(x);

        int st, en;
        int st2, en2;
        en = *itr;
        itr++;
        en2 = *itr;
        itr--;
        itr--;
        st = *itr;
        itr--;
        st2 = *itr;

        res += (ll)(en2 - en) * (ll)(x - st) * (ll)p[i].fs;
        res += (ll)(st - st2) * (ll)(en - x) * (ll)p[i].fs;

        pos.insert(x);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 5748