akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
long long s[100001],t[100001];
long long max(long long a,long long b){
    return (a<b)?b:a;
}
long long min(long long a,long long b){
    return (a<b)?a:b;
}
long long min(long long a,long long b,long long c){
    return min(a,min(b,c));
}
long long min(long long a,long long b,long long c,long long d){
    return min(min(a,b),min(c,d));
}
int main(){
    int a,b,q;
    scanf("%d%d%d",&a,&b,&q);
    for(int i=0;i<a;i++){
        scanf("%lld",&s[i]);
    }
    for(int i=0;i<b;i++){
        scanf("%lld",&t[i]);
    }
    for(int i=0;i<q;i++){
        long long x;
        scanf("%lld",&x);
        int la=0,ra=a-1,lb=0,rb=b-1;
        if(x<s[0])ra=0;
        if(x>s[a-1])la=a-1;
        if(x<t[0])rb=0;
        if(x>t[b-1])lb=b-1;
        while(ra-la>1){
            int ma=(la+ra)/2;
            if(s[ma]<x)la=ma;
            else ra=ma;
        }
        while(rb-lb>1){
            int mb=(lb+rb)/2;
            if(t[mb]<x)lb=mb;
            else rb=mb;
        }
        long long la_d=(x<s[la])?1e15:(x-s[la]), ra_d=(s[ra]<x)?1e15:(s[ra]-x),
                  lb_d=(x<t[lb])?1e15:(x-t[lb]), rb_d=(t[rb]<x)?1e15:(t[rb]-x);
        printf("%lld\n",min(max(la_d,lb_d),max(ra_d,rb_d),min(la_d,ra_d)+min(lb_d,rb_d)+min(la_d,ra_d,lb_d,rb_d)));
    }
    return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <stdlib.h>
#include <stdlib.h>
using namespace std;

int main()
{
    int n,m,x;
    int a[200];
    cin>>n>>m>>x;
    int i;
    for( i=0;i<m;i++)
        cin>>a[i];
        int flag;
        int sum=0;
        int j,p,u,k;
    for(j=x-1;j>0;j--)
    {
        flag=0;
        for(k=0;k<i;k++)
        {
            if(j==a[k])
                flag=1;
        }
        if(flag==1)
            sum++;
    }
    int ac;
    int act=0;
    for(p=x+1;p<n;p++)
    {
        ac=0;
        for(u=0;u<i;u++)
        {
            if(p==a[u])
                ac=1;
        }
        if(ac==1)
            act++;
    }
    int d;
    d=sum>=act?act:sum;
    cout<<d<<endl;
    }


Measured memory_bytes: 256
s = input() #sys.stdin.readlineは最後が改行
n=len(s)
ch = 0
ans = 0
left=0
right=n-1
while left<right:
    if s[left] == s[right]:
        left+=1
        right-=1
    else:
        if s[left] == 'x':
            ans+=1
            left+=1
        elif s[right] =='x':
            ans+=1
            right-=1
        else:
            print(-1)
            exit()
print(ans)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;

int main() {
    int N;
    double a;
    vector<double> v;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());

    for (int i = 1; i < N; i++) {
        v[i] = (v[i - 1] + v[i]) / 2;
    }

    cout << v[N - 1] << endl;
}

Measured memory_bytes: 256
import java.util.PriorityQueue;
import java.util.Scanner;

//Fibonacci Sets
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int N = 1001;
		int[] f = new int[N+1];
		f[0] = 1;
		f[1] = 2;
		for(int i=2;i<=N;i++)f[i] = (f[i-1]+f[i-2])%N;
		while(sc.hasNext()){
			int v = sc.nextInt();
			int d = sc.nextInt();
			PriorityQueue<Integer> q = new PriorityQueue<Integer>();
			for(int i=1;i<=v;i++)q.add(f[i]);
			int p = q.poll();
			int c = 1;
			while(!q.isEmpty()){
				int x = q.poll();
				if(x-p>=d)c++;
				p = x;
			}
			System.out.println(c);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
   int n,k;
   cin >> n >> k;
   string s;
   cin >> s;
   vector<int> vec;
   int now = 1;
   int cnt = 0;
   for(int i = 0; i < n; i++)
   {
       if (s[i] == (char)('0'+now)) {
           cnt++;
       }
       else
       {
           vec.push_back(cnt);
           now = 1 - now;
           cnt = 1;
       }
   }
   if (cnt != 0) {
       vec.push_back(cnt);
   }
   if (vec.size()%2 == 0) {
       vec.push_back(0);
   }
   int add = 2*k+1;
   int ans = 0;
   for(int i = 0; i < vec.size(); i+=2)
   {
       int tmp = 0;
       int left = i;
       int right = min(i + add, (int)vec.size());
       for(int j = left; j < right; j++)
       {
           tmp += vec[j];
       }
       ans = max(ans, tmp);
   }
   cout << ans << endl;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> v;
    for(int i=0;i<n;++i){
        int l;
        cin >> l;
        v.push_back(l);
    }

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

    int ans = 0;
    for(int i=0;i<k;++i){
        ans += v[v.size()-1-i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// 正答者の解答より(※一部改変, %d を 使用, %llu だと WA に なってしまう).
// iman12氏.
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3416985#1
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
  
LL g[102][102], matchU[102], ans;
bool vis[102];
LL X, Y, E;
  
bool dfs(LL v){
    for (int i = 0; i < Y; i++){
        if (g[v][i] && !vis[i]){
            vis[i] = true;
            if(matchU[i] < 0 || dfs(matchU[i])){
                matchU[i] = v;
                return true;
            }
        }
    }
    return false;
}
  
int main() {
 
    // 1. 入力.
    scanf("%d %d %d", &X, &Y, &E);
     
    // 2. 始点, 終点.
    for(int i = 0; i < E; i++) {
        int fr, to;
        scanf("%d %d", &fr, &to);
        g[fr][to] = 1;  
    }
     
    // 3. マッチング.
    for(int i = 0; i < 102; i++) matchU[i] = -1;
    for(int i = 0; i < X; i++){
        for (int j = 0; j < 102; j++) vis[j] = 0;
        if(dfs(i)) ans++; 
    }
     
    // 4. 出力.
    printf("%d\n", ans);
 
}


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

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
#define fir first
#define sec second

const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

int n;
int a[200010];

void solve() {
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == cnt + 1) cnt++;
	}

	if (cnt == 0) printf("%d\n", -1);
	else printf("%d\n", n - cnt);
}

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

	solve();
	
	return 0;
}

Measured memory_bytes: 1024
#include <sstream>
#include<iostream>
#include<string>
#include<algorithm> 
using namespace std;
int main(){
  int n,m,k,sum=0,x;
  string s[105]={" "},t[105]={" "};
  cin>>n;
  for(int i=1;i<=n;i++){
  	cin>>s[i];
  }
  cin>>m;
  for(int i=1;i<=m;i++){
  	cin>>t[i];
  }
  for(int i=1;i<=n;i++){
  	string check=s[i];
  	k=max(n,m);
  	for(int j=1;j<=k;j++){
  	  if(s[j]==check){
  	  	sum++;
		}  
	  if(t[j]==check){
	  	sum--;
	  }
	}
	x=max(sum,x);
	sum=0;
  }
  if(x)
    cout<<x<<endl;
  else
    cout<<0<<endl;
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int max_h = 50;
const int max_w = 50;

const int INF = 1000;

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

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

	int h,w;
	cin >> h >> w;

	string board[h];
	rep(i,h) cin >> board[i];

	queue<pii> qp;
	queue<vector<int> > qvi;

	qp.push((pii){0, 0});
	qvi.push(vector<int>());

	vector<int> sol;
	
	int dist[h][w];
	rep(i, h) rep(j, w) dist[i][j] = INF;
	dist[0][0] = 0;

	bool ok = false;
	while(qp.size() > 0){
		pii p = qp.front();
		qp.pop();

		vector<int> v = qvi.front();
		qvi.pop();
		
		rep(i,4){
			int tx = p.first + dx[i];
			int ty = p.second + dy[i];

			if(tx == h-1 && ty == w-1){
				sol = v;
				ok = true;
				break;
			}
			if(0 <= tx && tx < h && 0 <= ty && ty < w && board[tx][ty] == '.' && dist[tx][ty] == INF){
				dist[tx][ty] = dist[p.first][p.second] + 1;
				qp.push((pii){tx, ty});

				vector<int> v2;
				copy(v.begin(), v.end(), back_inserter(v2));
				v2.push_back(i);
				qvi.push(v2);
			}
		}
		if(ok) break;
	}


	if(!ok){
		cout << -1 << endl;
		return 0;
	}

	bool root[h][w];
	rep(i, h) rep(j, w) root[i][j] = false;
	root[0][0] = true;

	int tx = 0, ty = 0;
	rep(i, sol.size()){
		int d = sol[i];
		tx += dx[d];
		ty += dy[d];
		root[tx][ty] = true;
	}
 
	int ans = 0;
	rep(i,h){
		rep(j,w){
			if(i == 0 && j == 0) continue;
			if(i == h-1 && j == w-1) continue;

			if(!root[i][j] && board[i][j] == '.') ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
void chmax(int*,int);
void chmin(int*,int);
int main(void)
{
    int n;
    int a[100000][3];
    int dp[100000][3];

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            dp[i][j]=-1;
        }
    }
    dp[0][0]=dp[0][1]=dp[0][2]=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j==k)continue;
                chmax(&dp[i][k],dp[i-1][j]+a[i-1][k]);
            }
        }
    }
    int max=-1;
    for(int i=0;i<3;i++)chmax(&max,dp[n][i]);
    printf("%d\n",max);
    return 0;
}
void chmax(int* x,int y){if(*x<y)*x=y;}
void chmin(int* x,int y){if(*x>y)*x=y;}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define ios ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL)
int main() {
   string s;
    cin>>s;
   int a=(int)((s[0]-'0')*10+s[1]-'0');
   int b=(int)((s[2]-'0')*10+s[3]-'0');
   if(a==0&&b<=12&&b>=1)
     cout<<"YYMM";
    else if(b==0&&a<=12&&a>=1) cout<<"MMYY"; 
    else if(a==0||b==0||(a>12&&b>12))
	  cout<<"NA";
    else if(a<=12&&b<=12)
     cout<<"AMBIGUOUS";
    else if(a>12&&b<=12)
      cout<<"YYMM";
	else if(a<=12&&b>12)
	    cout<<"MMYY"; 	   
   		 
}


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

int main() {
    using namespace std;
    unsigned long X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<unsigned long> A(X), B(Y), C(Z);
    for(auto &i : A)cin >> i;
    for(auto &i : B)cin >> i;
    for(auto &i : C)cin >> i;

    unsigned long L = min(X * Y, K);
    auto comp = greater<>();

    vector<unsigned long> AB, ABC;
    
    for_each(A.cbegin(), A.cend(), [&B, &AB](auto i){for(const auto j : B)AB.push_back(i + j);});
    if(X * Y > K)nth_element(AB.begin(), AB.begin() + K, AB.end(), comp);
    
    for_each(AB.cbegin(), AB.cbegin() + L, [&C, &ABC](auto i) {for(const auto j : C)ABC.push_back(i + j);});

    partial_sort(ABC.begin(), ABC.begin() + K, ABC.end(), comp);
    for_each(ABC.cbegin(), ABC.cbegin() + K, [](auto i){cout << i << endl;});
    return 0;
}

Measured memory_bytes: 43368
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,k = readline() |> split |> parseMap
	r,s,p = readline() |> split |> parseMap
	t = split(chomp(readline()),"")
	x = 0
	if t[1] == "r"
		x += p
	elseif t[1] == "s"
		x += r
	else
		x += s
	end
	for i in 2:n
		if i-k<1||i-k>=1&&t[i]!=t[i-k]
			if t[i] == "r"
				x += p
			elseif t[i] == "s"
				x += r
			else
				x += s
			end
		else
			t[i] = "x"
		end
	end
	println(x)			
end

main()

Measured memory_bytes: 169116
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
        while(true){
        int sum=0;
        int count=0;
        int x=sc.nextInt();
        if(x==0)break;
        int[] data=new int[x];
        for(int i=0;i<x;i++){
           data[i]=sc.nextInt();
            sum+=data[i];         
        }
        for(int i=0;i<x;i++){
          if(data[i]<=sum/x){
              count++;
          }
        } 
         System.out.println(count);
      }

    }
}


Measured memory_bytes: 58928
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <sstream>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

const int MAX_N = 50;
int n, r, p, c;

int cards_a[MAX_N], cards_b[MAX_N];

int main() {
    while(cin >> n, cin >> r, n != 0 && r != 0) {
        for(int i = 0; i < n; i++) cards_a[i] = n - i;

        for(int i = 0; i < r; i++) {
            cin >> p >> c;
            for(int j = 0; j < p - 1; j++) {
                cards_b[j + c] = cards_a[j];
            }
            for(int j = 0; j < c; j++) {
                cards_b[j] = cards_a[j + p - 1];
            }
            for(int j = 0; j < p + c - 1; j++) {
                cards_a[j] = cards_b[j];
            }
        }
        cout << cards_a[0] << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  i64 M;
  cin >> N >> M;
  vector<int> as(N);
  F0R(i, N) {
    cin >> as[i];
  }
  sort(rng(as));

  // 指定した値以上の和はいくつあるか？
  auto count = [&](i64 lowerBound) {
    int r = as.size() - 1;
    int l = lower_bound(rng(as), lowerBound - as.back()) - as.begin();
    i64 re = 0;
    while (r >= l) {
      // l < r : l,r と r,l で2つある
      // l == r : l,l で1つだけ
      re += (r - l) * 2 + 1;
      r--;
      while (l <= r && as[l] < lowerBound - as[r]) {
        l++;
      }
    }
    return re;
  };

  // 指定した値以上の和の数がMである値を求める
  i64 ok = 0;
  i64 ng = 2e5 + 1;
  while (abs(ok - ng) > 1) {
    i64 mp = (ok + ng) / 2;
    i64 c = count(mp);
    if (c > M) {
      ok = mp;
    }
    else if (c < M) {
      ng = mp;
    }
    else {
      ok = mp;
      break;
    }
  }
  // ただし、同じ和が複数ある場合
  // この値以上の和の数がMを超えることがある

  //debug(ok);
  //debug(count(ok));

  vector<i64> ss(N);
  ss.back() = as.back();
  RF0(i, N - 1) {
    ss[i] = ss[i + 1] + as[i];
  }

  // 指定した値以上の和を全て足す
  auto sum = [&](i64 lowerBound) {
    int r = as.size() - 1;
    int l = lower_bound(rng(as), lowerBound - as.back()) - as.begin();
    i64 re = 0;
    while (r >= l) {
      //cout << l << ',' << r << newl;
      int cnt = r - l + 1;
      re += (ss[l] + (i64)as[r] * (cnt - 1)) * 2;
      if (r < as.size() - 1) re -= ss[r+1] * 2;
      r--;
      while (l <= r && as[l] < lowerBound - as[r]) {
        l++;
      }
    }
    return re;
  };

  i64 result = sum(ok);

  // ちょうど境界上に同じ和が複数ある場合
  i64 diff = count(ok) - M;
  result -= (i64)diff * ok;

  cout << result;
}
#endif


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  string s, t; cin >> s >> t;

  ll len_s = s.size();
  ll len_t = t.size();
  for (ll sh = 0; sh < (ll)s.size(); sh++) {
    if (s.substr(sh) == t.substr(0, len_s - sh)) {
      // cout << s + t.substr(len_s - sh) << endl;
      cout << sh + len_t << endl;
      return 0;
    }
  }
  cout << len_s + len_t << endl;

  return 0;
}



Measured memory_bytes: 3628
#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define read(a) scanf("%d", &a)
#define readf(a) scanf("%lf", &a)
#define pb push_back
#define mk make_pair
#define _rand mt19937 RAND(time(0))
#define mem(a) memset(a, 0, sizeof(a))
#define Buff ios::sync_with_stdio(false)
typedef long long ll;
using namespace std;
const int INF = 1e9 + 7;
const int N = 2e5 + 7;
const int M = 1e6 + 7;
//const ll mod = 998224353;
const ll mod = 998244353;

ll sum[N << 2], power[N << 2], pow10[N];
int color[N << 2];

#define lson rt << 1
#define rson rt << 1 | 1
#define ls lson, l, mid
#define rs rson, mid + 1, r

void pushUp(int rt)
{
    sum[rt] = (sum[lson] + sum[rson]) % mod;
    if(color[lson] != color[rson]) color[rt] = -1;
    else color[rt] = color[lson];
}

void build(int rt, int l, int r)
{
    if(l == r)
    {
        color[rt] = 1;
        power[rt] = pow10[l];
        sum[rt] = power[rt];
        return;
    }
    int mid = l + r >> 1;
    build(ls); build(rs);
    pushUp(rt);
    power[rt] = (power[lson] + power[rson]) % mod;
}

void pushDown(int rt)
{
    if(color[rt] == -1) return;
    color[lson] = color[rson] = color[rt];
    sum[lson] = power[lson] * (ll)color[rt] % mod;
    sum[rson] = power[rson] * (ll)color[rt] % mod;
    color[rt] = -1;
}

void update(int rt, int l, int r, int L, int R, int x)
{
    if(L <= l && r <= R)
    {
        sum[rt] = power[rt] * (ll)x % mod;
        color[rt] = x;
        return;
    }
    pushDown(rt);
    int mid = l + r >> 1;
    if(L <= mid) update(ls, L, R, x);
    if(R > mid) update(rs, L, R, x);
    pushUp(rt);
}
signed main()
{
    Buff;
    int n, q;
    cin >> n >> q;
    pow10[n] = 1ll;
    for(int i = n-1; i; i--) pow10[i] = pow10[i + 1] * 10ll % mod;
    build(1, 1, n);
    int Case = 0;
    while(q--)
    {
        int l, r, x;
        cin >> l >> r >> x;
        update(1, 1, n, l, r, x);
        cout << sum[1] << "\n";
    }
    return 0;
}
/**
**/


Measured memory_bytes: 15472
#include <bits/stdc++.h>
using namespace std;
int main (){
  int N,K,S;
  cin>>N>>K;
  S=1;
  for(int i=0;i<N;i++){
    if(S<K){
      S*=2;
    }
    else{
      S+=K;
    }
  }
  cout<<S<<endl;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[52][52];
int main() {
	string s,t;
	cin>>s>>t;
	vector<string> ans;
	for(ll i=s.size()-1;i>=0;i--){
		bool ch=true;
		for(ll j=0;j<t.size();j++){
			if(i+j==s.size()){
				//cout << "k";
				ch=false;
				break;
			}
			if(t[j]!=s[i+j]&&s[i+j]!='?'){
				ch=false;
				break;
			}
		}
		if(ch){
			string now;
			for(ll j=0;j<s.size();j++){
				if(j<i||j>=i+t.size()){
					if(s[j]=='?'){
						now.push_back('a');
					}
					else{
						now.push_back(s[j]);
					}
				}
				else{
					now.push_back(t[j-i]);
				}
			}
			ans.push_back(now);
		}
	}
	if(ans.size()!=0){
		sort(ans.begin(),ans.end());
		cout <<ans[0];
		return 0;
	}
	cout << "UNRESTORABLE";
	// your code goes here
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

ll h,w,k;

ll dp[101][8];

bool c(ll k){
	rep(i,8){
		if((k & (1<<i)) && (k & (1<<(i+1))))return true;
	}
	return false;
}

int main(){
	cin >> h >> w >> k;
	k--;
	dp[0][0] = 1;
	rep(i,h){
		rep(j,w){
			ll now = j;
			rep(k,(1<<(w-1))){
				if(c(k))continue;
				ll nxt = now;
				if((now != w - 1) && (k & (1 << now)))nxt = now + 1;
				else if((now != 0) && (k & (1 << (now - 1))))nxt = now - 1;
				dp[i+1][nxt] += dp[i][now];
				dp[i+1][nxt] %= MOD;
			}
		}
	}
	cout << dp[h][k] << endl;
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();
    int h, w;

    cin>> h>> w;
    char a[h+10][w+10];

    int r[h+1]= {}, c[w+1]={};


    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            cin>> a[i][j];

            if( a[i][j]=='#')
            {
                r[i]++;
                c[j]++;
            }
        }
    }


    for(int i=0; i<h; i++)
    {
        if(r[i]== 0)
            continue;
        for(int j=0; j<w; j++)
        {
            if(c[j]== 0)
            continue;

            cout << a[i][j];

        }
        nl;
    }




    return 0;
}




Measured memory_bytes: 3648
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	ll L;
	scan(L);
	double ans=pow((double)L/3,3);
	prin(setprecision(11)<<ans);
	return 0;
}


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

using namespace std;

typedef long long ll;

const int maxi = 1e6 + 7;
int main(){
	int n;
	cin >> n;
	int ar[n];
	set<int> st;
	map<int, int> mp;
	for(int i = 0; i < n; i++){
		int cur;
		cin >> cur;
		ar[i] = cur;
		st.insert(cur);
		mp[cur]++;
	}
	vector<int> sieve(maxi,1);
	sieve[0] = 0;
	for(int i = 1; i < maxi; i++){
		if(sieve[i] == 0) continue;
		if(st.count(i)){
			for(int j = 2; i * j < maxi; j++){
				sieve[i * j] = 0;
			}
		}
	}
	int cnt = 0;
	for(int x: ar){
		if(sieve[x] == 1 && mp[x] == 1) cnt++;
	}
	cout << cnt << '\n';
}


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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol a,b,c,d;
  cin >>n;
  a=n%10;
  if(a==3) cout <<"bon\n";
  else if(a==0||a==1||a==6||a==8) cout <<"pon\n";
  else cout <<"hon\n";
  return (0);
}


Measured memory_bytes: 3692
/*input
1000000
*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<long,long>
#define vi          vector<long long>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repi(i,a,b) for(ll i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define fIO         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define tr(it, a)   for(auto it = a.begin(); it != a.end(); it++)
#define clr(x)      memset(x, 0, sizeof(x))
#define deb(x)      cout << #x << "=" << x << endl
#define deb2(x, y)  cout << #x << "=" << x << "," << #y << "=" << y << endl
#define TIME        cerr << "\nTime elapsed: "<<1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; 
//#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update>;

ll sub(ll a, ll b){return (a-b+hell)%hell;}
ll add(ll a, ll b){return (a+b)%hell;}
ll mul(ll a, ll b){return (a*b)%hell;}
vector<ll>adj[100005];
bool vis[100005];
ll siz,edges;
void dfs(ll i)
{
    vis[i]=1;
    //siz++;
    for(ll j=0;j<adj[i].size();j++)
    {        
        edges++;
        if(!vis[adj[i][j]])
            dfs(adj[i][j]);
    }
}
const ll mod = 1000000007;
ll mpow(ll base, ll exp) {
  base %= mod;
  ll result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

int main()
{
fIO;
ll n,sum=0,t=1,m,ans;
//cin >> t;
while(t--){
  cin>>n;
  vi v;
  rep(i,1,n+1){if(i%3==0||i%5==0);else v.pb(i);}
  ll sum=0;
  rep(i,0,v.size())sum+=v[i];
  cout<<sum;














}
TIME;
    
}

Measured memory_bytes: 13964
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        int[] array = new int[N+1];
        int[] place = new int[N+1];
        for(int n=1;n<=N;n++){
        	array[n] = sc.nextInt();
        	place[array[n]] = n;
        }
        array[0]=0; place[0]=0;
        int max = 0;
        int line = 0;
        
        for(int n=1;n<=N;n++){
        	if(place[n]>place[n-1]){
        	    line++;
        	    max = Math.max(max,line);
        	}else{
        	    line = 1;
        	}
        }
        System.out.println(N-max);
    }
}

Measured memory_bytes: 87884
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
*/
#include<bits/stdc++.h>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second

void solve()
{
  string s,t;
  cin >> s;
  t=s;
  int cnt=0;
  reverse(s.begin(),s.end());
  f(i,s.length()/2)
  {
	  if(s[i]!=t[i])
	  	cnt++;
  }
  cout << cnt ;
  return;
}
signed main()
{
  FAST;
	int T=1;
	// cin >> T;
	while(T--)
	{
		solve();
	}
    return 0;
}

Measured memory_bytes: 256
#include <climits>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

const int MAX = 210;
const int HALF = MAX / 2;
const int WALL = -1;

int num = 0;
int field[MAX][MAX];
int label[MAX][MAX];
const int dx[6] = {0, 1, 1, 0, -1, -1};
const int dy[2][6] = {{1, 1, 0, -1, 0, 1}, {1, 0, -1, -1, -1, 0}};

struct edge {
	int to, cost;
	edge(int t, int c):to(t), cost(c){}
};
typedef pair<int, int> P;

vector<vector<edge> > es;

int dijkstra(int s, int t) {
	priority_queue<P, vector<P>, greater<P> > que;
	vector<int> dist(es.size(), INT_MAX);
	que.push(P(0, s));
	dist[s] = 0;

	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(dist[v] < p.first)
			continue;

		if(v % num == t)
			return p.first;

		for(int i = 0; i < es[v].size(); ++i) {
			edge& e = es[v][i];
			if(dist[e.to] > dist[v] + e.cost) {
				dist[e.to] = dist[v] + e.cost;
				que.push(P(dist[e.to], e.to));
			}
		}
	}

	return -1;
}

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

	int sx, sy, gx, gy, n;
	cin >> sx >> sy >> gx >> gy >> n;

	for(int i = 0; i < n; ++i) {
		int x, y;
		cin >> x >> y;
		field[y + HALF][x + HALF] = WALL;		
	}

	int lx, ly;
	cin >> lx >> ly;

	for(int i = 0; i < MAX; ++i) {
		field[i][lx + HALF + 1] = WALL;
		field[i][-lx + HALF - 1] = WALL;
		field[ly + HALF + 1][i] = WALL;
		field[-ly + HALF - 1][i] = WALL;
	}

	for(int i = -ly + HALF; i <= ly + HALF; ++i) {
		for(int j = -lx + HALF; j <= lx + HALF; ++j) {
			if(field[i][j] == WALL)
				continue;

			label[i][j] = num++;
		}
	}

	es.resize(num * 6);
	for(int i = -ly + HALF; i <= ly + HALF; ++i) {
		for(int j = -lx + HALF; j <= lx + HALF; ++j) {
			if(field[i][j] == WALL)
				continue;

			for(int t = 0; t < 6; ++t) {
				const int from = label[i][j] + num * t;
				const int next_t = (t + 1) % 6;
				const int instruct = abs((i - HALF) * (j - HALF) * t) % 6;

				es[from].push_back(edge(label[i][j] + num * next_t, 1));
				for(int d = 0; d < 6; ++d) {
					const int nx = j + dx[d], ny = i + dy[j % 2][d];
					if(field[ny][nx] != WALL) {
						const int cost = (d == instruct ? 0 : 1);
						const edge e(label[ny][nx] + num * next_t, cost);
						es[from].push_back(e);
					}
				}
			}
		}
	}

	cout << dijkstra(label[sy + HALF][sx + HALF], label[gy + HALF][gx + HALF]) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 26476
#!/usr/bin/env python3

seven_seg = {
        0: '0111111',
        1: '0000110',
        2: '1011011',
        3: '1001111',
        4: '1100110',
        5: '1101101',
        6: '1111101',
        7: '0100111',
        8: '1111111',
        9: '1101111'
        }

while True:
    seven_seg_state = ['0'] * 7
    n = int(input())
    if n == -1:
        break
    for _ in range(n):
        in_data = int(input())
        for i in range(7):
            if seven_seg[in_data][i] == seven_seg_state[i]:
                print("0", end="")
            else:
                print("1", end="")
            seven_seg_state[i] = seven_seg[in_data][i]

        print()

Measured memory_bytes: 7404
// <------------- Template -----------------------> //


#include<bits/stdc++.h>
using namespace std;

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(20);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAX5];

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, q, m, k;
string s, t, d;
ll sum = 0;
ll cou = 0;


// <------------- Implement Functions Here ----------> //

ll NCR(ll n, ll r) {
	if (n < r ) return 0;
	if (r == 0) return 1;
	if (r > n / 2) return NCR(n, n - r);
	ll res = 1;
	for (ll k = 1; k <= r; ++k) {
		res *= n - k + 1;
		res /= k;
	}
	return res;
}


// <------------- Start of main() -------------------> //

void MAIN() {
	ll z;
	cin >> x >> y >> z;
	x-=2*z;
	ll seat = x/(y+z);
	seat += ((x - (y+z)*seat) >= y);
	cout<<seat;
}

int main() {
	fastio; randomINT;
	//cin>>T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 5968
#include<stdio.h>
int main()
{
    int a[200002], n, i, j, num=0, b, min=200002;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        if (a[i] < min)
        {
            min = a[i];
        }
        if (a[i] <= min)
        {
            num++;
        }
    }
    printf("%d", num);
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n = s.size();
    int b = (n + (s.front() == s.back())) % 2;

    cout << (b ? "First" : "Second") << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = (int)1e9 + 7;
const int INF = (int)100100100;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    vector<ll> p(N);
    vector<ll> q(N);
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    q=p;
    int s=0;
    sort(q.begin(),q.end());
    for(int i=0;i<N;i++){
        if(p[i]!=q[i])s++;
    }
    if(s==0 || s==2)cout << "YES";
    else cout << "NO";

}

/*

प्रज्ञापारमिताहृदय

 */



Measured memory_bytes: 256
import sys
N, P = map(int,input().split())

if N == 1:
  print(P)
  sys.exit()
ans = 1
d = 2
while d * d <= P:
  cnt = 0
  while P % d == 0:
    P //= d
    cnt += 1
  ans *= d ** (cnt // N)
  d += 1
print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String readStr;
    int[] numPatternCount = new int[19];
    int i, j, k, l;
    int size = 9;
    int sum;
    int c = 0;
    for (i = 0; i <= size; i++)
      for (j = 0; j <= size; j++)
        k:for (k = 0; k <= size; k++)
          for (l = 0; l <= size; l++) {
            sum = i + j + k + l;
            if (sum > 27)
              break k;
            if (sum > 18)
              break;
            numPatternCount[i + j + k + l]++;
          }
    while ((readStr = reader.readLine()) != null) {
      int n = Integer.parseInt(readStr);
      System.out.println(
              n > 36 ? 0 :
                      numPatternCount[n > 18 ? numPatternCount.length - (n - numPatternCount.length) - 2 : n]
      );
    }
  }
 
}

Measured memory_bytes: 16852
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int x,a[4];
    while(cin>>x){
        a[0]=x/1000;
        a[1]=x/100-10*a[0];
        a[3]=x%10;
        a[2]=(x%100)/10;
        if(a[0]!=a[2]&&a[1]!=a[3]) cout<<"No"<<endl;
        else if(a[0]==a[2]){
            if(a[0]==a[1]) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
        else if(a[1]==a[3]){
            if(a[1]==a[2]) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
// #include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <bitset>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(a==0)
        return 0;
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a) {
  a %= mod;
  if (a < 0) a += mod;
  ll b = mod, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += mod;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
int mask[61];
int xori=0;
void in(int x)
{
    for(int i=59;i>=0;--i)
    {
        if((1ll<<i)&x)
        {
            if(!mask[i])
            {
                mask[i]=x;
                break;
            }
            else
                x^=mask[i];
        }

    }
}
int32_t main()
{
    IOS
    

    int n;
    cin>>n;
    int a[n+1];
    memset(mask,0,sizeof(mask));
    for(int i=1;i<=n;i++)
        cin>>a[i],xori^=a[i];
    for(int i=1;i<=n;i++)
    {
        int te=a[i];
        for(int j=59;j>=0;--j)
        {
            if((1ll<<j)&xori)
            {
                if((1ll<<j)&te)
                    te-=(1ll<<j);
            }
        }
        in(te);
    }
    int ans=0;
    for(int i=59;i>=0;--i)
    {
        if(!mask[i])
            continue;
        if(ans&(1ll<<i))
            continue;
        ans^=mask[i];
    }
    ans*=2;
    ans+=xori;
    cout<<ans;
}       

Measured memory_bytes: 1024
#include <stdio.h>

int main (){
	int N,A,B;
	scanf("%d %d %d", &N, &A, &B);
	int sum = 0;
	for (int i = 1; i <= N;i++){
		int digitSum = 0; 
		int temp = i;
		while (temp != 0){
		digitSum = digitSum + temp % 10 ;
		temp /= 10;
		}
		if (digitSum >= A && digitSum <= B){
			sum += i;
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<ll,pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main(){
    int x;
    cin >> x;
    cout << (x >= 30 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int ans = 0;
  int s[3]={a+b,b+c,c+a};
  sort(s,s+3);
  ans = s[0];
  cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin

def calc(r, D, x):
  y = r*x - D
  return y
  
def main():
    r, D, x_2000 = map(int, stdin.readline().rstrip().split())
    y=x_2000
    for i in range(10):
      y = calc(r, D, y)
      print(y)

input = lambda: stdin.readline()
main()


Measured memory_bytes: 2940
#include <stdio.h>
int main(void) 
{
	int b1, b2, b3;
	scanf("%d %d %d", &b1, &b2, &b3);
	if (b1 == 1 && b2 == 0 && b3 == 0 || b1 == 0 && b2 == 1 && b3 == 0 || b1 == 0 && b2 == 0 && b3 == 0)
		printf("Close\n");
	else 
		printf("Open\n");
	return 0;
}


Measured memory_bytes: 2144
#include <stdio.h>
#include <string.h>

struct node{
    int parent,left,right;
}T[30];

int H[30],D[30];

int setHeight(int u){
    int h1 = 0,h2 = 0;
    if(T[u].left != -1)
        h1 = setHeight(T[u].left)+1;
    if(T[u].right != -1)
        h2 = setHeight(T[u].right)+1;
    return H[u] = h1>h2?h1:h2;
}

void setDepth(int u,int d){
    D[u] = d;
    if(T[u].left != -1) setDepth(T[u].left,d+1);
    if(T[u].right != -1) setDepth(T[u].right,d+1);
}

void print(int u){
    int deg = 0;
    printf("node %d: parent = %d, ",u,T[u].parent);
    printf("sibling = ");
    if(T[u].parent == -1) printf("-1, "); 
    else if(T[T[u].parent].left != -1 && T[T[u].parent].left != u)
        printf("%d, ",T[T[u].parent].left);
    else if(T[T[u].parent].right != -1 && T[T[u].parent].right != u)
        printf("%d, ",T[T[u].parent].right);
    else
        printf("-1, ");
    if(T[u].left!=-1) deg++;
    if(T[u].right!=-1) deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);
    if(T[u].parent == -1) printf("root\n");
    else if(T[u].left == -1 && T[u].right == -1)printf("leaf\n");
    else printf("internal node\n");
}

int main(){
    int n,v,l,r;
    int root = 0;
    memset(T,-1,sizeof(T));
    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++){
        scanf("%d%d%d",&v,&l,&r);
        if(l != -1){ T[v].left = l,T[l].parent = v;}
        if(r != -1){ T[v].right =r,T[r].parent = v;}
    }
    for(int i = 0; i < n ; i++)
        if(T[i].parent == -1){
            root = i;
            break;
        }
    setHeight(root);
    setDepth(root,0);
    for(int i = 0 ; i < n ; i++)
        print(i);
    return 0;
}


Measured memory_bytes: 2044
# ABC127D - Integer Cards
import sys

input = sys.stdin.readline


def main():
    n, m = list(map(int, input().rstrip().split()))
    num = sorted(list(map(int, input().rstrip().split())))
    lst = sorted(
        [tuple(map(int, input().rstrip().split())) for _ in range(m)],
        key=lambda x: x[1],
        reverse=True,
    )
    ans, idx = 0, 0
    flg = False
    for i, j in lst:
        for _ in range(i):
            if idx < n and num[idx] < j:
                ans += j
                idx += 1
            else:
                flg = True
                break
        if flg:
            break
    if idx < n:
        ans += sum(num[idx:])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 23244
n, k = map(int, input().split())
h = list(map(int, input().split()))
inf = 10**9 + 7

dp = [inf] * n
dp[0] = 0

for i in range(n):
    for j in range(1, min(k+1, n-i)):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j]))
print(dp[n-1])


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

using namespace std;

double value[45];
int size[45];

double get_value(string &pile){
    bool b_can_move = 0, w_can_move = 0;
    double b_max, w_min;
    double last_value = 0;
    for(int i=0;i<pile.length();i++){
        double value;
        if(pile[i]=='B'){
            if(b_can_move){
                //b_max = max(b_max,last_value);
                b_max = last_value;
            }
            else{
                b_max = last_value;
            }
            b_can_move = 1;
            if(w_can_move){
                value = (b_max + w_min) / 2;
            }
            else{
                value = b_max + 1;
            }
        }
        if(pile[i]=='W'){
            if(w_can_move){
                //w_min = min(w_min,last_value);
                w_min = last_value;
            }
            else{
                w_min = last_value;
            }
            w_can_move = 1;
            if(b_can_move){
                value = (b_max + w_min) / 2;
            }
            else{
                value = w_min - 1;
            }
        }
        last_value = value;
    }
    return last_value;
}

//#define map unordered_map

void enumerate(int st, int ed,map<double,int> &table ,double value_sum = 0, int size_sum = 0){
    if(st==ed){
        if(table.count(value_sum)){
            table[value_sum] = max(table[value_sum], size_sum);
        }
        else{
            table[value_sum] = size_sum;
        }
    }
    else{
        enumerate(st+1, ed, table, value_sum, size_sum);
        enumerate(st+1, ed, table, value_sum + value[st], size_sum + size[st]);
    }
}

int find_zero_value(int st,int ed,map<double,int> &table ,double value_sum = 0, int size_sum = 0){
    if(st==ed){
        if(table.count(-value_sum)){
            return table[-value_sum] + size_sum;
        }
        else return 0;
    }
    else{
        int get1 = find_zero_value(st+1, ed, table, value_sum, size_sum);
        int get2 = find_zero_value(st+1, ed, table, value_sum + value[st], size_sum + size[st]);
        return max(get1, get2);
    }
}

map<double,int> table, table2;

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        string pile;
        cin>>pile;
        size[i] = pile.length();
        value[i] = get_value(pile);
    }
    if(n<=20){
        enumerate(0,n,table);
        printf("%d\n",table[0]);
    }
    else{
        enumerate(0,20,table);
        printf("%d\n",find_zero_value(20,n,table));
    }

    return 0;
}

Measured memory_bytes: 68736
#include<bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
template<typename T> inline void read(T &x)
{
	T data=0,w=1;
	char ch=0;
	while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
	if(ch=='-')w=-1,ch=getchar();
	while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
	x=data*w;
}
template<typename T> inline void write(T x,char c='\0')
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
	if(c!='\0')putchar(c);
}
template<typename T> inline void chkmin(T &x,T y){x=(y<x?y:x);}
template<typename T> inline void chkmax(T &x,T y){x=(y>x?y:x);}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
int main()
{
	int a,b,c;
	read(a);read(b);read(c);
	if(a+b>=c)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	vector <int> v(n);
    for(int i=0; i<n;i++){
    	cin>>v[i];
	}
	vector<int> dp(n+2, INT_MAX);
	dp[0]=0;
	for(int i=0; i<n;i++){
		dp[i+1] = min(dp[i+1], dp[i]+abs(v[i+1]-v[i]));
		dp[i+2] = min(dp[i+2], dp[i]+abs(v[i+2]-v[i]));
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024