akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident $($r:tt)*) => {
        let mut $var = $iter.next().unwrap().parse::<usize>().unwrap();
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, $var:ident $($r:tt)*) => {
        let $var = $iter.next().unwrap().parse::<usize>().unwrap();
        input_inner!{$iter $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().unwrap()
    };
}
#[allow(unused_macros)]
macro_rules! outbuf {
    ($var:ident) => {
        use std::io::{stdout, BufWriter, Write};
        let stdout = stdout();
        let mut $var = BufWriter::new(stdout.lock());
    };
}
use std::cmp::min;
fn main() {
    input! {n, k, xy: [(isize, isize); n]};
    // outbuf! {out};
    let mut ans = std::isize::MAX;
    let (mut x, mut y): (Vec<_>, Vec<_>) = xy.iter().cloned().unzip();
    let ok = |x1: isize, x2: isize, y1: isize, y2: isize| {
        let mut cnt = 0;
        for &(x, y) in &xy {
            if x1 <= x && x <= x2 && y1 <= y && y <= y2 {
                cnt += 1;
            }
        }
        cnt
    };
    x.sort();
    y.sort();
    for xi in 0..(n-1) {
        for xj in xi..n {
            let mut yj = 0;
            for yi in 0..n {
                while yj < n && ok(x[xi], x[xj], y[yi], y[yj]) < k {
                    yj += 1;
                }
                if yj == n {
                    yj -= 1;
                }
                if ok(x[xi], x[xj], y[yi], y[yj]) >= k {
                    ans = min(ans, (x[xi]-x[xj]).abs()*(y[yi]-y[yj]).abs());
                }
                if yi == yj {
                    yj += 1;
                }
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
h,w = map(int,raw_input().split())

arr = [raw_input() for i in range(h)]

ans = []
for i in range(h):
	count = 0
	for j in range(w):
		if arr[i][j] == '.':
			count += 1

	if count != w:
		ans.append(arr[i]) 


ret = [[] for i in range(len(ans))]
for i in range(w):
	count = 0
	for j in range(len(ans)):
		if ans[j][i] == '.':
			count += 1

	if count != len(ans):
		for j in range(len(ans)):
			ret[j].append(ans[j][i])

for i in ret:
	print ''.join(i)



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

int main(){
  cout<<setprecision(10)<<fixed;
  double n,m,d;
  cin>>n>>m>>d;
  double p;
  if(d==0) p=1/n;
  else p=2*(n-d)/(n*n);
  p*=m-1;
  cout<<p<<endl;
}

Measured memory_bytes: 3700
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int main() {
  int x, y;
  cin >> x >> y;
  int ret = 0;
  if (x <= 3) ret += (4 - x) * 100000;
  if (y <= 3) ret += (4 - y) * 100000;
  if (x + y == 2) ret += 400000;
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    ll n;
    cin >> n;
    string ns = to_string(n);
    ll size = ns.size();

    ll cnt = 0;
    REP2(i, 1, n+1) {
        string s = to_string(i);
        if (s[0] == s[s.size()-1]) {
            cnt += 1;
        }
        if (size > 1 && s[s.size()-1] != '0' && s[s.size()-1] - '0' <= ns[0] - '0') {
            if (s[s.size()-1] - '0' < ns[0] - '0') {
                cnt += pow(10, size-2);
            } else {
                if (s[0] - '0' <= ns[size - 1] - '0') {
                    if (size == 2) {
                        cnt += 1;
                    } else {
                        cnt += stoi(ns.substr(1, size-2)) + 1;
                    }
                } else {
                    if (size == 2) {
                        cnt += 1;
                    } else {
                        cnt += stoi(ns.substr(1, size-2));
                    }
                }
            }
        }
        REP2(j, 1, size-1) {
            if (s[s.size()-1] != '0') {
                cnt += pow(10, size-j-2);
            }
        }
    }

    std::cout << cnt << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{int to,cost;};
vector<edge> G[100005];
int co[100005];
void bfs(int x){
	queue<int> que;
	que.push(x);
	while(que.size()){
		int t=que.front(); que.pop();
		for(int i=0;i<G[t].size();i++){
			edge e=G[t][i];
			if(co[e.to]==0){
				que.push(e.to);
				if(co[t]==1){
					if(e.cost==0){
						co[e.to]=1;
					}else{
						co[e.to]=2;
					}
				}else{
					if(e.cost!=0){
						co[e.to]=1;
					}else{
						co[e.to]=2;
					}
				}
			}
		}
	}
}
int main(void){
    int n; cin>>n;
    int a,b,c;
    for(int i=0;i<n-1;i++){
		cin>>a>>b>>c;
		if(c%2==0){
			c=0;
		}else{
			c=1;
		}
		G[a].push_back(edge{b,c}); G[b].push_back(edge{a,c});
	}
	co[1]=1;
	bfs(1);
	for(int i=1;i<=n;i++){
		cout<<co[i]-1<<endl;
	}
	
    
}


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

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return y == 0 ? x : gcd(y, x%y);
}

bool can() {
    int n, k;
    scanf("%d%d", &n, &k);
    vector<int> a(n);
    for (int& i : a) scanf("%d", &i);
    
    int G = a[0];
    for (int i : a) G = gcd(G, i);
    return *max_element(a.begin(), a.end()) >= k && k % G == 0;
}

int main() {
    puts(can() ? "POSSIBLE" : "IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n, m, p; cin >> n >> m >> p;
    if(n == 0) break;
    m--;
    vi a(n);
    int su = 0;
    for(int i=0;i<n;++i) {
      cin >> a[i];
      su += a[i];
    }
    su *= (100 - p);
    if(a[m] == 0) cout << 0 << endl;
    else cout << su / a[m] << endl;
  }
}



Measured memory_bytes: 3144
def nxan(cr, ck, pk)
  if ck == 0
    if cr == "o"
      pk
    else
      1 - pk
    end
  else
    if cr == "o"
      1 - pk
    else
      pk
    end
  end
end

def solve
  n = gets.chomp.to_i
  s = gets.chomp

  al = Array.new(n)
  
  (0..1).each do |lc|
    (0..1).each do |fc|
      al[0] = fc
      al[1] = nxan(s[0], al[0], lc)
      
      (2..n-1).each do |i|
        al[i] = nxan(s[i-1], al[i-1], al[i-2])
      end

      if al[-1] == lc && nxan(s[n-1], al[n-1], al[n-2]) == al[0]
        puts al.map{|x| (x == 0) ? "S" : "W"}.join("")
        return
      end
    end
  end

  puts "-1"
end

solve



Measured memory_bytes: 7932
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

int main() {
string s;
int n;
cin >> s;
n = s.size();
VI ans(n, 0);
bool en = false;
int cnt = 0;
REP(i,n){
  cnt++;
  //cout << "cnt" << ' ' << cnt << ' ' << i << endl;
  if(s[i]=='R'&&s[i+1]=='L'){
    int cntl=0;
    //cout << i << endl;
    FOR(j, i+1, n){
      if(s[j]=='R'||j==n-1){
        if(j==n-1) cntl++;
        int cnta = cnt+cntl;
        if(cnta%2==0){
          ans[i]=cnta/2;
          ans[i+1]=ans[i];
        }else{
          if(cntl>cnt){
            if(cntl%2==0){
              ans[i]=cnta/2+1;
              ans[i+1]=cnta/2;
            }else{
              ans[i]=cnta/2;
              ans[i+1]=cnta/2+1;
            }
          }else{
            if(cnt%2==0){
              ans[i]=cnta/2;
              ans[i+1]=cnta/2+1;
            }else{
              ans[i]=cnta/2+1;
              ans[i+1]=cnta/2;
            }
          }

        }
        cnt=0;
        i=j-1;
        //cout << j << endl;
        j=n-1;
      }
      cntl++;
    }
      

  }
  if(i==n-1) break;

}
REP(i, n){
  cout << ans[i] << ' ';
}
cout << endl;

}

Measured memory_bytes: 1088
#include <cstdio>
#include <string>
#include <set>
#include <vector>
using  namespace std;

int dr[]={-1, -1, -1, 0, 0, 1, 1, 1};
int dc[]={-1, 0, 1, -1, 1, -1, 0, 1};

bool cmp(const string& a, const string& b)
{
    if (a.size()<b.size()) return 1;
    if (a.size()>b.size()) return 0;
    return a>b;
}

int main()
{
    int n, m;
    while (scanf("%d%d", &n, &m), n) {
        char s[11][21];
        for(int i=0;i<n;++i) scanf("%s", s[i]);

        int maxlen=0;
        vector<string> spells[200];
        for(int i=0;i<n;++i) for(int j=0;j<m;++j) for(int k=0;k<8;++k) {
            int r=i, c=j, q=0;
            string t;
            do {
                t+=s[r][c];
                spells[q++].push_back(t);
                r=(r+dr[k]+2*n)%n;
                c=(c+dc[k]+2*m)%m;
            } while (r!=i || c!=j);
            maxlen=max(maxlen, q);
        }

        string res;
        for(int k=1;k<maxlen;++k) {
            int N=spells[k].size();
            set<string> v;
            for(int i=0;i<N;++i) {
                if (v.count(spells[k][i]) and cmp(res, spells[k][i]))
                    res=spells[k][i];
                v.insert(spells[k][i]);
            }
        }
        puts(res.size()?res.c_str():"0");
    }
    return 0;
}

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

int main(){
	int A, B, N;
	cin >> N >> A >> B;
	int total = 0;
	int sum = 0;
	for(int n = 1; n <= N; n++){
		int a = n;
		int b = a;
		sum = 0;
		while(a > 0){
			sum += a % 10;
			a /= 10;
		}
		if(sum >= A && sum <= B) total += b;
	}
	cout << total << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pb push_back

int main()
{
	string s;
	cin>>s;
	
	int k;
	int n  = s.length();
	cin>>k;
	set<string>arr;
	for(int i=0;i<s.length();i++)
	{
		string x="";
		for(int j=i;j<min(n,(i+k));j++)
				{
					x=x+s[j];
					arr.insert(x);
				}
	}
auto it = arr.begin();
for(int i=0;i<k-1;i++)
	it++;
cout<<*it<<"\n";
}


Measured memory_bytes: 4712
#include <iostream>
#include <vector>

using namespace std;

struct Card
{
	int attack;
	int cost;
};



class Solver
{
private:
	vector<Card> cards;
	int card_num; 
	int cost_max;

public:
	Solver(){}

	Solver(vector<Card> cards_, int card_num_, int cost_max_) : cards(cards_), card_num(card_num_), cost_max(cost_max_) {}

	void exec() {
		vector<vector<int> > dp = vector<vector<int> >(card_num + 1, vector<int>(cost_max + 1, 0));
		for (int i = 0; i < card_num; ++i)
		{
			for (int j = 0; j <= cost_max; ++j)
			{
				if(i == 0) {
					if(j - cards[i].cost >= 0) dp[i][j] = cards[i].attack;
					continue;
				}
				if(j - cards[i].cost >= 0) {
					dp[i][j] = max(dp[i-1][j- cards[i].cost] + cards[i].attack, dp[i-1][j]);
				} else {
					dp[i][j] = dp[i-1][j];
				}
				// cout << dp[i][j] << " ";
			}
			// cout << endl;

		}
		cout << dp[card_num-1][cost_max] << endl;
	}
};




int main(int argc, char *argv[])
{
  	// start from 1 to ignore script name; argv[0] will be a name of processing file.
	// for (int i = 1; i < argc; i++) {
	// 	printf ("argv[%i]: %s\n", i, argv[i]);
	// }
	int card_num, cost_max;
 //    int arg_int = 1;
 //  	int card_num = argv[arg_int];
 //  	arg_int++;
 //  	int cost_max = argv[arg_int];
 //  	arg_int++;

  	vector<Card> cards;
	// for (int i = 0; i < card_num; ++i)
	// {
	// 	Card tmp_card = {argv[arg_int], argv[arg_int + 1]}
	// 	arg_int += 2;
	// 	cards.push_back(tmp_card);
	// }

	cin >> card_num;
	cin >> cost_max;
	cards.resize(card_num);
	for (int i = 0; i < card_num; ++i)
	{
		cin >> cards[i].attack >> cards[i].cost;
	}


	Solver s = Solver(cards, card_num, cost_max);
	s.exec();
	return 0;
}

Measured memory_bytes: 6836
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  long int n, sum = 0;
  cin >> n;
  rep(i, 1, n + 1){
    if(i % 3 != 0 && i % 5 != 0){
      sum += i;
    }
  }
  cout << sum << "\n";
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define rrep(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)

using namespace std;
using ll = long long;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}

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


//////////////////////////////////////////////////

// ll dp[100100][3];

int main() {
    int n, k; cin >> n >> k;
    vector<int> rsp(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> rsp[i];
    }
    string t; cin >> t;
    string ans = "";
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        int b = i-k;
        int tmp;
        if (t[i] == 'r') {
            ans += 'p';
            tmp = rsp[2];
        } else if (t[i] == 's') {
            ans += 'r';
            tmp = rsp[0];
        } else {
            ans += 's';
            tmp = rsp[1];
        }

        if (b >= 0 && ans[b] == ans[i]) {
            ans[i] = 'a';
        } else {
            sum += tmp;
        }
        // cout << sum << endl;
    }
    
    // cout << ans << endl;
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second

ll mod = 1e9+7;
ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}
ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll inv(ll a) {
	ll x, y;
	ll g = gcd(a, mod, x, y);
	x = (x % mod + mod) % mod;
	return x;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main() {
	int t;
	//cin>>t;
	t = 1;
	while(t--) {
		int a,b,c;
		cin>>a>>b>>c;
		int k;
		cin>>k;
		int x=0,y=0;
		while(b<=a) {
			b = 2*b;
			x++;
		}
		while(c<=b) {
			c = 2*c;
			y++;
		}
		if(x+y>k) cout<<"No";
		else cout<<"Yes";

	}
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define MAX 100005
using namespace std;
 
int a[MAX], ans, cnt;
int main(){
  int n, c, i;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &c);
    a[c]++;
  }
  for(i = 0; i < MAX; i++){
    if(a[i]){
      ans++;
      if(a[i]%2 == 0) cnt++;
    }
  }
  
  printf("%d\n", ans - cnt%2);
}

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

#define MyREPT(i,k,n) for(long long i = (k); i < (long long)(n); i++)

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}


int main(){
    long long s;
    cin>>s;
    long long mod = 1000000007;
    vector<long long> dp(s+1,0);
    long long sum = 0;
    MyREPT(i,3,s+1){
        dp[i]=(dp[i-3]+1+dp[i-1])%mod;
    }
    cout<<((dp[s]+mod)-dp[s-1])%mod<<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#define EPS 1e-8
using namespace std;
typedef complex<double> P;
#define X real()
#define Y imag()

bool equidistantpoint(const P& a, const P& b, double r, vector<P>& ep){
    if(abs(b-a)>r*2+EPS) return false;
    P mid = (a+b)/P(2,0);
    P len = P(sqrt(r*r-norm(b-mid)),0);
    P rot = P((b-a).Y,(a-b).X) / P(abs(b-a),0);
    ep.resize(2);
    ep[0] = len*rot + mid;
    ep[1] = -len*rot + mid;
    return true;
}

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        vector<P> pset(n);
        for(int i=0; i<n; i++){
            double x,y;
            cin >> x >> y;
            pset[i] = P(x,y);
        }

        int mnop=0;
        for(int i=0; i<n-1; i++){
            for(int j=i+1; j<n; j++){
                vector<P> endpoints;
                bool ret = equidistantpoint(pset[i], pset[j], 1, endpoints);
                if(!ret)continue;
                for(int lr=0; lr<2; lr++){
                    int count=0;
                    for(int k=0; k<n; k++){
                        if(abs(pset[k]-endpoints[lr]) < 1+EPS){
                            count++;
                        }
                    }
                    mnop = max(mnop, count);
                }
            }
        }

        if(mnop==0) mnop=1;
        cout << mnop << endl;
    }
            
    return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int a,b,h;

	cin >> a >> b >> h;

	cout << (a + b) * h / 2 << endl;



	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    ll X;
    cin >> X;

    auto calc = [&](ll a) {
        return a * a * a * a * a;
    };
    REP(a, -200, 201){
        REP(b, -200, 201){
            ll aa = calc(a), bb = calc(b);
            if (aa - bb == X){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n, k;
  cin >> n >> k;

  ll a[n], b[n];
  pair<ll, ll> p[n];
  REP(i, n){
    cin >> a[i] >> b[i];
    p[i].first = a[i];
    p[i].second = b[i];
  }
  sort(p, p + n);
  ll s = 0;
  REP(i, n){
    s += p[i].second;
    if(s >= k){
      cout << p[i].first << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3328
#66 A - Two Abbreviations
import math
N,M = map(int,input().split())
S = input()
T = input()

GCD = math.gcd(N,M)
L = N*M//GCD

dist_N = L//N
dist_M = L//M

# 同じ位置に書く文字は最大公約数 + 1 だけ存在する
for i in range(GCD):
    # S の s 文字目と T の t 文字目が同じ位置に来る
    s = dist_M * i
    t = dist_N * i
    if S[s] != T[t]:
        ans = -1
        break
else:
    ans = L
print(ans)

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

const ll MNA = -1e18;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	ll n, k;
	cin >> n >> k;
	ll p[n+1], c[n+1];
	for (int i=1; i<=n; i++) cin >> p[i];
	for (int i=1; i<=n; i++) cin >> c[i];
	ll ans = MNA;
	for (int i=1; i<=n; i++) {
		ll cur = 0;
		int tmp = 0;
		vector<bool> vis(n+1);
		vis[i] = true;
		int idx = i;
		while (tmp < k) {
			idx = p[idx];
			cur += c[idx];
			ans = max(ans, cur);
			tmp++;
			if (vis[idx]) break;
			vis[idx] = true;
		}
		if (cur > 0) {
			ll mul = k/tmp - 1;
			cur *= mul;
			ans = max(ans, cur);
			tmp = k - mul*tmp;
			idx = i;
			while (tmp--) {
				idx = p[idx];
				cur += c[idx];
				ans = max(ans, cur);
			}
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3744
#include <cstdio>

int h;

void maxHeapify(int A[], int i) {
        int l = i*2+1, r = i*2+2;
        int largest;
        if (l < h && A[l] > A[i]) {
                largest = l;
        } else {
                largest = i;
        }
        if (r < h && A[r] > A[largest]) {
                largest = r;
        }
        if (largest != i) {
                int tmp = A[i];
                A[i] = A[largest];
                A[largest] = tmp;
                maxHeapify(A, largest);
        }
}

void buildMaxHeap(int A[]) {
        for (int i = h/2; i >= 0; i--) {
                maxHeapify(A, i);
        }
}

int main() {
        const int H = 500000;
        int A[H];

        scanf("%d", &h);
        for (int i = 0; i < h; i++) {
                scanf("%d", &A[i]);
        }
        buildMaxHeap(A);
        for (int i = 0; i < h; i++) {
                printf(" %d", A[i]);
        }
        printf("\n");

        return 0;
}

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

int main(void){
    char input[1001];
    int sum;
    int i;
    
    while(cin >> input){
//    cout << input << endl;
    if(input[0] == '0') break;
    
    sum = 0;
    for(i = 0; input[i] != '\0'; i++){
        sum += static_cast<int>(input[i] - '0');
    }
    
    cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3080
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  /*

    your code

  */
  for(j=2;j<=n;j++){
    key = A[j];
    i = j -1;
    while( i > 0 && A[i] > key){
      A[i+1] = A[i];
      i=i-1;
    }
    A[i+1]= key;
    trace(A,n);
  }
  return 0;
}

Measured memory_bytes: 608
def main():
    n,x=map(int,input().split())
    j = 1
    if(x == 1 or x == 2 * n - 1):
        print("No")
        return 0
    print("Yes")
    ans=[]
    for i in range(n-2):
        if(j == x - 1):
            j += 3
        ans.append(j)
        j+=1
    ans+=[x-1,x,x+1]
    for i in range(n-2):
        if(j == x - 1):
            j += 3
        ans.append(j)
        j+=1
    print(*ans)
    return 0
main()


Measured memory_bytes: 18432
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    H, W = map(int, input().split())
    field = []
    for i in range(H):
        s = input()
        if s.count("#") != 0:
            field.append(s)

    ans = [""] * len(field)
    for x in range(W):
        ok = False
        for y in range(len(field)):
            ok |= field[y][x] == "#"

        if ok:
            for y in range(len(field)):
                ans[y] += field[y][x]

    print("\n".join(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4068
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================



	int N;
	cin >> N;

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


	vint ans;
	
	while (ans.size() < N) {

		for (int i = B.size() - 1; i >= 0; i--) {

			if (B[i] == i + 1) {
				ans.emplace_back(B[i]);
				B.erase(B.begin() + i);
				break;
			}

			if (i == 0) {
				cout << -1;
				return 0;
			}
		}

	}

	for (int i = N - 1; i >= 0; i--) {
		cout << ans[i] << endl;
	}



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
    int m,d;
    int z=0;
    cin>>m>>d;
    for(int i=1;i<=m;i++){
        for(int j=22;j<=d;j++){
            int a=j%10;
            int b=j/10;
            if(a>=2&&b>=2&&a*b==i) z++;
        }
    }
    cout<<z;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;

long long modpow(long long x,long long n,long long mod)
{
  if(n==0)return 1;
  long long res=modpow(x*x%mod,n/2,mod);
  if(n&1)res=res*x%mod;
  return res;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  int mod= 998244353;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int sa=0;
  rep(i,n)sa+=a[i];
  int l=sa/2;
  vector<int>dp(l+1,0);
  dp[0]=1;
  rep(i,n)
  {
    for(int j=l-a[i];j>=0;j--)
    {
      if(dp[j]==0)continue;
      dp[j+a[i]]+=dp[j]*2%mod;
      if(dp[j+a[i]]>=mod)dp[j+a[i]]-=mod;
    }
  }
  ll res=modpow(3,n,mod);
  rep(i,l+1)dp[i]=(ll)dp[i]*3%mod;
  for(auto i:dp){res+=mod-i;if(res>=mod)res-=mod;}
  if(!(sa&1))
  {
    fill(all(dp),0);
    dp[0]=1;
    rep(i,n)
    {
      for(int j=l-a[i];j>=0;j--)
      {
        if(dp[j]==0)continue;
        dp[j+a[i]]+=dp[j];
        if(dp[j+a[i]]>=mod)dp[j+a[i]]-=mod;
      }
    }
    res+=(ll)dp.back()*3;
  }
  cout<<res%mod<<endl;


  return 0;

}


Measured memory_bytes: 384
import bisect
import sys
input = sys.stdin.readline

INF = 10**12
n, q = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

# Calc cumrative sum
sum_even = [0] * (n + 1)
sum_odd = [0] * (n + 1)
sum_all = [0] * (n + 1)
for i, item in enumerate(a):
    if i % 2 == 0:
        sum_odd[i+1] = sum_odd[i] + a[i]
        sum_even[i+1] = sum_even[i]
    else:
        sum_even[i+1] = sum_even[i] + a[i]
        sum_odd[i+1] = sum_odd[i]
    sum_all[i+1] = sum_all[i] + a[i]

# Iterate in query
a.append(INF)
ans = []
for i in range(q):
    # Get div of aoki - takahashi
    x = int(input())
    l = 0
    r = n - 1
    # l: aoki takes, r: takahashi takes
    while r - l > 1:
        m = (r + l) // 2
        rng = abs(x - a[m])
        t_num = n - m
        a_num = n - t_num - (bisect.bisect_left(a, x - rng))
        if t_num <= a_num + 1:
            r = m
        else:
            l = m
    rng = abs(x - a[r])
    t_num = n - r
    rest = n - 2 * t_num
    t_sum = sum_all[n] - sum_all[n - t_num]
    a_sum = sum_all[r] - sum_all[r - t_num]

    # Add stripe area
    if n - t_num * 2 > 0:
        if rest % 2 == 0:
            t_sum += sum_even[rest]
            a_sum += sum_odd[rest]
        else:
            t_sum += sum_odd[rest]
            a_sum += sum_even[rest]
    ans.append(t_sum)

print("\n".join([str(item) for item in ans]))

Measured memory_bytes: 96108
a, b = map(int, input().split())

if b == 1:
    print(0)
    exit(0)

ans = 0
cnt = a
while b > cnt :
    cnt = a + (( a - 1 ) * (ans))
    ans += 1

#print( ans if ans != 0 else 1 )
print( ans if ans != 0 else 1 )


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
	ll s;
	if(k > 1){
		s = k*facctorialMethod(k-1);
	} else {
		s = 1;
	}
	return s;
}
vl primes(ll n){
	vl x(n);
	REP(i, n){
		x[i] = 0;
	}
	for(ll i = 2; i < sqrt(n) + 2; i++){
		while(n % i == 0){
			n /= i;
			x[i-1] += 1;
		}
	}
	if(n > 1){
		x[n-1] += 1;
	}
	return x;
}
const ll mod = 1000000007;
int main(){
	ll N;
	cin >> N;
	ll ans = (N-1)*N/2;
	cout << ans << endl;
}


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

lli n, m;

int main(void){
	cin >> n >> m;
	vector<bool> ac(n+1);
	vector<lli> wa(n+1);
	rep(i, m){
		int p;
		string s;
		cin >> p >> s;
		if(s == "AC") ac[p] = true;
		else{
			if(!ac[p]) wa[p]++;
		}
	}
	lli sumac = 0, sumwa = 0;
	rep(i, n+1){
		if(ac[i]){
			sumac++;
			sumwa+=wa[i];
		}
	}
	cout << sumac << " " << sumwa << endl;
	return 0;
}


Measured memory_bytes: 4024
#include <iostream>

using namespace std;
typedef long long ll;
ll d[1010],n,m,a[2010],b[2010],c[2010],inf = 1000000000000000000;
bool ne[1010];
void bellmann(int s){
	int i,j;
	for(i=0;i<n;i++) d[i] = inf;
	d[s] = 0;
	for(i=0;i<n-1;i++){
		for(j=0;j<m;j++){
			if(d[a[j]]!=inf && d[a[j]] + c[j] < d[b[j]]){
				d[b[j]] = d[a[j]] + c[j];
			}
		}
	}
}

//nに到達できる負閉路の検出
void find_negative_loop(){
	int i,j;
	for(i=0;i<n;i++) ne[i] = false;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(d[a[j]]!=inf && d[a[j]] + c[j] < d[b[j]]){
				d[b[j]] = d[a[j]] + c[j];
				ne[b[j]] = true;
			}
			if(ne[a[j]]) ne[b[j]] = true;
		}
	}
}

int main(){
	cin >> n >> m;
	int i,j;
	for(i=0;i<m;i++){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--; c[i] = -c[i];
	}
	bellmann(0);
	find_negative_loop();
	if(ne[n-1]){
		cout << "inf" << endl;
	}else{
		cout << -d[n-1] << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <map>
#include <stdio.h>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,a) for(int i=0;i<(a);++i)
typedef pair<int, int> P;
typedef pair<pair<P, P>, P>PP;
typedef long long LL;
#define INF LL(1e18)
#define N 1000000000
LL ans, temp;
int search(LL s, LL e, LL i)
{
	char a;
	LL mid = (s + e) / 2;
	cout << "? " << ans + mid * i << endl;
	cin >> a;
	if(mid - s == 1 && a == 'Y')
	{
		return s;
	}
	if(e - mid == 1 && a == 'N')
	{
		return mid;
	}
	return a == 'Y' ? search(s, mid, i): search(mid, e, i);
}
int solve(LL s, LL e, LL i)
{
	char a;
	if(s){
		cout << "? " << s * i + ans << endl;
		cin >> a;
		if(a == 'Y')
	 	 return s; 
	}
	cout << "? " << e * i + ans << endl;
	cin >> a;
	if(a == 'N')
	 return e;
	return search(s, e, i);
}
int main()
{

	for(LL i = LL(1e10); i > 1; i /= 10)
	{
		if(i == LL(1e10))
			ans += solve(1, 9, i) * i;
		else
			ans += solve(0, 9, i) * i;
	}
	char a;
	cout << "? " << ans << endl;
	cin >> a;
	ans /= 10;
	if(a == 'N')
	{
		ans++;
	}
	
	while(!(ans % 10))
	{	
		ans /= 10;
		if(ans % 10 != 9)
		{
			cout << "? " <<  ans + 1 << endl;
			cin >> a;
			if(a == 'N')
			{
				ans *=10;
				break;
			}
		}
		else
		{
			cout << "? " <<  ans - 1 << endl;
			cin >> a;
			if(a == 'Y')
			{
				break;
			}
		}
	}
	cout << "! " << ans << endl;
	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    if ((B - A) % 2 == 0){
      System.out.println("Alice");
    } else if ((B - A) % 2 == 1){
      System.out.println("Borys");
    } else {
      System.out.println("Draw");
    }
  }
}

Measured memory_bytes: 22996
N, Q = map(int, input().split())
S = input()
L, R = [0] * Q, [0] * Q
for q in range(Q):
    L[q], R[q] = map(int, input().split())

t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i:i + 2] == 'AC' else 0)

for q in range(Q):
    l, r = L[q], R[q]
    print(t[r - 1] - t[l - 1])


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define cout(d) cout<<d<<endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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; }

int main(){
  ll n, m;
  cin>>n>>m;
  priority_queue<ll> que;
  rep(i,n){
    ll A;cin>>A;
    que.push(A);
  }
  
  rep(i,m){
    ll now=que.top(); que.pop();
    if(now==0)break;
    now/=2;
    que.push(now);
  }
  
  ll ans=0;
  rep(i,n){
    int now=que.top(); que.pop();
    ans+=now;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<list>
#include<algorithm>
#include <utility>
#include<stdio.h>
#include<climits>

using namespace std;

int main(void){
    int n,m;
    int b[15]={},q[15]={};
    int i,j,k,a[2] = {},s0 = 0,s1 = 0;
    cin >> n >> m;
    for(i = 0;i < n;i++){
        cin >> b[i];
        if(b[i]) s1++;
    }
    for(i = 0,k = 0;i < m;i++){
        cin >> j;
        k += j;
        for(;j > 0;j--){
            q[k-j] = i%2;
            if(q[k-j]) s0++;
        }
    }
    if(s0 == s1){
        for(i = 0,j = 0;i < n;i++){
            if(b[i]){
                while(!q[j]) j++;
                a[0] += abs(i-j);
                j++;
            }
        }
    }else a[0] = INT_MAX;
    if(n-s1 == s0){
        for(i = 0,j = 0;i < n;i++){
            if(b[i]){
                while(q[j]) j++;
                a[1] += abs(i-j);
                j++;
            }
        }
    }else a[1] = INT_MAX;
    cout << min(a[0],a[1]) << endl;
}

Measured memory_bytes: 1164
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll a,b,c;
cin >> a >> b >> c;
ll cnt;
cin >> cnt;
for(int i = 0; i < cnt; i++){
    if(a >= b){
        b *= 2;
    }
    else if(b >= c){
        c *= 2;
    }
}
cout << (a < b && b < c ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
const ll INF = 1e18;
 
VV<> dp(301, V<>(301, INF));
 
int main(){
    ios;
    INT(n, k); 
    VEC(int, h, n); h.pb(0);
    dp[0][n] = 0;
    REP(i, n) REP(j, i + 1) REP(k, n + 1) if(i != k)
        chmin(dp[j + 1][i], dp[j][k] + max(h[i] - h[k], 0));
    ll res = INF;
    REP(j, n + 1) chmin(res, dp[n - k][j]);
    print(res);
}

Measured memory_bytes: 4360
#include <algorithm>
#include <iostream>
#include <string>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

// 158 - c
int main(void) {
    int a, b, c;
    int x, y;

    cin >> a >> b >> c >> x >> y;

    // int z = min(x, y) / 2;
    int z = max(x, y);

    int mVal = 5000 * 100000 * 2;
    int aCnt, bCnt, cCnt;
    repe(_z, 0, z) {
        cCnt = 2 * _z;
        aCnt = x - _z;
      if(aCnt < 0) aCnt = 0;
        bCnt = y - _z;
      if(bCnt < 0) bCnt = 0;

        int tVal = a * aCnt + b * bCnt + c * cCnt;
        mVal = min(mVal, tVal);
    }

    cout << mVal << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int x,a,b,c,d,e;
  cin>>x>>a>>b;
  c=abs(x-a);
  d=abs(x-b);
  e=min(c,d);
  if(e==c){
  cout<<"A"<<endl;
  }
  else{
  cout<<"B"<<endl;
  }
  

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if (n < m) {
    ans = (n * 2 + m) / 4;
    cout << ans << endl;
    }
    else cout << m / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String tmp_s = sc.next() + "L";
        String[] s = tmp_s.split("");
        int[] c = new int[s.length];
        int mass = 0;
        int left = 0;
        for(int i=0;i<s.length-1;i++){
            mass++;
            if(s[i].equals("R") && s[i+1].equals("L")){
                int tmp = (mass%2==0) ? mass/2 : (mass+1)/2;
                c[i] += tmp;
                c[i+1] += (mass-tmp);
                left = i+1;
                mass = 0;
                if(i+1 == s.length-1)c[i+1]=1;
            }
            if(s[i].equals("L") && s[i+1].equals("R")){
                int tmp = (mass%2==0) ? mass/2 : (mass+1)/2;
                c[left] += tmp;
                c[left-1] += (mass-tmp);
                mass = 0;
            }
            if(i+1 == s.length-1){
                int tmp = (mass%2==0) ? mass/2 : (mass+1)/2;
                c[left] += tmp;
                c[left-1] += (mass-tmp);
            }
        }
        for(int i=0;i<s.length-1;i++){
            System.out.print(c[i] + " ");
        }
    }
}

Measured memory_bytes: 48880
#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9+7;
long long d[200009][2],n,m,S,T;
long long N[200009][2];
long long f[200009];
vector<long long> v[200009],l[200009];
void dij (long long V, long long h)
{
    for (long long i = 1; i <= n; i++)
    d[i][h]=1e18,f[i] = 0;
    d[V][h]=0;
    N[V][h]=1;
    priority_queue<pair<long long,long long > > q;
    q.push({0,V});
    while(q.size())
    {
        pair<long long,long long> F = q.top();
        q.pop();
        if(f[F.second]==1) continue;
        f[F.second]=1; long long u=F.second;
        for (long long i = 0; i < v[u].size(); i++)
        {
            long long L = d[u][h]+l[u][i];
            if(L < d[v[u][i]][h])
            {
                d[v[u][i]][h]=L;
                N[v[u][i]][h]=N[u][h];
                q.push({-L,v[u][i]});
            }
            else
            if(L == d[v[u][i]][h])
               {
                N[v[u][i]][h]=(N[v[u][i]][h]+ N[u][h]);
                if(N[v[u][i]][h] > mod) N[v[u][i]][h] -= mod;
               }
        }
    }
}
main()
{
    cin >> n >> m;
    cin >> S >> T;
    for (long long i = 0;  i < m ; i++)
    {
        long long a, b , c;
        cin >> a >> b >> c;
        v[a].push_back(b);
        v[b].push_back(a);
        l[a].push_back(c);
        l[b].push_back(c);
    }
    dij(S,0);
    dij(T,1);
    long long ans = 0;
    for (long long i = 1; i <= n; i++)
    {
        if(d[i][0]+d[i][1] == d[T][0] && d[i][0] == d[i][1])
            ans =(ans + N[i][0]*N[i][1]%mod*N[i][0]%mod*N[i][1]%mod)%mod;
    }
    //cout << ans << endl;
    for (long long i = 1; i <= n; i++)
    {
        for (long long j =0; j<v[i].size(); j++)
        {
            long long x = i, y=v[i][j],L = l[i][j];
            if(d[x][0]+L+d[y][1]!=d[T][0] ) continue;
            if(abs(d[x][0] - d[y][1]) < L)
            {
                ans =(ans + N[x][0]*N[y][1]%mod*N[x][0]%mod*N[y][1]%mod)%mod;
            }
        }
    }
    ans = ((- ans)% mod+mod)%mod;
    ans = (ans + N[T][0]*N[T][0])%mod;
    cout << ans << endl;
 
}

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


int main(){
  string O, E;
  cin >>O >> E;
  
  
  rep(i, E.size()){
     cout << O[i] << E[i];
  }
  
  if(O.size() > E.size()){
    cout << O[O.size()-1];
  }
  cout << endl;
}
 
    
 
  
  
 

      

Measured memory_bytes: 256