akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>

typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
#define rep_r(i,s,n)for(ll i = n;i>s;i--)
#define rep_re(i,s,n)for(ll i = n;i>=s;i--)
using namespace std;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

int main() {
	string x; cin >> x;
	ll k; cin >> k;

	bool ok = true;
	rep(i, 1, x.size()) ok &= x[i] == x[i - 1];
	if (ok) {
		cout << x.size()*k / 2 << endl;
		return 0;
	}
	if (x[0] != x[x.size() - 1]) {
		ll ans = 0;
		string s = x;
		rep(i, 0, s.size()) {
			if (s[i] == s[i + 1]) {
				s[i + 1] = '.';
				ans++;
			}
		}
		cout << ans * k << endl;
		return 0;
	}

	ll i = 0;
	while (x[i] == x[i + 1])i++;

	ll j = x.size() - 1;
	while (x[j] == x[j - 1])j--;
	i++;
	j = x.size() - j;

	ll ans = ((i + j)/2) *(k - 1);
	ans += i / 2;
	ans += j / 2;

	string s = x;
	ll ans_b = 0;
	rep(p, i, s.size() - j) {
		if (s[p] == s[p + 1]) {
			s[p + 1] = '.';
			ans_b++;
		}
	}
	ans += ans_b * k;

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main(){
	string s;
	cin>>s;
	bool playable=true;
	for(int i=0; i<s.length(); i+=2){
		if(s[i]=='L'){
			playable=false;
		}
	}
	for(int i=1; i<s.length(); i+=2){
		if(s[i] == 'R'){
			playable=false;
		}
	}
	if(playable){cout<<"Yes"<<endl;}
	else{cout<<"No"<<endl;}
}

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

int main(){
 int N;
  cin >>N;
  vector<int> H(N);
  for(int i =0 ; i<N; i++){
    cin >> H.at(i);}
  
  int sum=1;
  bool T=true;
  for(int i=1; i<N; i++){
    
    for(int j=0; j<i; j++){
      
      if(H.at(i)<H.at(j)){
        T=false; break;}}
      
      if(T){sum++;}
  else{T=true;}}
  cout << sum <<endl;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 long long ll;
using namespace std;
int main(void){
    int n,r;cin>>n>>r;
    if(n>=10){
        cout<<r<<endl;
        return 0;
    }else{
        int res=100*(10-n);
        cout<<r+res<<endl;
        return 0;
    }
}


Measured memory_bytes: 256
//#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(){
    cout<<fixed<<setprecision(20);
    ll x,y,xt,yt; cin>>x>>y>>xt>>yt;
    ll n; cin>>n;
    vector<vector<ll>> nodes(n+2,vector<ll>(3,0));
    rep(i,n)rep(j,3){
        cin>>nodes[i+1][j];
    }
    nodes[0][0]=x; nodes[0][1]=y; 
    nodes[n+1][0]=xt; nodes[n+1][1]=yt;

    vector<vector<pair<ll,ld>>> path(n+2);
    rep(i,n+2)rep(j,n+2){
        if(i==j) continue;
        ld d=0;
        d+=(nodes[i][0]-nodes[j][0])*(nodes[i][0]-nodes[j][0]);
        d+=(nodes[i][1]-nodes[j][1])*(nodes[i][1]-nodes[j][1]);
        d=sqrt(d);
        d-=nodes[i][2]+nodes[j][2];
        if(d<0) d=0;
        path[i].push_back(mk(j,d));
    }

    priority_queue<pair<ld,ll>, vector<pair<ld,ll>>, greater<pair<ld,ll>>> pq;
    pq.push(mk(0,0));

    vector<ld> dis(n+2,INF); dis[0]=0;
    ll s,to;
    ld cost,w;
    while(!(pq.empty())){
            tie(cost,s)=pq.top(); pq.pop();
            if(cost!=dis[s]) continue;
            for(auto p : path[s]){
                tie(to,w)=p;
                if(dis[to]>cost+w){
                    dis[to]=cost+w;
                    pq.push(mk(dis[to],to));
                }
            }
    }
    cout<<dis[n+1]<<endl;
}

Measured memory_bytes: 42220
#include <iostream>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;

  if ( A == 1){
    A = A + 13;
  }
  if ( B == 1){
    B = B + 13;
  }

  if ( A > B){
    cout << "Alice" << endl;
  } else if ( A == B){
    cout << "Draw" << endl;
  } else if ( A < B){
    cout << "Bob" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  while(a>0&&c>0){
    c-=b;
    if(c<=0){
      cout << "Yes";
      return 0;
    }
    a-=d;
    if(a<=0){
      cout << "No";
      return 0;
    }
  }
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-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;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string>
    B3={"aa.","..b","..b"},
    B4={"aacd","bbcd","efgg","efhh"},
    B5={"aabbc","hii.c","h..jd","g..jd","gffee"},
    B6={"aa.ccd","..bf.d","..bfee","ccdaa.","f.d..b","fee..b"},
    B7={".aabbcc","a.ddee.","adff...","bd....g","be....g","ce....h","c...iih"};
    int N; cin >> N;
    if (N==2){
        cout << -1 << endl;
        return 0;
    }
    if (N==3){
        rep(i,3) cout << B3[i] << endl;
        return 0;
    }
    vector<vector<char>> ans(N,vector<char>(N,'.'));
    int x=(N-N%4)/4-1,y=N-x*4;
    rep(k,x) rep(i,4) rep(j,4){
        ans[4*k+i][4*k+j]=B4[i][j];
    }
    if (y==4) rep(i,4) rep(j,4){
        ans[4*x+i][4*x+j]=B4[i][j];
    }
    if (y==5) rep(i,5) rep(j,5){
        ans[4*x+i][4*x+j]=B5[i][j];
    }
    if (y==6) rep(i,6) rep(j,6){
        ans[4*x+i][4*x+j]=B6[i][j];
    }
    if (y==7) rep(i,7) rep(j,7){
        ans[4*x+i][4*x+j]=B7[i][j];
    }
    rep(i,N) rep(j,N){
        cout << ans[i][j];
        if (j==N-1) cout << endl;
    }
}

Measured memory_bytes: 2304
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
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; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)


string s;
vector<int> v(4);

string calc(string s) {
	REP(i, 4)v[i] = s[i] - '0';
	sort(ALL(v));
	int hi = 0, lo = 0;
	REP(i, 4) {
		lo += v[i];
		lo *= 10;
	}
	lo /= 10;
	reverse(ALL(v));
	REP(i, 4) {
		hi += v[i];
		hi *= 10;
	}
	hi /= 10;
	string ret = to_string(hi - lo);
	while (ret.size() != 4)ret = "0" + ret;
	return ret;
}

int main() {
	while (cin >> s&&s != "0000") {
		for (int i = 1;; i++) {
			if (i == 1000) {
				cout << "NA" << endl;
				break;
			}
			if (s == "6174") {
				cout << i-1 << endl;
				break;
			}
			s = calc(s);
		}
	}
}


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

typedef long long ll;
typedef long double ld;

ll n, t, mx;

int main(){
	cin>>n;
	mx = 0;
	vector<ll> vec(n, 0);
	for(int i = 0; i < n; ++i)cin>>vec[i];
	for(int i = 0; i < n; ++i){
		mx = max(vec[i], mx);
		if(vec[i] < mx)t += (mx - vec[i]);
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  int c[26];
  mem(c);
  rep(i,n) {
    string s;
    R s;
    rep(j,m) c[s[j]-'a']++;
  }
  sort(c,c+26,greater<int>());
  rep(i,n/2) {
    rep(j,m/2) {
      ll x=4;
      rep(k,26) {
        if(c[k]>=x) {
          c[k]-=x;
          x=0;
        }
      }
      if(x) {
        pr("No");
        return;
      }
    }
  }
  if(n%2) {
    rep(j,m/2) {
      ll x=2;
      rep(k,26) {
        if(c[k]>=x) {
          c[k]-=x;
          x=0;
        }
      }
      if(x) {
        pr("No");
        return;
      }
    }
  }
  if(m%2) {
    rep(i,n/2) {
      ll x=2;
      rep(k,26) {
        if(c[k]>=x) {
          c[k]-=x;
          x=0;
        }
      }
      if(x) {
        pr("No");
        return;
      }
    }
  }
  if(n%2&&m%2) {
    ll x=1;
    rep(k,26) {
      if(c[k]>=x) {
        c[k]-=x;
        x=0;
      }
    }
    if(x) {
      pr("No");
      return;
    }
  }
  pr("Yes");
}

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


Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

  priority_queue < string, std::vector<string>, std::greater<string> > sub;

  REP(i,s.size()){
    REP(j,K){
      if(i+j<s.size()){
        sub.push(s.substr(i, j + 1));
      }
    }
  }

  string now = "";
  string hoge;
  int cnt = 0;
  while (cnt<K){
    hoge = sub.top();
    sub.pop();
    if(now!=hoge){
      cnt++;
      now = hoge;
    }
  }

  cout << hoge << endl;
}


Measured memory_bytes: 1660
N, M = (int(x) for x in input().split())
L = []
R = []
for i in range(M):
	l, r = (int(x) for x in input().split())
	L.append(l)
	R.append(r)
	
lmax = max(L)
rmin = min(R)
ans = rmin - lmax + 1
if ans < 0:
	ans = 0

print(ans)

Measured memory_bytes: 11040
// ------------------------------------
// Date:2018/ 2/26
// Problem:ABC 051 BackAndForth c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

#define MOD 1000000007

int main()
{
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int mx,my;
  string output = "";
  mx = tx - sx;
  my = ty - sy;
  REP(h,2) {
    if (h == 1) {
      output += "D";
    }
    REP(i,mx+h) {
      output += "R";
    }
    REP(i,my+h) {
      output += "U";
    }
    if (h == 1) {
      output += "LU";
    }
    REP(i,mx+h) {
      output += "L";
    }
    REP(i,my+h) {
      output += "D";
    }
    if (h == 1) {
      output += "R";
    }
  }
  cout << output << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> A(N),B(N);
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N;i++) cin >> B[i];
    int inf = 1e9;
    vvec<int> dp(1<<N,vec<int>(51,inf));
    dp[0][0] = 0;
    for(int S=0;S<(1<<N);S++){
        int cost = 0;
        for(int j=0;j<N;j++){
            if(!(S&(1<<j))){
                int n = __builtin_popcount(S);
                int ne = (abs(n-j)%2? B[j]:A[j]);
                int T = S^(1<<j);
                for(int k=0;k<=50;k++) if(k<=ne && dp[S][k]!=inf){
                    dp[T][ne] = min(dp[T][ne],dp[S][k]+cost);
                }
                cost++;
            }
        }
    }
    int ans = inf;
    for(int k=0;k<=50;k++) ans = min(ans,dp[(1<<N)-1][k]);
    cout << (ans==inf? -1:ans) << endl;
}

Measured memory_bytes: 63744
#include <iostream>

using namespace std;

bool is_leap(int y) {
	if (y % 4 == 0) {
		if (y % 100 == 0) {
			if (y % 400 == 0) {
				return true;
			} else {
				return false;
			}
		} else {
			return true;
		}
	} else {
		return false;
	}
}

int w_month(int m, int y) {
	int montha[] = {4, 6, 9, 11};
	if (m == 2) {
		if (is_leap(y)) {
			return 3;
		} else {
			return 2;
		}
	} else {
		for (int i = 0; i < 4; i++) {
			if (m == montha[i]) {
				return 1;
			}
		}
		return 0;
	}
}

int main() {
	int y1, m1, d1, y2, m2, d2;
	const int year = 31 * 7 + 30 * 4 + 28;
	const int month[] = {31, 30, 28, 29};
	while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2) {
		if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0 ) {
			break;
		}
		int count = 0;
		if (y1 == y2) {
			if (m1 != m2) {
				for (int i = m1+1; i < m2; i++) {
					count += month[w_month(i, y1)];
				}
				count += d2;
				count += month[w_month(m1, y1)]-d1;
			} else {
				count = d2-d1;
			}
		} else {
			if (y2 - y1 > 1) {
				count += year * (y2-y1-1);
				for (int i = y1+1; i <= y2-1; i++) {
					if (is_leap(i)) {
						count++;
					}
				}
			}
			for (int i = m1+1; i < 13; i++) {
				count += month[w_month(i, y1)];
			}
			for (int i = 1; i < m2; i++) {
				count += month[w_month(i, y2)];
			}
			count += d2;
			count += month[w_month(m1, y1)]-d1;
		}
		cout << count << endl;
	}
	return 0;
}

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

int main()
{
    int H, W, K;
    cin >> H >> W >> K;

    vector<string> S(H);
    for (int h = 0; h < H; h++)
    {
        cin >> S.at(h);
    }

    int res = INT_MAX;
    for (int selection = 0; selection < (1 << H - 1); selection++)
    {
        int selected_h = __builtin_popcount(selection);

        int selected_w = 0;
        bool invalid = false;
        vector<int> cnt(selected_h + 1, 0);
        for (int w = 0; w < W; w++)
        {
            int g = 0;
            vector<int> cnt_w(selected_h + 1, 0);
            for (int h = 0; h < H; h++)
            {
                if (S.at(h).at(w) == '1')
                {
                    cnt_w.at(g) += 1;
                }
                if ((selection >> h) & 1)
                {
                    g++;
                }
            }

            for (int g = 0; g < selected_h + 1; g++)
            {
                if (cnt_w.at(g) > K)
                {
                    invalid = true;
                }
                cnt.at(g) += cnt_w.at(g);
                if (cnt.at(g) > K)
                {
                    selected_w++;
                    for (int i = 0; i < selected_h + 1; i++)
                    {
                        cnt.at(i) = cnt_w.at(i);
                    }
                    break;
                }
            }

            if (invalid)
            {
                break;
            }
        }

        if (!invalid && selected_h + selected_w < res)
        {
            res = selected_h + selected_w;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc140/tasks/abc140_f>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> S(1<<N); for(auto& in:S) cin >> in;
    sort(S.rbegin(),S.rend());
    
    vector<ll> slimes,t_slimes;
    slimes.push_back(S[0]);
    
    multiset<ll> T;
    for(int i = 1; i < (1<<N);i++) T.insert(S[i]);
    
    for(int i = 0; i < N;i++){
        t_slimes = slimes;
        for(auto v:slimes){
            auto it = T.lower_bound(v);
            if(it == T.begin()){
                return "No";
            }
            it--;
            t_slimes.push_back(*it);
            T.erase(it);
        }
        slimes = t_slimes;
        sort(slimes.begin(),slimes.end());
    }
    return "Yes";
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 16760
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

n=gets.to_i
N=n
if n==1
    puts 0
else
    primes=[]
    2.upto((n**0.5).to_i+1) do|i|
      while (n%i).zero?
          primes.push(i)
          n/=i
      end
    end
    primes.push(n) if n!=1
    primes.uniq!
    ans=N.to_f
    primes.each do|p_|
        ans*=((p_-1).to_f/p_.to_f).to_f
    end
    puts ans.to_i
end


Measured memory_bytes: 6924
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <stack>
#include <queue>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define ll long long
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    string s;
    int k;
    cin >> s;
    cin >> k;
    int len = s.size();
    int ans=0;
    rep(i,len){
        if(s[i]!='1'){
            ans=(int)(s[i]-'0');
            if(k>i){
                cout << ans << endl;
                return 0;
            }
            break;
        }
    }
    cout << 1 << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (i != p[i-1]) cnt++;
    }
    if (cnt <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3604
//
// Created on 2020/02/09.
//

//#include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;
using gragh = vector<vector<int>>;

int main() {
    int n;
    cin>>n;
    map<ll,int>mp;

    for (int i = 0; i < n; ++i) {
        int temp;
        cin>>temp;

        if(mp[temp]!= 0){
          cout<<"NO"<<endl;
          return 0;
        }
        mp[temp] ++;
    }
    cout<<"YES"<<endl;

}


Measured memory_bytes: 12800
// AOJ 2809: Graduation Ceremony
// 2018.1.4 bal4u@uu

#include <stdio.h>

#define min(a,b) ((a)<=(b)?(a):(b))
#define max(a,b) ((a)>=(b)?(a):(b))

#define MAX 2002

char s[MAX];
short u[MAX], d[MAX], l[MAX], r[MAX];
int dx[4] = { 0,1,0,-1};	// URDL
int dy[4] = {-1,0,1, 0};
int tr['Z'];

int main()
{
	int k, i, j, j2, dir, ans;
	char *p;

	tr['U'] = 0, tr['R'] = 1, tr['D'] = 2, tr['L'] = 3;

	scanf("%s%d", s, &k);
	p = s; while (*p) {
		dir = tr[*p++];
		j2 = j = k; while (j--) {
			u[j2] = min(-d[j], u[j2]) + dy[dir];
			r[j2] = max(-l[j], r[j2]) + dx[dir];
			d[j2] = max(-u[j], d[j2]) + dy[dir];
			l[j2] = min(-r[j], l[j2]) + dx[dir];
			j2--;
		}
		l[0] += dx[dir], r[0] = l[0];
		d[0] += dy[dir], u[0] = d[0];
	}
	ans = 0;
	for (i = 0; i <= k; i++) {
		j  = -l[i];   if (j  < r[i  ]) j  = r[i];
		j2 = -u[k-i]; if (j2 < d[k-i]) j2 = d[k-i];
		j += j2;
		if (j > ans) ans = j;
	}
	printf("%d\n", ans);
	return 0;
}



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

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

  ll r = 0;
  vector<ll> v(n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) v[j]++;
    r += i * v[i];
  }
  cout << r << endl;
}


Measured memory_bytes: 81396
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;

string l;
int cnt, s[110000];

ll mpow(ll base, ll power) {
    if (power == 0) return 1;
    ll t = mpow(base, power / 2);
    return (t * t * (power % 2 ? base : 1)) % mod;
}

int main() {
    cin >> l;
    ll r = 0, n = l.length();
    for (auto &e:l)if (e == '1') cnt++;
    for (int i = 1; i < n; i++) {
        s[i] = s[i - 1] + (l[i - 1] == '1' ? 1 : 0);
    }
    for (int i = 0; i < n; i++) {
        if (l[i] == '1') {
            r = (r + mpow(3, n - (i + 1)) * mpow(2, s[i])) % mod;
        }
    }
    r = (r + mpow(2, cnt)) % mod;
    cout << r << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <algorithm>

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

typedef long long int lli;

inline int min(int x, int y) {return x < y ? x : y;}
inline long min(long x, long y) {return x < y ? x : y;}
inline int max(int x, int y) {return x > y ? x : y;}
inline long max(long x, long y) {return x > y ? x : y;}

inline void swap(int &a, int &b) {
    int tmp = a;
    a = b;
    b = tmp;
}

inline int euclid(int a, int b) {
    if (a > b) swap(a, b);
    int r = a % b;
    while (r > 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

using namespace std;
class UnionFindWithSize {
    public:
        UnionFindWithSize(int N) : parent(N, -1) {}
        void unite(int x, int y) {
            x = find(x);
            y = find(y);
            if (x == y) return;
            if (parent[x] > parent[y]) swap(x, y);
            parent[x] += parent[y];
            parent[y] = x;
        }
        int find(int x) {
            if (parent[x] < 0) return x;
            return parent[x] = find(parent[x]);
        }
        int size(int x) {
            return -parent[find(x)];
        }
    private:
        vector<int> parent;
};;

// ( ´･ω･)( ´･ω)ぐる( ´･)( ´)ぐる( )(` )ぐる(･` )(ω･` )ぐる(･ω

lli func(lli x) {
    if (x & 1)
        return (x + 1) / 2 % 2;
    return (x / 2 % 2) ^ x;
}

signed main() {
    lli A, B;
    cin >> A >> B;
    cout << (func(A - 1) ^ func(B)) << endl;
}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int a, b;
    cin >> a >> b;
    if(a < b) swap(a, b);
    for(int i=0;i<a;i++) cout << b;
    cout << "\n";
    return 0;
}



Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }

//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL A, B;
	cin >> A >> B;

	O(A * B - 1 * A - 1 * B + 1 * 1);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int min=1000000,count=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]<min)
		{
			min=a[i];
			count++;
		}
	}
	cout<<count;
	return 0;
}

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

using Graph = vector<vector<pair<int, int>>>;
Graph G;
vector<int> color;

void dfs(int v, int cur = 0) {
    color[v] = cur;
    for (auto e : G[v]) {
        if (color[e.first] != -1) continue;
        if (e.first == v) continue;
        if (e.second % 2 == 0) {
            dfs(e.first, cur);
        }
        else dfs(e.first, 1-cur);
    }
}

int main() {
    int N;
    cin >> N;
    G.assign(N, vector<pair<int, int>>());
    color.assign(N, -1);

    for (int i = 0; i < N-1; i++) {
        int a, b, c; cin >> a >> b >> c; a--; b--;
        G[a].push_back(pair<int, int>(b, c));
        G[b].push_back(pair<int, int>(a, c));
    }

    dfs(0);

    for (int i = 0; i < N; i++) {
        cout << color[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int n;
    cin >> n;
    map <string, int> m;
    loop(i, n) {
        string s; cin >> s;
        ++m[s];
    }
    int cnt = 0;
    for (auto it : m)
        cnt = max(cnt, it.S);
    for (auto it : m)
        if (it.S == cnt)
            cout << it.F << "\n";
}

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

Measured memory_bytes: 19216
#include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define Test(){int t;cin >> t;for(int i=1;i<=t;i++){cout << "Case #" << i << ": ";solve();}}
        #define test(){int t; cin>>t; for(int i=1;i<=t;i++){solve();}}
        #define vi vector<int>
        #define vii vector<pair<int,int> > 
        #define vci vector<pair<char,int> >
        #define vic vector<pair<int,char> > 
        #define N 200005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
	
		void solve()
		{
			int n,x,t;
			cin>>n>>x>>t;
			
			int p=n/x;
			if(n%x)
			p++;
			
			cout<<p*t;
		}
		signed main()
		{
		//	test();
		solve();
		}

Measured memory_bytes: 3592
S,T=input().split()
A,B = map(int,input().split())
U = input()
ans = ""
if U==S:
    A=A-1
    a=str(A)
    b=str(B)
    ans = a+" "+b
    print(ans)
else:
    B-=1
    a=str(A)
    b=str(B)
    ans=a+" "+b
    print(ans)

Measured memory_bytes: 3060
import sys 
# try:
# 	sys.stdin = open('input.txt', 'r') 
# 	sys.stdout = open('output.txt', 'w')
# except:
# 	pass

def GCD(p,q):
	if (p%q==0):
		return q
	return GCD(q,p%q)
s = 0
k = int(sys.stdin.readline())
for i in range(1,k+1):
	for j in range(1,k+1):
		for m in range(1,k+1):
			s += GCD(GCD(i,j),m)
sys.stdout.write(str(s))

Measured memory_bytes: 74336
using System;
using System.Text;

namespace AOJ.Volume0
{
    public class GoldbachConjecture
    {
        public static int Main()
        {
            // 50000??\???????´???°??????????????????
            var prime = new bool[50001];
            prime[0] = false;
            prime[1] = false;
            prime[2] = true;
            for(int i = 3; i <= 50000; i = i + 2)
            {
                bool is_prime = true;
                int sqrt = (int)Math.Sqrt(i);
                for (int j = sqrt; j > 1; j--)
                {
                    if (i % j == 0)
                    {
                        is_prime = false;
                        break;
                    }
                }

                if (is_prime) { prime[i] = true; }
                else { prime[i] = false; }
            }

            var output = new StringBuilder();
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) { break; }

                int ans = 0;
                // n??????????????§?????????
                for(int i = 2; i <= n / 2; i++)
                {
                    // ?´???°??§????????´??????????????????
                    if (!prime[i]) { continue; }
                    // ???????´???°?????´??????????????????
                    if (prime[n - i]) { ans++; }
                }
                output.AppendLine(ans.ToString());
            }

            Console.Write(output);
            return 0;
        }
    }
}

Measured memory_bytes: 9536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
    IOS();
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << max({a*c,b*c,a*d,b*d}) << endl;
}


Measured memory_bytes: 3644
N, K = map(int, input().split())
p = list(map(int, input().split()))

E = [(i + 1)/2 for i in p]
S = sum(E[0:K])
ans = S
for i in range(1, N - K + 1):
    S += E[i+K-1] - E[i-1]
    if ans < S:
        ans = S
print(ans)

Measured memory_bytes: 25604
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            var leftDic = new Dictionary<int, int>();
            var rightDic = new Dictionary<int, int>();
            var All = new Dictionary<int, int>();

            for (int i = 0; i < n; i++)
            {
                //left
                if(i%2 == 0)
                {
                    if (!leftDic.ContainsKey(s[i])) leftDic[s[i]] = 1;
                    else{
                        leftDic[s[i]]++;
                    }
                }
                else
                {
                    if (!rightDic.ContainsKey(s[i])) rightDic[s[i]] = 1;
                    else
                    {
                       rightDic[s[i]]++;
                    }
                }

                if (!All.ContainsKey(s[i])) All[s[i]] = 1;
                else
                {
                    All[s[i]]++;
                }
            }
            var sortedLeftDic = leftDic.OrderByDescending(x => x.Value).ToArray();
            var sortedRightDic = rightDic.OrderByDescending(x => x.Value).ToArray();



            //判定
            if(All.Count == 1) { WriteLine(n / 2);return;}

            if (sortedLeftDic[0].Key == sortedRightDic[0].Key)
            {
                WriteLine(
                    n - (Max(sortedLeftDic[0].Value, sortedRightDic[0].Value) + Max(sortedLeftDic[1].Value, sortedRightDic[1].Value))
                    );
            }else
                WriteLine(
                    n - (sortedLeftDic[0].Value + sortedRightDic[0].Value)
                    );

        }
    }
}


Measured memory_bytes: 29152
import java.util.Scanner;

public class Main {
    public static boolean[][][] visited;

    public static double sushi(double[][][] dp, int i, int j, int k, int N) {
        if(i <=0 && j <= 0 && k <= 0) {
            return 0;
        }

        if(visited[i][j][k]) {
            return dp[i][j][k];
        }

        visited[i][j][k] = true;

        double sum = i+j+k;
        dp[i][j][k] = N/sum;
        if(i > 0) {
            double r1;
            r1 = sushi(dp, i-1, j, k, N);
            r1 = r1 * i / sum;
            dp[i][j][k] += r1;
        }
        if(j > 0) {
            double r2;
            r2 = sushi(dp, i+1, j-1, k, N);
            r2 = r2 * j / sum;
            dp[i][j][k] += r2;
        }
        if(k > 0) {
            double r3;
            r3 = sushi(dp, i, j+1, k-1, N);
            r3 = r3 * k / sum;
            dp[i][j][k] += r3;
        }

        return dp[i][j][k];
    }

    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int N = sc.nextInt();
        double[][][] dp;

        int[] a = new int[Math.max(N+1, 3+1)];

        for(int i=0; i<N; ++i) {
            int t = sc.nextInt();
            a[t]++;
        }

        int fromA3 = a[3];
        int fromA23 = a[2] + fromA3;
        dp = new double[a[1]+1+fromA23][a[2]+1+fromA3][a[3]+1];
        visited = new boolean[a[1]+1+fromA23][a[2]+1+fromA3][a[3]+1];

        double r = sushi(dp, a[1], a[2], a[3], N);
        System.out.printf("%.10f\n", r);
    }
}


Measured memory_bytes: 307744
n=int(input())
ns=list(map(int,input().split()))
ans=0
for i in range(n):
    minj=i
    for j in range(i,n):
        if(ns[j]<ns[minj]):
            minj=j
    if i!=minj:
        ans+=1
        k=ns[i]
        ns[i]=ns[minj]
        ns[minj]=k
 
for i in range(n):
    if(i!=n-1):
        print(ns[i],end=' ')
print(ns[n-1])
print(ans)


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

const int mxN = 4000;

int n;
double p[mxN];
double dp[mxN][mxN];

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }

    cin >> n;
    for (int i = 1; i <= n; i++) cin >> p[i];

    dp[0][0] = 1.0;

    for (int h = 0; h <= n; h++) {
        for (int t = 0; t <= n; t++) {
            if (h+t >= n) continue;

            if (h+1 <= n && h+t+1 <= n) dp[h+1][t] = dp[h+1][t] + (dp[h][t] * p[h+t+1]);
            if (t+1 <= n && h+t+1 <= n) dp[h][t+1] = dp[h][t+1] + (dp[h][t] * (1.0 - p[h+t+1]));
        }
    }

    double ans = 0.0;
    for (int h = 0; h <= n; h++) {
        int t = n-h;
        if (h > t) ans += dp[h][t];
    }

    cout << setprecision(15) << ans << endl;

    return 0;
}

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

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int x[101];
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }

    int mn = 987654321;
    for (int i = 1; i <= 100; i++) {
        int sum = 0;
        for (int j = 0; j < n; j++) {
            sum += (i - x[j]) * (i - x[j]);
        }
        mn = min(mn, sum);
    }

    cout << mn << '\n';

    return 0;
}


Measured memory_bytes: 256