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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<llll> vllll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }
template<typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template<typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

vi depths;
vvi nexts;

int depth(int u) {
    if (depths[u] != -1) return depths[u];
    int d = 0;
    for (int v: nexts[u]){
        amax(d, 1+depth(v));
    }
    return depths[u] = d;
}

int solve(int N,int M,vi& x,vi& y) {
    depths.assign(N, -1);
    nexts.resize(N);

    rep(i,M){
        nexts[ x[i] ].pb(y[i]);
    }
    rep(i,N) depth(i);

    return *max_element(ALL(depths));
}

int main() {
    int N, M; scanf("%d%d", &N, &M);
    vi x(M),y(M);
    rep(i,M) {
        scanf("%d%d", &x[i], &y[i]);
        --x[i]; --y[i];
    }
    cout << solve(N,M,x,y) << endl;
    return 0;
}


Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,mx=1;
    string a;
    cin>>a;
    if(a[0]=='R' && a[1]=='R' && a[2]=='R') cout<<3<<endl;
    else if(a[0]=='R' && a[1]=='R' || a[1]=='R' && a[2]=='R') cout<<2<<endl;
    else if(a[0]=='R' || a[1]=='R' || a[2]=='R') cout<<1<<endl;
    else cout<<0<<endl;
 return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()

int pr[40], in[40], post[40], n;
int pos, id;
void dfs(int left, int right){
    if(left >= right)return;
    int root = pr[pos++], it;
    rep(i,n)if(in[i] == root)it = i;
    dfs(left, it);
    dfs(it + 1, right);
    post[id++] = root;
}
int main(){
    cin >> n;
    rep(i,n)cin >> pr[i];
    rep(i,n)cin >> in[i];
    dfs(0, n);
    rep(i,n)cout << post[i] << ((i < n-1)? " ": "\n");
    return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  vector<string>s(200),t(200);
  cin>>N;
  for(int i=0;i<N;i++)cin>>s.at(i);
  cin>>M;
  for(int i=0;i<M;i++)cin>>t.at(i);
  map<string,int>m;
  for(int i=0;i<N;i++)m[s.at(i)]++;
  for(int i=0;i<M;i++)m[t.at(i)]--;
  int ans=0;
  for(auto &itr:m)ans=max(ans,itr.second);
  cout<<ans<<endl;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

	while(1){
	int H, W;
	cin>>H>>W;
	if(H == 0 && W ==0) break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
			if(i == 0 || i == H - 1 || j == 0 || j == 0 || j == W - 1) cout<<"#";
			else cout<<".";
			}
		cout<<endl;
		}
	cout<<endl;
	}

	return 0;
}
		


Measured memory_bytes: 2984
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PA;
const int MOD = 1000000007;
const ll INF=2e18;

ll N;
string s;
int main(){
    cin>>N;
    int cnt=0;
    for(int i=1;i<=N;i++){
        string s=to_string(i);
        if(s.length()%2==1){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque


def main():
    height, width = [int(x) for x in input().split()]
    init_h, init_w = [int(x) - 1 for x in input().split()]
    dest_h, dest_w = [int(x) - 1 for x in input().split()]
    grid = [input() for _ in range(height)]

    adjacents = (
        (1, 0),
        (0, 1),
        (-1, 0),
        (0, -1)
    )

    # この処理を何度もやるのは無駄な，ワープ先を作成しておく。
    def gen_warp_can_reach():
        for h in range(-2, 3):
            for w in range(-2, 3):
                if h == 0 == w:
                    continue
                if (h, w) in adjacents:
                    continue
                yield (h, w)

    warp_can_reach = tuple(gen_warp_can_reach())

    qu = deque()
    qu.append((init_h, init_w))
    distances = [[-1] * width for _ in range(height)]
    # distances のインデックスアクセスが遅いので，訪問済みは set で管理する。
    arrived_total = set()
    arrived_total.add((init_h, init_w))
    warp_count = 0

    def append_qu(now_h, now_w, next_go_to):
        """行き先へ進めそうならキューに追加し， arrived_total に記録する。"""
        for h_delta, w_delta in next_go_to:
            new_h, new_w = h + h_delta, w + w_delta
            if new_h < 0 or new_h >= height or new_w < 0 or new_w >= width:
                continue
            if (new_h, new_w) in arrived_total:
                continue
            if grid[new_h][new_w] == '#':
                arrived_total.add((new_h, new_w))
                continue
            qu.append((new_h, new_w))
            arrived_total.add((new_h, new_w))

    while qu:
        arrived_set_by_cost = set()
        # 歩行 BFS
        while qu:
            h, w = qu.popleft()
            if h == dest_h and w == dest_w:
                return warp_count
            distances[h][w] = warp_count
            arrived_set_by_cost.add((h, w))
            append_qu(h, w, adjacents)

        warp_count += 1
        # ワープして行ける場所を列挙し，次期スタート地点とする。
        for h, w in arrived_set_by_cost:
            append_qu(h, w, warp_can_reach)

    return distances[dest_h][dest_w]


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 243732
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x,a=0;
cin>>n>>x;
while(1)
{
if(n==0&&x==0) break;
a=0;
for(int i=1;i<n-1; i++)
	{for(int i2=i+1;i2<n;i2++)
		{for(int i3=i2+1;i3<=n;i3++)
			{if(x==i+i2+i3) a++;
			}
		}
	}
cout<<a<<endl;
cin>>n>>x;
}
return 0;
}


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

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

  // END_CHECK_NUM
  for(int i=1;i<=N;i++){
    int x = i;
    // CHECK_NUM
    if(x%3 == 0){
      cout << " " << i;
    } else {
      // INCLUDE3
      for(int j=x;j>0;j/=10){
        if(j%10==3){
          cout << " " << i;
          break;
        }
      }
    }
  }
  cout << endl;
}



Measured memory_bytes: 3092
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, readline().split())
A = np.array(readline().split(), dtype=np.int64) + 1


Acum = np.zeros(N+1, np.float64)
Acum[1:] = A.cumsum()

x = Acum[K:] - Acum[:-K]
print(x.max()/2)


Measured memory_bytes: 23344
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;



typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L,T;
ll A[300005] = {};
ll B[300005] = {};
ll C[100][3005] = {};
bool f, ff;
string S,SS;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;
queue<ll> ql;


struct ST
{
	ll first;
	ll second;
	ll kaisuu;
	

	bool operator<(const ST& another) const
	{
		return first < another.first;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}



double ab[200];


int main() {
	
	cin >> N;

	

	for (int i = 0; i < N; i++) {
		cin >> A[i];

		a = A[i];
		b = 0;
		while (a>0)
		{
			B[b] += a % 2;
			a /= 2;
			b++;
		}
	}


	f = true;
	ff = true;

	for (int i = 0; i < 2000; i++) {
		if (B[i] == 0) {

		}
		else if(B[i]==N*2/3){
			ff = false;
		}
		else {
			f = false;
		}
	}

	if (N % 3 != 0 && ff==false) {
		f = false;
	}

	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;


	
}


Measured memory_bytes: 8448
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long

void solve() {
	int h; cin >> h;
    int cnt = 0;
    while(h > 1) {
        ++cnt; 
        h /= 2;
    }
    int ans = 1;
    rep(i, cnt + 1) {
        ans *= 2LL;

    }
    cout << ans - 1 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    private static void solve() {
        final Scanner scanner = new Scanner(System.in);

        for (int i = 1; ; i++) {
            final int n = scanner.nextInt();
            final int m = scanner.nextInt();
            if (n == 0 && m == 0) {
                break;
            }
            int counter = 0;
            int[] current = new int[m + 2];
            current[0] = n;
            while (current[m] == 0) {
                final int[] next = new int[current.length];
                for (int j = 0; j < m; j++) {
                    next[j] += current[j] % 2;
                    next[j + 1] += current[j] / 2;
                    next[0] += current[j] / 2;
                }
                current = next;
                counter++;
            }
            System.out.println(String.format("Case %d: %d", i, counter));
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
<?php

fscanf(STDIN, "%d", $N);
$s =array();
for($i=0;$i<$N;$i++){
fscanf(STDIN, "%s %d", $a, $b);
  $c =(100-$b);
  if($c<10){
    $c="00".$c;
  }elseif($c<100){
    $c="0".$c;
  }
  $s[] = $a.$c;
}
asort($s);
foreach($s as $key=>$ss){
  echo ($key+1)."\n";
}


?>

Measured memory_bytes: 4728
import sys
from io import StringIO
import unittest


def num_divisors_table(n):
    table = [0] * (n + 1)

    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1

    return table

def resolve():
    n = int(input())

    ans = num_divisors_table(n)

    print(sum([i * a for i, a in enumerate(ans)]))



class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4"""
        output = """23"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """100"""
        output = """26879"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10000000"""
        output = """838627288460105"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 364560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		sc.close();

		String[][] count = new String[2][26];
		String[][] count2 = new String[2][26];
		int i = 0;
		for ( char c = 'a';c < ('a' + 26);c++) {
		    count[0][i] = String.valueOf(c);
		    count[1][i] = "-";
		    count2[0][i] = String.valueOf(c);
		    count2[1][i] = "-";
		    i++;
		}

		String ans ="Yes";
		for(int j = 0 ; j < S.length() ; j++){
			for(int k = 0 ; k < 26 ; k++){
				if(count[0][k].equals(S.substring(j, j+1)) && count[1][k].equals("-")){
					count[1][k] = T.substring(j, j+1);
					break;
				}
				else if(count[0][k].equals(S.substring(j, j+1)) && !count[1][k].equals(T.substring(j,j+1))){
					//System.out.println(k + " "+j + " " + 1);
					ans = "No";
					break;
				}
			}
		}

		for(int j = 0 ; j < T.length() ; j++){
			for(int k = 0 ; k < 26 ; k++){
				if(count2[0][k].equals(T.substring(j, j+1)) && count2[1][k].equals("-")){
					count2[1][k] = S.substring(j, j+1);
					break;
				}
				else if(count2[0][k].equals(T.substring(j, j+1)) && !count2[1][k].equals(S.substring(j,j+1))){
					//System.out.println(k + " "+j + " " + count2[1][k]  + " " + S.substring(j,j+1));
					ans = "No";
					break;
				}
			}
		}
		System.out.println(ans);

/*

		for(int k = 0 ; k < 26 ; k++){
				System.out.println(count2[0][k] + " " + count2[1][k]);
		}
*/
	}
}

Measured memory_bytes: 274740
#include<stdio.h>

int main (void){
	
	int S, h, m, s;
	
	scanf("%d", &S);
	
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-h*3600-m*60;
	
	printf("%d:%d:%d\n", h, m, s);
	
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<pair<pair<string, int>, int>> data(n);

  for (int i = 0; i < n; i++) {
      string s;
      int k;
      cin >> s >> k;
      k *= -1;
      data.at(i) = make_pair(make_pair(s,k),i+1);
  }

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

  for (auto it : data) {
      cout << it.second << endl;
  }
}


Measured memory_bytes: 3592
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        long ans = x;
        for(int i = 1; i < 11; i++){
            ans = ans*r - d;
            System.out.println(ans);
        }
    }
    
}


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

int main() {
	int N, x;
	cin >> N >> x;
	long long ans = 0;
	int before, now;
	cin >> before;
	for (int i = 1; i < N; i++) {
		cin >> now;
		int buf = now;
		now = min(now, max(0, x - before));
		ans += (long long)buf - now;
		buf = before;
		before = min(before, max(0, x - now));
		ans += (long long)buf - before;
		before = now;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,j,n;
    cin>>n;
    
    
    if(n==22)
    cout<<"Christmas Eve Eve Eve"<<endl;
    if(n==23)
    cout<<"Christmas Eve Eve"<<endl;
    if(n==24)
    cout<<"Christmas Eve"<<endl;
    if(n==25)
    cout<<"Christmas"<<endl;
    
    
    
    
    
    
    return 0;
}





Measured memory_bytes: 3544
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val h, w = sc.nextInt()

    val d = Array.ofDim[Int](10, 10)
    for (i <- 0 to 9) {
      for (j <- 0 to 9) {
        d(i)(j) = sc.nextInt()
      }
    }

    for (k <- 0 to 9) {
      for (i <- 0 to 9) {
        for (j <- 0 to 9) {
          d(i)(j) = Math.min(d(i)(j), d(i)(k) + d(k)(j))
        }
      }
    }

    var ans = 0

    for (i <- 0 until h) {
      for (j <- 0 until w) {
        val n = sc.nextInt()
        if ((n != (-1)) && (n != 1)) {
          ans += d(n)(1)
        }
      }
    }

    println(ans)
  }


  def isParent(par: Array[Int], x: Int): Boolean = {
    par(x) == x
  }

  def init(par: Array[Int]): Unit = {
    for (i <- par.indices) {
      par(i) = i
    }
  }


  def root(par: Array[Int], x: Int): Int = {
    if (par(x) == x) {
      x
    } else {
      par(x) = root(par, par(x))
      par(x)
    }
  }

  def same(par: Array[Int], x: Int, y: Int): Boolean = {
    root(par, x) == root(par, y)
  }

  def unite(par: Array[Int], x: Int, y: Int): Unit = {
    var (xx, yy) = (root(par, x), root(par, y))
    if (!(xx == yy))
      par(xx) = yy
  }
}


Measured memory_bytes: 43388
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  char c;
  cin >> c;
  if(c >= 'a')cout << 'a' << endl;
  else cout << 'A' << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	while(true) {
		int N;
		cin>>N;
		if(N == 0) break;
		vector<P> d(N);
		d[0] = P(0, 0);
		REP(i, N - 1) {
			ll n, s;
			cin>>n>>s;
			switch(s) {
				case 0: {
					d[i + 1].first = d[n].first - 1;
					d[i + 1].second = d[n].second;
					break;
				}
				case 1: {
					d[i + 1].first = d[n].first;
					d[i + 1].second = d[n].second - 1;
					break;
				}
				case 2: {
					d[i + 1].first = d[n].first + 1;
					d[i + 1].second = d[n].second;
					break;
				}
				case 3: {
					d[i + 1].first = d[n].first;
					d[i + 1].second = d[n].second + 1;
					break;
				}
			}
		}
		ll maxx = -INF, minx = INF, maxy = -INF, miny = INF;
		REP(i, N) {
			maxx = max(d[i].first, maxx);
			minx = min(d[i].first, minx);
			maxy = max(d[i].second, maxy);
			miny = min(d[i].second, miny);
		}
		cout<<maxx - minx + 1<<" "<<maxy - miny + 1<<endl;
	}
}

Measured memory_bytes: 2984
n, k = map(int, input().split())

ans = 0
if k == 0:
    ans = n * n
else:
    for b in range(k+1, n+1):
        ans += (n // b) * (b-k)
        ans += max(((n % b) - k + 1), 0)
        # print(b, (n // b) * (b-k) + max(((n % b) - k + 1), 0))

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int m;
    cin>>m;
    int a[m];
    int sum=0;
    for(int i=0;i<m;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>n)
    {
        cout<<"-1";
    }
    else
    {
        cout<<n-sum;
    }
}






Measured memory_bytes: 3704
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int n = sc.nextInt();
                int yono = 0;
                if(n >= 165) yono++;
                if(n >= 105) yono++;
                if(n >= 195) yono++;
                if(n >= 135) yono++;
                if(n >= 189) yono++;
                sc.close();
                System.out.println(yono);
        }
}
//計算ミスしていました、悲しい

Measured memory_bytes: 35888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int primaryRange = Integer.valueOf(in.readLine());

		int result = 0;
		for (int index = 0; index < primaryRange; index++) {
			result += primaryNumber(Integer.valueOf(in.readLine()));
		}
		System.out.println(result);
	}

	public static int primaryNumber(int target) {

		int count = 0;
		boolean isPrime = true;
		int sqrt = (int)Math.sqrt(target);

		for (int i = 2; i <= sqrt; i++) {
			if (target % i == 0) {
				isPrime = false;
				break;
			}
		}
		if (isPrime) {
			++count;
		}
		return count;
	}
}



Measured memory_bytes: 30860
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
 
using namespace std;
 
const int maxn=1e7+10;
 
int32_t main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int n,m;
	scanf("%d %d",&n,&m);
	priority_queue<int> pq;
	for(int i=0;i<n;++i){
		int x;scanf("%d",&x);
		pq.push(-x);
	}
	vii q(m);
	for(int i=0;i<m;++i){
		scanf("%d %d",&q[i].ss,&q[i].ff);
	}
	sort(q.rbegin(),q.rend());
	for(int i=0;i<m;++i){
		int x=q[i].ss,y=q[i].ff;
		if(y>(-pq.top())){
			while(y>(-pq.top()) && x){
				pq.pop();
				pq.push(-y);
				--x;
			}
		}
		else
			break;
	}
	ll ans=0;
	while(!pq.empty()){
		ans+=(-pq.top());
		pq.pop();
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (b % a) {
    cout << b - a << '\n';
  } else {
    cout << a + b << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
cnt = int(input())
numbers = list(map(int, input().split(' ')))


def bubblesort(A, N):
    swap_cnt = 0
    flag = True
    while flag:
        flag = False
        for j in range(N-1, 0, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                swap_cnt += 1
                # ループで一回でもswapしたらTrueとなる
                flag = True

    return A, swap_cnt


numbers, swap_cnt = bubblesort(numbers, cnt)
print(' '.join(map(str, numbers)))
print(swap_cnt)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    int n; cin >> n;
    int nrest = n%1000;
    if(nrest == 0) cout << 0 << endl;
    else cout << 1000-nrest << endl;
}

Measured memory_bytes: 3620
a = []
c = 0
for i in range(5):
  a.append(int(input()))
#print(a)
k = int(input())
#print(k)
for i in range(5):
  for j in range(5):
    if abs(a[i] - a[j]) > k:
      #print(abs(a[i] - a[j]))
      c = 1
if c == 1:
  print(":(")
else:
  print("Yay!")

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

using namespace std;

long long dp[3001][3001];

long long solve(vector<long long>& points ,int i ,int j){
    if(i==j)
        return points[i];
    if(i+1==j)
        return max(points[i],points[j]);
        
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    
    long long start = points[i] + min(solve(points,i+2,j),solve(points,i+1,j-1));
    long long end = points[j] + min(solve(points,i+1,j-1),solve(points,i,j-2));
    
    return dp[i][j] = max(start,end);
}

int main() {
	// your code goes here
	int n ;
	cin>>n;
	vector<long long> points(n+1);
	long long sum =0;
	for(int i=1;i<=n;i++){
	    cin>>points[i];
	    sum+=points[i];
	}
	memset(dp,-1,sizeof(dp));
	long long x = solve(points,1,n);
	long long y = (sum - x);
	cout<<(x-y)<<endl;
	return 0;
}


Measured memory_bytes: 74128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long X,Y;
  cin >> X >> Y;
  if(Y%2==0&&-Y+4*X>=0&&Y-2*X>=0){
   cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
Node treeMinimum(Node x){
  while(x->right != NIL){
    x=x->left;
  }
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL){
    x=x->right;
  }
  return x;
}

Node treeSearch(Node u, int k){
  
  if(u==NIL || k==u->key){
    return u;
  }
  if(k<u->key){
    return treeSearch(u->left,k);
  }
  else
    return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL){
    return treeMinimum(x->right);
  }
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL){
    y=z;
  }
  else
    y=treeSuccessor(z);
  
  if(y->left != NIL){
    x=y->left;
  }
  else x=y->right;

  if(x != NIL){
    x->parent=y->parent;
  }

  if(y->parent==NIL){
    x=root;
  }
  else if(y==y->parent->left){
    y->parent->left=x;
  }
  else y->parent->right=x;

  if(y != z){
    z->key=y->key;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x != NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else
      x=x->right;
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else if(z->key<y->key){
    y->left=z;
  }
  else y->right=z;
}


void inorder(Node u){
  if(u!=NIL){
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20488
#include<iostream>
#include <string>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define fi first
#define se second
P2 p;
int n,h,w;
string s[21],t;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
P2 get_tank(){
  r(i,h)r(j,w){
    if(s[i][j]=='^')return P2(0,P(i,j));
    if(s[i][j]=='>')return P2(1,P(i,j));
    if(s[i][j]=='v')return P2(2,P(i,j));
    if(s[i][j]=='<')return P2(3,P(i,j));
  }
}
void shoot(){
  int y=p.se.fi;
  int x=p.se.se;
  while(1){
    y+=dy[p.fi];
    x+=dx[p.fi];
    if(x<0||y<0||y>=h||x>=w)break;
    if(s[y][x]=='#')break;
    if(s[y][x]=='*'){
      s[y][x]='.';
      break;
    }
  }
}
void GGG(int po){
  p.fi=po;
  int y=p.se.fi+dy[po];
  int x=p.se.se+dx[po];
  if(x<0||y<0||y>=h||x>=w)return;
  if(s[y][x]!='.')return;
  p.se.fi=y;
  p.se.se=x;
}
int main(){
  cin>>n;
  while(n--){
    cin>>h>>w;
    r(i,h)cin>>s[i];
    p=get_tank();
    s[p.se.fi][p.se.se]='.';
    cin>>t>>t;
    r(i,t.size()){
      if(t[i]=='S')shoot();
      else{
	int po;
        if(t[i]=='U')po=0;
        if(t[i]=='R')po=1;
        if(t[i]=='D')po=2;
        if(t[i]=='L')po=3;
	GGG(po);
      }
    }
    if(p.fi==0)s[p.se.fi][p.se.se]='^';
    if(p.fi==1)s[p.se.fi][p.se.se]='>';
    if(p.fi==2)s[p.se.fi][p.se.se]='v';
    if(p.fi==3)s[p.se.fi][p.se.se]='<';
    r(i,h)cout<<s[i]<<endl;
   if(n!=0)cout<<endl;
  }
}

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

using namespace std;

int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if(s==u){
        a--;
    }
    else if (t==u)
    {
        b--;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

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 T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if(s == "SUN") cout << 7 << '\n';
	else if(s == "MON") cout << 6 << '\n';
	else if(s == "TUE") cout << 5 << '\n';
	else if(s == "WED") cout << 4 << '\n';
	else if(s == "THU") cout << 3 << '\n';
	else if(s == "FRI") cout << 2 << '\n';
	else cout << 1 << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
       
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  int A = a.size(), B = b.size(), C = c.size();

  auto match = [](char c1, char c2) -> bool {
    return c1 == '?' || c2 == '?' || c1 == c2;
  };

  const int M = 2000;
  const int OFFSET = 4 * M;
  vector<bool> matchAB(2 * OFFSET + 1, true), matchAC(2 * OFFSET + 1, true),
      matchBC(2 * OFFSET + 1, true);

  for (int i = 0; i < (int)(A); ++i) for (int j = 0; j < (int)(B); ++j) if (!match(a[i], b[j])) matchAB[OFFSET - j + i] = false;
  for (int i = 0; i < (int)(A); ++i) for (int j = 0; j < (int)(C); ++j) if (!match(a[i], c[j])) matchAC[OFFSET - j + i] = false;
  for (int i = 0; i < (int)(B); ++i) for (int j = 0; j < (int)(C); ++j) if (!match(b[i], c[j])) matchBC[OFFSET - j + i] = false;

  int ans = 3 * M;
  for (int ab = -B - C; ab <= A + C; ++ab) {
    for (int ac = -C - B; ac <= A + B; ++ac) {
      if (!matchAB[OFFSET + ab] || !matchAC[OFFSET + ac] ||
          !matchBC[OFFSET + ac - ab])
        continue;
      int r = max({A, ab + B, ac + C});
      int l = min({0, ab, ac});
      chmin(ans, r - l);
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main (){
    ll N, M;
    cin>>N>>M;
    vector<pair<ll, ll>> AB(N);
    for(int i=0; i<N; i++){
        cin>>AB.at(i).first>>AB.at(i).second;
    }
    sort(AB.begin(), AB.end());
    ll Sum=0;
  	ll Num=0;
  	ll Key=0;
  	while(Num<M){
      	if(M-Num>AB.at(Key).second){
          	Sum += AB.at(Key).first*AB.at(Key).second;
          	Num += AB.at(Key).second;
          	Key ++;
        }
      	else{
          	Sum += AB.at(Key).first*(M-Num);
          	Num = M;
          	//Key++;
        }
    }
  	cout<<Sum;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(x) (x).begin(),(x).end()
typedef vector<int> vi;
#define inf 10e18;
#define pb push_back
#define pii pair<int,int>
#define vector<pii> vp
int i=0,j=0;
#define pi atan(1)*4
#define mp make_pair
#define F first
#define S second
#define loop(n) for(int i=0;i<n;++i)
#define ld long double

int main(){
   int n;cin>>n;
   while(n){
        int r = n%10;
        if(r==7){
            cout <<"Yes" << endl;
            return 0;
        }
        n/=10;
   }
   cout << "No" << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll j = 0;
    rep(i, 9) {
        if("AKIHABARA"[i] == s[j]) {  // AKIHABARAのi文字目とsのj文字目が一致していたら
            j++;  // jを1増やしてsのj+1文字目を調べる
        }
        else if("AKIHABARA"[i] != 'A') {  // AKIHABARAのi文字目が'A'以外のときにsのj文字目と一致していないならダメ
            out("NO");
            re0;
        }
    }

    if(j == s.size()) {  // sの文字を全て調べていたらok
        out("YES");
    }
    else {  // sの文字を全て調べていなければダメ
        out("NO");
    }
    
    re0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[list(input().split()) for _ in range(m)]

ac=[True]*n
d=[0]*n
tw=0
ta=0
for i in a:
  j=int(i[0])-1
  if (ac[j]):
    if (i[1]=="WA"):
      d[j]+=1
    else :
      tw+=d[j]
      ta+=1
      ac[j]=False
print(ta,tw)

Measured memory_bytes: 27448
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

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

	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		int s = 0;
		for (int j = i; j; j /= 10)
		{
			s += j % 10;

		}

		if (a <= s && s <= b)
		{
			sum += i;
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	pp := make([]pair, n)
	for i := 0; i < n; i++ {
		pp[i][0] = m - getNextInt(scanner)
		pp[i][1] = getNextInt(scanner)
	}
	sort.SliceStable(pp, func(i, j int) bool {
		return pp[i][0] < pp[j][0]
	})
	mh := mheap{}
	j := 0

	for i := 0; i <= m; i++ {
		for j < n && pp[j][0] <= i {
			if pp[j][0] >= 0 {
				mh.push(pp[j][1])
			}
			j++
		}
		for len(mh) > i+1 {
			mh.pop()
		}
	}
	var ans int
	for len(mh) > 0 {
		ans += mh.pop()
	}
	fmt.Fprintln(writer, ans)
}

type pair [2]int

type mheap []int

func (m *mheap) pop() int {
	n := len(*m) - 1
	m.swap(0, n)
	m.down(0, n)
	x := (*m)[n]
	*m = (*m)[:n]
	return x
}
func (m *mheap) push(x int) {
	n := len(*m)
	*m = append(*m, x)
	for n > 0 && m.less(n, (n-1)>>1) {
		m.swap(n, (n-1)>>1)
		n = (n - 1) >> 1
	}
}
func (m mheap) less(i, j int) bool {
	return m[i] < m[j]
}
func (m mheap) swap(i, j int) {
	m[i], m[j] = m[j], m[i]
}
func (m mheap) down(i, n int) {
	for {
		l := i<<1 + 1
		r := l + 1
		if r < n && m.less(r, l) {
			l = r
		}
		if l < n && m.less(l, i) {
			m.swap(i, l)
			i = l
			continue
		}
		break
	}
}


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


using namespace std;
#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 repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T> constexpr void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n, m;
void solve() {
    cin >> n >> m;

    priority_queue<ll> que;
    rep(i, n) {
        ll a;
        cin >> a;

        que.push(a);
    }

    rep(i, m) {
        auto p = que.top(); que.pop();
        p >>= 1;
        que.push(p);
    }

    ll ans = 0;
    while (!que.empty()) {
        auto p = que.top(); que.pop();
        ans += p;
    }

    cout << ans << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    cout << flush;

    return 0;
}


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

typedef struct node *link;

struct node
{
	int key;
	link parent,left,right;
};

link root;
link in;

void insert(link z)
{
	link p=NULL;
	link x=root;
	while(x!=NULL)
	{
		p=x;
		if(z->key<x->key)
		{
			x=x->left;
		}
		else
		{
			x=x->right;
		}
		z->parent=p;
	}
	if(p==NULL)
	{
		root=z;
	}
	else if(z->key<p->key)
	{
		p->left=z;
	}
	else
	{
		p->right=z;
	}
}

void traverse1(link a)
{
	if(a==NULL) return;
	printf(" %d",a->key);
	traverse1(a->left);
	traverse1(a->right);
}

void traverse2(link a)
{
	if(a==NULL) return;
	traverse2(a->left);
	printf(" %d",a->key);
	traverse2(a->right);
}

void find(link a,int k)
{
	while(a!=NULL&&k!=a->key)
	{
		if(k<a->key)
		{
			a=a->left;
		}
		else
		{
			a=a->right;
		}
	}
	if(a!=NULL)
	{
		printf("yes\n");
	}
	else
	{
		printf("no\n");
	}
}

int main(void)
{
	root=NULL;

	int i,num,N;
	char get[10];

	scanf("%d",&N);

	for(i=0;i<N;i++)
	{
		scanf("%s",get);

		if(strcmp(get,"insert")==0)
		{
			scanf("%d",&num);
			in=malloc(sizeof(*in));
			in->key=num;
			in->left=NULL;
			in->right=NULL;
			in->parent=NULL;
			insert(in);
		}
		else if(strcmp(get,"print")==0)
		{
			traverse2(root);
			printf("\n");
			traverse1(root);
			printf("\n");
		}
		else if(strcmp(get,"find")==0)
		{
			scanf("%d",&num);
			find(root,num);
		}
	}

	return 0;
}



Measured memory_bytes: 20448
package main

import "fmt"

func max(vs []int) int {
	m := vs[0]
	for _, v := range vs {
		if v > m {
			m = v
		}
	}
	return m
}
func min(vs []int) int {
	m := vs[0]
	for _, v := range vs {
		if v < m {
			m = v
		}
	}
	return m
}
func score(a, b, c int) int {
	return max([]int{a, b, c}) - min([]int{a, b, c})
}

func c1(a, b int) int {
	v1 := a / 3 * b
	v2 := (a - a/3) / 2 * b
	v3 := a*b - v1 - v2
	return score(v1, v2, v3)
}
func c2(a, b int) int {
	v1 := a / 3 * b
	a_rem := a - a/3
	v2 := b / 2 * a_rem
	v3 := a*b - v1 - v2
	return score(v1, v2, v3)
}
func c3(a, b int) int {
	v1 := (a/3 + 1) * b
	a_rem := a - a/3 - 1
	v2 := b / 2 * a_rem
	v3 := a*b - v1 - v2
	return score(v1, v2, v3)
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	fmt.Println(min([]int{c1(h, w), c1(w, h), c2(h, w), c2(w, h), c3(h, w), c3(w, h)}))
}


Measured memory_bytes: 512
import Control.Monad
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as B

main=do
    n<-readLn::IO Int
    as<-sort.map (\(i,a)->a-i).zip [1..].unfoldr (B.readInt.B.dropWhile(==' ')) <$> B.getLine::IO[Int]
    let m = as !! (n `div` 2)
    print $ sum $ map (\a->abs $ a-m) as


Measured memory_bytes: 32124
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.stream.Collector;
import java.util.stream.IntStream;

public class Main {
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();


        int[][] pos = new int[n][2];

        for (int cnt = 0; cnt < n; cnt++) {
            pos[cnt][0] = scanner.nextInt();
            pos[cnt][1] = scanner.nextInt();
        }

        String st = IntStream.range(0, n).mapToObj(it -> "" + it)
                .collect(Collector.of(StringBuilder::new, StringBuilder::append, StringBuilder::append, StringBuilder::toString));
        ArrayList<String> list = new ArrayList<>();
        permutation(st, "", list);

        BigDecimal bigDecimal = IntStream.range(0, factorial(n))
//        OptionalDouble average = IntStream.range(0, n)
                .mapToObj(list::get)
                .map(it -> {
//                    System.out.println(it);
                    char[] chars = it.toCharArray();
//                    double result = 0;
                    BigDecimal result = BigDecimal.ZERO;
                    for (int idx = 1; idx < chars.length; idx++) {
                        int pos1 = Integer.parseInt(chars[idx - 1] + "");
                        int pos2 = Integer.parseInt(chars[idx] + "");
//                        System.out.println(pos1 + "," + pos2);
                        result = result.add(new BigDecimal(distance(pos[pos1][0], pos[pos1][1], pos[pos2][0], pos[pos2][1])), MathContext.DECIMAL128);
//                        result += ;
                    }

                    return result;
                })
                .reduce(BigDecimal.ZERO, BigDecimal::add)
                .divide(new BigDecimal(factorial(n) + ""), MathContext.DECIMAL128);
//                .divide(new BigDecimal(""))
//                .get();

        System.out.println(bigDecimal.toString());
    }

    static String distance(int x1, int y1, int x2, int y2) {
        return "" + Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
    }

    static int factorial(int n) {
        int fact = 1;
        if (n == 0) return fact;
        else {
            for (int i = n; i > 0; i--) fact *= i;
            return fact;
        }
    }

    // http://chakotay.jugem.jp/?eid=612
    public static void permutation(String q, String ans, ArrayList<String> result) {
        // Base Case
        if (q.length() <= 1) {
//            System.out.println(ans + q);
            result.add(ans + q);
        }
        // General Case
        else {
            for (int i = 0; i < q.length(); i++) {
                permutation(q.substring(0, i) + q.substring(i + 1), ans + q.charAt(i), result);
            }
        }
    }
}


Measured memory_bytes: 137424
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll k,a,b;
    cin>>k>>a>>b;
    ll bisket=1;
    if(2>=b-a) bisket+=k;
    else{
        bisket+=a-1;
        k-=a-1;
        if(k%2==1) bisket++,k--;
        bisket+=(b-a)*(k/2);
    }
    cout<<bisket;
}

Measured memory_bytes: 3592