akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:isize,
    b:isize,
    c:isize,
    }
    println!("{}",if (c-b)%2==0{(c-b)/2}else{min(b-1,a-c)+1+(c-b-1)/2})
}

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

using namespace std;

typedef long long ll;
const int INF = 1001001001;

int main() {
  int n, m;
  cin >> n >> m;
  vector< pair<int, int> > keys;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    int s = 0;
    for (int j = 0; j < b; ++j) {
      int c;
      cin >> c;
      --c;
      s |= 1 << c;
    }
    keys.emplace_back(s, a);
  }

  vector<int> dp(1<<n, INF); // 2^nXS
  dp[0] = 0;
  for(int s = 0; s < 1 << n; ++s) {
    for (int i = 0; i < m; ++i) {
      int t = s | keys[i].first;
      int cost = dp[s] + keys[i].second;
      dp[t] = min(dp[t], cost);
    }
  }
  cout << (dp[(1 << n) - 1] == INF? -1: dp[(1<<n) -1]) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
int main() {
    int N, M, L,tmp;
    cin >> N >> M >> L;
    tmp = N; 
    N = M; M = tmp;tmp = N;N = L;L = tmp; 
  cout << N << " " << M << " " << L << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <iomanip> //小数点以下を表示させる(setprecision())

#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 << " " \
                      << "(L:" << __LINE__ << ")" << '\n';

typedef long long ll;

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    double ans = 0;

    FOR(i, 1, N + 1)
    {
        double p = 1;
        int x = i;
        while (x < K)
        {
            p *= 0.5;
            x *= 2;
        }
        ans += p / N;
    }
    cout << fixed << setprecision(9);
    cout << ans << endl;

    return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  cout << min(B / A, C) << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
int n, a, c;
int x[1000001];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		x[a]++;
	}
	for (int i = 1; i <= 1000000; i++) {
		if (x[i] == 1) c++;
		if (x[i]) {
			for (int j = 2; i * j <= 1000000; j++) {
				x[i * j] = 0;
			}
		}
	}
	printf("%d\n", c);
}

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

int main() {
    
    int x;
    scanf("%d", &x);
    int ans = 0;
    ans += 1000 * (x / 500);
    x = x - 500 * (x / 500);
    ans += 5 * (x / 5);
    printf("%d\n", ans);
}

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

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

  vector<char> ans;

  for (int k = 0; k < (int)s.size(); k += w) {
    cout << s[k];
  }
  cout << endl;
}

Measured memory_bytes: 256
_, m = gets.split.map(&:to_i)

l1 = (1..(m / 2) * 2 + 1).to_a
l2 = (((1 + m / 2) * 2)..(2 * m + 1)).to_a
loop do
  break if l1.size < 2
  puts [l1.shift, l1.pop].join(' ')
end
loop do
  break if l2.size < 2
  puts [l2.shift, l2.pop].join(' ')
end

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

int main(){
  int n, k, sum, d;
  cin >> n >> k;
  sum = 0;
  for(int i = 0; i < n; i++, sum += d){
    int x;
    cin >> x;
    if(x < k - x){
      d = 2 * x;
    }
    else{
      d = 2 * (k - x);
    }
  }
  cout << sum << endl;
}
      
      
      


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    string S[N], X;
    int t[N];
    for(int i=0;i<N;i++)
        cin >> S[i] >> t[i];
    cin >> X;

    int ans = 0;
    bool flag = false;
    for(int i=0;i<N;i++){
        if(flag)
            ans += t[i];
        if(S[i] == X)
            flag = true;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define exp 0.001
#define sqr(x) ((x) * (x))
ll read() {ll x = 0;char f = 1, ch = getchar();while(ch < '0' || ch > '9') {if(ch == '-')f = -1;
ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();}return x * f;}
void write(ll x) {if(x < 0) x = -x, putchar('-');if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
using namespace std;
const int N = 2e6;

ll a[N];
ll ans;

int main() {
	int n;
	n = read();
	for(int i = 1; i <= n; ++i)
		a[i] = i - read();
	sort(a + 1, a + 1 + n);
	int mid = (n + 1) / 2;
	for(int i = 1; i <= n; ++i)
		ans += abs(-a[mid] + a[i]);
	writeln(ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

vector<int> G[101010];


i64 ans = 0;
i64 N,K;

int dfs(int v,int f = -1){
  int cnt = 0;
  for(int to : G[v]){
    cnt = max(cnt , dfs(to,v) + 1);
  }
  if(f == -1) return 0;
  if(cnt == K - 1 && f != 0){
    ans++;
    cnt = -1;
  }
  return cnt;
}


int main(){
  cin >> N >> K;
  vector<int> a(N);
  rep(i,0,N - 1){
    cin >> a[i];
    a[i]--;
  }
  if(a[0] != 0) ans++;
  a[0] = 0;
  rep(i,1,N - 1){
    G[a[i]].push_back(i);
  }
  dfs(0);
  cout << ans << endl;
}


Measured memory_bytes: 10752
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

vector<int> group;
vector<bool> seen;
vector<vector<int>> g;
vector<int> offset;

void dfs(Graph &G, Graph &K, int v, int index){
    seen[v] = true;
    g[index].push_back(v);
    group[v] = index;
    for(auto x: G[v]){
        if(seen[x] == true)continue;
        dfs(G, K, x, index);
    }
}

int main(){
    int N, M, K;
    cin >> N >> M >> K;
    Graph f(N);
    Graph k(N);
    rep(i, M){
        int a, b;
        cin >> a >> b;
        a--;b--;
        f[a].push_back(b);
        f[b].push_back(a);
    }
    rep(i, K){
        int a, b;
        cin >> a >> b;
        a--;b--;
        k[a].push_back(b);
        k[b].push_back(a);
    }
    group.assign(N, -1);
    seen.assign(N, false);
    offset.assign(N, 0);
    int index = 0;
    rep(i, N){
        if(seen[i] == true) continue;
        g.push_back(vector<int>());
        dfs(f, k, i, index);
        index++;
    }

    rep(i, N){
        for(auto x: k[i]){
            if(group[x] != group[i]) offset[i]++;
        }
    }

    // rep(i, g.size()){
    //     rep(j, g[i].size())cout << g[i][j] << " ";
    //     cout << endl;
    // }
    // rep(i, N)cout << offset[i] << " ";
    // cout << endl;

    rep(i, N) cout << g[group[i]].size() + offset[i] - f[i].size() - k[i].size() - 1 << " ";
    cout << endl;
}

Measured memory_bytes: 15100
#pragma GCC optimize(2)
#pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include<cstring>
#include <stack>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include <string>
#define itn int
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
const int maxn = 2*1000 * 100;
const int maxa = 1000 * 1000 * 1000 + 7;
typedef long long ll;
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;
int t, n, m, T,d;
int main()
{
#ifdef _DEBUG
	freopen("E:\\input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
#endif
	int i, j;
	std::ios::sync_with_stdio(false); cin.tie(0);
	while (cin >> n) {
		itn max1=0, max2=0,a[maxn];
		for (int i = 0; i < n; i++) {
			
			cin >> a[i];
			int& tmp = a[i];
			if (tmp > max1) {
				max2 = max1;
				max1 = tmp;
			}
			else if (tmp > max2) {
				max2 = tmp;
			}
		}
		F2(i,0, n) {
			if (a[i] == max1)cout << max2;
			else cout << max1;
			cout << "\n";

		}
	}
	return 0;
}

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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

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

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

ll n, x;

int main() {
	megaRandom();
	cin >> n >> x;
	bool cont = 1;
	ll res = 0;
	while(cont) {
		cont = 0;
		ll blocks = n / x;
		if(n % x > 0) {
			cont = 1;
			res += (blocks - 1) * 3 * x;
			ll old = x;
			x = n % x;
			n = old + x;
		} else {
			res += (blocks - 1) * 3 * x;
		}
	}
	cout << res;
	return 0;  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector< pair< int, int > > vc(n);
  for (int i = 0; i < n; i++) cin >> vc[i].first >> vc[i].second;
  int f = 0;
  for (int i = 2; i < n; i++) {
    if (vc[i].first == vc[i].second && vc[i - 1].first == vc[i - 1].second && vc[i - 2].first == vc[i - 2].second) {
      f = 1;
      break;
    }
  }
  if (f == 1) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
using namespace std;

int main()
{

	long long int a, b, c, k;

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

    if(k % 2 == 0) cout << a - b << endl;

    else cout << b - a << endl;

	return 0;

}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int n, k;
    cin >> n >> k;

    int cnt = 0;
    vvi G(n, vi(n, 1));

    rep(i, 1, n) {
        rep(j, 1, n - i) {
            if (cnt == k) { break; }
            G[j][j + i] = 2;
            ++cnt;
        }
        if (cnt == k) { break; }
    }

    if (cnt != k) {
        cout << -1 << endl;
        return 0;
    }

    cout << n * (n - 1) / 2 - k << endl;
    rep(i, 0, n) {
        rep(j, i + 1, n) {
            if (G[i][j] == 1) { cout << i + 1 << " " << j + 1 << endl; }
        }
    }

    return 0;
}

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

int n,a,b,c;
vector<int> l(8);

int dfs(int d,int aa,int bb,int cc){
    int ans=10000;
    if(d==n){
        if(aa>0&&bb>0&&cc>0){
            ans=min(ans,abs(aa-a)+abs(bb-b)+abs(cc-c)-30);
        }
        return ans;
    }
    int e=dfs(d+1,aa,bb,cc);
    int f=dfs(d+1,aa+l[d],bb,cc)+10;
    int g=dfs(d+1,aa,bb+l[d],cc)+10;
    int h=dfs(d+1,aa,bb,cc+l[d])+10;

    return min(e,min(f,min(g,h)));
}

int main(){

    cin >> n >> a >> b >> c;

    rep(i,n) cin >> l[i];

    int ans=dfs(0,0,0,0);
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int a,b,x,y,r;
   scanf("%d %d",&a,&b);
   if(a<b){
      x=b;y=a;}
   else if(a>b){
      x=a;y=b;}
   else if(a==b){
      x=a;y=b;}
      
   while(y>0){
      r=x%y;
      x=y;
      y=r;}
   printf("%d\n",x);
return 0;
   
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
int main(void){
    int n,w,h;
    cin>>n>>w>>h;
    vi wl(w+1,0),hl(h+1,0);
    rep(i,n){
        int x,y,l;
        cin>>x>>y>>l;
        wl[max(x-l,0)]++;
        wl[min(x+l,w)]--;
        hl[max(y-l,0)]++;
        hl[min(y+l,h)]--;
    }
    partial_sum(all(wl),wl.begin());
    partial_sum(all(hl),hl.begin());
    cout<<(count(all(wl),0)>1 && count(all(hl),0)>1?"No":"Yes")<<endl;
}

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

int main(){
  while(true){
    int n,x;
    cin >> n >> x;
    if(n+x==0) break;

    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
      for (int j = 1; j <= n; j++)
      {
        if(i==j) continue;
        for (int k = 1; k <= n; k++)
        {
          if(i==k || j==k) continue;
          if(i+j+k==x) ans++;          
        }
      }
    }
    cout << ans/6 << endl;
  }
}


Measured memory_bytes: 3084
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;

ll n,k;
ll sum[200003];

int solve() 
{
	//happy coding

	cin>>n>>k;

	for(int i=1;i<=200001;i++){
		sum[i] = sum[i-1]+i;
	}	

	ll ans = 0;
	for(int i=k;i<=n+1;i++){
		ll mnsum = sum[i-1];
		ll mxsum = sum[n]-sum[n-i];
		ans = ans+ (mxsum - mnsum+1);
		ans%=M;
	}

	cout<<ans%M<<endl;
	
	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}


Measured memory_bytes: 5192
#include <stdio.h>

using namespace std;
//行列を出力
void output(int H[3][10])
{
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            printf(" %d", H[i][j]);
        }
        printf("\n");
    }
}

int main()
{
    int H1[3][10], H2[3][10], H3[3][10], H4[3][10];
    int n;
    int h_num, f_num, r_num, div_num;

    //行列を初期化
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            H1[i][j] = H2[i][j] = H3[i][j] = H4[i][j] = 0;
        }
    }

    scanf("%d", &n); //反復回数設定

    //行列で判定した成分に値を代入
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d %d %d", &h_num, &f_num, &r_num, &div_num);
        switch (h_num)
        {
        case 1:
            H1[f_num - 1][r_num - 1] += div_num;
            break;
        case 2:
            H2[f_num - 1][r_num - 1] += div_num;
            break;
        case 3:
            H3[f_num - 1][r_num - 1] += div_num;
            break;
        case 4:
            H4[f_num - 1][r_num - 1] += div_num;
            break;
        }
    }

    output(H1);
    printf("####################\n");
    output(H2);
    printf("####################\n");
    output(H3);
    printf("####################\n");
    output(H4);
}


Measured memory_bytes: 2720
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    int n;
    vector<LL> a;
    LL tmp_a;
    LL ans;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a.push_back(tmp_a);
    }

    sort(a.begin(), a.end());
    ans = a[n-1]-a[0];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
a = [4, 6, 9, 11]
b = [1, 3, 5, 7, 8, 10, 12]
if x == 2 or y == 2:
    print('No')
elif x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9172
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

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


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

int main() {
	int n, u, k, v, c;
	cin >> n;
	vector<vector<pair<int, int>>> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> u >> k;
		for (int j = 0; j < k; ++j) {
			cin >> v >> c;
			a[u].emplace_back(v, c);
		}
	}
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> b;
	b.emplace(0, 0);
	vector<bool> d(n);
	vector<int> e(n, INT_MAX);
	e[0] = 0;
	while (!b.empty()) {
		pair<int, int> f = b.top();
		b.pop();
		d[f.second] = true;
		for (int i = 0; i < a[f.second].size(); ++i) {
			if (!d[a[f.second][i].first]) {
				if (a[f.second][i].second + e[f.second] < e[a[f.second][i].first]) {
					e[a[f.second][i].first] = a[f.second][i].second + e[f.second];
					b.emplace(e[a[f.second][i].first], a[f.second][i].first);
				}
			}
		}
	}
	for (int i = 0; i < n; ++i) cout << i << ' ' << e[i] << endl;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    priority_queue<int> q;
    for (auto i = 0; i < n; i++) {
        int a; cin >> a;
        q.push(a);
    }

    while(m > 0) {
        auto p = q.top(); q.pop();
        q.push(p / 2);
        m--;
    }

    int64_t ans = 0;
    while(not q.empty()) {
        auto p = q.top(); q.pop();
        ans += p;
    }

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

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
using namespace std;

struct SGT {
	LLI tree[1000007] = {};
	
	int LC( int i) { return i*2;}
	int RC( int i) { return i*2+1;}
	
	void pull( int i) {
		tree[i] = max( tree[LC(i)], tree[RC(i)]);
	}
	void upd( int x, LLI d, int l, int r, int i=1) {
		if( l == r) {
			tree[i] = d;
			return;
		}
		
		int m = ( l + r ) / 2;
		if( x <= m)
			upd( x, d, l, m, LC(i));
		if( m+1 <= x)
			upd( x, d, m+1, r, RC(i));
		pull(i);
	}
	LLI query( int x1, int x2, int l, int r, int i=1) {
		if( x1 <= l && r <= x2) {
			return tree[i];
		}
		int m = ( l + r ) / 2;
		LLI ans = 0;
		if( x1 <= m)
			ans = max( ans, query( x1, x2, l, m, LC(i)));
		if( m+1 <= x2)
			ans = max( ans, query( x1, x2,m+1, r, RC(i)));
		return ans;
	}
}dp;

int h[200007] = {};
int a[200007] = {};

int main() {
	
	int i,j;
	int N;
	
	cin >> N;
	for( i=1; i<=N; i++)
		cin >> h[i];
	for( i=1; i<=N; i++)
		cin >> a[i];
		
	for( i=1; i<=N; i++) {
		LLI q = dp.query( 0, h[i]-1, 0, N);
//		printf(">>> %lld\n", q);
		dp.upd( h[i], q + a[i], 0, N);
	}
	
//	while(1) {
//		int l,r;
//		scanf("%d %d", &l, &r);
//		LLI q = dp.query( l, r, 0, N);
//		printf("%lld\n", q);
//	}
	
	LLI ans = dp.query( 0, N, 0, N);
	printf("%lld\n", ans);
	
	return 0;
} 

Measured memory_bytes: 9408
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<ll, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << i << std::endl
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  ll x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;


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

  ll n;
  std::cin>>n;

  std::cout<<n/2-((n%2==0)?1:0);

  return 0;
}

Measured memory_bytes: 256
/**
 *   author  : The San Cao (caothesan@gmail.com)
 *   created : 2020.02.08 10:32:46 +07
 */

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>


using namespace std;

const int maxn = 2e5 + 10;

int n;
int t[maxn];
vector<pair<int, int>> robots;

void update(int x, int v) {
  for (; x < maxn; x += x & -x) t[x] = max(t[x], v);
}

int get(int x) {
  int res = 0;
  for (; x > 0; x -= x & -x) res = max(res, t[x]);
  return res;
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(NULL);
  cin >> n;
  vector<int> c;
  for (int i = 0; i < n; ++i) {
    int x, l; cin >> x >> l;
    robots.emplace_back(x + l, x - l);
    c.push_back(x + l); c.push_back(x - l);
  }
  sort(c.begin(), c.end());
  for (auto &it : robots) {
    it.first = lower_bound(c.begin(), c.end(), it.first) - c.begin() + 1;
    it.second = lower_bound(c.begin(), c.end(), it.second) - c.begin() + 1;
  }
  sort(robots.begin(), robots.end());
  int answer = 0;
  for (auto it : robots) {
    int cur = get(it.second);
    answer = max(answer, cur + 1);
    update(it.first, cur + 1);
  }
  cout << answer << "\n";
  return 0;
}



Measured memory_bytes: 2796
import math
k=int(input())
a,b=map(int,input().split())

ans=0

for i in range(int(a/k-1),math.ceil((b/k)+1)):
  if(k*i>=a):
    if(k*i<=b):
      ans=1
      break
if(k==1):
  ans=1

if(ans==0):
  print("NG")
if(ans==1):
  print("OK")
   

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

bool notToStep[100005];

ll countWays(ll n)
{
    ll res[n];
    for( int i = 0 ; i < n ; i++ )
        res[i] = 0;
    res[0] = 1;
    res[1] = 1;
    for( int i = 2 ; i < n ; i++ )
    {
        res[i] = 0;
        for( int j = 1 ; j <= 2 && j <= i ; j++ )
        {
            if( notToStep[i - j] == false && notToStep[i] == false )
            {
                res[i] = ( res[i] + res[i - j] ) % 1000000007;
            }
        }
    }
    return res[n - 1] % 1000000007;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n , m;
    cin >> n >> m;
    ll a[m];
    memset( notToStep , false , sizeof( notToStep ) );
    for( int i = 0 ; i < m ; i++ )
    {
        cin >> a[i];
        notToStep[a[i]] = true;
    }
    cout << countWays(n + 1) << endl;
    return 0;
}


Measured memory_bytes: 1920
import math
import numpy as np
import itertools

N, A, B, C = list(map(int, input().split(" ")))
l_list = np.asarray(sorted([int(input()) for _ in range(N)]))

def calc_mp(X, in_list):
    n_elm = len(in_list)
    mps = []
    ans = np.min(np.abs(in_list - X))
    if n_elm >= 2:
        ans2 = min([abs(in_list[i] + in_list[j] - X) for i in range(n_elm) for j in range(i+1, n_elm)]) + 10
        #print(ans1, ans2)
        ans = min(ans, ans2)
    if n_elm >= 3:
        ans3 = min([abs(in_list[i0] + in_list[i1] + in_list[i2] - X) for i0 in range(n_elm) for i1 in range(i0+1, n_elm) for i2 in range(i1+1, n_elm)]) + 10 + 10
        #print(ans1, ans2)
        ans = min(ans, ans3)
    if n_elm >= 4:
        ans3 = min([abs(in_list[i0] + in_list[i1] + in_list[i2] + in_list[i3] - X) for i0 in range(n_elm) for i1 in range(i0+1, n_elm) for i2 in range(i1+1, n_elm) for i3 in range(i2+1, n_elm)]) + 10 + 10 + 10
        #print(ans1, ans2)
        ans = min(ans, ans3)
    if n_elm >= 5:
        ans3 = min([abs(in_list[i0] + in_list[i1] + in_list[i2] + in_list[i3] + in_list[i4] - X) for i0 in range(n_elm) for i1 in range(i0+1, n_elm) for i2 in range(i1+1, n_elm) for i3 in range(i2+1, n_elm) for i4 in range(i3+1, n_elm)]) + 10*4
        #print(ans1, ans2)
        ans = min(ans, ans3)
    if n_elm >= 6:
        ans3 = min([abs(in_list[i0] + in_list[i1] + in_list[i2] + in_list[i3] + in_list[i4] + in_list[i5] - X) for i0 in range(n_elm) for i1 in range(i0+1, n_elm) for i2 in range(i1+1, n_elm) for i3 in range(i2+1, n_elm) for i4 in range(i3+1, n_elm) for i5 in range(i4+1, n_elm)]) + 10*5
        #print(ans1, ans2)
        ans = min(ans, ans3)
    if n_elm >= 7:
        ans3 = min([abs(in_list[i0] + in_list[i1] + in_list[i2] + in_list[i3] + in_list[i4] + in_list[i5] + in_list[i6] - X) for i0 in range(n_elm) for i1 in range(i0+1, n_elm) for i2 in range(i1+1, n_elm) for i3 in range(i2+1, n_elm) for i4 in range(i3+1, n_elm) for i5 in range(i4+1, n_elm) for i6 in range(i5+1, n_elm)]) + 10*6
        #print(ans1, ans2)
        ans = min(ans, ans3)
    if n_elm >= 8:
        ans3 = min([abs(in_list[i0] + in_list[i1] + in_list[i2] + in_list[i3] + in_list[i4] + in_list[i5] + in_list[i6] - in_list[i7] - X) for i0 in range(n_elm) for i1 in range(i0+1, n_elm) for i2 in range(i1+1, n_elm) for i3 in range(i2+1, n_elm) for i4 in range(i3+1, n_elm) for i5 in range(i4+1, n_elm) for i6 in range(i5+1, n_elm) for i7 in range(i6+1, n_elm)]) + 10*7
        #print(ans1, ans2)
        ans = min(ans, ans3)





    return ans

mps = []
for belongings in itertools.product(*[range(3) for _ in range(N)]):
    bs = np.asarray(belongings)
    l_list0 = l_list[bs==0]
    l_list1 = l_list[bs==1]
    l_list2 = l_list[bs==2]
    #print(l_list0, l_list1, l_list2)
    if 0 in [len(l_list0), len(l_list1), len(l_list2)]:
        continue

    a_mp = calc_mp(A, l_list0)
    b_mp = calc_mp(B, l_list1)
    c_mp = calc_mp(C, l_list2)
    cur_mp = a_mp+b_mp+c_mp
    #print(cur_mp, a_mp, b_mp, c_mp)
    mps.append(cur_mp)

print(min(mps))

Measured memory_bytes: 20644
#include<bits/stdc++.h>
#define chal ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lli long long
using namespace std;
int main()
{
    char r;
    cin>>r;
    if(r>='A' && r<='Z')
        cout<<"A";
    else
        cout<<"a";
    return 0;
}


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

using namespace std;

using ll = long long;

bool judge(vector<ll>& a, int n) {
	for (int i = 0; i < n; i++) {
		if (a[i] >= n) return false;
	}
	return true;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll ans = 0;
	while (!judge(a, n)) {
		ll sum = 0;
		for (int i = 0; i < n; i++) {
			sum += a[i] / n;
		}
		for (int i = 0; i < n; i++) {
			a[i] += sum - a[i] / n - (a[i] / n) * n;
		}
		ans += sum;
	}
	cout << ans << endl;	
	return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

ll gcd(ll a,ll b){
  if(a%b == 0) return b;
  else return gcd(b,a%b);
}

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  sort(a.begin(),a.end());
  bool flag = true;
  for(int i=0;i<n-1;i++){
    if(a[i] != a[i+1]) continue;
    flag = false;
    break;
  }
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef int ftype;
typedef complex<ftype> point;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)

const int MAXN = 1e2+3;
const int MOD = 1e9+7;
const LL INF = 1e18+1;

char S[101];
LL K;
int C[3];
int E[3];

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> S >> K;
    int N = strlen(S);

    if(N == 1) {
        cout << K/2 << endl;
        return 0;
    } else {
        for(int i = 1; i < N;) {
            if(S[i]==S[i-1]) {
                C[1]++;
                if(i==N-1) E[1] = 1;
                i+=2;
            } else i++;
        }


        LL ans;
        if(K == 1 || S[0]!=S[N-1] || E[1]) {
            ans = C[1]*K;
        } else {
            C[0] = 1;
            for(int i = 2; i < N;) {
                if(S[i]==S[i-1]) {
                    C[0]++;
                    if(i==N-1) E[0] = 1;
                    i+=2;
                } else i++;
            }

            if(E[0]) ans = K/2*(C[1]+C[0]) + (K%2)*C[1];
            else ans = C[1] + (K-1)*C[0];
        }

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int S;
  scanf("%d",&S);
  if(S%10==(S%100-S%10)/10)
    printf("Bad");
  else if((S%100-S%10)/10==(S%1000-S%100)/100)
    printf("Bad");
  else if((S%1000-S%100)/100==(S-S%1000)/1000)
    printf("Bad");
  else 
    printf("Good");

  return 0;
}

Measured memory_bytes: 128
def main():
    N = int(input())
    jobs = [None] * N
    for i in range(N):
        A, B = map(int, input().split())
        jobs[i] = (B, A)
    jobs.sort()
    t = 0
    for B, A in jobs:
        t += A
        if t > B:
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    main()


Measured memory_bytes: 53720
import java.awt.Rectangle;
import java.util.HashSet;
import java.util.Scanner;


public class Main {

	static Scanner sc = new Scanner(System.in);
	static Rectangle[] rec = new Rectangle[26];
	static boolean[] check = new boolean[26];
	
	public static void main(String[] args) {
		int n;
		n = sc.nextInt();	// input
		while(n-- > 0) {
			for(int i=0; i < 26; i++) {	// initialize
				rec[i] = new Rectangle();
				rec[i].x = rec[i].y = 50;
				rec[i].width = rec[i].height = 0;
				check[i] = false;
			}
			HashSet<Integer> count = new HashSet<Integer>();
			int h, w;
			h = sc.nextInt();	// input
			w = sc.nextInt();	// input
			int map[][] = new int[h][w];
			for(int y=0; y < h; y++) {
				String str = sc.next();
				for(int x=0; x < w; x++) {
					map[y][x] = (int)str.charAt(x); // input
					if(map[y][x] == '.') continue;
					int idx = map[y][x] - 'A';
					if(rec[idx].x > x) rec[idx].x = x;				// start
					if(rec[idx].y > y) rec[idx].y = y;				// start
					if(rec[idx].width < x) rec[idx].width = x;		// end
					if(rec[idx].height < h) rec[idx].height = y;	// end
					check[idx] = true; count.add(idx);
				}
			}
			int cnt = 0;
			boolean flg = true;
			while(flg) {
				flg = false;
				for(int i=0; i < 26; i++) {
					if(check[i]){
						int mozi = 'A' + i;
						boolean success = true;
						for(int y=rec[i].y; y <= rec[i].height; y++)
							for(int x=rec[i].x; x <= rec[i].width; x++){
								if(map[y][x] != mozi && map[y][x] != -1) {
									success = false;
									break;
								}
							}
						if(success){
							for(int y=rec[i].y; y <= rec[i].height; y++)
								for(int x=rec[i].x; x <= rec[i].width; x++){
									map[y][x] = -1;
								}
							flg = true;
							check[i] = false;
							cnt++;
						}
					}
				}
			}
			if(cnt == count.size())
				System.out.println("SAFE");
			else
				System.out.println("SUSPICIOUS");
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

int main(void){
  fast_io
  int h,w,n;
  cin>>h>>w>>n;
  int ans = 0;
  int moto = h*w;
  while(moto-h*w < n){
    if(h<w){
      h--;
      ans++;
    }else{
      w--;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
	int a,b,t=0;
	scanf("%d%d",&a,&b);
	t=a*b;
	if(t%2!=0||(2*t)%2!=0||(3*t)%2!=0)
		printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    char ar[11];
    cin>>a;
    cin>>ar;
    if(a<3200)
    {
        cout<<"red"<<endl;
    }
    else
    {
        cout<<ar<<endl;
    }
    return 0;
}


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

using namespace std;

int const size = 100006;
int arr[size];
int dp[size];

int getans(int n, int i){
	if(i == n-1) return 0;
	if(i > n-1) return size;
	if(dp[i] != -1) return dp[i];
	int ans = INT_MAX;
	ans = getans(n, i+1) + abs(arr[i]-arr[i+1]);
	if(i<n-2) ans = min(ans, getans(n, i+2) + abs(arr[i] - arr[i+2]));
	dp[i] = ans;
	return ans;
}

int main(){
	int n, h;
	scanf("%d",&n);
	for(int x=0;x<=n;x++){
		dp[x] = -1;
	}
	for(int x=0;x<n;x++){
		scanf("%d",&arr[x]);
	}
	cout<<getans(n,0);
	return 0;
}

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

int main(){
  long long S;
  cin>>S;
  long long A=S%1000000000;
  long long B=S/1000000000;
  if(S==1000000000000000000){
    cout<<0<<" "<<0<<" "<<1000000000<<" "<<0<<" "<<0<<" "<<1000000000<<endl;
    return 0;
  }

  cout<<setprecision(18)<<0<<" "<<0<<" "<<1000000000<<" "<<1<<" "<<1000000000-A<<" "<<B+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#import sys
#input = sys.stdin.readline
from collections import Counter
def func(x):
    cnt = 0
    y = x
    while x > 0:
        if x%2 == 1:
            cnt += 1
        x //= 2
    return y%cnt
        
def main():
    N = int( input())
    X = list( map( int, list( input())))
    base_plus = 0
    base_minus = 0
    r = 1
    one = Counter(X)[1]
    for x in X[::-1]:
        base_plus += r*x
        base_plus %= one+1
        r *= 2
        r %= one+1
    r = 1
    if one > 1:
        for x in X[::-1]:
            base_minus += r*x
            base_minus %= one-1
            r *= 2
            r %= one-1

    ANS = [0]*N
    # print(base)
    # print(bin(base))
    for i in range(N):
        if one == 1:
            if X[i] == 1:
                ANS[i] = 0
                continue
        if X[i] == 1:
            xi = (base_minus -  pow(2,N-1-i,one-1))%(one-1)
            # print(i, bin(base -  pow(2,N-1-i)), one-1)
        else:
            xi = (base_plus +  pow(2,N-1-i,one+1))%(one+1)
            # print(i, bin(base +  pow(2,N-1-i)), one+1)
        # print(i,xi)
        if xi == 0:
            ANS[i] = 1
            continue
        ans = 1
        while xi > 0:
            ans += 1
            xi = func(xi)
        ANS[i] = ans
    print("\n".join( map( str, ANS)))
    
    
if __name__ == '__main__':
    main()


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

int main(){
      int k,a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  	cin>>k;
  	cout<<a[k-1]<<endl;
}

Measured memory_bytes: 256
import sys

n = int(input())
a_list = list(map(int,input().split()))

a_even = list(filter(lambda x: x % 2 == 0, a_list))
for a in a_even:
    if a % 3 != 0 and a % 5 != 0:
        print('DENIED')
        sys.exit()
print('APPROVED')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define int long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;
const int MAXN = 1e6+5;



int32_t main() {
	int n;
	cin >> n;
	vector<int> v(n);
	for(int &i : v)
		cin >> i;
	sort(v.begin(), v.end());
	
	int ans = 0;
	for(int i = 0; i < n-2; i++)
		for(int j = i+1; j < n-1; j++) {
			auto it = lower_bound(v.begin()+j+1, v.end(), v[i] + v[j]);
			it--;
			ans += it - v.begin();
			ans -= j; 
		}
	cout << ans << endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<cmath>
using namespace std;
#define MAX 10
#define EPS 0.000000001

main(){
  double len, v1, v2, A[MAX+1], l;
  char ch;
  while( cin >> l ){
    for ( int i = 0; i <= MAX; i++ ) A[i] = 0;
    A[0] = 0;
    A[1] = l;
    for ( int i = 2; i <= MAX; i++ ) {
      cin >> ch >> l;
      A[i] = A[i-1] + l;
    }
    cin >> ch >> v1 >> ch >> v2;
    double p = 1.0*A[MAX]*v1/(v1+v2);
    int cur = 0;
    for ( ; ;cur++ ){
      if (  p < A[cur] || fabs(p - A[cur]) < EPS) {
	cout << cur << endl;
	break;
      }
    }
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
#define int long long
int n, a[100005], res, p, x;
main() {
    DAU
    cin >> n;
    ++n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];
    for (int i = 1; i < n; ++i) {
        cin >> x;
        if (a[i] >= x)
            res += x;
        else {
            res += a[i];
            x -= a[i];
            p = min(x, a[i+1]);
            res += p;
            a[i+1] -= p;
        }
    }
    cout << res;
    PLEC
}


Measured memory_bytes: 4432
fun main() = ABC162C.main()

object ABC162C {
    fun log(message: Any?) {
        //println(message)// TODO: ←消す
    }

    fun main() {
        val K = readInt()
        var ans = 0
        (1..K).forEach { a ->
            (1..K).forEach { b ->
                (1..K).forEach { c ->
                    ans += Gcd.get(a, Gcd.get(b, c))
                }
            }
        }

        println(ans)
        //log("calcCount=${Gcd.calcCount}")
    }


    /*####################################################################################*/
    object Gcd {
        //var calcCount = 0
        //    private set
        private val cache = hashMapOf<Pair<Int, Int>, Int>()

        fun get(a: Int, b: Int): Int {
            val m = if (a > b) a else b
            val n = if (a < b) a else b
            val cached = cache[m to n]
            return if (cached == null) {
                val gcd = calc(m, n)
                cache[m to n] = gcd
                gcd
            } else cached
        }

        private fun calc(m: Int, n: Int): Int { // m > n
            //assert(m > n)
            var m = m
            var n = n
            while (n != 0) {
                val r = m % n
                m = n
                n = r
            }
            //calcCount++
            return m
        }
    }

    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map { it.toInt() }
}

Measured memory_bytes: 57280
#include <iostream>
#include <set>
#include <string>

typedef std::set<int> TDictionary;

int CharToInt(char c)
{
	switch(c)
	{
	case 'A' : return 0;
	case 'G' : return 1;
	case 'C' : return 2;
	case 'T' : return 3;
	}
	return 0;
}

int ToInt(std::string String)
{
	int Result = 0;
	int Order = 1;
	for(unsigned int i=0;i<String.size();i++)
	{
		Result += CharToInt(String[i]) * Order;
		Order *= 4;
	}
	return Result + Order;
}

std::string GetResultString(bool Result)
{
	return Result ? "yes" : "no";
}

int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	TDictionary Dictionary;
	int Count = 0;
	std::cin >> Count;
	
	for(int i=0;i<Count;i++)
	{
		std::string Command;
		std::cin >> Command;
		std::string Input;
		std::cin >> Input;
		if(Command == "insert")
		{
			Dictionary.insert(ToInt(Input));
		}
		else if(Command == "find")
		{
			std::cout << GetResultString(Dictionary.find(ToInt(Input)) != Dictionary.end()) << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 14140
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	x := r.nextInt()

	for i := x; ; i++ {
		f := fact(i)
		if len(f) == 1 && f[0].count == 1 {
			fmt.Fprintln(stdout, i)
			break
		}
	}
}


Measured memory_bytes: 640
S = input()
slist = []
for i in S:
    slist.append(i)

ans = 0

for i in range(1, len(S)):
    if slist[i - 1] == slist[i]:
        if slist[i] == '0':
            slist[i] = '1'
            ans += 1
        else:
            slist[i] = '0'
            ans += 1
print(ans)

Measured memory_bytes: 4084