akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define abs(x) (((x) < 0) ? ((x) * (-1)) : (x))

void warp(int *px, int *py, int x, int y, int w, int h, int *cou)
{
	int minx, miny, sx, sy, ret;
	
	minx = abs(x - *px);
	miny = abs(y - *py);
	sx = *px;
	sy = *py;
	ret = 0;
	
	while (1){
		if (x < *px){
			sx--;
			sy--;
//			printf("w[%d][%d]\n", sx, sy);
			ret++;
		}
		else if (x > *px){
			sx++;
			sy++;
//			printf("w[%d][%d]\n", sx, sy);
			ret++;
		}
		
		
//		printf("minx:%d, miny:%d, sx:%d, sy:%d, x:%d, y:%d, ret:%d\n", minx, miny, sx, sy, x, y, ret);
		
		if ((minx + miny) > (abs(x - sx) + abs(y - sy))){
			minx = abs(x - *px);
			miny = abs(y - *py);
			*px = sx;
			*py = sy;
		}
		else {
			break;
		}
		if ((sx <= w && sy <= h) && (sx > 0 && sy > 0)) break;
	}
	
	*cou += ret;
}

int main(void)
{
	int w, h, n, x[1000], y[1000];
	int i, j, px, py, sx, sy, cou;
	
	scanf("%d %d %d", &w, &h, &n);
	for (i = 0; i < n; i++){
		scanf("%d %d", &x[i], &y[i]);
	}
	
	px = x[0];
	py = y[0];
	cou = 0;
	i = 1;
	
	while (i < n){
		if ((x[i] > px && y[i] > py) || (x[i] < px && y[i] < py)){
//			printf("Start_warp %d %d %d %d %d\n", px, py, cou, x[i], y[i]);
			warp(&px, &py, x[i], y[i], w, h, &cou);
//			printf("End_warp %d %d %d %d %d\n", px, py, cou, x[i], y[i]);
		}
		else if (abs(x[i] - px) == abs(y[i] - py)){
			if ((x[i] - px) > 0){
				px++;
				cou++;
			}
			else if ((x[i] - px) < 0){
				px--;
				cou++;
			}
			if ((y[i] - py) > 0){
				py++;
				cou++;
			}
			else if ((y[i] - py) < 0){
				py--;
				cou++;
			}
			
//			printf("n[%d][%d]\n", px, py);
		}
		else if (abs(x[i] - px) < abs(y[i] - py) && abs(x[i] - px) != 0 || abs(y[i] - py) == 0 && abs(x[i] - px) != 0){
			if ((x[i] - px) > 0){
				px++;
//					printf("[%d][%d]\n", px, py);
			}
			else if ((x[i] - px) < 0){
				px--;
//					printf("[%d][%d]\n", px, py);
			}
			cou++;
			
		}
		else if (abs(x[i] - px) > abs(y[i] - py) && abs(y[i] - py) != 0 || abs(x[i] - px) == 0 && abs(y[i] - py) != 0){
			if ((y[i] - py) > 0){
				py++;
//					printf("[%d][%d]\n", px, py);
			}
			else if ((y[i] - py) < 0){
				py--;
//					printf("[%d][%d]\n", px, py);
			}
			cou++;
		}
		
		
		if (px == x[i] && py == y[i]){
			i++;
//				printf("i = %d, cou = %d, [[%d][%d]]\n", i, cou, px, py);
		}
	}
	
	printf("%d\n", cou);
	
	return (0);
}

Measured memory_bytes: 604
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <complex>
using namespace std;

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

const int INF = 1e9;
int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef long long ll;

int a, b;

int main() {
  cin >> a >> b;
  if(a + b == 15)cout << "+" << endl;
  else if(a * b == 15)cout << "*" << endl;
  else cout << "x" << endl;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= 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
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int d;
  ll g;
  cin >> d >> g;
  vector<ll> p(d), c(d);
  rep(i, d) cin >> p[i] >> c[i];

  int ans = INF;

  for(int bit = 0; bit < 1<<d; ++bit) {

    //cout << bitset<5>(bit) << endl;
    ll score = 0;
    int num = 0;
    vector<ll> t;
    rep(i, d) {
      if(bit & 1<<i) {
        score += (i+1)*100*p[i]+c[i];
        num += p[i];
      }
      else rep(j, p[i]-1) t.push_back((i+1)*100);
    }

    //cout << "nokori " << max(0ll, g-score) << endl;
    sort(rALL(t));
    t.insert(t.begin(), 0);
    rep(i, t.size()) t[i+1] += t[i];

    //line_out(t);

    if(lower_bound(ALL(t), max(0ll, g-score)) == t.end()) continue;

    num += distance(t.begin(), lower_bound(ALL(t), max(0ll, g-score)));



    chmin(ans, num);

  }
  cout << ans << endl;
}

Measured memory_bytes: 3484
#include<bits/stdc++.h>
using namespace std;
typedef pair<string,int> as;

string s;
map<string,int> len;
map<as,int> arr;

string array_name(size_t &p){
  string res;
  while(p<s.size() && isalpha(s[p]))res += s[p++];
  return res;
}

int number(size_t &p){
  int res = 0;
  while(p<s.size() && isdigit(s[p]))res = res*10 + (int)(s[p++]-'0');
  return res;
}

int expression(size_t &p){
  if(isdigit(s[p]))return number(p);
  string s = array_name(p);
  int id = expression(++p);
  p++;
  if(id<0)return -1;
  if(id >= len[s])return -1;
  if(arr.count(as(s,id)) == 0)return -1;
  return arr[as(s,id)];
}

int assignment(size_t &p){
  string s = array_name(p);
  int id = expression(++p);
  p += 2;
  int x = expression(p);
  if(id<0 || x<0)return -1;
  if(id >= len[s])return -1;
  arr[as(s,id)] = x;
  return x;
}

int declaration(size_t &p){
  string s = array_name(p);
  int l = number(++p);
  len[s] = l;
  return 1;
}

int statement(void){
  size_t p = 0;
  if(s.find("=") == string::npos)return declaration(p);
  return assignment(p);
}

int main(){
  for(;;){
    len.clear(); arr.clear();

    int cnt = 0, bug = 0;
    cin >> s;
    while(s != "."){
      int res = statement();
      
      cin >> s; cnt++;
      if(res<0 && bug==0)bug = cnt;
    }
    if(cnt==0)break;
    cout << bug << endl;
  }
}

Measured memory_bytes: 1312
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cmath>
#include <iomanip>
using namespace std;
#define mod (long)(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
//#define long long long
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; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int main(){
    int s;
    cin >> s;
    int now = s;
    vector<bool> is_opened(2000000, false);
    int count = 0;
    while(!is_opened[now]){
        is_opened[now] = true;
        count++;
        if(now % 2 == 0){
            now /= 2;
        }else{
            now = now * 3 + 1;
        }
    }
    cout << count + 1 << endl;
}


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

int main(){
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;
  if(x - r >= 0 && y - r >= 0 && x + r <= w && y + r <= h) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
 
int main() {
  int currentRating, wantedRating;
  std::cin >> currentRating;
  std::cin >> wantedRating;
  
  int aimingPerformance = 2 * wantedRating - currentRating;
  
  std::cout << aimingPerformance;
}



Measured memory_bytes: 3616
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

vector<vector<long long> > comb(int n) {
  vector<vector<long long> > v(n + 1,vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int N;cin>>N;
    vector<pair<int, string> > P;
    //base
    string s;cin>>s;
    P.pb(paired(1,s));
    //score
    REP(i,N-1)
    {
        string ss;cin>>ss;

        //search
        bool is_in=false;
        REP(j,P.size())
        {
            if (P[j].second==ss)
            {
                is_in=true;
                P[j].first++;
                break;
            }
        }
        if (!is_in) P.pb(paired(1,ss));
    }
    //loss
    int M;cin>>M;
    REP(i,M)
    {
        string ss;
        cin>>ss;
      	
        REP(j,P.size())
        {
            if (P[j].second==ss)P[j].first--;
        }
        
    }

    RSORT(P);
    cout << max(P.front().first,0)<<endl;

  
    return 0;
}



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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int f[1000000]= {0};
    for(int i=1;i<=100;i++)
    {
        for(int j=1;j<=100;j++)
        {
            for(int k=1;k<=100;k++)
            {
                int p = (i*i) + (j*j) + (k*k) + (i*j) + (j*k) + (k*i);
                f[p]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        cout<<f[i]<<endl;
    }
}


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

//https://atcoder.jp/contests/arc074/tasks/arc074_a

ll h, w;

ll f(ll a, ll b, ll c) {
	ll mi = min(a, min(b, c));
	ll ma = max(a, max(b, c));
	return ma - mi;
}
ll g(ll x, ll y) {
	ll a = x / 3 * y;
	ll b = max((x - x / 3) / 2 * y, y / 2 * (x - x / 3));
	ll c = x * y - a - b;
	ll rv = f(a, b, c);

	a = (x + 2) / 3 * y;
	b = max((x - (x + 2) / 3) / 2 * y, y / 2 * (x - (x + 2) / 3));
	c = x * y - a - b;
	rv = min(rv, f(a, b, c));
	return rv;

}

int main() {
	cin >> h >> w;
	cout << min(g(h, w), g(w, h));
}


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

using namespace std;

int main() {
    // Input
    int N;
    vector<string> S;
    
    cin >> N;
    S = vector<string>(N);
    for (int i = 0; i < N; i++) cin >> S[i];

    // Process
    map<string, int> cnt_map;
    int max_cnt = 0;
    for (string s : S){
        if (cnt_map[s] == 0) cnt_map[s] = 1;
        else cnt_map[s]++;

        if (cnt_map[s] > max_cnt) max_cnt = cnt_map[s];
    }

    vector<string> ans_s;
    for (pair<string, int> item : cnt_map){
        if (item.second == max_cnt) ans_s.push_back(item.first);
    }
    sort(ans_s.begin(), ans_s.end());

    // Output
    for (string s : ans_s) cout << s << endl;

    return 0;
}


Measured memory_bytes: 28404
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define PI 3.14159265358979323846264338327950288
 
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;



int main(){
    FAST_IO ;
    int N ; cin >> N ;
    string str ; cin >> str ;
    int cnt = 0 ;
    for( int i = 0 ; i < N ; i++ ){
        if( str[i] == 'R' )
            cnt++ ;
    }
    int ans = 0 ;
    for( int i = 0 ; i < cnt ; i++ ){
        if( str[i] == 'W' )
            ans++ ;
    }
    cout << ans << endl ;
    return 0 ;
}
 
 

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
void chmin(int &a, int b) {if(a > b) a = b;}
void chmax(int &a, int b) {if(a < b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ll n;
    cin >> n;
    cout << (n-1)*n/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main() 
{
      ll h,w;
      cin>>h>>w;
      char ar[h][w];
      for(int i=0; i<h; i++)
      {
        for(int j=0; j<w; j++)
        {
             cin>>ar[i][j];
        }
      }
      
      ll dp[h][w];
       dp[0][0]=1;
       bool flag=0;
       for(int i=1; i<w; i++)
         {
                if(flag)
                dp[0][i]=0;
                else
                {
                  if(ar[0][i]=='#')
                  { dp[0][i]=0;
                  flag=1;}
                  else
                    dp[0][i]=1;
                }
                
         }
         flag=0;
         for(int i=1; i<h; i++)
         {
                if(flag)
                dp[i][0]=0;
                else
                {
                  if(ar[i][0]=='#')
                  { dp[i][0]=0;
                  flag=1;}
                  else
                    dp[i][0]=1;
                }
                
         }
         for(int i=1; i<h; i++)
         {
           for(int j=1; j<w; j++)
           {   int t1=0,t2=0;
               if(ar[i][j]=='#')
               dp[i][j]=0;
               else
               {
               if(dp[i-1][j]!=0)
                t1=dp[i-1][j];
               if(dp[i][j-1]!=0)
                 t2=dp[i][j-1];
                
                if(t1==INT_MIN && t2==INT_MIN)
                 dp[i][j]=0;
                 else
                 dp[i][j]=((t1%mod)+(t2%mod))%mod;
               }
           }
         }
         
         cout<<(dp[h-1][w-1])%mod<<endl;
         
      
        return 0;
}

Measured memory_bytes: 12332
#include<bits/stdc++.h>
#define N 32769
#define LL long long
using namespace std;
const int mo=998244353;
int n,m,k,g[2][N],fc[N],xf[N],f[N],h[N],z[N],v[N],e,ep,ie,ans,R[N];
char A[N],B[N];
LL fpm(LL x,LL y){ LL s=1; while(y){ if(y&1) s=(s*x)%mo; y>>=1,x=(x*x)%mo;} return s;}
void FFT(int *x,int o)
{
	int i,j,k,w,wn,p,q;
	for(i=0;i<e;i++) if(R[i]>i) swap(x[i],x[R[i]]);
	for(i=1;i<=e;i<<=1)
		for(j=0,wn=g[o][i];j<e;j+=i)
			for(k=0,w=1;k<i/2;k++){
				p=x[j+k],q=1LL*x[j+k+i/2]*w%mo;
				x[j+k]=p+q,x[j+k+i/2]=p-q;
				if(x[j+k]>=mo) x[j+k]-=mo;
				if(x[j+k+i/2]<0) x[j+k+i/2]+=mo;
				w=1LL*w*wn%mo;
			  }
}
void mult(int *x,int *y)
{
	int i;
	for(i=0;i<e;i++) v[i]=y[i],z[i]=x[i];
	FFT(z,0),FFT(v,0);
	for(i=0;i<e;i++) z[i]=1LL*z[i]*v[i]%mo;
	FFT(z,1);
	for(i=0;i<=m;i++)	x[i]=1LL*z[i]*ie%mo;
}
int main()
{
	int i;
	scanf("%s",A+1);
	scanf("%s",B+1);
	n = strlen(A+1);
	fc[0]=xf[0]=1;
	for(i=1;i<N;i++){
		fc[i]=(1LL*fc[i-1]*i)%mo;
		xf[i]=fpm(fc[i],mo-2);
	  }
	for(i=1;i<=n;i++){
		if(A[i]=='1') k++;
		if(A[i]=='1'&&B[i]=='1') m++;
	  }
	for(e=1,ep=0;e<=2*m;e<<=1,ep++);
	ie=fpm(e,mo-2);
	for(i=1;i<e;i++) R[i]=(R[i>>1]>>1)|((i&1)<<(ep-1));
	for(i=0;i<=ep;i++){
		g[0][1<<i]=fpm(3,((mo-1)>>i));
		g[1][1<<i]=fpm(g[0][1<<i],mo-2);
	  }
	k-=m,f[0]=1;
	for(i=0;i<=m;i++) h[i]=xf[i+1];
	for(i=k;i;){
		if(i&1) mult(f,h);
		i>>=1 , mult(h,h);
	  }
	for(i=0;i<=m;i++)
		ans=(ans+1LL*fc[m]*xf[m-i]%mo*f[i]%mo*fc[m-i])%mo;
	ans=1LL*ans*fc[k+m]%mo*fc[k]%mo;
	cout<<ans;
	return 0;
}


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

using namespace std;

#define foru(i, l, r) for (register int i = l; i <= r; i++)
#define ford(i, r, l) for (register int i = r; i >= l; i--)

int read() {
  int res = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) res = res * 10 + c - '0', c = getchar();
  return res;
}

const int maxn = 1e5 + 5;
vector<int> G[maxn];
void link(int u, int v) {
  G[u].push_back(v);
  G[v].push_back(u);
}
int N, M, Q, mx[maxn], col[maxn];
int v[maxn], d[maxn], c[maxn];

void dfs(int x, int _mx, int _col) {
  if (!col[x]) col[x] = _col;
  if (_mx <= mx[x] || !_mx) return;
  mx[x] = _mx;
  for (auto to : G[x]) dfs(to, _mx - 1, _col);
}

int main() {
  //  freopen("b.in", "r", stdin);
  //  freopen("b.out", "w", stdout);
  N = read(), M = read();
  foru(i, 1, M) link(read(), read());
  Q = read();
  foru(i, 1, Q) v[i] = read(), d[i] = read(), c[i] = read();
  ford(i, Q, 1) dfs(v[i], d[i], c[i]);
  foru(i, 1, N) printf("%d\n", col[i]);
  return 0;
}


Measured memory_bytes: 8440
#!/usr/bin/env python3
import sys
MOD = 1000000007

def solve(N: int, A: "List[int]"):
    l, r = 0, 1
    sux, su, ans = A[0], A[0], 0
    while l < len(A):
        while r < len(A) and (sux ^ A[r]) == (su + A[r]):
            sux ^= A[r]
            su += A[r]
            r += 1
        ans += r - l
        sux ^= A[l]
        su -= A[l]
        l += 1
    return ans

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, A))

if __name__ == '__main__':
    main()


Measured memory_bytes: 24992
n=int(input())
a=[list(map(int,input().split())) for i in range(2)]
sm = [sum(a[0])+a[1][n-1]]
for i in range(n-1):
  sm.append(sm[-1]-a[0][-i-1]+a[1][-i-2])
print(max(sm))

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

int main() {
  int a,b,c;
  int amari;
  cin>>a>>b;
  c=(a+b)/2;
  amari=(a+b)%2;
  if(amari!=0){
    cout<<c+1;
  }else{
    cout<<c;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
const int MAX_N=105;
int n;
int a[MAX_N],b[MAX_N],c[MAX_N],d[MAX_N];
vec g[MAX_N*2];
bool used[MAX_N*2];
int match[MAX_N*2];
bool dfs(int v)
{
	used[v]=true;
	rep(i,0,g[v].size())
	{
		int u=g[v][i],w=match[u];
		if(w<0 || !used[w] && dfs(w))
		{
			match[u]=v;
			match[v]=u;
			return true;
		}
	}
	return false;
}
int bipartite_matching()
{
	int res=0;
	memset(match,-1,sizeof(match));
	rep(v,0,2*n)
	{
		if(match[v]<0)
		{
			memset(used,false,sizeof(used));
			if(dfs(v))res++;
		}
	}
	return res;
}
int main()
{
	cin>>n;
	rep(i,0,n)cin>>a[i]>>b[i];
	rep(i,0,n)cin>>c[i]>>d[i];
	rep(i,0,n)
	{
		rep(j,0,n)
		{
			if(a[i]<c[j] && b[i]<d[j])
			{
				g[i].pb(j+n);
				g[j+n].pb(i);
			}	
		}
	}
	cout<<bipartite_matching()<<endl;
	return 0;
}



Measured memory_bytes: 256
/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

// #define int            	long long
#define tree         	ped
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<integer>
#define pint        	pair<integer, integer>
#define umint        	unordered_map<integer, integer>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define fj(x)			for(int j=0; j<x; j++)
#define fn(n, x)			for(int i=n; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

// #include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

vector<vint> dp;

void print(vector<vint> arr){
	f(arr.size()){
		fj(arr[i].size()) cout<<arr[i][j]<<" ";
		cout<<endl;
	}
	cout<<endl;
}

int32_t main(){
    
    om_shree_ganeshaya_namah();

    in(n); in(m);
    vector<string> arr(n);
    dp = vector<vint>(n, vint(m));
    f(n) cin>>arr[i];

    f(n){
    	fj(m){
    		if(arr[i][j]=='#'){
    			dp[i][j] = 0;
    			continue;
    		}
    		if(i==0 || j==0){
    			if(i==0 && j==0)
    				dp[i][j]=1;
    			else if(i==0)
    				dp[i][j] = dp[i][j-1];
    			else
    				dp[i][j] = dp[i-1][j];
    			continue;
    		}
    		int a = dp[i-1][j];
    		int b = dp[i][j-1];
    		dp[i][j] = (a+b)%mod;
    	}
    }
    // print(dp);
    cout<<dp[n-1][m-1];
}

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

ll N;
vector<ll> A;

void solve() {
  ll res = 0, cnt = 0;
  bool zero = false;

  for (int i = 0; i < N; i++) {
    if (A[i] < 0) {
      cnt++;
    }
    if (A[i] == 0) {
      zero = true;
    }
  }
  for (int i = 0; i < N; i++) {
    res += abs(A[i]);
  }

  if (!(cnt % 2 == 0 || zero)) {
    {
      ll Amin = 10000000000;
      for (int i = 0; i < N; i++) {
        Amin = min(Amin, abs(A[i]));
      }
      res -= 2 * Amin;
    }
  }

  cout << res << "\n";
  return;
}
int main() {
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 1024
n = int(input())
dp = [float('Inf')] * (n + 1)
dp[0] = 0
for i in range(1, n + 1):
    j = 1
    while j <= i:
        dp[i] = min(dp[i], dp[i - j] + 1)
        j *= 6
    j = 1
    while j <= i:
        dp[i] = min(dp[i], dp[i - j] + 1)
        j *= 9
print(dp[n])


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

void dfs(int u, vector<vector<int>>& adjList, bool* vis, ll* dp){
    if(vis[u]){
        return;
    }
    
    if(adjList[u].empty()){
        dp[u] = 0;
        vis[u] = true;
        return;
    }
    
    int m = 0;
    for(int i=0; i<adjList[u].size(); i++){
        int v = adjList[u][i];
        dfs(v, adjList, vis, dp);
        m = (dp[v]>m)?dp[v]:m;
    }
    dp[u] = 1 + m;
    vis[u] = true;
    
}
 
int main() {
    int n, m;
    cin>>n>>m;
    vector<vector<int>> adjList(n);
    
    while(m--){
        int u, v;
        cin>>u>>v;
        adjList[u-1].push_back(v-1);
    }
    bool vis[n];
    ll dp[n];
    memset(vis, false, sizeof(vis));
    memset(dp, false, sizeof(dp));
    
    for(int i=0; i<n; i++){
        if(!vis[i]){
            dfs(i, adjList, vis, dp);
        }
    }
    cout<<*max_element(dp, dp+n);
}

Measured memory_bytes: 13720
#include <bits/stdc++.h>
using namespace std;
 int main() {
 	int dist,t,s;
 	cin>>dist>>t>>s;
	if(ceil((float)dist/s)<=t) {
		 cout<<"Yes"<<endl;
	}else {
		cout<<"No"<<endl;
	}
 	
 	return 0;
 }

Measured memory_bytes: 3632
// :)
// "Khodaya, be man "Tagwaye setiz" biamooz ta
//  dar anbuh masuliat nalaghzam ..." -Shariati
#include <bits/stdc++.h>

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;
typedef pair<int64,int64> pii64;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e5+10;
const int64 MO = 1e9+7;
const int64 IN = 1e9;

vector <pii> ans;
int n;

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	if (n % 2) {
		for (int i = 1; i <= n; i++)
			for (int t = i + 1; t <= n; t++) {
				if (i + t == n)
					continue;
				ans.PB( MP(i, t) );
			}
	} else {
		for (int i = 1; i <= n; i++)
			for (int t = i + 1; t <= n; t++) {
				if (i + t == n + 1)
					continue;
				ans.PB( MP(i, t) );
			}
	}
  	cout << sz(ans) << "\n";
	for (auto x : ans)
		cout << x.F << " " << x.S << "\n";
}


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

int main(){
    int n,m,l;
    cin >> n >> m >> l;
    
    vector<vector<ll> > A(n,vector<ll>(m));
    vector<vector<ll> > B(m,vector<ll>(l));
    vector<vector<ll> > C(n,vector<ll>(l,0));
    
    rep(i,n){
        rep(j,m){
            cin >> A[i][j];
        }
    }
    
    rep(i,m){
        rep(j,l){
            cin >> B[i][j];
        }
    }
    
    rep(i,n){
        rep(j,l){
            rep(k,m){
                C[i][j] += A[i][k] * B[k][j];
            }
        }
    }
    
    rep(i,n){
        rep(j,l){
            if(j != l - 1) cout << C[i][j] << " ";
            else cout << C[i][j] << endl;
        }
    }
}





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

int main( void ) {
	char str1[ 100000 ], str2[ 100000 ], fig, tmp;
	int n, idx1, idx2, sum;

	while ( scanf( "%d", &n ), n ) {
		scanf( "%s", str1 );

		while ( n-- ) {
			idx1 = idx2 = 0;
			while ( ( fig = str1[ idx1 ] ) != '\0' ) {
				sum = 1;
				while ( ( tmp = str1[ ++idx1 ] ) != '\0' && fig == tmp )
					sum++;
				sprintf( str2 + idx2++, "%d%c", sum, fig );

				do {
					idx2++;
				} while ( sum /= 10 );
			}

			strcpy( str1, str2 );
		}

		printf( "%s\n", str1 );
	}

	return 0;
}

Measured memory_bytes: 708
#include<cstdio>
using namespace std;
const int maxn = 107;
char s[maxn][maxn];
bool row[maxn], col[maxn];
int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    for(int i = 1; i <= h; ++i){
        scanf("%s", s[i] + 1);
    }
    for(int i = 1; i <= h; ++i){
        for(int j = 1; j <= w; ++j){
            if(s[i][j] == '#'){
                row[i] = true;
                break;
            }
        }
    }
    for(int i = 1; i <= w; ++i){
        for(int j = 1; j <= h; ++j){
            if(s[j][i] == '#'){
                col[i] = true;
                break;
            }
        }
    }
    for(int i = 1; i <= h; ++i){
        if(!row[i])continue;
        for(int j = 1; j <= w; ++j){
            if(!col[j])continue;
            printf("%c", s[i][j]);
        }
        printf("\n");
    }
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    private static Scanner sc;
    public static void main(String[] args) {Main instance = new Main();sc = instance.new Scanner();instance.solve();}
    private class Scanner {String[] s = new String[0];String regex = " ";int i = 0;BufferedReader br = new BufferedReader(new InputStreamReader(System.in));public String next() {try {if (i < s.length) { return s[i++];}String st = br.readLine();while ("".equals(st)) { st = br.readLine(); }s = st.split(regex, 0);i = 0;return s[i++];} catch (IOException e) { return null; }}public int nextInt(){return Integer.parseInt(next());}}        

    private void solve() {
        int N = sc.nextInt();
        int[] a = new int[N];
        int[] a1 = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for (int i = 0; i < N; i++) {
            a1[i] = a[(N-1)-i];
        }
        int ans = 0;
        for (int i = 0; i < N; i++) {
            ans += a1[i] * (i%2==0 ? 1 : -1 );
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21332
#include<iostream>
#include<algorithm>

constexpr int MAX_N = 10000, INF = (int)1e9;

int n;
int a[MAX_N + 1];
int dp[2][MAX_N / 2 + 1][2][2];//??????????????????????????????????????°???????????????????????????????????´???????????????????????????

int main() {
	std::cin >> n;
	for (int i = 1; i < n; ++i)
		std::cin >> a[i];
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j <= n / 2; ++j) {
			for (int k = 0; k < 2; ++k) {
				for (int l = 0; l < 2; ++l)
					dp[i][j][k][l] = INF;
			}
		}
	}
	for (int i = 0; i <= 1; ++i) {
		for (int j = 0; j < 2; ++j) {
			for (int k = 0; k < 2; ++k)
				dp[0][j][!j][k] = 0;
		}
	}

	for (int i = 1; i < n; ++i) {
		for (int j = 1; j <= n / 2; ++j) {
			dp[i % 2][j][0][0] = std::min(dp[(i - 1) % 2][j - 1][0][0], dp[(i - 1) % 2][j - 1][0][1]);
			dp[i % 2][j][0][1] = std::min(dp[(i - 1) % 2][j - 1][1][0], dp[(i - 1) % 2][j - 1][1][1]) + a[i];
			dp[i % 2][j][1][0] = std::min(dp[(i - 1) % 2][j][0][0], dp[(i - 1) % 2][j][0][1]) + a[i];
			dp[i % 2][j][1][1] = std::min(dp[(i - 1) % 2][j][1][0], dp[(i - 1) % 2][j][1][1]);
		}
		dp[i % 2][0][1][1] = 0;
	}

	int ans = INF;
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < 2; ++j)
			ans = std::min(ans, dp[1][n / 2][i][j]);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3292
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int n,m;
  cin>>n>>m;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  
  int count=0;
  for(int i=0;i<n;i++) count +=a[i];
  
        sort(a.begin(), a.end()); 
    reverse(a.begin(),a.end());
  if(a[m-1] * 4*m >= count  )cout<<"Yes"<<endl;
  else cout<< "No"<<endl;
  





}

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

int main(){
    ll q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;

    ll a=q*4;
    ll b=q*2+h;
    ll c=h*2;

    ll ans=0;
    ll minv=min(min(a,b),min(c,s));
    
    if(n%2==1) ans=(n/2)*min(d,minv*2)+minv;
    else ans=(n/2)*min(d,minv*2);
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3548
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans = 0;
        if (N < 10) {
            System.out.println(N);
        } else if (N < 100) {
            System.out.println(9);
        } else if (N < 1000) {
            ans += 9;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 100;
            System.out.println(ans);
        } else if (N < 10000) {
            System.out.println(909);
        } else if (N < 100000) {
            ans += 909;
            String stringN = String.valueOf(N);
            String lead = stringN.substring(0, 1);
            String rest = stringN.substring(1, stringN.length());
            ans += Integer.parseInt(rest) + 1 + (Integer.parseInt(lead) - 1) * 10000;
            System.out.println(ans);
        } else {
            System.out.println(90909);
        }
    }
}


Measured memory_bytes: 21844
n = int(input())
a = list(map(int, input().split()))
allxor = 0
ans = [0]*n
for i in range(n):
    allxor = allxor^a[i]
for i in range(n):
    ans[i] = allxor^a[i]
ansstr = " ".join(map(str,ans))
print(ansstr)

Measured memory_bytes: 41644
#include <stdio.h>

void swap(int *, int *);

int bubbleSort(int [], int);

void printArray(int [], int);

int main()
{
    int n, i, count, arr[100];
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", arr + i);
    }
    count = bubbleSort(arr, n);
    printArray(arr, n);
    printf("%d\n", count);
    return 0;
}

void swap(int *ap, int *bp)
{
    int tmp;
    tmp = *ap;
    *ap = *bp;
    *bp = tmp;
}

int bubbleSort(int arr[], int n)
{
    int i, j, count = 0;
    for (i = 0; i < n - 1; i++) {
        for (j = 0; j < n - 1 - i; j++) {
	    if (arr[j + 1] < arr[j]) {
		swap(&(arr[j]), &arr[j + 1]);
                count++;
	    }
	}
    }
    return count;
}

void printArray(int arr[], int n)
{
    int i;
    for (i = 0; i < n; i++){
	printf("%d", arr[i]);
	if (i < n - 1) {
	    printf(" ");
        } else {
            printf("\n");
	}
    }
}



Measured memory_bytes: 2100
x, y, a, b, c = [int(i) for i in input().split()]
p = sorted([int(i) for i in input().split()])[::-1]
q = sorted([int(i) for i in input().split()])[::-1]
r = sorted([int(i) for i in input().split()])[::-1]
 
# print(p, q, r)
pp = x - 1
qp = y - 1
rp = 0
while rp < c:
    if pp < 0 and r[rp] > q[qp]:
        q[qp] = r[rp]
        qp -= 1
    elif qp < 0 and r[rp] > p[pp]:
        p[pp] = r[rp]
        pp -= 1 
    elif pp < 0 and qp < 0:
        break
    elif r[rp] > p[pp] or r[rp] > q[qp]:
        if p[pp] > q[qp]:
            q[qp] = r[rp]
            qp -= 1
        else:
            p[pp] = r[rp]
            pp -= 1
    rp += 1
 
# print(p,q)
print(sum(p[:x]) + sum(q[:y]))

Measured memory_bytes: 107620
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(0, n-2):
    if p[i] < p[i+1] and p[i+1] < p[i+2]:
        count += 1
    elif p[i] > p[i+1] and p[i+1] > p[i+2]:
        count += 1
print(count)

Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

// x: base length,  h: height of pyramid
double get_surface_area_of_pyramid(int x, int h) {
	double height_of_triangle = sqrt(x * x / 4.0 + h * h);

	return 2 * x * height_of_triangle + x * x;
}

int main(void) {
	int x, h; // 4角推

	while (cin >> x >> h) {
		if (x == 0 && h == 0) {
			break;
		}
		printf("%.6f\n",get_surface_area_of_pyramid(x, h));
	}

	return 0;
}

Measured memory_bytes: 1192
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

int a[1<<18];
void solve(){  
	  vll cand;
	  int n;
	  cin>>n;
	  multiset<int> ms;
	  rep(i,0,1<<n) cin>>a[i],ms.insert(a[i]);
	  sort(a,a+(1<<n));
	  cand.pb(a[(1<<n)-1]);
	  ms.erase(ms.find(a[(1<<n)-1]));
	  while(sz(cand)<(1<<n)){
	  	vll new_cand;
	  	for(int i:cand){
	  		auto it=ms.lower_bound(i);
	  		if(it==ms.begin()){
	  			cout<<"No"<<endl;
	  			return;
	  		}
	  		else{
	  			--it;
	  			new_cand.pb(*it);
	  			ms.erase(it);
	  		}
	  	}
	  	for(int i:new_cand) cand.pb(i);
	  	sort(all(cand));
	  }
	  cout<<"Yes"<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 14996
#include <stdio.h>
 
int main()
{
    int n, ctr = 0;
    scanf("%d", &n);
    char input[n];
    scanf("%s", input);
    for(int i = 0; i < 1500; i++)
    {
    	int math[3] = {i%10, i/100 ,(i/10)%10};
    	int temp = 0;
    	for(int j = 0; j < n; j++)
    	{
    		if(input[j] == (math[temp] + '0'))
    		{
    			temp++;
			}
			if(temp == 3)
			{
				break;
			}
		}
		if(temp == 3)
		{
			ctr++;
		}
	}
	printf("%d", ctr);
 
    return 0;
}

Measured memory_bytes: 1760
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = unsigned long long;
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;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}

int main(void){
    ll L,R; cin >> L >> R;
    ll ans = 3000;
    if(L / 2019 != R / 2019) ans = 0;
    else{
        for(int i = L; i < L + 2019 - 1; i++){
            if(i > R) break;
            //cout << i << endl;
            for(int j = i+1; j < L + 2019; j++){
                if(j > R) break;
                ans = min(((i%2019)*(j%2019))%2019,ans);
                //if(ans == 0) cout << i << ' ' << j << endl;
            }
        }
    }
    cout  << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<< #x << ": " << x << "\n";
using namespace std;
#define inf 1e9+7


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


}

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

int main(){
    string o, e;
    cin >> o >> e;
    size_t sizeo = o.size();
    size_t sizee = e.size();
    
    string pass;
    
    for(int i=0; i<sizeo+sizee; i++){
        if(i%2==0){
            pass.push_back(o.front());
            o.erase(o.begin());
        }
        else{
            pass.push_back(e.front());
            e.erase(e.begin());
        }
    }
    cout << pass << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define SUM(v) accumulate(v.begin(),v.end(),lli(0))
#define rev(n,d) for(int i=n;i>=d;i--)
#define FOR0(n) for(int i=0;i<n;i++)
#define FOR(a,n) for(int i=a;i<n;i++)
#define FORQ(a,n) for(int i=a;i<=n;i++)
#define inf 1000000009
#define inff 0x3f3f3f3f
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define mem(ar,x) memset(ar,x,sizeof ar)
#define present(container, element) (container.find(element) != container.end())
#define max3(a,b,c) return (lli(a)>lli(b)?(lli(a)>lli(c)?a:c):(lli(b)>lli(c)?b:c))
#define max4(a,b,c,d) return (max3(a,b,c)>lli(d)?(max3(a,b,c)):d)
#define min3(a,b,c) return (lli(a)<lli(b)?(lli(a)<lli(c)?a:c):(lli(b)<lli(c)?b:c))
#define min4(a,b,c,d) return (max3(a,b,c)<lli(d)?(max3(a,b,c)):d)
typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<int,pii>ppii;
typedef vector<lli>vi;
typedef vector<vi>vvi;
typedef vector<pii>vpii;
const int N=100005;
int dr8[]={0,0,1,-1,1,1,-1,-1};
int dc8[]={1,-1,0,0,-1,1,-1,1};
int dr4[]={0,1,-1,0};
int dc4[]={1,0,0,-1};
int main(){
	fast
	int d;string s;
	cin>>s>>d;
	int l=s.length();
	lli dp[d+5][2];
	mem(dp,0);
//	for(char c='0';c<=s[0];c++){
//		dp[c-'0'][c-'0']++;
//	}
	dp[0][0]=1;
	FORQ(0,l-1){
		lli ndp[d+5][2];
		mem(ndp,0);
		for(lli sm=0;sm<d;sm++){
			for(int pr=0;pr<2;pr++){
				for(int cur=0;cur<10;cur++){
					if(cur>s[i]-'0'&&pr==0) break;
					ndp[(sm+cur)%d][pr||cur<s[i]-'0']=(ndp[(sm+cur)%d][pr||cur<(s[i]-'0')]+dp[sm][pr])%mod;
				}
			}
		}
		for(int j=0;j<d;j++){
			for(int k=0;k<2;k++){
				dp[j][k]=ndp[j][k];
			}
		}
	}
	lli an=0;
	for(int i=0;i<2;i++){
		an=(an+dp[0][i])%mod;	
	}
	an=(an-1+mod)%mod;
	cout<<an;
}



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

using namespace std;

int n, k;
int a[101];
bool dp[100001];

int main()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    //false is lose for person going next: true is win for perso going next
    dp[0] = false;

    for(int i = 1; i <= k; i++)
    {
        int cnt = 0;
        for(int j = 0; j < n; j++)
        {
            if(i - a[j] >= 0 && !dp[i-a[j]]) cnt ++;
        }
        if(cnt != 0) dp[i] = true;
        else dp[i] = false;
    }

    if(dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define     LL              long long int
#define     FOR(I,A,B)      for( int I = A; I < B; ++I )
#define     SFI(X)          scanf("%d",&X)
#define     SFL(X)          scanf("%lld",&X)

struct Edge {

    int U,V;
};

int N, X, Y;

vector<int>Ans;
vector<vector<Edge>>Adj;

void Dfs(int Root, int Color, int Idx, int Parent ) {

    if(Color != -1) Ans[Idx] = Color;
    int Count = 1;
    for(Edge It:Adj[Root]) {
        if(Parent == It.U) continue;
        if(Color == Count) Count++;
        Dfs(It.U, Count, It.V, Root);
        Count++;
    }
}

int main() {

    SFI(N);

    Adj.resize(N);
    Ans.resize(N);

    for(int I = 0; I < N - 1; I++) {
        SFI(X);
        SFI(Y);
        --X;
        --Y;
        Adj[X].push_back({Y,I});
        Adj[Y].push_back({X,I});
    }

    Dfs(0,-1,-1,-1);

    printf("%d\n",*std::max_element(Ans.begin(),Ans.end()));
    for(int I = 0; I < N - 1; I++) {
        printf("%d\n",Ans[I]);
    }

}


Measured memory_bytes: 11024
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	b = readline() |> split |> parseMap
	b= sort(b,rev = true)
	l = 0
	r = 0
	x = -1
	for i in 1:n
		if a[i]==b[i]
			x = a[i]
			r = i
			if l==0
				l = i
			end
		end
	end
	if x!=-1
		al = 0
		ar = 0
		bl = 0
		br = 0
		for i in 1:n
			if a[i]==x
				ar = i
			end
			if a[n+1-i]==x
				al = n+1-i
			end
			if b[i]==x
				br = i
			end
			if b[n+1-i]==x
				bl = n+1-i
			end
		end
		if min(al,bl)-1+n-max(ar,br)<r-l+1
			println("No")
		else
			println("Yes")
			for i in l:r
				if i-l+1<min(al,bl)
					b[i]=b[i-l+1]
					b[i-l+1] = x
				else
					b[i] = b[max(ar,br)+i-l-min(al,bl)+2]
					b[max(ar,br)+i-l-min(al,bl)+2] = x
				end
			end
			for i in 1:n-1
				print(b[i]," ")
			end
			println(b[n])
		end
	else
		println("Yes")
		for i in 1:n-1
			print(b[i]," ")
		end
		println(b[n])
	end
end

main()

Measured memory_bytes: 222288