akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
ll mod=1e9+7;
int main()
{
IOS
ll n;
cin>>n;
if(n%1000==0)
    cout<<0;
else
    cout<<1000-(n%1000);
return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(void){
    int a,b,q; cin>>a>>b>>q;
    vector <long long> shrines(a+2);
    vector <long long> temples(b+2);
    shrines[0]=-INF; shrines[a+1]=INF;
    temples[0]=-INF; temples[b+1]=INF;
    for(int i=1;i<=a;i++){
        cin>>shrines[i];
    }
    for(int j=1;j<=b;j++){
        cin>>temples[j];
    }
    sort(shrines.begin(),shrines.end());
    sort(temples.begin(),temples.end());
    for(int i=0;i<q;i++){
        long long p;
        long long ans=INF;
        cin>>p;
        auto ls = (lower_bound(shrines.begin(),shrines.end(),p));
        auto lt = (lower_bound(temples.begin(),temples.end(),p));
        long long ws = abs(*(ls-1)-p), es= abs(*ls-p);
        long long wt = abs(*(lt-1)-p), et= abs(*lt-p);
        
        //右に行く
        if(es>=et) chmin(ans,es); 
        else chmin(ans,et);
        //左に行く
        if(ws>wt) chmin(ans,ws); 
        else chmin(ans,wt);
        //残り( ´∀｀)
        chmin(ans, ws*2 + et); 
        chmin(ans, es*2 + wt);
        chmin(ans, et*2 + ws);
        chmin(ans, wt*2 + es);
        cout<<ans<<endl;
    }
    
}

Measured memory_bytes: 2944
#include <iostream>

using namespace std;

int main()
{
    string s,t;
    int n,y;
    cin>>n>>s;
    y=0;

    t="ABC";
    for(int i=0;i<=n;i++){
            if(s[i]==t[0]&&s[i+1]==t[1]&&s[i+2]==t[2]){
                y++;}
        }



cout<<y<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};

const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

vector< vector<int> > Graph;
vector< int > value;





int main(int argc, const char * argv[]) {
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    cout << s.front() << s.size() - 2 << s.back() << endl;
    
    
    
    
    
    
    
    
    
    
}



Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]

dp=[0]*(n)
dp[1]=abs(h[0] - h[1])
if n >= 3:
    dp[2]=abs(h[0] - h[2])

#print(dp)

for i in range(3,n):
    cost1 = abs(h[i] - h[i - 1]) +dp[i-1]
    cost2 = abs(h[i] - h[i - 2]) +dp[i-2]

    if cost1 < cost2:
        dp[i] = cost1
    else:
        dp[i] = cost2

print(dp[n-1])

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


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

using P = pair<int, int>;
using iP = pair<int, P>;
using Pi = pair<P, int>;
int n, m;
void solve() {
    cin >> n >> m;
    map<P, vector<Pi>> g;
    rep(i, m) {
        int  p, q, c;
        cin >> p >> q >> c;
        g[{p, c}].emplace_back(make_pair(q, c), 0);
        g[{q, c}].emplace_back(make_pair(p, c), 0);
        g[{p, 0}].emplace_back(make_pair(p, c), 1);
        g[{p, c}].emplace_back(make_pair(p, 0), 0);
        g[{q, 0}].emplace_back(make_pair(q, c), 1);
        g[{q, c}].emplace_back(make_pair(q, 0), 0);
    }
    priority_queue<iP, vector<iP>, greater<iP>> que;
    map<P, bool> vis;
    que.emplace(0, make_pair(1, 0));
    while (!que.empty()) {
        iP val = que.top(); que.pop();
        int cst = val.first;
        P p = val.second;
        if (p == make_pair(n, 0)) { cout << cst << endn; return; }
        if (vis[p]) continue;
        vis[p] = 1;
        rep(i, g[p].size()) {
            if (vis[g[p][i].first]) continue;
            que.emplace(cst + g[p][i].second, g[p][i].first);
        }
    }
    cout << -1 << endn;

}

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

    solve();

    cout << flush;

    return 0;
}


Measured memory_bytes: 89268
/***
*  author  :_shamim
*  created : 08.05.2020
*
***/

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <list>
#include <set>
#include <queue>
#include <iterator>
#include <bitset>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll             long long
#define _              ios_base::sync_with_stdio(0);cin.tie(0);
#define loop           for(i=0;i<n;i++)
#define pb             push_back
#define tc()           int t;cin>>t;while(t--)

using namespace std;

ll i,j,temp;

int main()
{_

    char order[11];
    cin>>order;
    vector<char > sentence;
    vector<char>::iterator it;
    for(i=0;order[i]!='\0';i++){
        if(order[i]=='B'){
            if(!sentence.empty()){
                sentence.pop_back();
            }
        }
        else{
            sentence.pb(order[i]);
        }
    }



    //sentence.pop_back();
    for(it = sentence.begin();it!=sentence.end();it++){
        cout<<*it;
    }
    cout<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

using namespace std;

int main() {
  int a, b, n;
  cin >> n >> a >> b;
  cout << min(b, a * n) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mex = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n; cin >> n;
    ll arr[3], dp[2][3] = {0LL};
    for(ll i = 0; i < 3; i++) {
        cin >> arr[i];
        dp[0][i] = arr[i];
    }
    for(ll i = 1; i < n; i++) {
        for(ll j = 0; j < 3; j++) cin >> arr[j];
        dp[1][0] = max(dp[0][1], dp[0][2]) + arr[0];
        dp[1][1] = max(dp[0][0], dp[0][2]) + arr[1];
        dp[1][2] = max(dp[0][0], dp[0][1]) + arr[2];   
        for(ll j = 0; j < 3; j++) dp[0][j] = dp[1][j];
    }
    cout << *max_element(dp[0], dp[0] + 3) << '\n';
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
int n,in[M];
LL ans[M];
int main()
{
	RI(n);
	REP(i,1,n) RI(in[i]);

	vector<pair<int,int>> ord; //(num, pos)
	map<int,int> cnt;
	REP(i,1,n)
	{
		if(!cnt[in[i]])
			ord.PB(MP(in[i],i));
		cnt[in[i]]++;
	}
	sort(ord.begin(), ord.end(), greater<pair<int,int>>());

	int pos=n+1;
	int num=0;
	int go;
	REP(i,0,(int)ord.size()-1)
	{
		pos = min(pos, ord[i].S);
		num += cnt[ord[i].F];
		
		if(i==(int)ord.size()-1)
			go = ord[i].F;
		else
			go = ord[i].F - ord[i+1].F;

		ans[pos] += (LL)num*go;
	}
	REP(i,1,n) printf("%lld\n", ans[i]);
	return 0;
}



Measured memory_bytes: 7668
def pj(n, k):
  p=n
  ans=1.0
  while(True):
    if (k <= p):
      break
    ans /= 2
    p*= 2
  return ans

n,k=map(int,input().split())
ans=0.0
for i in range(1,n+1):
  ans += (float(1.0)/float(n))*pj(i, k)
print("%.12f"%ans)

Measured memory_bytes: 39280
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 

using namespace std;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, 0, h - 1)
	{
		cin >> s[i];
	}
	int res = 0;
	rep(i, 0, h - 1)
	{
		rep(j, 0, w - 1)
		{
			if (s[i][j] == '.')++res;
		}
	}
	vector<vector<int>> memo(h, vector<int>(w, -1));
	memo[0][0] = 0;
	int d[] = { 1,0,-1,0 };
	queue<pair<int, int>> q;
	q.push({ 0,0 });
	while (!q.empty())
	{
		int y = q.front().first;
		int x = q.front().second;
		q.pop();
		rep(i, 0, 3)
		{
			int ny = y + d[i];
			int nx = x + d[i ^ 1];
			if (0 <= ny && ny < h && 0 <= nx && nx < w && s[ny][nx] == '.' && memo[ny][nx] == -1)
			{
				q.push({ ny,nx });
				memo[ny][nx] = memo[y][x] + 1;
			}
		}
	}
	if (memo[h - 1][w - 1] == -1)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << res - memo[h - 1][w - 1] -1 << endl;
	}
}

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


void solve(long long N, long long M){
  if(N==1&&M==1)cout<<1<<endl;
  else if(N==1)cout<<M-2<<endl;
  else if(M==1)cout<<N-2<<endl;
  else cout<<(N*M-((N+M)*2-4))<<endl;

}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  solve(N, M);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=0,m=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0')n++;
        else m++;
    }
    cout<<2*min(n,m)<<endl;
    return 0;
}


Measured memory_bytes: 512
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - Lamp
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_H = 2000;
const int MAX_W = 2000;

/* typedef */

/* global variables */

char flds[MAX_H][MAX_W + 4];
int cs[MAX_H][MAX_W];

/* subroutines */

/* main */

int main() {
  int h, w;
  scanf("%d%d", &h, &w);

  for (int y = 0; y < h; y++) scanf("%s", flds[y]);

  for (int y = 0; y < h; y++)
    for (int x = 0; x < w;) {
      while (x < w && flds[y][x] == '#') x++;
      if (x >= w) break;
      int x1 = x + 1;
      while (x1 < w && flds[y][x1] == '.') x1++;
      int l = x1 - x;
      while (x < x1) cs[y][x++] += l;
    }

  for (int x = 0; x < w; x++)
    for (int y = 0; y <h;) {
      while (y < h && flds[y][x] == '#') y++;
      if (y >= h) break;
      int y1 = y + 1;
      while (y1 < h && flds[y1][x] == '.') y1++;
      int l = y1 - y;
      while (y < y1) cs[y++][x] += l;
    }

  int maxc = 0;
  for (int y = 0; y <h; y++)
    for (int x = 0; x < w; x++)
      if (maxc < cs[y][x]) maxc = cs[y][x];

  printf("%d\n", maxc - 1);
  return 0;
}


Measured memory_bytes: 19840
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

int main () {
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef long double ld;
typedef vector<int> vt;
typedef vector<vt> vtt;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};


int main(void){
	lld a,b,c,d;
	cin >> a >> b >> c >> d;
	lld ans = -1e18;
	ans = max(ans,a*c);
	ans = max(ans,a*d);
	ans = max(ans,b*c);
	ans = max(ans,b*d);
	printf("%lld\n",ans);
	return 0;
}


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

int main() {
    int n,m,a,b;
    cin>>n>>m>>a>>b;
    int mat[n][m];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if((i<b)^(j<a))
            {
                mat[i][j]=1;
            }
            else
            {
                mat[i][j]=0;
            }
        }
    }
        for(int i=0;i<n;i++)
        {
        for(int j=0;j<m;j++)
        {
            cout<<mat[i][j];
        }
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 5120
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,m; cin>>n>>m;
    string ans="No";
    vector<string> a(n),b(m);
    rep(i,n) cin>>a[i];
    rep(i,m) cin>>b[i];
    rep(i,n-m+1)rep(j,n-m+1){
        int cnt=0;
        rep(k,m)rep(l,m){
            if(a[i+k][j+l]==b[k][l]) cnt++;
        }
        if(cnt==m*m) ans="Yes";
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using ld = long double;
int n;
ld dp[305][305][305];

ld memo_rec(int One, int Two, int Three){
    if(dp[One][Two][Three] != -1)   return dp[One][Two][Three];
    if(One + Two + Three == 0)  return dp[One][Two][Three] = 0.0;
    
    ld res = n;
    if(One > 0) res += memo_rec(One - 1, Two, Three) * One;
    if(Two > 0) res += memo_rec(One + 1, Two - 1, Three) * Two;
    if(Three > 0)   res += memo_rec(One, Two + 1, Three - 1) * Three;
    res *= 1.0 / (One + Two + Three);

    return dp[One][Two][Three] = res;
}

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

    cin >> n;
    vector<int> cnt(4, 0);
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        ++cnt[a];
    }
    
    for(int i = 0; i <= 300; ++i){
        for(int j = 0; j <= 300; ++j){
            for(int k = 0; k <= 300; ++k){
                dp[i][j][k] = -1;
            }
        }
    }

    cout << fixed << setprecision(15);
    cout << memo_rec(cnt[1], cnt[2], cnt[3]) << endl;
}

Measured memory_bytes: 438528
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define INF LLONG_MAX/3
#define Bpri T priority_queue
#define Spri T priority_queue<T,vector<T>,greater<T>>
using namespace std;
int pa[100000];//親
int ra[100000];//木の高さ
int si[100000];
int a[100000],b[100000],z;
vector<int> v;
void init(int x){//初期化
	f(i,x){
		pa[i]=i;
		ra[i]=0;
		si[i]=1;
	}
}
int find(int x){//根を求める
	if(pa[x]==x) return x;
	else return pa[x]=find(pa[x]);
}
void unite(int x,int y){//木の併合
	x=find(x);
	y=find(y);
	if(x==y) return;
	z+=si[y]*(si[y]-1)/2;
	z+=si[x]*(si[x]-1)/2;
	if(ra[x]<ra[y]){
		pa[x]=y;
		si[y]+=si[x];
		z-=si[y]*(si[y]-1)/2;
	}
	else{
		pa[y]=x;
		if(ra[x]==ra[y]) ra[x]++;
		si[x]+=si[y];
		z-=si[x]*(si[x]-1)/2;
	}
}
bool same(int x,int y){
	return find(x)==find(y);
}
signed main(){
	int n,m;
	cin>>n>>m;
	init(n);
	z=n*(n-1)/2;
	f(i,m){
		cin>>a[i]>>b[i];
	}
	for(int i=m-1;i>=0;i--){
		v.push_back(z);
		unite(a[i],b[i]);
	}
	for(int i=v.size()-1;i>=0;i--){
		cout<<v[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 6132
while 1:
    n,s=map(int,input().split())
    if n==s==0:break
    ans=0
    for a0 in range(2):
        for a1 in range(2):
            for a2 in range(2):
                for a3 in range(2):
                    for a4 in range(2):
                        for a5 in range(2):
                            for a6 in range(2):
                                for a7 in range(2):
                                    for a8 in range(2):
                                        for a9 in range(2):
                                            if a0+a1+a2+a3+a4+a5+a6+a7+a8+a9==n and 1*a1+2*a2+3*a3+4*a4+5*a5+6*a6+7*a7+8*a8+9*a9==s:ans+=1
    print(ans)


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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define fs first
#define sc second
#define fr(i, a, b) for(int i = a ; i < b ; i++)
#define frr(i, a, b) for(int i = a ; i >= b ; i--)
#define tr(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define trr(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define its(x) static_cast< ostringstream & >( ( ostringstream() << dec << x ) ).str() // int to string
#define boost ios_base::sync_with_stdio(false)
#define deb(x) cout << #x" = " << x << '\n'
#define has(cont, x) ((cont).find((x)) != (cont).end())
#define sz(x) ((int)(x).size())

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

int a, b, h;

int main() {
//    freopen("input.in", "r", stdin);
	boost;
	cin >> a >> b >> h;
	cout << ((a+b)*(h/2)) << '\n';
	return 0;
}

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

using ll=long long;
array<int,200000> buf;
void merge(vector<int>& lhs,vector<int> rhs){
    int n=lhs.size();
    for(int i=0;i<n;i++){
        buf[i]=lhs[rhs[i]];
    }
    for(int i=0;i<n;i++) lhs[i]=buf[i];
}
int main(){
    int n;
    cin>>n;
    vector<ll> x(n);
    for(int i=0;i<n;i++) cin>>x[i];
    int m; ll k;
    cin>>m>>k;   
    vector<int> a(m);
    for(int i=0;i<m;i++) cin>>a[i],a[i]--;

    // cerr<<"#PERM PHASE"<<endl;
    vector<int> perm(n-1);
    iota(perm.begin(),perm.end(),0);
    for(int i=0;i<m;i++){
        // assert(0<=a[i]-1 && a[i]<n-1);
        swap(perm[a[i]-1],perm[a[i]]);
    }
    vector<int> diff(n-1);
    for(int i=0;i+1<n;i++) diff[i]=x[i+1]-x[i];

    // cerr<<"#POW PHASE"<<endl;
    while(k){
        if(k&1) merge(diff,perm);
        k>>=1;
        merge(perm,perm);
    }

    // cerr<<"#RESTORE PHASE"<<endl;
    vector<ll> res(n);
    res[0]=x[0];
    for(int i=1;i<n;i++){
        res[i]=res[i-1]+diff[i-1];
    }
    for(int i=0;i<n;i++){
        cout<<res[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 4728
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;

int main(){
    ll a, b, k;
    cin >> a >> b >> k;
    if(a >= k){
        a -= k;
    }else{
        //prt("!");
        k -= a;
        a = 0;
        b -= k;
        if(b < 0){b = 0;}
    }
    prt(a); prt(" "); prt(b);
}


Measured memory_bytes: 3568
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fore(i, l, r) for (int i = (l); i < (r); ++i)
#define loop for(int i=0;i<n;i++)
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max3(a,max(b,c),d)
#define max5(a,b,c,d,e) max4(a,max(b,c),d,e)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min3(a,min(b,c),d)
#define min5(a,b,c,d,e) min4(a,min(b,c),d,e)
#define sec second
#define fir first
#define vec vector<int>
#define M_PI           3.14159265358979323846  /* pi */
#define pb push_back
#include<bits/stdc++.h>
#include<cmath>
using namespace std;

int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	long double r;
	cin>>r;
	cout<<2*M_PI*r;
}

Measured memory_bytes: 3772
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars
    }
    let c1 = s.iter().enumerate().filter(|&(i, c)| {
        i % 2 == 0 && c == &'0' || i % 2 == 1 && c == &'1'
    }).count();
    let c2 = s.iter().enumerate().filter(|&(i, c)| {
        i % 2 == 0 && c == &'1' || i % 2 == 1 && c == &'0'
    }).count();
    let result = std::cmp::min(c1, c2);

    println!("{}", result);
}


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

int main() {
    long long unsigned int N, n_three, n_five, n_fifteen;
    long long unsigned int l_three, l_five, l_fifteen;

    scanf("%lld", &N);
    
    n_three = N / 3;
    l_three = N - N % 3;
    n_five = N / 5 ;
    l_five = N - N % 5;
    n_fifteen = N / 15;
    l_fifteen = N - N % 15;

    printf("%lld\n",N*(1 + N)/2 - n_three*(3 + l_three)/2 - n_five*(5+l_five)/2 + 
            n_fifteen*(15 + l_fifteen)/2 );

    return 0;
}

Measured memory_bytes: 1732
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s,t=input().split()
    a,b=MI()
    u=SI()
    if s==u:a-=1
    else:b-=1
    print(a,b)

main()

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

int main(){
  int N,ans;
  cin >> N;
  //奇数か偶数かで場合分け
  if(N%2==0){
    ans = N / 2 - 1;
  }else{
    ans = N / 2;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){ 
  int H, A, ans;
  cin >> H >> A;
  
  ans = H / A;
  
  if (H % A != 0) ans++;
  
  cout << ans << endl;

}

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

A_k = [i for i in A if i < 0]

A_abs = list(map(abs, A))

if len(A_k) % 2 == 0:
    print(int(sum(A_abs)))
    exit()
else:
    print(int(sum(A_abs) - 2 * min(A_abs)))

Measured memory_bytes: 14284
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>

using namespace std;

array<int, 300000> buf;
bool solve() {
    int N, Q;
    if(!(cin >> N >> Q)) return false;
    if(!N && !Q) return false;
    for(int i = 0; i < N; ++i) {
        cin >> buf[i];
    }
    sort(buf.begin(), buf.begin()+N);
    while(Q--) {
        int q;
        cin >> q;
        int res = 0;
        for(int i = q; i <= buf[N-1]+q; i += q) {
            auto it = lower_bound(buf.begin(), buf.begin()+N, i-1);
            if(it == buf.begin()+N || (it != buf.begin() && *it >= i)) --it;
            //cout << i << ' ' << *it << endl;
            res = max(res, *it % q);
        }
        cout << res << endl;
    }
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 2384
from collections import deque


def main():
    h, w = [int(i) for i in input().split()]
    f = []
    c_of_sharp = 0
    for i in range(h):
        line = list(input())
        for c in line:
            if c == '#':
                c_of_sharp += 1
        f.append(line)
    sy, sx = (0, 0)
    q = deque([[sy, sx]])
    BIG = 100000
    f2 = [[BIG for i in range(w)] for j in range(h)]
    f2[0][0] = 0
    s = True

    while q:
        y, x = q.pop()
        if (y, x) == (h-1, w-1):
            break
        for dy, dx in [[-1, 0], [1, 0], [0, -1], [0, 1]]:
            if 0 <= y+dy < h and 0 <= x+dx < w and f2[y+dy][x+dx] == BIG and \
                f[y+dy][x+dx] != '#':
                f2[y+dy][x+dx] = f2[y][x]+1
                q.appendleft([y+dy, x+dx])
    else:
        s = False
        print(-1)

    if s:
        print(h*w-f2[h-1][w-1]-c_of_sharp-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

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

  cout << S.substr(0, 5) << " " << S.substr(6, 7) << " " << S.substr(14, 18)
       << endl;

  return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
dif = abs(a-b)
result = 0
bigger = 0

if a >= b:
    bigger = a
else:
    bigger = b
    
if dif%2 == 0:
    result = bigger - dif/2
    print(int(result))
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<ll>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(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--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

ll rsl = 0;

vector<ll> divisor(ll n) {
    vector<ll> res;
	for(ll i = 1ll; i * i <= n; i++) {
		if(n % i == 0) {
			res.push_back(i);
            ll j = n / i;
			if(i != j) {
                res.push_back(j);
            }
		}
	}
    return res;
}

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

    ll n;
    cin >> n;
    vector<ll> div = divisor(n);

    for(auto r: div) {
        if(r <= 1) continue;
        ll m = r - 1;
        if(n / m == n % m) rsl += m;
    }

    cout << rsl << endl;
}


Measured memory_bytes: 384
/*  Kadai4_1
    saitomo   */

#include <stdio.h>
#include <math.h>

int main(void){
    double num_tree, scope;
    //木の本数と範囲を指定
    scanf("%lf%lf", &num_tree, &scope);

    int num_observer = ceil(num_tree / (2 * scope + 1));
    // 必要な監視員の数
    //1人で2*scope+1本の木を監視できる
    //余りが出た場合は切り上げる
    printf("%d\n", num_observer);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <fstream>

using namespace std;

int main()
{
    int n;char x;
    cin>>n;
    set<char>s;
    while(n--)
    {
        cin>>x;
        s.insert(x);
    }
    if(s.size() == 3)
        cout<<"Three"<<endl;
    else
        cout<<"Four"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define maxN 200000

int asc(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

int
main(int argc, char *argv[])
{
  int n, k, a, c[maxN] = {}, max = 0;
  scanf("%d %d", &n, &k);
  for(int i = 0; i < n; i++){
    scanf("%d", &a);
    max = (max > a ? max : a);
    c[a - 1]++;
  }
  

  qsort(c, max, sizeof(int), asc);

  
  int i = 0; int l = 0; int z = 0;
  while(max > k){
    if(c[i] == 0) max--;
    else{
      l += c[i];
      max--;
    }
    i++;
  }

  printf("%d\n", l);

  return 0;
}


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

const int N = 2e5;
const int MOD = 1e9+7;

int dmod(int x){
	return x%MOD;
}

int n;
int c[N+5];
int li[N+5];
int nxt[N+5];

int memo[N+5];

int dp(int x){
	if(x > n) return 1;
	int &ret = memo[x];
	if(ret!=-1) return ret;
	ret = dp(x+1); // skip
	if(nxt[x] != -1 && nxt[x] != x+1) ret = dmod(ret + dp(nxt[x]));
	return ret;
}

int main(){
	memset(memo,-1,sizeof(memo));
	memset(c,-1,sizeof(c));
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&li[i]);
//		nxt[i] = c[li[i]];
//		c[li[i]] = i;
//		cout << ">> " << nxt[i] << endl;
	}
	for(int i=n;i>=1;i--){
		nxt[i] = c[li[i]];
		c[li[i]] = i;
	}
	int ans = dp(1);
	printf("%d\n",ans);
	return 0;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  vector<long long int> H(N);
  for(auto& h : H){
    cin >> h;
  }
  sort(H.begin(), H.end());
  long long int ans=0;
  for(int ii=0; ii<max(0, N-K); ii++){
    ans += H[ii];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        string s;
        cin>>s;
        rep(i,Size(s)){
            if(s[i]=='h'&&s[i+1]!='i'||s[i]!='h'){
                cout<<"No"<<endl;
                return 0;
            }
            i++;
        }
        cout<<"Yes"<<endl;
    }

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nk = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        var n = nk[0];
        var k = nk[1];
        var ts = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

        var f = 0L;
        for (int i = 39; i >= 0; i--)
        {
            var d = 1L << i;
            var one = ts.Sum(x => x >> i & 1);
            if (k >= d && one < n - one)
            {
                k -= d;
                f += (n - one) * d;
            }
            else
            {
                f += one * d;
            }
        }
        Console.WriteLine(f);
    }
}


Measured memory_bytes: 31196
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		int[] d = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		boolean[] usedred = new boolean[n];
		boolean[] usedblue = new boolean[n];
		int count = 0;
		for (int i = 0; i < n; i++) {
			int bluei = -1;
			int bluex = 2 * n + 1;
			int bluey = 0;
			for (int j = 0; j < n; j++) {
				if (c[j] < bluex && !usedblue[j]) {
					bluei = j;
					bluex = c[j];
					bluey = d[j];
				}
			}
			if (bluei == -1) {
				continue;
			}
			usedblue[bluei] = true;
			int redi = -1;
			int redx = -1;
			int redy = -1;
			for (int j = 0; j < n; j++) {
				if (a[j] < bluex && !usedred[j] && b[j] > redy && b[j] < bluey) {
					redi = j;
					redx = a[j];
					redy = b[j];
				}
			}
			if (redi == -1) {
				continue;
			}
			usedred[redi] = true;
			count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)
 
int main() 
{	
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
 
	int a,b;
	cin>>a>>b;
	double c[a],d[a],l=0,ct=0,e[a];
	forr(i,0,a)
	{
		double x;
		cin>>x;
		c[i]=(x+1)/2;
	}
	d[0]=c[0];
	forr(i,1,a)
	{
		d[i]=d[i-1]+c[i];
	}
	forr(i,0,a-b)
	{
		e[i]=d[i+b]-d[i];
	}
	e[a-b]=d[b-1];
	sort(e,e+a-b+1);
	cout<<fixed<<setprecision(11)<<e[a-b];
	return 0;	
}

Measured memory_bytes: 4992
class PriorityQueue
  def initialize(&comp)
    @heap = []
    @node_num = 0
    if !block_given?
      @comp = Proc.new { |x, y| x <= y }
    else
      @comp = comp
    end
  end

  attr_reader :heap

  def push(x)
    current_node_num = @node_num
    @node_num += 1
    while current_node_num > 0
      parent_node_num = (current_node_num - 1) / 2
      break if @comp.call(@heap[parent_node_num], x) # 逆転してないなら抜ける
      # 親ノードを下ろして自分を上に
      @heap[current_node_num] = @heap[parent_node_num]
      current_node_num = parent_node_num
    end
    @heap[current_node_num] = x
  end

  alias_method(:<<, :push)

  def pop
    # 最(小|大)値
    ret = @heap[0]
    # 根にもってくる値
    @node_num -= 1
    x = @heap[@node_num]
    # 根から下ろしていく
    i = 0
    while (a = i * 2 + 1) < @node_num
      # 子どうしを比較
      b = a + 1
      a = b if b < @node_num && @comp.call(@heap[b], @heap[a])
      break unless @comp.call(@heap[a], x)
      @heap[i] = @heap[a]
      i = a
    end
    @heap[i] = x
    return ret
  end

  def get
    @node_num == 0 ? nil : @heap[0]
  end

  def empty?
    return get.nil?
  end
end

n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
q = PriorityQueue.new { |x, y| x > y }
a.each do |e|
  q.push e
end

m.times do
  q.push(q.pop / 2)
end
puts q.heap.inject(:+)


Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    vector<int> xs(n),ys(m);
    for(int i=0;i<n;i++)cin>>xs[i];
    for(int i=0;i<m;i++)cin>>ys[i];
    for(int z=x+1;z<=y;z++){
        bool b=true;
        for(int i=0;i<n;i++){
            if(xs[i]>=z){
                b=false;
                break;
            }
        }
        for(int i=0;i<m;i++){
            if(ys[i]<z){
                b=false;
                break;
            }
        }
        if(b){
            cout<<"No War"<<endl;
            return 0;
        }
    }
    cout<<"War"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

struct D { ld r, l, exp; };
int main()
{
	int K;
	ld R, L, P, E, T;
	cin >> K >> R >> L >> P >> E >> T;
	queue<pair<D, int>> que;
	que.push(make_pair(D{ R,L,1 }, 0));
	ld ans = 0;
	while (que.size())
	{
		D tmp = que.front().first;
		int cnt = que.front().second;
		que.pop();
		ld h = (tmp.r + tmp.l) / 2;
		if (cnt == K)
		{
			if (abs(h - T) < E) ans += tmp.exp;
		}
		else
		{
			if (abs(tmp.r - T) <= E&&abs(tmp.l - T) <= E) ans += tmp.exp;
			else if (!(tmp.r-T>E||T-tmp.l>E))
			{
				if (h >= T)
				{
					que.push(make_pair(D{ tmp.r,h,tmp.exp*(1-P) }, cnt + 1));
					que.push(make_pair(D{ h,tmp.l,tmp.exp*P }, cnt + 1));
				}
				else
				{
					que.push(make_pair(D{ tmp.r,h,tmp.exp*P }, cnt + 1));
					que.push(make_pair(D{ h,tmp.l,tmp.exp*(1-P) }, cnt + 1));
				}
			}
		}
	}
	cout << D10 << ans << endl;
	return 0;
}

Measured memory_bytes: 3304
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    double a, b, C, S, L, h, PI = acos(-1);
    scanf("%lf %lf %lf", &a, &b, &C);
    //S = 1/2 * a*b*sin(C)
    S = sin(C * PI / 180) * a * b / 2;
    //c^2 = a^2 + b^2 - 2*a*b*cos(C)
    L = a + b + sqrt(a*a + b*b - 2*a*b * cos(C * PI / 180));
    //S = 1/2 * a * h
    h = S/a*2;
    printf("%lf %lf %lf\n", S, L, h);
    return 0;
}



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

#define int long long
#define pb push_back
#define ff first
#define ss second

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int x,y;
    cin>>x>>y;
    
    
    for(int i=0;i<=x;i++)
    {
        int ans=i*2+(x-i)*4;
        if(ans==y)
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
}

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

int main(void){
	char buff[128];
	char *p;
	scanf("%s",buff);
	p=buff;
	p=p+strlen(buff);
	while(p!=buff){
		putchar(*(--p));
	}
	putchar('\n');
	return 0;
}

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

using namespace std;
using ll = long long;
const ll mod = 1000000007;


int main()
{
    int n;
    string s;
    cin >> n >> s; 
    s.erase(unique(s.begin(), s.end()), s.end());
    cout << s.size() << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), output("\n"))
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int n;

//num 何個反対側に行くか
string func(int num){
	output("?");
	rep(i, n-num){
		output(i+1);
	}
	rep(i, num){
		output(n*2-i);
	}
	outendl();
	string res;
	cin >> res;
	return res;
}

int main(){
	cin >> n;
	string first;
	vector<char> ans(2*n+1, ' ');
	output("?");
	rep(i, n){
		output(i+1);
	}
	outendl();
	cin >> first;
	//何個反対側にすると結果が反転するか判定
	int lp = 1;
	int rp = n+1;
	while(lp<rp){
		int mid = (lp + rp) / 2;
		if(func(mid) == first){
			lp = mid + 1;
		}else{
			rp = mid;
		}
	}
	//lpの位置のやつが経典のため
	set<int> selector;
	ans[n*2-lp+1] = first=="Red"?'B':'R';
	rep(i, n-lp){
		selector.emplace(i+1);
	}
	rep(i, lp-1){
		selector.emplace(n*2-i);
	}
	repa(i, n*2+1){
		if(selector.count(i))continue;
		output("?");
		foreach(j, selector)output(j);
		output(i);
		outendl();
		string str;
		cin >> str;
		ans[i] = str[0];
	}
	set<int> s;
	int nr = n / 2;
	int nb = n / 2;
	repa(i, n*2+1){
		if(selector.count(i))continue;
		if(ans[i]=='R'){
			if(nr){
				--nr;
				s.emplace(i);
			}
		}else{
			if(nb){
				--nb;
				s.emplace(i);
			}
		}
	}
	selector = s;
	repa(i, n*2+1){
		if(selector.count(i))continue;
		output("?");
		foreach(j, selector)output(j);
		output(i);
		outendl();
		string str;
		cin >> str;
		ans[i] = str[0];
	}
	cout << "! ";
	repa(i, n*2+1){
		cout << ans[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 724
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=1<<18;


int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<ll> b(0);
    b.push_back(a[n-1]);
    for(int i=n-2;i>=0;i--){
        if(a[i] >= *b.rbegin()){
            b.push_back(a[i]);
        }else{
            int itr=upper_bound(b.begin(),b.end(),a[i])-b.begin();
            b[itr]=a[i];
        }
    }
    cout<<b.size()<<endl;

}

Measured memory_bytes: 5084
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};
int main(){
  Dice d;
  for(int i=0;i<6;i++) cin >> d.s[i];
  int n;cin >> n;
  while(n--){
    int a,b;cin >> a >> b;
    if(d.left()==a) d.roll('E');
    if(d.right()==a) d.roll('W');
    while(d.top()!=a) d.roll('N');
    while(d.front()!=b) d.roll('R');
    cout << d.right() << endl;
  }
  return 0;
}



Measured memory_bytes: 3116