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

const int N = 301;
const int MOD = 998244353;

signed main(){

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

  static int dp[N][N*N + N];
  //i個目まで見て、Rで塗った辺の長さがjとなる場合の数
  //一辺の値が(R+G+B)/2以上ならば三角形は作れない
  static int dp2[N][N*N + N];
  //2色に塗り分けたとき、i個目まで見て、Rで塗った辺の長さがj
  //R=G=(R+G+B)/2,B=0の重複カウントを取り除く
  dp[0][0] = 1;
  dp2[0][0] = 1;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n*N; j++){
      dp[i+1][j + a[i]] = (dp[i+1][j + a[i]] + dp[i][j]) % MOD;
      dp[i+1][j] = (dp[i+1][j] + dp[i][j] * 2) % MOD;
      dp2[i+1][j + a[i]] = (dp2[i+1][j + a[i]] + dp2[i][j]) % MOD;
      dp2[i+1][j] = (dp2[i+1][j] + dp2[i][j]) % MOD;
    }
  }

  int ans = 1;
  for(int i = 0; i < n; i++){
    ans = ans * 3 % MOD;
  }

  int ng = 0;
  for(int i = (sum+1)/2; i < n*N; i++){
    ng = (ng + dp[n][i]) % MOD;
  }
  if(sum%2 == 0) ng = ng - dp2[n][sum/2] + MOD;
  ng = ng * 3 % MOD;

  cout << (ans - ng + MOD) % MOD << endl;

  return 0;
}


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

int main(void)
{
long double L;
  
  scanf("%Lf", &L);
  printf("%Lf\n", (L/3.0)*(L/3.0)*(L/3.0));
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
using namespace std;

#define LL long long
LL a, b, c, x, y;

int main() {
    #ifdef LOCAL
    freopen("test.txt", "r", stdin);
    #endif // LOCAL

    while(cin >> a >> b >> c >> x >> y) {
        if(x > y) {
            swap(x, y);
            swap(a, b);
        }
        LL ans = a * x + b * y;
        ans = min(ans, x * 2 * c + (y - x) * b);
        ans = min(ans, y * 2 * c);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
def function(N, D, X, Y):
    number = 0
    D2 = D**2
    for i in range(N):
        if (X[i] <= D) & (Y[i] <= D):
            r = X[i]**2+Y[i]**2
            if r <= D2:
                number += 1
    return number


if __name__ == '__main__':
    x = input().split()
    N = int(x[0])
    D = int(x[1])
    X = []
    Y = []
    for _ in range(N):
        y = input().split()
        X += [int(y[0])]
        Y += [int(y[1])]
    print(function(N, D, X, Y))


Measured memory_bytes: 24900
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<P> a(n);
  rep(i,n){
    cin>>a[i].fi;
    a[i].se=i;
  }
  sort(begin(a),end(a));
  int ans=0;
  rep(i,n){
    if(i%2!=a[i].se%2) ans++;
  }
  cout<<ans/2<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n, m;
map<ll, int> data;

int main()
{
    cin>>n>>m;
    REP(i,n) {
        int a;
        cin>>a;
        data[a]++;
    }
    while (m) {
        auto mdata = data.end();
        mdata--;
        if (mdata->fst == 0) {
            break;
        }
        if (m > mdata->scd) {
            data[mdata->fst / 2] += mdata->scd;
            m -= mdata->scd;
            data.erase(mdata->fst);
        } else {
            data[mdata->fst / 2] += m;
            data[mdata->fst] -= m;
            break;
        }
    }
    ll ans = 0ll;
    for (auto itr = data.begin(); itr != data.end(); itr++) {
        ans += itr->fst * itr->scd;
    }
    cout<<ans<<endl;

    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(26, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 26; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'a'] = i;
    }
    return res;
}

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

    string s, t;
    cin >> s >> t;

    auto next = calcNext(s);

    /*
    REP(i, s.size()){
        REP(j, 26){
            cerr << next[i][j] << " ";
        }
        cerr << endl;
    }
    */
    

    ll now = -1;
    ll res = 0;
    ll i = 0;
    ll cnt = 0;
    bool flag = false;
    while(i<t.size()){
        //dump(now)
    	ll moji = t[i] - 'a';
    	ll tmp = next[now+1][moji];
    	if(tmp == s.size()){
            cnt++;
    		if(cnt > 1010101){
    			cout << -1 << endl;
    			return 0;
    		}
    		res += s.size();
    		now = -1;
    		flag = true;
    	}else{
    		now = tmp;
    		i++;
    		flag = false;
    	}    	
    }
    res += (now) + 1;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 13776
#include<bits/stdc++.h>
using namespace std; 
using lint =                            long long int;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD 1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){
  int N, K;
  cin>>N >> K;
  vector<lint> H(N);
  cin>>H;

  sort(ALL(H));
  while(K and H.size()) H.pop_back(),--K;
  cout<< accumulate(ALL(H),0LL) << endl;
}

int main(){   
  
 solve();

 return 0;
}


Measured memory_bytes: 1792
from collections import *
from heapq import*
import sys
input=sys.stdin.readline
d=defaultdict(list)
n=int(input())
 
for s in range(n-1):
    a,b,c=map(int,input().split())
    d[a].append([b,c])
    d[b].append([a,c])
#defaultdict(<class 'list'>, {1: [[2, 1], [3, 1]], 2: [[1, 1], [3, 3]], 3: [[1, 1], [2, 3]]})
 
def DIJKSTRA(point,d):
    cost      = {node:1e18 for node in d.keys()}
    Q         = []  #頂点のリスト
    cost[point]=0  #開始地点のコストをゼロとする（当たり前
    heappush(Q,(point,cost[point]))
    while Q:
        prefnd,tmpC=heappop(Q)
        if cost[prefnd]<tmpC:
            continue
        for node,c in d[prefnd]:
            altC=c+tmpC
            if cost[node]>altC:
                cost[node]=altC
                heappush(Q,(node,altC))
    return cost
 
q,k=map(int,input().split())
y=DIJKSTRA(k,d)
 
for i in range(q):
    a,b=map(int,input().split())
    print(y[a]+y[b])


Measured memory_bytes: 64672
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int Q = sc.nextInt();
        boolean order = true;
        Deque<String> deq = new ArrayDeque<>();
        for (String s : S.split("")) {
            deq.addLast(s);
        }
        for (int i = 0; i < Q; i++) {
            int Ti = sc.nextInt();
            if (Ti == 2) {
                int Fi = sc.nextInt();
                String P = sc.next();
                if (order) {
                    if (Fi == 1) {
                        deq.addFirst(P);
                    } else {
                        deq.addLast(P);
                    }
                } else {
                    if (Fi == 1) {
                        deq.addLast(P);
                    } else {
                        deq.addFirst(P);
                    }
                }
            } else {
                order = !order;
            }
        }
        StringBuilder sb = new StringBuilder();
        while (!deq.isEmpty()) {
            String s = null;
            if (order) {
                s = deq.pollFirst();
            } else {
                s = deq.pollLast();
            }
            sb.append(s);
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 82748
#include<stdio.h>
#include<math.h>

int main(){
    
    int K;

    scanf("%d",&K);

    int A,B;
    scanf("%d %d",&A,&B);

    int i;
    int flag=0;
    for(i=A;i<=B;i++){
    
    int ans = i%K;

    if(ans == 0){
        flag = 1;
    }
    }

    if(flag == 1){printf("OK");}
    else{printf("NG");

}
return 0;

}

Measured memory_bytes: 1732
#include<stdio.h>

int main(){
	
	int n,z,c;
	
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		
		z=1000-n;
		c=0;
		
		while(1){
			if(z>=500){
				z-=500;
				c++;
			}
			else if(z<500 && z>=100){
				z-=100;
				c++;
			}
			else if(z<100 && z>=50){
				z-=50;
				c++;
			}
			else if(z<50 && z>=10){
				z-=10;
				c++;
			}
			else if(z<10 && z>=5){
				z-=5;
				c++;
			}
			else if(z<5 && z>=1){
				z-=1;
				c++;
			}
			else if(z==0){
				printf("%d\n",c);
				break;
			}
		}
	
	}
	
return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=2010;
int n,k,q;
int a[N],v[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline int check(int l,int r) {
    int ret=0;
    for(int i=1;i<=n;i++) {
	if(a[i]<l||a[i]>r) continue;
	int j=i,la=0,cnt=1;
	while(i>1&&a[i-1]>r&&la!=k-1) ++la,--i;
	la=0;
	while(j<n) {
	    if(a[j+1]<l) break;
	    if(a[j+1]>r) {
		if(la==k-1) break;
		++la;
	    }
	    else ++cnt,la=0;
	    ++j;
	}
	ret+=max(0,min(cnt,j-i-k+2)),i=j;
    }
    return ret;
}
int main() {
    int ans=1<<30;
    cin>>n>>k>>q;
    for(int i=1;i<=n;i++) a[i]=v[i]=gi();
    sort(v+1,v+1+n);
    for(int i=1,j=1;i<=n;i++) {
	while(j<=n&&check(v[i],v[j])<q) ++j;
	if(j>n) break;
	ans=min(ans,v[j]-v[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<map>
#include<climits>
#include<set>
#include<queue>
#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<bitset>
#include<cstring>
#include<list>
using namespace std;
typedef vector<int>VI;
typedef vector<VI>VVI;
typedef vector<string>VS;
typedef pair<int,int>PII;
typedef long long LL;
typedef pair<LL,LL>PLL;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define PB push_back
#define EACH(i,c) for(typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define F first
#define S second

LL gcd(LL a,LL b){
    if(a<b)swap(a,b);
    return b?gcd(b,a%b):a;
}
LL lcm(LL a,LL b){
    return a/gcd(a,b)*b;
}
int main(){
    int a[3],m[3];
    while(true){
        bool endFlag=true;
        REP(i,3){
            cin>>a[i]>>m[i];
            if(a[i]||m[i])endFlag=false;
        }
        if(endFlag)break;

        LL c[3];
        REP(i,3){
            int x=1;
            REP(j,1000000000){
                x=(a[i]*x)%m[i];
                if(x==1){
                    c[i]=j+1;
                    break;
                }
            }
        }
        LL ans=lcm(lcm(c[0],c[1]),c[2]);
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
N = int(input())
H = list(map(int, input().split()))
dp = [0] * N
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))
print(dp[N - 1])



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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int N; cin >> N;
  int ans = N-1;

  FOR(l,1,sqrt(N)+1) {
    int r = N/l;
    if(l*r == N) {
      ans = min(ans, l+r-2);
    }
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 15;

int w[MAXN][MAXN];

void floyd ()
{
    for (int k = 0; k < 10; k ++)
    {
        for (int i = 0; i < 10; i ++)
        {
            for (int j = 0; j < 10; j ++)
            {
                if (w[i][k] + w[k][j] < w[i][j])
                {
                    w[i][j] = w[i][k] + w[k][j];
                }
            }
        }
    }
}

int main ()
{
    int n, m;
    scanf ("%d%d", &n, &m);
    for (int i = 0; i < 10; i ++)
    {
        for (int j = 0; j < 10; j ++)
        {
            scanf ("%d", &w[i][j]);
        }
    }
    floyd ();
    int ans = 0;
    for (int i = 1; i <= n; i ++)
    {
        for (int j = 1; j <= m; j ++)
        {
            int x;
            scanf ("%d", &x);
            if ((x != -1) && (x != 1))
            {
                ans += w[x][1];
            }
        }
    }
    printf ("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  for(var i=1;i<=9;i++){
    for(var j=1;j<=9;j++){
      if(N===i*j){
        console.log('Yes');
        return;
      }
    }
  }
  console.log('No');

}




//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main() {
    string s;   cin >> s;
    int ans = 0;
    for (int i = 0; i+1< s.length(); i++) {
        if (s[i] != s[i+1])
            ans++;
    }

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

Measured memory_bytes: 512
s = list(input())
n = len(s)
ans = 0
c = 0
i = 0
while i < n-1:
    if s[i] == "B" and s[i+1] == "C":
        ans += c
        i += 1
    elif s[i] == "A":
        c += 1
    else:
        c = 0
    i += 1
print(ans)

Measured memory_bytes: 82552
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] v = new int[n];
        for(int i = 0; i < n; i++){
            v[i] = Integer.parseInt(sc.next());
        }
        
        HashMap<Integer, Integer> map1 = new HashMap<>();
        HashMap<Integer, Integer> map2 = new HashMap<>();
        for(int i = 0; i < n/2; i++){
            map1.put(v[i*2], map1.getOrDefault(v[i*2], 0) +1);
            map2.put(v[i*2 +1], map2.getOrDefault(v[i*2 +1], 0) +1);
        }
        
        Set<Integer> keySet1 = map1.keySet();
        int maxKey1 = 0;
        int maxValue1 = 0;
        int secondValue1 = 0;
        for(int i : keySet1){
            if(map1.get(i) > maxValue1){
                maxKey1 = i;
                secondValue1 = maxValue1;
                maxValue1 = map1.get(i);
            }else if(map1.get(i) > secondValue1){
                secondValue1 = map1.get(i);
            }
        }
        
        Set<Integer> keySet2 = map2.keySet();
        int maxKey2 = 0;
        int maxValue2 = 0;
        int secondValue2 = 0;
        for(int i : keySet2){
            if(map2.get(i) > maxValue2){
                maxKey2 = i;
                secondValue2 = maxValue2;
                maxValue2 = map2.get(i);
            }else if(map2.get(i) > secondValue2){
                secondValue2 = map2.get(i);
            }
        }
        
        int ans;
        if(maxKey1 == maxKey2){
            ans = n - Math.max(maxValue1 + secondValue2, maxValue2 + secondValue1);
        }else{
            ans = n - maxValue1 - maxValue2;
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 50360
#include<iostream>
#include<sstream>
#include<iomanip>
#include<vector>
#include<deque>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<bitset>
#include<string>
#include<numeric>
#include<algorithm>
#include<functional>
#include<iterator>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<complex>
#include<ctime>
using namespace std;

int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    int q=s.length();
    //cout<<q<<endl;
    if(q>k)
    {
        for(int i=0;i<k;i++)
            cout<<s[i];
        cout<<"..."<<endl;
    }
    else
        cout<<s<<endl;
    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> arr;
    for (int i = 0, t = 0; i < n; i++) {
        cin >> t;
        arr.push_back(t);
    }
    int times = 0;
    for (int i = 0; i < n; i++) {
        int j = 0;
        while (j < n - i) {
            if (arr[j] < arr[j - 1]) {
                swap(arr[j], arr[j - 1]);
                times++;
            }
            j++;
        }
    }

    for (int i = 0; i < arr.size() - 1; i++) {
        cout << arr[i] << " ";
    }
    cout << arr[arr.size() - 1] << endl;
    cout << times<<endl;
    return 0;
}


Measured memory_bytes: 3168
import java.util.Scanner;
 
public class Main {
 
    static Scanner in = new Scanner(System.in);
 
    void solve() {
		int n = in.nextInt(), k = in.nextInt();
		int ans = 1;
		for(int i = 0; i < n; i++){
			if(ans > k){
				ans += k;
			}else{
				ans *= 2;
			}
		}
		System.out.println(ans);
	}
	
    public static void main(String[] args) {
		new Main().solve();
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair

using namespace std;

const int N = int(3e5) + 7;
const int logN = 17;
const int mod = int(1e9) + 7;
typedef pair<int, int> pii;

int p[N][logN + 1], x[N], n, l, q, a, b;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> x[i];
    cin >> l;
    for(int i = 1, j = 1; i <= n; ++i) {
       while(j <= n && x[j] - x[i] <= l) ++j;
       p[i][0] = j - 1;
    }
    for(int j = 1; j <= logN; ++j) {
       for(int i = 1; i <= n; ++i)
          p[i][j] = p[p[i][j - 1]][j - 1];
    }
    cin >> q;
    while(q --) {
        cin >> a >> b; int res = 1;
        if(a > b) swap(a, b);
        for(int j = logN; j >= 0; --j)
            if(p[a][j] < b) res += (1 << j), a = p[a][j];
        cout << res << '\n';
    }
}


Measured memory_bytes: 10240
#include <stdio.h>
#define Num 1001
int main () {
    char str[Num];
    int cou[100]={0};
    int i,j;
     
    //複数行に渡る文字列をload
    while (fgets (str,sizeof(str),stdin) != NULL) { //ctrl + d で抜ける
        for (i = 0;i < Num;i ++) { //read str[i]
            for (j = 0;j < 26;j ++) { //j=0 -> a
                if (str[i] - 'a' - j == 0 || str[i] - 'A' - j == 0) {
                    cou[j] ++;
                }
            }
            if (str[i] == '\0') { //after reading str
                break;
            }
        }
    }
    for (i = 0 ;i < 26;i ++) {
        printf ("%c : %d\n",'a' + i,cou[i]); //%c
    }
     
     
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int n,k;cin>>n>>k;
    vi p(n);
    rep(i,n)cin>>p[i];
    sort(all(p));
    int sum=0;
    rep(i,k)sum+=p[i];
    cout<<sum<<endl;
}


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

int main() {
  string s;
  cin >> s;
  int count=0;
  if(s[0]=='1'){
    count++;}
  if(s[1]=='1'){
    count++;}
  if(s[2]=='1'){
    count++;}
  cout << count <<endl;
}


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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test

const int maxn = 1e6 + 4;
int32_t d[maxn];

void solve() {
    for (int i = 1; i < maxn; ++i) {
        for (int j = i; j < maxn; j += i) {
            d[j]++;
        }
    }
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < n; ++i) {
        ans += d[i];
    }
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 7524
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <utility>
#include <cmath>
#include <string>
#include <bitset>
#include <queue>
#include <cstdio>
#include <cstring>
#include <deque>
#include <unordered_map>
#include <climits>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <ctime>


#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define fa(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>b;--i)
#define setp pair<pair<int,int>,int>
#define setl pair<LL,LL>
#define micro 0.000001
using namespace std;

int gcd(int a, int b) { return a % b ? gcd(b, a % b) : b; }
pair <int, int> vu[4] = { {0,1}, {0,-1} , {1,0},{-1,0} }; // EWSN

const int max_v = 1e2 + 7;
const int INF = 1e9 + 7;

struct cmp
{
	bool operator()(string a, string b)
	{
		if (a.size() == b.size())
		{
			fa(i, 0, a.size())
			{
				if (a[i] != b[i])
				{
					return a[i] > b[i];
				}
			}
		}
		return a.size() > b.size();
	}
};

priority_queue<string, vector<string>, cmp> pq;

void fun(string a)
{
	if (a.back() == '0')
	{
		a.push_back('1');
		pq.push(a);
		a.pop_back();		
		a.push_back('0');
		pq.push(a);
		a.pop_back(); 
	}
	else if (a.back() == '9')
	{
		a.push_back('9');
		pq.push(a);
		a.pop_back();
		a.push_back('8');
		pq.push(a);
		a.pop_back();
	}
	else
	{
		a.push_back(a.back());
		pq.push(a);
		a.pop_back();
		a.push_back(a.back()-1);
		pq.push(a);
		a.pop_back();
		a.push_back(a.back()+1);
		pq.push(a);
		a.pop_back();
	}
	
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	fa(i, 1, 10)
	{		
		pq.push(to_string(i));
	}
	int n;
	ci(n);
	if (n < 10)
	{
		co(n);
		return 0;
	}

	while (!pq.empty())
	{
		--n;
		if (n == 0)
		{
			co(pq.top());
			return 0;
		}

		string s = pq.top();
		fun(s);
		pq.pop();
	}
	return 0;
}	

Measured memory_bytes: 13680
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから

void solve(){
  int n;
  cin>>n;
  int l=0,r=n;
  cout<<0<<endl;
  string s;
  cin>>s;
  if(s=="Vacant")return;
  string pre_s=s;
  while(r-l>1){
    int mid=(l+r)/2;
    cout<<mid<<endl;
    cin>>s;
    if(s=="Vacant")return;
    if(mid%2==0){
      if(pre_s!=s)r=mid;
      else l=mid;
    }
    else {
      if(pre_s==s)r=mid;
      else l=mid;
    }
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 100000000000000009
#define MOD 1000000007
#define int long long
using P = pair<int,int>;
signed main(){
  int n,m;
  cin >> n >> m;
  cout << pow(2,m)*(1900*m + 100*(n-m)) << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var k, n int
	fmt.Scan(&k, &n)
	a := make([]int, n)
	for i, _ := range a {
		fmt.Scan(&a[i])
	}

	sort.Ints(a)

	var length []int
	for i, v := range a {
		if i == len(a)-1 {
			length = append(length, k-v+a[0])
		} else {
			length = append(length, a[i+1]-v)
		}
	}

	sort.Ints(length)

	ans := 0
	for i, v := range length {
		if i == len(length)-1 {
			fmt.Println(ans)
		} else {
			ans += v
		}
	}

}

Measured memory_bytes: 9344
#include "bits/stdc++.h"
using namespace std;

int main() {
	int H1, M1, H2, M2, K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;
	long long S = H1 * 60 + M1, T = H2 * 60 + M2;
	cout << T - S - K << endl;
}

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

int main() {
    int q;
    cin >> q;
    while (q--) {
        string X, Y;
        cin >> X >> Y;
        int dp[X.size() + 1][Y.size() + 1];
        memset(dp, 0, sizeof(dp));
        for (int i = 0; i < X.size(); ++i) {
            for (int j = 0; j < Y.size(); ++j) {
                if (X[i] == Y[j]) {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                } else {
                    dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
                }
            }
        }
        cout << dp[X.size()][Y.size()] << endl;
    }

    return 0;
}


Measured memory_bytes: 7072
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
sp_T = []
for i in range(K):
    sp_T.append(T[i::K])
ans = 0
win_d = {"s": "r", "r": "p", "p": "s"}
point = {"r": R, "s": S, "p": P}
for t in sp_T:
    sakki = ""
    for i in range(len(t)):
        if win_d[t[i]] != sakki:
            my_hand = win_d[t[i]]
            ans += point[my_hand]
            sakki = my_hand
        else:
            if i == len(t) - 1:
                pass
            else:
                next_want_hand = win_d[t[i + 1]]
                if sakki == next_want_hand:
                    sakki = "X"
                else:
                    sakki = "X"
print(ans)


Measured memory_bytes: 12708
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>

#define lowbit(x) (x&(-x))
#define MAX(a,b) (a<b?b:a)
#define MIN(a,b) (a<b?a:b)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 1e7;
const int maxn = 1e5 + 5;
ll mod = 1e9 + 7;

int n, m;

int cnt[maxn], vis[maxn];

int main()
{
	int x, y;
	scanf("%d%d", &n, &m);
	
	vis[1] = 1;
	for (int i = 1; i <= n; i++) cnt[i] = 1;
	while (m--)
	{
		scanf("%d%d", &x, &y);
		if (vis[x])
		{
			if (cnt[x] == 1)
			{
				vis[x] = 0;
			}
			vis[y] = 1;
		}
		--cnt[x]; ++cnt[y];
	}

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

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

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

	int ctr = 0;

	for(long long int i = 1; i <= N; i = i+2)
	{
		long long int count = 0;
		for(long long int j = 1; j <= i; j = j+2)
		{
			if (i%j == 0)
				// cout << count << "\n";
				count++;
		}
		// cout << count << "\n";
		if (count == 8)
			ctr++;
	}
	cout << ctr << "\n";

	return 0;

}

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
static const ll INF = 1LL << 60;
//Write From this Line



const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

int main()
{
	ll n ;
	cin >> n ;
	map<ll,ll> my_m;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	rep(i,n){
		my_m[a[i]] ++;
	}
	ll max_ans = 0;
	for(auto x:my_m){
		max_ans += (x.second *(x.second - 1)) / 2;
	}
	rep(i,n){
		ll x = my_m[a[i]] ;
		ll ans = max_ans;
		ans -= (x * (x -1) ) / 2;
		x--;
		ans += (x *(x - 1)) / 2;
		cout << ans << endl;
	}
}


Measured memory_bytes: 12544
#include <iostream>

using namespace std;

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

  while(true){
    c = a % b;
    if(c == 0){
      break;
    }
    a = b;
    b = c;
  }
  cout << b << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=1;i<=n;i++)
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    if(s[n-1]=='s')cout << s << "es" << endl;
    else cout << s << 's' << endl;
}

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

using namespace std;

int main() {
	string s;
	cin >> s;
	
	int winNum = 0;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == 'o') {
			winNum++;
		}
	}
	
	if(winNum + (15 - s.size()) >= 8) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
word=input()

wordList=["dream","dreamer","erase","eraser"]



while 1:
  if word[len(word)-5:]==wordList[0]:
    word=word[:len(word)-5]
  elif word[len(word)-7:]==wordList[1]:
    word=word[:len(word)-7]
  elif word[len(word)-5:]==wordList[2]:
    word=word[:len(word)-5]
  elif word[len(word)-6:]==wordList[3]:
    word=word[:len(word)-6]
  else:
    print("NO")
    break
  if word=="":
    print("YES")
    break

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void debug_out() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H), debug_out(T...);
}

int main() {
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
#define debug(...) 3
    fastIO;
#endif
    ll d, t, s;
    cin >> d >> t >> s;
    if((d + s - 1) / s <= t)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

ll n, m, k, a, b, c;
string s, t, r;
char c1, c2, c3;

int A[200005];
int B[200005];
int C[200005];
ll f[400005];

ll pot(ll x, ll y) {
	if (y == 0) return 1;
	ll sol = pot(x, y/2);
	sol = sol*sol%MOD;
	if (y%2) sol=sol*x%MOD;
	return sol;
}

ll div_(ll x, ll y) {
	//cout <<"x = "<<x<<" y = "
	return x*pot(y, MOD-2)%MOD;
}

map <ll, vector<ll> > M;

ll choose(ll x, ll y) {
	ll sol = 1;
	for (ll pos=x-y+1 ; pos<=x ; pos++) {
		sol = (sol*pos)%MOD;
	}
//	cout <<"sol = "<<sol<<endl;
	return div_(sol, f[y]);
}

int main() {
	f[0] = 1;
	for (int i=1 ; i<400005 ; i++) {
		f[i] = (f[i-1]*i) % MOD;
	}
	cin >>n>>a>>b;
	ll sol = pot(2, n)-1;
	sol -= choose(n, a);
	sol -= choose(n, b);
	while (sol<0) sol+=MOD;
	cout <<sol<<endl;
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> x(n);
  for(ll i = 0; i < n; i++) cin >> x[i];

  ll l = 0, r = k-1;
  ll ans = 10000000000;
  for(ll i = 0; i < n - k + 1; i++){
    l = i;
    ans = min({ans, abs(x[r])+abs(x[r]-x[l]), abs(x[l])+abs(x[l]-x[r])});
    r++;
  }

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin >> N;
    long long sum{}, _1{}, _2{}, input;
    vector<long long> a(N);
    for(auto& item: a) {
        cin >> input;
        item = input;
        sum += input;
    }
    auto y = sum / N;
    for(auto&& x: a) {
        _1 += pow(x - y, 2);
    }
    y = sum / N + 1;
    for(auto&& x: a) {
        _2 += pow(x - y, 2);
    }
    cout << std::min(_1, _2) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<set>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> p(n), inv(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
        inv[p[i]-1] = i;
    }
    set<int> ind;
    ind.insert(inv[n-1]);
    ind.insert(-1); ind.insert(n);
    ll ans = 0;
    for(int i = n-2; i >= 0; i--){
        int center = inv[i];
        set<int>::iterator r = ind.upper_bound(center);
        set<int>::iterator l = r;
        l--;
        set<int>::iterator l2 = l;
        l2--;
        set<int>::iterator r2 = r;
        r2++;
        if((*l) == -1){
            ans += (ll)(center+1)*((*r2)-(*r))*(i+1);
        }else if((*r) == n){
            ans += (ll)((*l)-(*l2))*(n-center)*(i+1);
        }else{
            ans += (ll)((*l)-(*l2))*((*r)-center)*(i+1);
            ans += (ll)(center-(*l))*((*r2)-(*r))*(i+1);
        }
        ind.insert(center);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
typedef pair<ll,ll>pi; typedef pair<ll,pi>spi; typedef pair<pi,pi>dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (300006)
ll n;
int main()
{
	FAST
	cin>>n;
	ll lg=(log2l(n))+1;
	cout<<(1ll<<lg)-1<<'\n';
}


Measured memory_bytes: 640
import math
from collections import deque

class UnionFind():
  def __init__(self, n):
    self.seg_tree = [-1 for i in range(n)]
  
  def root(self, i):
    if self.seg_tree[i] < 0:
      return i
    else:
      self.seg_tree[i] = self.root(self.seg_tree[i])
      return self.seg_tree[i]

  def size(self, i):
    return -self.seg_tree[self.root(i)]

  def unite(self, i, j):
    if self.same(i, j):
      return

    if self.size(i) == self.size(j):
      self.seg_tree[self.root(i)] -= self.size(j)
      self.seg_tree[self.root(j)] = self.root(i)
    elif self.size(i) > self.size(j):
      self.seg_tree[self.root(i)] -= self.size(j)
      self.seg_tree[self.root(j)] = self.root(i)
    else:
      self.seg_tree[self.root(j)] -= self.size(i)
      self.seg_tree[self.root(i)] = self.root(j)

  def same(self, i, j):
    return self.root(i) == self.root(j)

def nC2(n):
  return math.factorial(n) / math.factorial(2) / math.factorial(n - 2)

N, M = map(int, raw_input().split())
AB = [map(long, raw_input().split()) for _ in range(M)]

uf = UnionFind(N)
rev_res = []

ans = N * (N - 1) / 2
for a, b in reversed(AB):
  rev_res.append(ans)
  if not uf.same(a - 1, b - 1):
    ans -= uf.size(a - 1) * uf.size(b - 1)
  uf.unite(a - 1, b - 1)

for r in reversed(rev_res):
  print r

Measured memory_bytes: 27368
#include<iostream>
using namespace std;
using ll=long long int;
int main(){
  ll a[100100];
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    if(a[i]==0){
     cout<<0<<endl;
      return 0;
    }
  }
  ll ans=1;
  for(int i=0;i<n;i++){
    if(a[i]<=1000000000000000000/ans){
        ans*=a[i];
    }else{
      cout<<-1<<endl;
      return 0;
    }
  }
cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4308
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  string S;
  cin >>S;
  if((S.at(0)==S.at(1)) &&(S.at(1)==S.at(2))) {
cout <<"Yes" << endl;
  }
else if ((S.at(2)==S.at(1)) &&(S.at(1)==S.at(3))) {
cout <<"Yes" << endl;
  }
  else {
cout <<"No" << endl;
  }
}


Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (sb-int:defconstant-eqx OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0))
    #'equal)
  #+swank (ql:quickload '(:cl-debug-print :fiveam) :silent t)
  #-swank (set-dispatch-macro-character
           #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT)
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setf minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return (if minus (- result) result))))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;;;
;;; Body
;;;

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (duration (read))
         (ts (make-array (+ n 1) :element-type 'uint32 :initial-element #xffffffff)))
    (declare (uint32 n duration))
    (dotimes (i n) (setf (aref ts i) (read-fixnum)))
    (println
     (loop for i below n
           sum (min duration (- (aref ts (+ i 1)) (aref ts i)))
           of-type uint62))))

#-swank (main)


Measured memory_bytes: 17760
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> tank(M, vector<int>(2));
  vector<vector<int>> search(N+1, vector<int>(0));    
  for(int i=0; i<M; i++){
    int p, y;
    cin >> p >> y;
    tank[i][0]=p;
    tank[i][1]=y;    
    search[p].push_back(y);    
  }
  for(int i=1; i<N+1; i++){
    sort(search[i].begin(), search[i].end());  
  }

  for(int i=0; i<M; i++){
    int a=tank[i][0], b=tank[i][1];
    vector<int> temp(6);
    for(int j=0; j<6; j++){
      temp[j]=a%10;
      a/=10;
    }
    for(int j=5; j>=0; j--){
      cout << temp[j];
    }
    a=tank[i][0];
    auto it=lower_bound(search[a].begin(), search[a].end(), b);    
    int k=it-search[a].begin()+1;
    for(int j=0; j<6; j++){
      temp[j]=k%10;
      k/=10;
    }
    for(int j=5; j>=0; j--){
      cout << temp[j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 12416