akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#define endl "\n"
#define whats(x) cout<<#x<<" is: "<<x<<endl;
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int heights[n];
    int costs[n];
    for(int i=0; i<n; ++i)
        cin>>heights[i];
    costs[0]=0;
    costs[1]=abs(heights[1]-heights[0]);
    for(int i=2; i<n; ++i){
        costs[i]=min(abs(heights[i]-heights[i-1])+costs[i-1], abs(heights[i]-heights[i-2])+costs[i-2]);
    }
    cout<<costs[n-1]<<endl;
    return 0;
}


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

int main(int argc, char const *argv[])
{
  int N, M, len = 0;
  scanf("%d %d", &N, &M);
  if (N > M) {
    printf("0\n");
    exit(0);
  }

  int dest[M], space[M-1];
  for (int i = 0; i < M; ++i) scanf("%d", &(dest[i]));
  std::sort(dest, dest + M);

  for (int i = 0; i < M-1; ++i) space[i] = dest[i+1] - dest[i];
  std::sort(space, space + M-1);
  std::reverse(space, space + M-1);

  for (int i = 0; i < N-1; ++i) len += space[i];
  printf("%d\n", dest[M-1] - dest[0] - len);

  return 0;
}


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

int main(){
	/*input*/
	int k;	cin >> k;
	/*calculation*/
	int o = 0, e = 0;
	for(int i = 1; i <= k; i++){
		switch(i%2){
			case 0:
			e++;
			break;
			case 1:
			o++;
			break;
		}
	}
	/*output*/
	cout << o*e << endl;
}


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

int main(){
  long long H, W, ans = 0;
  cin >> H >> W;
  if((H == 1) || (W == 1)){
    cout << 1 << endl;
    return 0;
  }

  if((H % 2) && (W % 2)){
    cout << (H * W) / 2 + 1 << endl;
  }else{
    cout << H * W / 2 << endl;
  }
}

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

using namespace std;

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

  while (true) {
    int n, x;
    cin >> n >> x;

    if (!n && !x) {
      break;
    }

    int ans = 0;
    for (int a = 1; a <= n; a++) {
      for (int b = a + 1; b <= n; b++) {
        for (int c = b + 1; c <= n; c++) {
          if (a + b + c == x) {
            ans++;
          }
        }
      }
    }
    cout << ans << "\n";
  }

  return 0;
}


Measured memory_bytes: 3152
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n, k; cin >> n >> k;
    ll res = 0;
    rep(i, n){
        ll b = i+1;
        ll num = (max(0LL, b - k)) * (n / b) + max(0LL, (n % b) - k + 1);
        res += min(num, (ll)n);
    }
    cout << res << ln;
}
    



Measured memory_bytes: 3544
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int w[300001];
int e[300001];
int main() {
    int n;
    string s;
    cin >> n >> s;
    reps(i, n - 1){
        if(s[i-1] == 'W')
            w[i] = w[i-1] + 1;
        else 
            w[i] = w[i-1];
    }
    for(int i = n - 2; i >= 0; i--){
        if(s[i+1] == 'E')
            e[i] = e[i+1] + 1;
        else
            e[i] = e[i+1];
    }
    int mn = 1 << 30;
    rep(i, n){
        mn = min(mn, w[i]+e[i]);
    }
    cout << mn << endl;
}


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

double length( double x1, double y1, double x2, double y2 )
{
    return sqrt( pow( x1 - x2, 2 ) + pow( y1 - y2, 2 ) );
}

double calculate_surface_area( double a, double b, double c )
{
    double co, si;
    co = ( a * a - b * b - c * c ) / ( -2 * b * c );
    si = sqrt( 1 - co * co );
    return 0.5 * b * c * si;
}

int main()
{
    double xa, ya, xb, yb, xc, yc, xd, yd;
    char p;
    while( cin >> xa >> p >> ya >> p >> xb >> p >> yb >> p >> xc >> p >> yc >> p >> xd >> p >> yd )
    {
        double ab = length( xa, ya, xb, yb ), bc = length( xb, yb, xc, yc ), ca = length( xc, yc, xa, ya );
        double ad = length( xa, ya, xd, yd ), bd = length( xb, yb, xd, yd ), cd = length( xc, yc, xd, yd );

        double square = calculate_surface_area( bc, ca, ab ) + calculate_surface_area( ca, ad, cd);
        double tabc = calculate_surface_area( bc, ca, ab );
        double tbcd = calculate_surface_area( cd, bd, bc );
        double tcda = calculate_surface_area( cd, ad, ca );
        double tdab = calculate_surface_area( bd, ad, ab );

        //（正解）四角形abcdにおいて、abc+adc = abd + bdcであれば、窪みが無いといえる。
        if( fabs( tabc + tcda - tdab - tbcd ) < 0.0000001 )
            cout << "YES" << endl;
        else
            cout << "NO" << endl;

        //（誤り）四角形の面積が、三点を選んでできたどんな三角形の面積より大きいならば、凹みが無い。
        //三角形abcが窪んでいるところで、四角形の面積を表さない時、これは成立しないので誤り。
    }       
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    int n, l;
    cin >> n >> l;
    vector<string> vec;
    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        vec.push_back(s);
    }
    sort(vec.begin(), vec.end());
    for (int i = 0; i < n; i++) {
        cout << vec[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, q;
	string s;
	cin >> n >> q >> s;
	
	vector<int> l(q), r(q);
	for(int i = 0; i < q; ++i) {
		cin >> l[i] >> r[i];
		l[i]--;
		r[i]--;
	}
	
	vector<int> sum(n + 1, 0);
	int cnt = 0;
	for(int i = 0; i < n - 1; ++i) {
		//sum[i + 1] = sum[i] + (s.substr(i, 2) == "AC");
		if( s[i] == 'A' && s[i + 1] == 'C' ) cnt++;
		
		sum[i + 1] = sum[i] + cnt;
		cnt = 0;
	}
	
	for(int i = 0; i < q; ++i) {
		cout << sum[r[i]] - sum[l[i]] << endl;
	}

	return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}/*swap 交換*/
ll max2(ll a,ll b){return a>=b?a:b;}/*2つのうち大きい数を返す*/ 
ll min2(ll a,ll b){return a>=b?b:a;}/*2つのうち小さい数を返す*/ 
ll ABS(ll a){return a>=0?a:(-a);}/*絶対値*/ 
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    ll n,ans=0;
    scanf("%lld",&n);
    ll a=11;
    ans=n/a*2;
    if(n%a<=6&&n%a!=0){
        ans++;
    }
    if(n%a>=7){
        ans+=2;
    }
    // if(n%a<=12 && n%a>=10){
    //     ans+=3;
    // }
    // if(n%a>=11 ){
    //     ans+=4;
    // }
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
const int N=100000+10;
int par[N],rankk[N];
void init(int n)
{
	for(int i=1;i<=n;i++)par[i]=i;
}
int find(int x)
{
	return x==par[x]?x:par[x]=find(par[x]);
}
void joint(int x,int y)
{
	x=find(x);
	y=find(y);
	if(x==y)return;
	if(rankk[x]<rankk[y]){
		par[x]=y;
	}
	else{
		par[y]=x;
		if(rankk[x]==rankk[y])rankk[x]++;
	}
}
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,x,y,v;
    cin>>n>>m;
    init(n);
    while(m--){
    	cin>>x>>y>>v;
    	joint(x,y);
    }
    int ans=0;
    for(int i=1;i<=n;i++)if(find(i)!=0){
    	par[find(i)]=0;
    	ans++;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3


def main() -> None:
    N = ri()
    a = rmi()
    assert len(a) == N
    result = []
    all_xor = 0
    for item in a:
        all_xor ^= item
    for item in a:
        result.append(item ^ all_xor)
    w(' '.join(map(str, result)))


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10 ** 9)
    main()


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

int p, q, a, n;
int seek(int pp, int qq, int aa, int nn) {
	if (p*qq == pp*q) return 1;
	if (p*qq < pp*q) return 0;
	if (nn == n) return 0;

	int count = 0;
	for (int i = aa; i*qq <= a; i++){
		count += seek(qq + pp*i, i*qq, i, nn+1);
	}

	return count;
}

int main()
{
	while (cin >> p >> q >> a >> n, p || q || a || n) {
		cout << seek(0, 1, 1, 0) << endl;
	}
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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


    ll sum = 0;
    for(int i=0; i<n; i++){
        ll c; cin >> c;
        sum += c;
        mp[sum%m]++;
    }
    mp[0]++;

    ll ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(itr->second > 1){
            ans += (itr->second) * (itr->second - 1) / 2;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;
using pli = pair<long long, int>;
using vpli = vector<pli>;

int main() {
  string S;
  cin >> S;
  int len = S.size();
  long long ans = 0;
  string temp = "";
  
  for (int i = 0; i < (1 << len-1); i++) {
    bitset<9> bs(i);
    temp = S.at(0);
    
    for (int j = len-1; j > 0; j--) {
      if (bs.test(j-1) == 1) {
        ans += stoll(temp);
        temp = "";
      }
      temp += S.at(len-j);      
    }

    ans += stoll(temp);
  }
  
  cout << ans << endl;
  
}

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

ll n;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    print(n*(n-1)/2);
}

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



int main() {
    int N,K;
    cin>>N>>K;
    int ans=0;
    rep(i,N){
        int h;
        cin>>h;
        if(h>=K){ans++;}
    }
    cout<<ans<<endl;
}

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

typedef long long ll;
#define gc getchar()
inline int read(){
	int x=0,f=1;char c=gc;
	for(;c<48||c>57;c=gc)
		if(c=='-')f=-1;
	for(;c>47&&c<58;c=gc)
		x=x*10+c-48;
	return x*f;
}
#define io read()

#define maxn 200005
int n,a[maxn],fl=1;

inline void init(){
	n=io;
	for(int i=1;i<=n;++i)a[i]=io;
	for(int i=1;i<=n;++i)
		if(a[i]>i-1||a[i]-a[i-1]>1){fl=0;break;}
}

ll ans;
inline void solve(){
	if(!fl){puts("-1");return;}
	for(int i=1;i<=n;++i){
		if(a[i+1]!=a[i]+1)ans+=a[i];
	}
	printf("%lld\n",ans);
}

int main(){
	init();
	solve();
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int num;
  int res = 10000000;
  for (int i = 0; i <= (int)s.size() - 3; i++) {
    num = (s.at(i) - '0') * 100 + (s.at(i + 1) - '0') * 10 + (s.at(i + 2) - '0');
    res = min(res, abs(num - 753));
  }
  cout << res << endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  long long la,lb;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a >> b;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------
  ans = a+b;
  if(a-b>ans) ans = a-b;
  if(a*b>ans) ans = a*b;
  //else ans = c-a;

  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  ll k,x;
  cin>>k>>x;
  if(500*k>=x){
cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


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

using namespace std;

long long int dp[105][100005];

vector<long long int> weights;
vector<long long int> values; 

long long int knapSack(long long int W,long long int n){
  long long int i,j;
  for(i=0;i<=n;i++){
    for(j=0;j<=W;j++){
      if(i==0 || j==0){
        dp[i][j] = 0;
      }
      else if(weights[i-1] <= j){
        dp[i][j] = max(values[i-1] + dp[i-1][j-weights[i-1]],dp[i-1][j]);
      }
      else{
        dp[i][j] = dp[i-1][j];
      }
    }
  }
  return dp[n][W];
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n,W,i,j,x,y;
  cin>>n>>W;
  for(i=0;i<n;i++){
    cin>>x>>y;
    weights.push_back(x);
    values.push_back(y);
  }
  long long int ans = knapSack(W,n);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 80128
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
double f[1005][1005],dis[1005],a[1005][3];
bool b[1005];
int main()
{
    int i,j,k,n;
    double xi,xs,ys,xt,yt;
    scanf("%lf%lf%lf%lf",&xs,&ys,&xt,&yt);
    scanf("%d",&n);
    a[0][0]=xs;a[0][1]=ys;a[0][2]=0;
    a[n+1][0]=xt;a[n+1][1]=yt;a[n+1][2]=0;
    for(i=1;i<=n;i++)
        scanf("%lf%lf%lf",&a[i][0],&a[i][1],&a[i][2]);
    for(i=0;i<=n+1;i++)
        for(j=i+1;j<=n+1;j++)
            f[i][j]=f[j][i]=max(0.0,sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1]))-a[i][2]-a[j][2]);//
    fill(dis,dis+1005,1e18);//
    dis[0]=0;
    for(i=0;i<=n+1;i++){
        xi=1e18;//
        k=0;
        for(j=0;j<=n+1;j++){
            if(b[j]==0&&dis[j]<xi){
                xi=dis[j];
                k=j;
            }
        }
        b[k]=1;
        for(j=0;j<=n+1;j++)
            dis[j]=min(dis[j],dis[k]+f[k][j]);
    }
    printf("%.9lf\n",dis[n+1]);//
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
const int MAX = 1000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long 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] % MOD) % MOD;
}
int main() {
  COMinit();
  long long n,k;cin>>n>>k;k=min(k,n-1);
  long long ans=0;
  for(long long i=0;i<=k;i++)ans=(ans+COM(n,i)*COM(n-1,i)%MOD)%MOD;
  cout<<ans;
}



Measured memory_bytes: 23680
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String[] cs = sc.nextLine().split(" ");
        String[] cfb = cs.clone();
        for (int i = 0; i < cfb.length; i++) {
            for (int j = cfb.length - 1; j > i; j--) {
                int vj = Integer.parseInt(cfb[j].substring(1));
                int vj_1 = Integer.parseInt(cfb[j - 1].substring(1));
                if (vj_1 > vj) {
                    String tmp = cfb[j];
                    cfb[j] = cfb[j - 1];
                    cfb[j - 1] = tmp;
                }
            }
        }
        System.out.println(Stream.of(cfb).collect(Collectors.joining(" ")));
        // Because Bubble sort is stable sort
        System.out.println("Stable");
        String[] cfs = cs.clone();
        for (int i = 0; i < cfs.length; i++) {
            int minj = i;
            for (int j = i; j < cfs.length; j++) {
                int vminj = Integer.parseInt(cfs[minj].substring(1));
                int vj = Integer.parseInt(cfs[j].substring(1));
                if (vminj > vj) {
                    minj = j;
                }
            }
            if (minj != i) {
                String tmp = cfs[minj];
                cfs[minj] = cfs[i];
                cfs[i] = tmp;
            }
        }
        System.out.println(Stream.of(cfs).collect(Collectors.joining(" ")));
        boolean isStable = true;
        for (int i = 0; i < cfb.length; i++) {
            if (cfb[i] != cfs[i]) {
                isStable = false;
                break;
            }
        }
        if (isStable) {
            System.out.println("Stable");
        } else {
            System.out.println("Not stable");
        }
    }
}




Measured memory_bytes: 32672
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
top1 = 0
top2 = 0
c = Counter()

for a in A:
    c[a] += 1
    if c[a] % 2 == 0:
        L = [a, top1, top2]
        L.sort()
        top1 = L[2]
        top2 = L[1]
print(top1 * top2)


Measured memory_bytes: 18600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int s[1000];
int top;

void initialize(){
	top = 0;
}

int isEmpty(){
	return top == 0;
}

int isFull(){
	return top > 1000;
}

void push(int x){
	if(isFull()){
		exit(1);
	}
	top++;
	s[top] = x;
}

int pop(){
	if(isEmpty()){
		exit(0);	
	};
	top--;
	return s[top+1];
}

int main(void){
	int a,b,top=0;
	char str[10];
	while((scanf("%s",str)!=EOF)){
		if((strcmp(str,"+"))==0){
			a = pop();
			b = pop();
			push(b+a);
		}else if((strcmp(str,"-"))==0){
			a = pop();
			b = pop();
			push(b-a);
		}else if((strcmp(str,"*"))==0){
			a = pop();
			b = pop();
			push(b*a);
		}else{
			push(atoi(str));
		}
	}
	printf("%d\n",pop());
	return 0;
}


Measured memory_bytes: 2056
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

int N, M;
int tx[5000], ty[5000];

int acc[5002][5002] = {};
int cx[5000], cy[5000];

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

    cin >> N >> M;
    for (int j = 0; j < N; ++j) {
        cin >> tx[j] >> ty[j];
    }

    // initialize
    for (int j = 0; j <= N; ++j) fill(acc[j], acc[j]+N+1, 0);

    copy(tx, tx+N, cx); sort(cx, cx+N);
    copy(ty, ty+N, cy); sort(cy, cy+N);

    for (int j = 0; j < N; ++j) {
        int xx = lower_bound(cx, cx+N, tx[j]) - cx;
        int yy = lower_bound(cy, cy+N, ty[j]) - cy;
        ++ acc[xx+1][yy+1];
    }

    for (int j = 1; j <= N; ++j) {
        for (int k = 1; k <= N; ++k) {
            acc[j][k] += acc[j-1][k] + acc[j][k-1] - acc[j-1][k-1];
        }
    }

    for (int j = 0; j < M; ++j) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;

        int ix1 = lower_bound(cx, cx+N, x1) - cx + 1;
        int ix2 = upper_bound(cx, cx+N, x2) - cx;
        int iy1 = lower_bound(cy, cy+N, y1) - cy + 1;
        int iy2 = upper_bound(cy, cy+N, y2) - cy;

        cout << acc[ix2][iy2] - acc[ix1-1][iy2] - acc[ix2][iy1-1] + acc[ix1-1][iy1-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 101008
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  int a,b,c;cin>>a>>b>>c;
  /*if(abs(a-b)==abs(b-c)){
    cout << "YES";
  }else{
    cout << "NO";
  }*/
  cout << (b+a)%24;
}


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

int main()
{
    string str,str1,str2;
    cin>> str;
    
    str1 = str.substr(0,2);
    str2 = str.substr(2,2);
  
    if (stoi(str1)<=12 && stoi(str1)>0 && stoi(str2)<=12 && stoi(str2)>0)
        cout<<"AMBIGUOUS";   
    else if(stoi(str1)<=12 && stoi(str1)>0)
        cout<<"MMYY";
    else if(stoi(str2)<=12 && stoi(str2)>0)
        cout<<"YYMM";
    else
        cout<<"NA";
   
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i;
	    String str = sc.nextLine();
	    char[] strArray = str.toCharArray();
	    int a = strArray.length;
        for(i = a - 1; i >= 0; i--) {
        	System.out.print(strArray[i]);
        }
        System.out.println();
        sc.close();
    }
}


Measured memory_bytes: 26132
#include <bits/stdc++.h>
#define MAXS 500007
#define INF 2147483647
 
#define mp(a, b) make_pair(a,b)
#define pb(a) push_back(a)
#define INP freopen("input.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
#define STREE int bch = no*2, mid = (l+r)/2
#define ALL(a) a.begin(), a.end()
 
using namespace std;
typedef long long ll;
typedef vector < int > vi;
typedef pair < int, int > pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());




int n; 
int arr[MAXS][3];
int dp[MAXS][3];

ll solve(int d, int c){
  if(dp[d][c] != -1) return dp[d][c];
  if(d >= n) return 0;
  if(c == 0) return dp[d][c] = max(solve(d+1, 1), solve(d+1, 2)) +arr[d][c];
  else if(c==1) return dp[d][c] = max(solve(d+1, 0), solve(d+1, 2)) + arr[d][c];
  else return dp[d][c] = max(solve(d+1, 0)+arr[d][c], solve(d+1, 1)+arr[d][c]);
}


int main(){
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
  }
  memset(dp, -1, sizeof dp);
  solve(0, 0); solve(0, 1), solve(0, 2);
  cout << max(max(dp[0][0], dp[0][1]), dp[0][2]);
}

Measured memory_bytes: 11520
#!/usr/bin/env python3

import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

x = int(readline())

q = (x + 10) // 11
tot = 0
if 11 * q - x >= 5:
    tot -= 1

tot += q * 2
print(tot)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

//公約数
int gcd(int a, int b){
  if(a == 0 || b == 0)return max(a, b);
  if(a == b)return a;
  if(a > b)a = a%b;
	else b = b%a;
  return gcd(a, b);
}

const int MAX = 200000;
int a[MAX], dp[2][MAX];

signed main(){
  int n;cin >> n;
  rrep(i,n)cin >> a[i];
  dp[0][1] = a[1];dp[1][n] = a[n];
  repi(i,2,n+1)dp[0][i] = gcd(dp[0][i-1], a[i]);
  drep(i,n-1,1)dp[1][i] = gcd(dp[1][i+1], a[i]);
  int ans = 1;
  rrep(i,n)ans = max(ans, gcd(dp[0][i-1], dp[1][i+1]));
  cout << ans << endl;
  return 0;
}






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

vector<bool> pt;

void MakeTable(int n){
  pt.resize(++n);
  pt[0] = pt[1] = false;pt[2] = true;
  
  int i = 2;
  while(++i<n)pt[i] = i&1;
  
  i = 3;
  while(i*i<n){
    for(int j=3*i;j<n;j+=2*i)pt[j]=false;
    do{i+=2;}while(!pt[i]);
  }
}

int main(){
  int n,ans;
  MakeTable(50000);

  while(1){
    cin >> n;
    if(!n)break;

    ans = 0;
    for(int i=0;i<=n/2;i++)
      if(pt[i] && pt[n-i])ans++;
    cout << ans << endl;
  }
}
	

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

#define ll long long
#define pb push_back
#define INF 1e9+7
#define cases int t;cin>>t;while(t--)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define ff first
#define ss second

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	string s,t;
	cin>>s>>t;
	ll cnt=0;
	rep(i,0,s.size()){
		if(s[i]!=t[i])
			cnt++;
	}
	cout<<cnt;
	
	
	
	return 0;
}

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

using namespace std;

int main(int argc, const char *argv[])
{
  int k, x;
  cin >> k >> x;

  for (int i = x - k + 1; i <= x + k - 1; i++) {
    if (i != x - k + 1) {
      cout << " ";
    }

    cout << i;
  }

  cout << "\n";
  
  return 0;
}

Measured memory_bytes: 256
from collections import Counter, defaultdict, deque
import itertools 
import bisect
from sys import stdin, stdout
from itertools import repeat
import sys


# sys.stdin = open('input')
# sys.stdout = open('/mnt/d/Gg/output', 'w')
# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())




def main():
    n, a, b, c = map(int, raw_input().split())
    da = [a, b, c]
    ans = []
    query = []
    for i in range(n):
        query.append(raw_input().strip())
    
    def get(idx, x, y):
        if da[x]+da[y]==0:
            return
        if da[x]+da[y]==1:
            if da[x]==1:
                ans.append(query[idx][1])
                da[x] -= 1
                da[y] += 1
            else:
                ans.append(query[idx][0])
                da[y] -= 1
                da[x] += 1
            return 
        if da[x]==1 and da[y]==1 and idx < n-1:
            if query[idx][0] not in query[idx+1]:
                ans.append(query[idx][1])
                da[x] -= 1
                da[y] += 1
            else:
                ans.append(query[idx][0])
                da[y] -= 1
                da[x] += 1
            return
        if da[x]>da[y]:
            ans.append(query[idx][1])
            da[y] += 1
            da[x] -= 1 
        else:
            ans.append(query[idx][0])
            da[y] -= 1
            da[x] += 1 

    for i in range(n):
        if query[i] == 'AB':
            get(i, 0, 1)
        elif query[i] == 'AC':
            get(i, 0, 2)
        else:
            get(i, 1, 2)
    if len(ans) < n:
        print "No"
    else:
        print "Yes"
        print '\n'.join(ans)

    
# import time
# pre = time.time()
main()



Measured memory_bytes: 89064
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
int32_t main(){
	fastio();
	int n;
	cin >> n;
	string a , b;
	cin >> a >> b;
	string ans ;
	int l = 0, r = 0;
	 for(int i = 0;i < 2*n; i++){
	 	if(i%2) ans += b[r] ,r++;
	 	else ans +=a[l] ,l++;
	 }
	 cout << ans;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define cerr if(false) cerr
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(long long a, long long b, long long h){
	ll ans = (a+b)*h/2;
	cout << ans << endl;
}



int main(){	
	ios::sync_with_stdio(false);
	long long b;
	long long h;
	long long a;
	cin >> a;
	cin >> b;
	cin >> h;
	solve(a, b, h);
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iostream>
#include <vector>
using namespace std;

const int N = 1e6 + 7;
const int MOD = 1e9 + 7;

int n, p[N], nn[N];

int visit[N], lower[N], h[N];

int lowbit(int x) {
	return x & -x;
}

void ins(int pos) {
	for (int i = pos; i <= n; i += lowbit(i)) {
		h[i]++;
	}
}

int ask(int pos) {
	int ret = 0;
	for (int i = pos; i; i -= lowbit(i)) {
		ret += h[i];
	}
	return ret;
}

void add(int &a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	if (a < 0) a += MOD;
}

int calc(int x) {
	return 1LL * x * (x + 1) / 2 % MOD;
}

int main() {
	scanf("%d", &n);
	nn[0] = 1;
	for (int i = 1; i <= n; i++) {
		nn[i] = 1LL * nn[i - 1] * i % MOD;
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", &p[i]);
		if (p[i] != 0) {
			visit[p[i]] = 1;
		}
	}
	int sum = 0;
	vector<int> remain;
	for (int i = 1; i <= n; i++) {
		if (!visit[i]) {
			remain.push_back(i);
			add(sum, i - 1);
		}
		lower[i] = lower[i - 1] + !visit[i];
	}
	int ans = 0, k = 0;
	int ss = 0;
	for (int i = 1; i <= n; i++) {
		if (p[i] != 0) {
			add(ans, 1LL * nn[n - i] * (p[i] - 1) % MOD * nn[remain.size()] % MOD);
			int s = ask(p[i]);
			add(ans, -1LL * s * nn[n - i] % MOD * nn[remain.size()] % MOD);
			add(ans, -1LL * nn[n - i] * k % MOD * nn[remain.size() - 1] % MOD * lower[p[i]] % MOD);
			add(ss, lower[n] - lower[p[i]]);
			ins(p[i]);
		} else {
			k++;
			add(ans, 1LL * nn[n - i] * sum % MOD * nn[remain.size() - 1] % MOD);
			add(ans, -1LL * ss * nn[n - i] % MOD * nn[remain.size() - 1] % MOD);
			if (remain.size() > 1) {
				add(ans, -1LL * calc(remain.size() - 1) * (k - 1) % MOD * nn[remain.size() - 2] % MOD * nn[n - i] % MOD);
			}
		}
	}
	add(ans, nn[remain.size()]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 11888
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int q;
    cin >> q;
    set<int> st[26];
    for (int i = 0; i < n; i++) {
        st[s[i] - 'a'].insert(i);
    }
    while (q--) {
        int t, a;
        cin >> t >> a;
        if (t == 1) {
            char b;
            cin >> b;
            --a;
            st[s[a] - 'a'].erase(a);
            s[a] = b;
            st[s[a] - 'a'].insert(a);
        } else {
            int b;
            cin >> b;
            --a;
            --b;
            int res = 0;
            for (int i = 0; i < 26; i++) {
                auto it = st[i].lower_bound(a);
                if (it != st[i].end() && (*it) <= b) {
                    res++;
                }
            }
            cout << res << '\n';
        }
    }
}

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

int main() {
  uint64_t a, b;
  std::cin >> a >> b;

  const auto num = b - a + 1;
  std::vector<uint64_t> c(40);
  c[0] = 1;

  uint64_t ans = 0;

  for (uint64_t i = 0; i < 40; i++) {
    uint64_t bit = (a >> i) % 2;

    if (bit == 0) {
      c[i + 1] = c[i] + (static_cast<uint64_t>(1) << i);
    } else {
      c[i + 1] = c[i];
    }
    uint64_t t = static_cast<uint64_t>(1) << (i + 1);
    auto con = std::min(c[i], num % t);
    const auto reast = std::min(num % t - con, t / 2);
    con = num % t - reast;
    const auto po = num - num % t;

    const auto num = con * bit + reast * (1 - bit) + po / 2;
    if (num % 2 == 1) {
      ans += static_cast<uint64_t>(1) << i;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  int k, n;
  cin >> n >> k;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    v.push_back(c);
  }
  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = n-1; k > 0 ; i--) {
    k--;
    ans += v[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    stack<int> box1;
    box1.push(0);
    vector<int> box2(N);
    int res = 0;
    for(int i = 0; i < N; i++){
        cin >> box2[i];
    }
    
    for(int i = 0; i < N; i++){
        if(box1.top() + 1 == box2[i]){
            box1.push(box2[i]);
        }else{
            res+=1;
        }
    }
    
    if(res == N){
        cout << -1;
    } else{
        cout << res;
    }
}

Measured memory_bytes: 1792
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return x*f;
}

#define MAXN 100000
int N;
int A[MAXN+5];
long long Sum;

int main(){
	N=read();
	for(int i=1;i<=N;i++)
		A[i]=read(),Sum+=A[i];
	Sum/=2;
	for(int i=1;i<=N-1;i+=2)
		Sum-=A[i];
	int Ans=A[N]-Sum;
	for(int i=1;i<=N-1;i++)
		printf("%d ",2*Ans),
		Ans=A[i]-Ans;
	printf("%lld",Sum*2);
}


Measured memory_bytes: 1664
N,M = map(int,input().split())

if N >= 3 and M >= 3:
    print(N*M-(N+M)*2+4)
elif N == 2 or M == 2:
    print(0)
elif N == 1 and M == 1:
    print(1)
else:
    print(N*M-2)

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

const int A[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(void) {
	int K;
	cin >> K;
	cout << A[K-1] << endl;
  return 0;
}


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

using namespace std;


#define int long long


main(){



	int n; cin >> n;


	vector <int> d(n);

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


	int sum = 0;


	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			sum += d[i] * d[j];
		}
	}


	cout << sum << endl;

	

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;

bool ac(string s){
    return s == "AC";
}

int main(void){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;

    map<int, int> all;
    vector<bool> t(n, false);

    for0(i, m){
        int p;
        string s;
        cin >> p >> s;
        --p;
        if(!t[p] && !ac(s)) ++all[p];
        if (ac(s)) {t[p] = true;}
    }

    int OK = count(t.begin(), t.end(), true);

    int pen = 0;

    for0(i, n){
        if (t[i]) {
            pen += all[i];
        }
    }
    cout << OK << " " << pen;

    return 0;
}


Measured memory_bytes: 4992
lst = [int(i) for x in input().split() for i in x]
length = len(lst)
idealLst1 =[ i&1 for i in range(1,length+1)]
idealLst2 = [i&1 for i in range(length)]
count1 = 0
count2 = 0

for i in range(length):
    if(lst[i] != idealLst1[i]):
        count1+=1    

for i in range(length):
    if(lst[i] != idealLst2[i]):
        count2+=1
print(min(count1,count2))


Measured memory_bytes: 5532
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        final long A,V,B,W,T ;
        A = sc.nextInt();
        V = sc.nextInt();
        B = sc.nextInt();
        W = sc.nextInt();
        T = sc.nextInt();
        sc.close();
        long diff = Math.abs(A - B);  
        if (Math.abs(V - W) * T >= diff && V - W >0){System.out.println("YES");}
        else {System.out.println("NO");}
    }
}

Measured memory_bytes: 27052
from collections import Counter
from itertools import combinations
n = int(input())
S = [input()[0] for _ in range(n)]
C = Counter(S)
ans = 0
for i, j, k in combinations(['M', 'A', 'R', 'C', 'H'], 3):
    ans += C[i] * C[j] * C[k]
print(ans)


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

using namespace std;

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;

    // 0,1の連の長さを1-0-1-0-...-1の形で記録。
    vector<int> nums;
    if (S[0] == '0') nums.emplace_back(0); // 最初の1の連の長さ
    for (int i = 0; i < S.size();) {
        int j = i;
        while (j < S.size() && S[j] == S[i]) ++j; // S[i] の数値がどこまで続くか
        nums.emplace_back(j - i);
        i = j;
    }
    if (S[N - 1] == '0') nums.emplace_back(0); // 最後の1の連の長さ

    // 累積和
    vector<int> sums((int) nums.size() + 1, 0);
    for (int i = 0; i < nums.size(); ++i) {
        sums[i + 1] = sums[i] + nums[i];
    }

    // 偶数番目の添字から始まる、長さ 2K+1 の区間の総和のうち、最大値を求める
    int res = 0;
    for (int left = 0; left < sums.size(); left += 2) {
        int right = left + K * 2 + 1;
        if (right >= sums.size()) right = (int) sums.size() - 1;
        res = max(res, sums[right] - sums[left]);
    }
    cout << res << endl;
    return 0;
}


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

void fnInput(lnglng& rnNumA, double& rnNumB)
{
  cin >> rnNumA >> rnNumB;
}

lnglng fnMultiple(lnglng nNumA, double nNumB)
{
  int nIntB = nNumB * 100 + 0.5;
  return (lnglng)(nNumA * nIntB / 100);
}
  
int main()
{
  lnglng nNumA;
  double nNumB;

  fnInput(nNumA, nNumB);
  cout << fnMultiple(nNumA, nNumB) << endl;

  return 0;
}

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

int main()
{
  string s;
  string ans;
  
  cin >> s;
  REP(i, s.size())
  {
  	if(ans.size() == 0 && s[i] == 'B') continue;
    if(s[i] == 'B') ans = ans.substr(0, ans.size() - 1);
    else ans += s[i];
  }
  
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

int main()
{
    int x, y, z;    cin >> x >> y >> z;

    set <int> st;

    st.insert(x);
    st.insert(y);
    st.insert(z);

    puts(st.size() == 2 ? "Yes" : "No");
}


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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r,g,b;cin>>r>>g>>b;
    if((10*g+b)%4)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int min = sc.nextInt();
		int ans = 1;
		for(int i=1;i<N;i++) {
			int x = sc.nextInt();
			if(x<min) {
				min = x;
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 49000
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-11-7 21:19:09
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int A, B, K;
set<int> S;

int main()
{
  cin >> A >> B >> K;
  for (auto i = 0; i < K; i++)
  {
    if (A + i <= B)
    {
      S.insert(A + i);
    }
    if (B - i >= A)
    {
      S.insert(B - i);
    }
  }
  for (auto x : S)
  {
    cout << x << endl;
  }
}

Measured memory_bytes: 256
function Main(input){ 
  var N = input.split(" ")[0];
  var L = input.split(" ")[1];
  N = parseInt(N,10);
  L = parseInt(L,10);
  var taste = [];
  var tasteSum = 0;
  for(i=0;i<=(N-1);i++){
    tasteSum += (L + (i+1) - 1); 
    taste[i] = Math.abs(L + (i+1) - 1); 
  }
  var min = Math.min(...taste);
  var ind = taste.indexOf(min,0);
  tasteSum -= (L + (ind+1) - 1);
  console.log(tasteSum);

  
}
    Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372