akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
     ios::sync_with_stdio(false);
  cin.tie(0);
    STR(S);
    int ans1 = 0;
    int ans2 = 0;

    for(int i = 0; i < S.size(); ++i){
        if(i%2 != S[i] - '0'){
            ans1++;
        } else {
            ans2++;
        }
    }
    cout << min(ans1,ans2) << endl;
    
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll n, m; cin >> n >> m;
  vector<ll> c(m); rep(i, m) cin >> c[i];
  const ll MAX_N = 50000;
  ll dp[MAX_N + 1] = {};
  for (int i = 0; i <= MAX_N; i++) dp[i] = INF;

  dp[0] = 0;
  rep(i, m) {
    for (int j = c[i]; j <= MAX_N; j++) {
      if (dp[j-c[i]] != INF) dp[j] = min(dp[j], dp[j-c[i]]+1);
    }
  }
  outl(dp[n]);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}



Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int a,b,c; cin >> a >> b >> c;
    cout << min(b/a,c) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main( )
{
  while(1){
    int m,f,r;
    scanf("%d %d %d",&m,&f,&r);
    if(m==-1&&f==-1&&r==-1){
      break;
    }
    else if(m==-1||f==-1){
      printf("F\n");
      continue;
    }
    else if(m+f>=80){
      printf("A\n");
      continue;
    }
    else if(m+f>=65){
      printf("B\n");
      continue;
    }
    else if(m+f>=50){
      printf("C\n");
      continue;
    }
    else if(m+f>=30&&r<50){
      printf("D\n");
      continue;
    }
    else if(m+f>=30&&r>=50){
      printf("C\n");
      continue;
    }
    else printf("F\n");
  }
  return 0;
}

Measured memory_bytes: 2644
<?php
function gcd($a, $b)
{
    if ($b == 0)
    {
        return $a;
    }
    return gcd($b, $a % $b);
}

fscanf(STDIN, "%d %d", $a, $b);
if ($a < $b)
{
    list($a, $b) = array($b, $a);
}
echo gcd($a, $b);
?>



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

int main(){
    int W, H, x, y, r;
    bool c1, c2, c3 ,c4;
    
    cin >> W >> H >> x >> y >> r;
    
    c1 = x - r >= 0;
    c2 = y - r >= 0;
    c3 = x + r <= W;
    c4 = y + r <= H;
    
    if (c1 && c2 && c3 && c4)
        cout << "Yes" << endl;
    else 
        cout << "No" << endl;
    
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <set>
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  int K;
  cin >> K;
  vector<string> x;
  for(int i = 0; i < s.size(); ++i){
    for(int j = 1; j <= K; ++j){
      string tmp = s.substr(i,j);
      x.push_back(tmp);
    }
  }
  sort(x.begin(), x.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  cout << x[K-1] << endl;
}


Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;
static const ll MAX_N = 100001;
static const ll MAX_M = 100001;

struct edge { int to, cost; };
typedef pair<ll, ll> P;
int V;
vector<edge> G[MAX_N];
ll d[MAX_N];
priority_queue<P, vector<P>, greater<P>> que;

void dijkstra(int s) {
	fill(d, d + V, INF);
	d[s] = 0;
	que.push(P(0, s));

	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		rep(i, 0, G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main() {
	ll E, r;
	cin >> V >> E >> r;

	rep(i, 0, E) {
		int s, t, d; cin >> s >> t >> d;
		edge *e = new edge();
		e->to = t;
		e->cost = d;

		G[s].push_back(*e);
	}

	dijkstra(r);

	rep(i, 0, V) {
		if (d[i] == INF)cout << "INF" << endl;
		else cout << d[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 29720
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main() {
    int x;
    cin >> x;
    if (x < 100){
        printf("0");
        return 0;
    }
    int n = x / 100;
    int xu = n * 100;
    int xo = n * 105;
    if (xu <= x && x <= xo) {
        printf("1");
    } else {
        printf("0");
    }


}

Measured memory_bytes: 256
#include <cstdio>
#include <string.h>
#include <algorithm>
#include<iostream>
#include<math.h>
using namespace std;

int change(string ss,int p,string tt){
	int n = ss.length();
	for(int i=0;i<n;i++){
		if(ss[(p+i)%n]!=tt[i])
			return 0;
	}
	return 1;
}

int main(){
	string s,t;
	cin>>s>>t;
	int n = s.length();
	int flag =0;
	for(int i=0;i<n;i++){
		if(change(s,i,t)){
			flag = 1;
			break;
		}
	}
	if(flag) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3+20;
int n,l[N],ans;
int main(void)
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%d",&l[i]);
    sort( l+1 , l+n+1 );
    for (int i=1;i<=n;i++)
        for (int j=i+1;j<=n;j++)
            ans += max( 1LL*(lower_bound( l+1 , l+n+1 , l[i]+l[j] ) - l - j - 1) ,1LL* 0 );
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
    } else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repl(i,n) for(int64_t i=0;i<(int64_t)(n);i++)
#define ll int64_t
#define all(v) (v).begin(),(v).end()
#define P pair<int,int>
using namespace std;

int main() {
    int n,ans=0; cin>>n;
    vector<int> d(n);
    rep(i,n) cin>>d[i];

    for(int i=0;i<n-1;i++) {
        for(int j=i+1;j<n;j++) {
            ans+=d[i]*d[j];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};





struct UnionFind{
    vector<int> par, rank;

    void init(int n){
        par.resize(n);
        rank.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
    }

    int find(int x){
        if(par[x]==x){
            return x;
        }
        else{
            return par[x]=find(par[x]);
        }
    }

    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){
            par[x]=y;
        }
        else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }
};


int main(){
    LL n,m,q;cin >> n >> m >> q;
    vector<int> a(q);
    for (int i = 0; i < q; i++) {
        cin >> a[i];
    }
    LL t = 7 * n / m;
    vector<vector<int>> v(m, vector<int> (7,0));
    vector<vector<int>> vv(2 * m, vector<int> (7,0));
    vector<vector<int>> va(m/7, vector<int> (7,0));
    vector<vector<int>> vb(2*m/7, vector<int> (7,0));
    for (int i = 0; i < q; i++) {
        int y = a[i] / 7, x = a[i] % 7;
        if(m % 7 == 0){
            va[y][x] = 1;
            vb[y][x] = 1;
            vb[m / 7 + y][x] = 1;
        }
        else{
            for (int j = 0; j < 7; j++) {
                y = (a[i] + m * j) / 7, x = (a[i] + m * j) % 7;
                v[y][x] = 1;
                vv[y][x] = 1;
                vv[y+m][x] = 1;
            }
        }
    }
    auto f = [](vector<vector<int>> &a){
        int h = a.size(), w = a[0].size();
        UnionFind uf;
        uf.init(h*w);
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if(j+1<w && a[i][j] == a[i][j+1]) uf.unite(i*7+j,i*7+j+1);
                if(i+1<h && a[i][j] == a[i+1][j]) uf.unite(i*7+j,(i+1)*7+j);
            }
        }
        int ret = 0;
        for (int i = 0; i < h*w; i++) {
            if(uf.find(i) == i && a[i/7][i%7] == 0) ret++;
        }
        return ret;
    };
    if(m%7==0){
        if(t == 1){
            cout << f(va) << endl;
        }
        else if(t == 2){
            cout << f(vb) << endl;
        }
        else{
            cout << f(va) + (t - 1) * (f(vb) - f(va)) << endl;
        }
    }
    else{
        t = n / m;
        if(t == 1){
            cout << f(v) << endl;
        }
        else if(t == 2){
            cout << f(vv) << endl;
        }
        else{
            cout << f(v) + (t - 1) * (f(vv) - f(v)) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 35360
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

#%%
husoku = [a-b for a, b in zip(A, B) if a-b < 0]
amari = [a-b for a, b in zip(A, B) if a-b > 0]
amari.sort(reverse=True)

H = abs(sum(husoku))
if len(husoku) == 0:
    ans = 0
elif H > sum(amari):
    ans = -1
else:
    for i, a in enumerate(amari, start=1):
        H -= a
        if H <= 0:
            ans = len(husoku) + i
            break

print(ans)

Measured memory_bytes: 24296
import Control.Monad
import Text.Printf
import Control.Applicative
import Data.List as L

main :: IO()
main = do
  [a, b, x] <- map read . words <$> getLine
  printf "%s" $ slv a b x

slv :: Int -> Int -> Int -> String
slv a b x | x - a >= 0 && x - a <= b = "YES"
          | otherwise = "NO"

Measured memory_bytes: 508
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
int Digitsum(int x)
{
	int sum = 0;
	while (x > 0) {
		sum += x % 10;
		x /= 10;
	}
	return sum;
}
int main()
{
	int N;
	scanf("%d", &N);
	if (N % Digitsum(N) == 0) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
    {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
    {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
    {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
    #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
    #define dump(...)
    #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
    int n; cin >> n;
    int bef = 0;
    bool ok = true;
    REP (i, n) {
        int x; cin >> x;
        if (i == 0) {
            bef = x - 1;
        } else {
            if (bef > x) {
                ok = false;
            } else {
                bef = max(bef, x - 1);
            }
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}


ll pl[4];
ll b[4] = {8, 4, 2, 1};
int main() {
	ll Q, H, S, D;
	ll N;

	cin >> pl[0] >> pl[1] >> pl[2] >> pl[3];

	cin >> N;

	ll min_one, min_two;

	min_two = pl[0] * b[0];
	for (int i = 0; i < 4; i++) {

		min_two = min(min_two, pl[i] * b[i]);

	}
	min_one = pl[0] * b[0] / 2;
	for (int i = 0; i < 3; i++) {

		min_one = min(min_one, pl[i] * b[i] / 2);
	}
	
	cout << min_two * (N / 2) + min_one * (N % 2) << endl;
	
	


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int c(int d,vector<int> v){
    int e = 0;
    int n = v.size();
    for (int y=0;y<n;y++){
        e =(v[y]-d)*(v[y]-d) + e;
    }
    return e;
}
int main() {
    int a=0;
    int n; cin>>n;
    vector<int> v(n);
    for (int i=0;i<n;i++){
        cin>>v[i];
    }
    for (int u=0;u<n;u++){
        a = v[u]+a;
    }
    int b = a/n;
    cout << min(c(b,v),c(b+1,v));
}

Measured memory_bytes: 3600
#include<cstdio>
#include<algorithm>

#define	rep(i,n)	for(int i=0;i<n;i++)

using namespace std;

int main(){
	for(int w,d;scanf("%d%d",&w,&d),w;){
		int h_w[21]={},h_d[21]={};
		rep(i,w){ int h; scanf("%d",&h); h_w[h]++; }
		rep(i,d){ int h; scanf("%d",&h); h_d[h]++; }

		int ans=0;
		rep(h,21)	ans+=max(h_w[h],h_d[h])*h;
		printf("%d\n",ans);
	}

	return 0;
}

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

using namespace std;

int main(){
	int a,b;
while (cin>>a>>b){
	int n=a+b;
	 if(n>999999){
		cout<<7<<endl;
	}
	else if (n>99999){	
	cout<<6<<endl;
}
	else if(n>9999){
		cout<<5<<endl;
	}
		else if(n>999){
		cout<<4<<endl;
	}
		else if(n>99){
		cout<<3<<endl;
		}
		else if(n>9){
		cout<<2<<endl;
	}
	else{ 
	cout<<1<<endl;
	}
	}
}



Measured memory_bytes: 3088
N = int(input())
A = list(map(int, input().split()))

w = sum(A)//2
for i in range(0,N-2,2):
  w -= A[i]
W = [0]*N
W[N-1]=w
W[0] = A[N-1]-W[N-1]
for i in range(1,N-1):
  W[i] = A[i-1]-W[i-1]
W = [2*w for w in W]
print(*W)

Measured memory_bytes: 14916
n,m=map(int,input().split())
ac=[0]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)
    if ac[p-1] == 1:#このテストをクリアしていたら飛ばす。
        continue
    
    if s=='AC':#テストをクリアしたらフラグをつける
        ac[p-1] = 1
    else:#テストをクリアするまでは失敗を繰り返す。
        wa[p-1] += 1
        
# 最終的に出力するものを決める
AC=0
WA=0
for i in range(n):
    AC += ac[i]#クリアした回数
    if ac[i] == 1:
      WA += wa[i]#クリアできなかった回数
print("{} {}".format(AC,WA))

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

int N,C,X;
int D[30][39];
int t[3][30];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin>>S;
    int ans=INF;
    int sum=0;
    for(int i=0;i<S.size();i++){
        if(i%2==0){
            if(S[i]!='1') sum++;
        }
        else{
            if(S[i]!='0') sum++;
        }
    }
    ans=min(ans,sum);
    //cout<<ans<<endl;
    sum=0;
    for(int i=0;i<S.size();i++){
        if(i%2==0){
            if(S[i]!='0') sum++;
        }
        else{
            if(S[i]!='1') sum++;
        }
        //cout<<sum<<endl;
    }
    ans=min(ans,sum);
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int ST_MAX = (1 << 18);

template <class T , class U> class ST{
	T x[ST_MAX * 2];
	U lazy[ST_MAX * 2];
	
	T eval(T a , T b){
		return max(a,b);
	}
	
	U syn(U a , U b){
		return a+b;
	}
	
	void work(int a){
		if(a < ST_MAX){
			lazy[a * 2] = syn(lazy[a] , lazy[a * 2]);
			lazy[a * 2 + 1] = syn(lazy[a] , lazy[a * 2 + 1]);
		}
		x[a] += lazy[a];
		lazy[a] = 0;
	}
	
	void ren(int a , int b , int e , int s , int f , U z){
		if(e <= s || f <= b){
			work(a);
			return;
		}
		if(s <= b && e <= f){
			lazy[a] = syn(lazy[a] , z);
			work(a);
			return;
		}
		work(a);
		ren(2 * a , b , (b + e) / 2 , s , f , z);
		ren(2 * a + 1 , (b + e) / 2 , e , s , f , z);
		x[a] = eval(x[a * 2] , x[a * 2 + 1]);
	}
	
	T read_ST(int a , int b , int e , int s , int f){
		work(a);
		if(e <= s || f <= b) return -1;
		if(s <= b && e <= f) return x[a];
		return eval(read_ST(2 * a , b , (b + e) / 2 , s , f) , read_ST(2 * a + 1 , (b + e) / 2 , e , s , f));
	}
	
public:
	
	ST(){
		fill(lazy,lazy+ST_MAX*2,0);
		repp(i,0,ST_MAX) x[ST_MAX+i] = i;
		repm(i,ST_MAX-1,0) x[i] = max(x[i*2],x[i*2+1]);
	}
	
	void put(int t){
		ren(1 , 0 , ST_MAX , 0 , t , 1);
	}
	
	T get(int s , int f){
		return read_ST(1 , 0 , ST_MAX , s , f);
	}
};

ST<int,int> solve;

int main(){
	int N,M; cin >> N >> M;
	vector<pair<int,int>> V(N);
	repp(i,0,N) cin >> V[i].first >> V[i].second;
	sort(V.begin(),V.end());
	int ans = max(0,N-M);
	int p = 0;
	repp(i,0,M){
		while(p < N && V[p].first == i){
			solve.put(V[p].second);
			++p;
		}
		ans = max(ans,solve.get(i+1,M+1)-M-i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6016
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Main{

    static StringBuilder sb;

    public static void main(String[] args) {
	try {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();

	    for (String line = br.readLine(); line != null; line = br.readLine()) {
		lines.add(line);
	    }

	    //lines.add("3");
	    //lines.add("1 1 3 8");
	    //lines.add("3 2 2 7");
	    //lines.add("4 3 8 1");

	    br.close();

	    Integer[][][] doom = new Integer[4][3][10];

	    for (int i = 0; i < doom.length; i++) {
		for (int j = 0; j < doom[i].length; j++) {
		    for (int k = 0; k < doom[i][j].length; k++) {
			doom[i][j][k] = 0;
		    }
		}
	    }

	    for (int i = 1; i < lines.size(); i++) {
		String[] sep = lines.get(i).split(" ");
		Integer no = Integer.parseInt(sep[0]) - 1;
		Integer floor = Integer.parseInt(sep[1]) - 1;
		Integer room = Integer.parseInt(sep[2]) - 1;

		doom[no][floor][room] += Integer.parseInt(sep[3]);
	    }

	    for (int i = 0; i < doom.length; i++) {
		for (int j = 0; j < doom[i].length; j++) {
		    String t = Arrays.toString(doom[i][j]);
		    t = t.replaceAll(",", "");
		    t = t.substring(1, t.length() - 1);
		    t = " " + t;

		    //if (i==doom.length-1 && j==doom[i].length-1) {
		    // 	System.out.print(t);
		    //} else {
			System.out.println(t);
			//}
		}
		if (i!=doom.length-1) {
		    System.out.println("####################");
		}
	    }

	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    }
}

Measured memory_bytes: 24932
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;
const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
 
vector<ll> dp;
int main()
{
	string s;
	cin >> s;
	int n = s.length();
	dp.resize(13, 0);
	dp[0] = 1;
	for(char c: s) {
	     vector<ll> dp_next(13, 0);
			for(int i=0; i<10; ++i) {
			for(int j=0; j<13; ++j) {
		  	   if(c == '?' || c == ('0' +i))	
		   	  	dp_next[(10*j + i)%13] = 
		   	  	(dp_next[(10*j + i)%13] %MOD+
		   	  	dp[j]%MOD)%MOD;			
			}
		}
		dp = dp_next;
	}
	cout << dp[5] << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007ll
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define db(x) cout << #x << " = " << x << '\n'
#define sep cout << "********************************************\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL)
ll n;
ll a[25][25];
ll dp[2][1 << 21];
ll bc(ll num)
{
	ll ans = 0;
	while (num)
	{
		ans += (num & 1);
		num >>= 1;
	}
	return ans;
}
int main(int argc, char const *argv[])
{
	fast;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			cin >> a[i][j];
		}
	}
	dp[1][0] = 1;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < (1ll << n); ++j)
		{
			if (bc(j) != (i + 1))
				continue;
			for (int k = 0; k < n; ++k)
			{
				if ((j & (1ll << k)) && a[i][k])
					dp[i & 1][j] = (dp[i & 1][j] + dp[!(i & 1)][j ^ (1ll << k)]) % mod;
			}
		}
	}
	cout << dp[(n - 1) & 1][(1ll << n) - 1];
	return 0;
}

Measured memory_bytes: 33024
#include <iostream>
#include <string.h>
using namespace std;
int main(void){
   char str[15];
   cin>>str;
   long N;
   long ans=0;
   N=strlen(str);
   for(int i=0;i<(1<<(N-1));i++){
       long add=str[0]-'0';
       long sum=0;
       for(int j=0;j<N-1;j++){
           if(i&(1<<j)){
               sum+=add;
               add=0;
           }
           add=add*10+str[j+1]-'0';
       }
       sum+=add;
       ans+=sum;
   }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))
C = Counter(A)
s = []
dp = [True] * (10 ** 6 + 1)

for a, b in C.items():
    if b == 1:
        s.append(a) 

a = set(A)
for ss in a:
    for m in range(2 * ss, 10 ** 6 + 1, ss):
        dp[m] = False

res = 0
for ss in s:
    if dp[ss] is True:
        res += 1

print(res)


Measured memory_bytes: 169212
N = int(input())
C = [[0 for i in range(10)] for i in range(10)]

for i in range(N):
    si = str(i+1)
    f,l = int(si[0]),int(si[len(si)-1])
    C[f][l] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += C[i][j] * C[j][i]
    
print(ans)




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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while(0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll s=0;
  rep(i,3){
    ll a;
    cin >> a;
    s+=a;
  }
  if (s >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  return 0;
}


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

 int main() {
   int A,B;
   cin >> A >> B;
   
   int a = 0;
   int b = 1;
   while(b < B){
     b += (A-1);
     a++;
   }
  
     cout << a << endl;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N ((ll)101*1000)
#define MOD ((ll)1e9+7)

ll n,a[N],dp[N];
vector <ll> e[N];
vector <ll> topol;
bool mark[N];

void dfs(ll x)
{
	mark[x]=1;
	for(auto u:e[x])
		if(!mark[u])
			dfs(u);
	topol.push_back(x);
}


int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	for(int i=2;i<=n;i++)cin>>a[i],e[a[i]].push_back(i);
	for(int i=1;i<=n;i++)
		if(!mark[i])
			dfs(i);
	for(auto u:topol)
	{
		vector <ll> ex;
		for(auto v:e[u])
			ex.push_back(dp[v]);
		sort(ex.begin(),ex.end());
		for(int i=0;i<ex.size();i++)dp[u]=max(dp[u],ex[i]+(ll)ex.size()-i);
	}
	cout<<dp[1]<<"\n";
	return 0;
}

Measured memory_bytes: 13040
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = 0;
  if(a + b > 2 * c){
    if(x > y){
      ans += y * 2 * c;

      if(a>2*c){
        ans += (x - y) * 2 * c;
      }else{
        ans += (x - y) * a;
      }
    }else{
      ans += x * 2 * c;
      
      if(b>2*c){
        ans += (y - x) * 2 * c;
      }else{
        ans += (y - x) * b;
      }
    }
  }else{
     if(a>2*c){
       ans += x * 2 * c;
     }else{
       ans += x * a;
     }
     if(b>2*c){
       ans += y * 2 * c;
     }else{
       ans += y * b;
     }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
<?php 
  list($a, $b) = explode(" ", trim(fgets(STDIN)));
  $i = 0;
  for($i = 0; $i < 10 ** 7; $i++){
    if(floor($i * 0.08) == $a && floor($i * 0.1) == $b){
      echo $i;
      break;
    }
    if($i == 10 ** 6){
      echo -1;
      break;
    }
  }
 ?>

Measured memory_bytes: 4732
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a = S()
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
if a in ascii_lowercase:
    print('a')
else:
    print('A')

Measured memory_bytes: 68304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N,L; cin>>N>>L;
    vector<string> S(N);
    rep(n,0,N) cin>>S.at(n);

    sort(ToEnd(S));
    string ans="";
    for(auto s:S) ans+=s;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict

n, k = map(int, input().split())
sushi = [list(map(int, input().split())) for _ in range(n)]

sushi.sort(key=lambda x: -x[1])
# print(sushi)

kinds = defaultdict(list)
remove_candidates = []
umami = 0

ans_candidates = {}
for i in range(n):
    t, d = sushi[i]
    # print("t, d = ", t, d)
    if i < k:
        if t in kinds:
            remove_candidates.append(d)
        kinds[t].append(i)
        umami += d
    elif t not in kinds and len(remove_candidates) > 0:
        kinds[t].append(i)
        x += 1
        d2 = remove_candidates.pop()
        umami = umami - d2 + d
        ans_candidates[x] = umami + x * x
        # print("remove", remove_candidates)
        # print(x, umami, ans_candidates[x])

    if i == k - 1:
        x = len(kinds.keys())
        ans_candidates[x] = umami + x * x
        remove_candidates.sort(key=lambda x: -x)
        # print(umami)
        # print(kinds, x)
        # print(remove_candidates)
        # print(x, umami, ans_candidates[x])

# print()
# print(ans_candidates)
print(max(ans_candidates.values()))


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

int main(){

    double n,k;
    cin >> n >> k;


    double ans=0.;
    int cnt=0;
    rep(i,n){
        double s=i+1.;
        cnt=0;
        double tt=1./n;
        while(s<k){
            s*=2;
            cnt++;
        }
        while(cnt>0){
            cnt--;
            tt*=0.5;
        }
        ans+=tt;
    }
    cout << setprecision(14);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
using namespace std;
ll dp[114][10];
int main(){
	int h,w,c;
	cin>>h>>w>>c;
	if(w==1){
		cout<<1<<endl;
		return 0;
	}
	dp[0][1]=1;
	for(int i=1;i<=h;i++){
		for(int j=0;j<(1<<(w-1));j++){
			int isb[8];
			int cur = j;
			for(int k=0;k<(w-1);k++){
				isb[k] = cur%2;
				cur = cur/2;
			}
			bool fl = true;
			for(int k=0;k<w-2;k++){
				if( isb[k] == 1 && isb[k+1]==1){
					fl = false;
				}
			}
			if(fl){
				for(int k=1;k<=w;k++){
					if(k<w && isb[k-1]==1){
						dp[i][k+1]+=dp[i-1][k];
						dp[i][k+1] %= inf;
					}
					if(k>1 && isb[k-2]==1){
						dp[i][k-1]+=dp[i-1][k];
						dp[i][k-1] %= inf;
					}
					if( ( (k==1) && (isb[0]==0) ) || ( (k==w) && (isb[k-2]==0) ) || ( (isb[k-1]==0) && (isb[k-2] == 0) )){
						dp[i][k]+=dp[i-1][k];
						dp[i][k]%=inf;
					}
				}
			}
		}
	}
	cout<< dp[h][c] <<endl;
	return 0;
}

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

ll gcd(ll m, ll n) {
  if(m < n) swap(m, n);
  if(n == 0) return abs(m);
  else return gcd(n, m % n);
}

ll lcm(ll m, ll n) {
  return abs(m*n) / gcd(m, n);
}

int f(int x) {
  int res = 0;
  while(x%2==0) {
    x/=2;
    res++;
  }
  return res;
}

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

  for(int i = 0; i < n; i++) {
    a[i] /= 2;
  }

  int t = f(a[0]);
  for(int i = 0; i < n; i++) {
    if(f(a[i]) != t) {
      cout << 0 << endl;
      return 0;
    }
    a[i] >>= t;
  }
  m >>= t;

  ll l = 1;
  for(int i = 0; i < n; i++) {
    l = lcm(l, a[i]);
    if(l > m) {
      cout << 0 << endl;
      return 0;
    }
    a[i] >>= t; // a[i] /= 2^t
  }

  m /= l;
  int ans = (m+1)/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{

    public static void main(String[] args){
        int MOD_NUM = (int)Math.pow(10,9)+7;
        Scanner sc = new Scanner(System.in);

        int[] abc = new int[26];
        for(int i = 0; i < 26; i++)abc[i] = 0;
        int N = sc.nextInt();
        String str = sc.next();

        for(int i = 0; i < N; i++){
            abc[(char)str.charAt(i) - 'a']++;
        }

        long ans = 1;
        for(int i = 0; i < 26; i++){
            ans = (ans  * (abc[i]+1))% MOD_NUM;
        }

        System.out.println((ans - 1));

    }
}

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

int main(){
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double x = abs((h*30+m/2)-6*m);
    double y = x * acos(-1) / 180;
    cout << fixed << setprecision(15) << sqrt(a*a+b*b-2*a*b*cos(y)) << endl;
    
    return 0;
}


Measured memory_bytes: 4228
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi a;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>n;
	a.resize(n);
	map<ll,ll> ma;
	rep(i,n){
		cin>>a[i];
		ma[a[i]]++;
	}
	ll idt = 1;
	Vi tws;
	Sort(a);
	ll mx = a[0] + a[1];
	while(idt<=mx){
		idt *= 2;
		tws.pb(idt);
	}
	ll ans = 0;
	rep(i,n){
		if(ma[a[i]]<=0)continue;
		ll id = upper_bound(all(tws),a[i]) - tws.begin();
		for(ll j=tws.size();j>=id;j--){
			ll now = tws[j] - a[i];
			if(ma[now]<=0)continue;
			if(a[i]==now){
				if(ma[a[i]]>=2){
					ans++;
					ma[a[i]] -= 2;
					break;
				}
			}else{
				ans++;
				ma[a[i]]--;
				ma[now]--;
				break;
			}
		}
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 67200
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map
//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
//--main function
int main(){
	int n;
	cin>>n;
	int l=n/2;
	int r=n/2;
	vi a(n);
	vi b(n,0);
	REP(i,0,n-1)cin>>a[i];
	b[n/2]=a[0];
	if(n%2==0){
		REP(i,1,n-1){
		if(i%2==0){
			r+=1;
			b[r]=a[i];	
		}
		else{
			l-=1;
			b[l]=a[i];
		}
	}
	}
	else{
		REP(i,1,n-1){
		if(i%2==0){
			l-=1;
			b[l]=a[i];	
		}
		else{
			r+=1;
			b[r]=a[i];
		}
	}
	}
	REP(i,0,n-1)cout<<b[i]<<" ";
	
	return 0;

//   TimeTaken();
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N),B(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(int i=0;i<N;i++){
    B.at(i) = A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  for(int i=0;i<N;i++){
    if(A.at(0) == B.at(i))
      cout << A.at(1) << endl;
    else
      cout << A.at(0) << endl;
  }
}

Measured memory_bytes: 3200
import java.util.*;

class Main{

    int n, m, sz;
    char[] kakko;
    int[] a, bkt, add;

    void solve(){
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        m = sc.nextInt();
        kakko = sc.next().toCharArray();

        sz = Math.max(1, (int)Math.sqrt(n) - 1);
        a = new int[n];
        bkt = new int[n/sz+10];
        add = new int[n/sz+10];
        TreeSet<Integer> set = new TreeSet<Integer>();

        for(int i=0; i<n; i++){
            if(i==0) a[i] = 1;
            else{
                if(kakko[i]=='(') a[i] = a[i-1] + 1;
                else{
                    a[i] = a[i-1] - 1;
                    set.add(new Integer(i));
                }
            }
            bkt[i/sz] = Math.min(a[i], bkt[i/sz]);
        }

        for(int i=0; i<m; i++){
            int q = sc.nextInt()-1;
            int idx = 0;
            if(kakko[q]=='('){
                kakko[q] = ')';
                set.add(new Integer(q));
                add(q, n, -2);
                idx = set.higher(new Integer(-1));
                kakko[idx] = '(';
                set.remove(new Integer(idx));
                add(idx, n, 2);
            }else{
                kakko[q] = '(';
                set.remove(new Integer(q));
                add(q, n, 2);
                idx = search(q);
                kakko[idx] = ')';
                add(idx, n, -2);
                set.add(new Integer(idx));
            }
            //System.out.println(Arrays.toString(kakko));
            System.out.println(idx+1);
        }
    }

    void add(int start, int last, int num){
        int from = start - start%sz;
        int to = from + sz;
        for(int i=start/sz; i<=last/sz; i++){
            if(start<=from && to<=last){
                add[i] += num;
            }else{
                for(int j=from; j<to; j++){
                    if(start<=j && j<last){
                        a[j] += num;
                        if(a[j] < bkt[i]) bkt[i] = a[j];
                    }
                }
            }
            from = to;
            to += sz;
        }
    }

    int search(int f){        
        int from = f - f%sz;
        int to = from + sz;
            
        for(int i=f/sz; i>=0; i--){
            if(bkt[i]+add[i]<=1){
                for(int j=Math.min(f-1, to-1); j>=from; j--){
                    if(a[j]+add[i]==1) return j+1;
                }
            }
            to = from;
            from -= sz;
        }
        return 0;
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

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

int main(){
  int n;cin>>n;
  vector<int> arr(n);
  for(int i=0;i<n;++i)cin>>arr[i];
  sort(arr.begin(),arr.end());
  //for(auto i:arr)cout<<i<<" ";cout<<endl;
  int res=0;
  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;++j){
      // smallest = a
      // largest = b;
      // a+c > b
      // c > b-a
      int id = upper_bound(arr.begin(),arr.end(),arr[j]-arr[i]) - arr.begin();
      if( id >= j)continue;
      res += min(j-id,j-i-1);
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define P pair<ll,ll>
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S>
void print(vector<S> &v){
	for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main(){
	int n,m;cin >> n >> m;
	vector<bool> b(n);
	rep(i,m){
		int t;
		cin >> t;
		b[t] = true;
	}
	vector<mint> dp(n+1, mint(0));
	dp[0] = mint(1);
	for(int i=1; i<=n; i++){
		if(!b[i]){
			dp[i] = dp[i-1];
			if(i > 1){
				dp[i] += dp[i-2];
			}
		}
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
s = input()
S = ""
for i in range(len(s)):
  if s[i] == "0":
    S = S[:] + "0"
  elif s[i] == "1":
    S = S[:] + "1"
  elif s[i] == "B" and S != "":
    S = S[:len(S)-1]
print(S)

Measured memory_bytes: 3060
import math
n, d = map(int,input().split())
lst = []
for i in range(n):
    x,y = map(int,input().split())
    lst.append([x,y])

cnt = 0
for i in range(n):
    x,y = lst[i]
    if math.sqrt(x**2 + y**2) <= d:
        cnt += 1
print(cnt)

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

int main(){
    ll a,b,ans=0,cnt;
    cin >> a >> b;
    if(a==b) {cout << a << endl;return 0;}
    if(a%2) ans = a,a ++;
    if(!(b%2)) ans ^= b,b --;
    ans ^=  ((b-a+1)/2)%2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256