stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstring>

#include<algorithm>

#define fo(i,a,b) for(int i=a;i<=b;i++)

#define fod(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long ll;

const int N=1e5+10,inf=(1<<30);

ll f[N],p[N];int n,e,t;

int main()

{

	scanf("%d%d%d",&n,&e,&t);

	fo(i,1,n) scanf("%lld",&p[i]);

	memset(f,63,sizeof(f));f[0]=0;

	ll mn=inf;

	for(int i=1,j=0;i<=n;i++) {

		for(;t<=(p[i]-p[j+1])<<1;j++)

			mn=min(mn,f[j]-2*p[j+1]);

			if(j<i) f[i]=min(f[i],f[j]+t);

			f[i]=min(f[i],mn+2*p[i]);

	}

	printf("%lld\n",f[n]+e);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7700795404490093x):
#include <bits/stdc++.h>

using namespace std;

#define int long long

const int MAXN = 1e5 + 10, INF = 2e18;

int x[MAXN], dp[MAXN];

int n, e, t;

int32_t main () {

    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin >> n >> e >> t;

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

        cin >> x[i];

        dp[i] = INF;

    }

    x[n] = e;

    int mn = INF;

    int point = n;

    for (int i = n - 1; i >= 0; --i) {

        while (x[point - 1] - x[i] > t / 2) {

            mn = min(mn,dp[point] + x[point] + 2 * x[point - 1]);

            --point;

        }

        dp[i] = min(mn - 3 * x[i], dp[point] + x[point] - x[i] + t);

    }

    cout << dp[0] + x[0];

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstring>

#include<algorithm>

#define fo(i,a,b) for(int i=a;i<=b;i++)

#define fod(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long ll;

const int N=1e5+10,inf=(1<<30);

ll f[N],p[N];int n,e,t;

int main()

{

	scanf("%d%d%d",&n,&e,&t);

	fo(i,1,n) scanf("%lld",&p[i]);

	memset(f,63,sizeof(f));f[0]=0;

	ll mn=inf;

	for(int i=1,j=0;i<=n;i++) {

		for(;t<=(p[i]-p[j+1])<<1;j++)

			mn=min(mn,f[j]-2*p[j+1]);

			if(j<i) f[i]=min(f[i],f[j]+t);

			f[i]=min(f[i],mn+2*p[i]);

	}

	printf("%lld\n",f[n]+e);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.768338012729954x):
#include <bits/stdc++.h>



using namespace std;



constexpr int N = 1e5 + 10;

constexpr int MOD = 1e9 + 7;



long long t, n, a[N], mn, dp[N], e, en, ps[N];



void upd (int x) {

    if (!mn)

        mn = x;

    long long ghabli = 2 * a[mn] + a[mn + 1] + dp[mn + 1];

    long long jadid = 2 * a[x] + a[x + 1] + dp[x + 1];

    if (jadid < ghabli)

        mn = x;

}



int main() {

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin >> n >> e >> t;

    for (int i = 1; i <= n; i++)

        cin >> a[i];

    en = n;

    a[n + 1] = e;

    for (int i = n; i; i--) {

        while (2 * (a[en] - a[i]) > t) {

            upd (en);

            en--;

        }

        // ta en berim va bargardim

        dp[i] = t + a[en + 1] - a[i] + dp[en + 1];

        // ta min berim va bargardim

        if (mn)

            dp[i] = min (dp[i], 2 * a[mn] + a[mn + 1] + dp[mn + 1] - 3 * a[i]);

    }

    cout << dp[1] + a[1] << '\n';

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstring>

#include<algorithm>

#define fo(i,a,b) for(int i=a;i<=b;i++)

#define fod(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long ll;

const int N=1e5+10,inf=(1<<30);

ll f[N],p[N];int n,e,t;

int main()

{

	scanf("%d%d%d",&n,&e,&t);

	fo(i,1,n) scanf("%lld",&p[i]);

	memset(f,63,sizeof(f));f[0]=0;

	ll mn=inf;

	for(int i=1,j=0;i<=n;i++) {

		for(;t<=(p[i]-p[j+1])<<1;j++)

			mn=min(mn,f[j]-2*p[j+1]);

			if(j<i) f[i]=min(f[i],f[j]+t);

			f[i]=min(f[i],mn+2*p[i]);

	}

	printf("%lld\n",f[n]+e);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8170158193296904x):
#include<cstdio>

#include<iostream>

#include<cstring>

#define RG register

#define LL long long

using namespace std;

const int N=1e5+10;

int n;

LL e,t,x[N],dp[N],tt=1e18;

template<typename I> inline void read(I &ot){

	I ch=getchar(), x=0, f=1;

	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}

	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}

	ot=x*f;}

template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}

template<typename I>inline I mi(const I&a,const I&b){return a<b ? a : b;}

int main()

{

//	freopen("Shik and Game.in","r",stdin);

	//freopen(".out","w",stdout);

	read(n,e,t);

	for(int i=1;i<=n;i++) read(x[i]), dp[i]=2e9;

	for(int i=1,j=0;i<=n;i++)

	{

		while(2*(x[i]-x[j+1])>=t) 

		{

			tt=mi(tt,dp[j]-2*x[j+1]);

			j++;

		}

		dp[i]=mi(dp[j]+t,tt+2*x[i]);

	}

	printf("%lld\n",dp[n]+e);

	//fclose(stdin); fclose(stdout);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstring>

#include<algorithm>

#define fo(i,a,b) for(int i=a;i<=b;i++)

#define fod(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long ll;

const int N=1e5+10,inf=(1<<30);

ll f[N],p[N];int n,e,t;

int main()

{

    scanf("%d%d%d",&n,&e,&t);

    fo(i,1,n) scanf("%lld",&p[i]);

    memset(f,63,sizeof(f));f[0]=0;

    ll mn=inf;

    for(int i=1,j=0;i<=n;i++) {

        for(;t<=(p[i]-p[j+1])<<1;j++)

            mn=min(mn,f[j]-2*p[j+1]);

            if(j<i) f[i]=min(f[i],f[j]+t);

            f[i]=min(f[i],mn+2*p[i]);

    }

    printf("%lld\n",f[n]+e);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8170158193296904x):
#include<cstdio>

#include<iostream>

#include<cstring>

#define RG register

#define LL long long

using namespace std;

const int N=1e5+10;

int n;

LL e,t,x[N],dp[N],tt=1e18;

template<typename I> inline void read(I &ot){

	I ch=getchar(), x=0, f=1;

	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}

	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}

	ot=x*f;}

template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}

template<typename I>inline I mi(const I&a,const I&b){return a<b ? a : b;}

int main()

{

//	freopen("Shik and Game.in","r",stdin);

	//freopen(".out","w",stdout);

	read(n,e,t);

	for(int i=1;i<=n;i++) read(x[i]), dp[i]=2e9;

	for(int i=1,j=0;i<=n;i++)

	{

		while(2*(x[i]-x[j+1])>=t) 

		{

			tt=mi(tt,dp[j]-2*x[j+1]);

			j++;

		}

		dp[i]=mi(dp[j]+t,tt+2*x[i]);

	}

	printf("%lld\n",dp[n]+e);

	//fclose(stdin); fclose(stdout);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstring>

#include<algorithm>

#define fo(i,a,b) for(int i=a;i<=b;i++)

#define fod(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long ll;

const int N=1e5+10,inf=(1<<30);

ll f[N],p[N];int n,e,t;

int main()

{

	scanf("%d%d%d",&n,&e,&t);

	fo(i,1,n) scanf("%lld",&p[i]);

	memset(f,63,sizeof(f));f[0]=0;

	ll mn=inf;

	for(int i=1,j=0;i<=n;i++) {

		for(;t<=(p[i]-p[j+1])<<1;j++)

			mn=min(mn,f[j]-2*p[j+1]);

			if(j<i) f[i]=min(f[i],f[j]+t);

			f[i]=min(f[i],mn+2*p[i]);

	}

	printf("%lld\n",f[n]+e);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.765029070749627x):
#include <algorithm>

#include <iostream>

#include <cstring>

#include <vector>

using namespace std;



typedef long long ll;



const ll MAX_N = 1e5 + 5, inf = 1000000LL * 1000000LL * 1000000LL;

ll n, E, T;

ll x[MAX_N];

ll dp[MAX_N];

ll seg[MAX_N << 2];

ll lazy[MAX_N << 2];



void shift (ll id) {

	seg[id << 1] += lazy[id];

	lazy[id << 1] += lazy[id];



	seg[id << 1 | 1] += lazy[id];

	lazy[id << 1 | 1] += lazy[id];

	lazy[id] = 0;

}



void add (ll l, ll r, ll val, ll s = 0, ll e = n, ll id = 1) {

	if (l <= s && e <= r) {

		seg[id] += val;

		lazy[id] += val;

		return ;

	}



	if (r <= s || e <= l)

		return ;



	shift(id);



	ll mid = e + s >> 1;

	add(l, r, val, s, mid, id << 1);

	add(l, r, val, mid, e, id << 1 | 1);

	seg[id] = min(seg[id << 1], seg[id << 1 | 1]);

}



ll get (ll l, ll r, ll s = 0, ll e = n, ll id = 1) {

	if (l <= s && e <= r)

		return seg[id];



	if (r <= s || e <= l)

		return inf;



	shift(id);

	ll mid = e + s >> 1;

	return min(get(l, r, s, mid, id << 1), get(l, r, mid, e, id << 1 | 1));

}



int main() {

	ios::sync_with_stdio(false), cin.tie(0);

	cin >> n >> E >> T;

	for (ll i = 0; i < n; i++)

		cin >> x[i];



	dp[n - 1] = T;

	for (ll i = n - 2; ~i; i--) {

		add(i + 1, n, 2 * (x[i + 1] - x[i]));

		add(i, i + 1, dp[i + 1]);

		ll ind = lower_bound(x, x + n, x[i] + (T + 1) / 2) - x;

		ind--;



		dp[i] = T + dp[ind + 1];

		if (ind + 1 < n)

			dp[i] = min(dp[i], get(ind + 1, n));

	}



	cout << dp[0] + E << "\n";

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstring>

#include<algorithm>

#define fo(i,a,b) for(int i=a;i<=b;i++)

#define fod(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long ll;

const int N=1e5+10,inf=(1<<30);

ll f[N],p[N];int n,e,t;

int main()

{

    scanf("%d%d%d",&n,&e,&t);

    fo(i,1,n) scanf("%lld",&p[i]);

    memset(f,63,sizeof(f));f[0]=0;

    ll mn=inf;

    for(int i=1,j=0;i<=n;i++) {

        for(;t<=(p[i]-p[j+1])<<1;j++)

            mn=min(mn,f[j]-2*p[j+1]);

            if(j<i) f[i]=min(f[i],f[j]+t);

            f[i]=min(f[i],mn+2*p[i]);

    }

    printf("%lld\n",f[n]+e);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.765029070749627x):
#include <algorithm>

#include <iostream>

#include <cstring>

#include <vector>

using namespace std;



typedef long long ll;



const ll MAX_N = 1e5 + 5, inf = 1000000LL * 1000000LL * 1000000LL;

ll n, E, T;

ll x[MAX_N];

ll dp[MAX_N];

ll seg[MAX_N << 2];

ll lazy[MAX_N << 2];



void shift (ll id) {

	seg[id << 1] += lazy[id];

	lazy[id << 1] += lazy[id];



	seg[id << 1 | 1] += lazy[id];

	lazy[id << 1 | 1] += lazy[id];

	lazy[id] = 0;

}



void add (ll l, ll r, ll val, ll s = 0, ll e = n, ll id = 1) {

	if (l <= s && e <= r) {

		seg[id] += val;

		lazy[id] += val;

		return ;

	}



	if (r <= s || e <= l)

		return ;



	shift(id);



	ll mid = e + s >> 1;

	add(l, r, val, s, mid, id << 1);

	add(l, r, val, mid, e, id << 1 | 1);

	seg[id] = min(seg[id << 1], seg[id << 1 | 1]);

}



ll get (ll l, ll r, ll s = 0, ll e = n, ll id = 1) {

	if (l <= s && e <= r)

		return seg[id];



	if (r <= s || e <= l)

		return inf;



	shift(id);

	ll mid = e + s >> 1;

	return min(get(l, r, s, mid, id << 1), get(l, r, mid, e, id << 1 | 1));

}



int main() {

	ios::sync_with_stdio(false), cin.tie(0);

	cin >> n >> E >> T;

	for (ll i = 0; i < n; i++)

		cin >> x[i];



	dp[n - 1] = T;

	for (ll i = n - 2; ~i; i--) {

		add(i + 1, n, 2 * (x[i + 1] - x[i]));

		add(i, i + 1, dp[i + 1]);

		ll ind = lower_bound(x, x + n, x[i] + (T + 1) / 2) - x;

		ind--;



		dp[i] = T + dp[ind + 1];

		if (ind + 1 < n)

			dp[i] = min(dp[i], get(ind + 1, n));

	}



	cout << dp[0] + E << "\n";

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstring>

#include<algorithm>

#define fo(i,a,b) for(int i=a;i<=b;i++)

#define fod(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long ll;

const int N=1e5+10,inf=(1<<30);

ll f[N],p[N];int n,e,t;

int main()

{

	scanf("%d%d%d",&n,&e,&t);

	fo(i,1,n) scanf("%lld",&p[i]);

	memset(f,63,sizeof(f));f[0]=0;

	ll mn=inf;

	for(int i=1,j=0;i<=n;i++) {

		for(;t<=(p[i]-p[j+1])<<1;j++)

			mn=min(mn,f[j]-2*p[j+1]);

			if(j<i) f[i]=min(f[i],f[j]+t);

			f[i]=min(f[i],mn+2*p[i]);

	}

	printf("%lld\n",f[n]+e);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.790639502747311x):
#include<bits/stdc++.h>

using namespace std;

int n,m,t,x[100010];

long long f[100010],k=1e18;

int main()

{

	scanf("%d%d%d",&n,&m,&t);

	for(int i=1;i<=n;i++)

		scanf("%d",&x[i]);

	for(int i=1,j=0;i<=n;i++)

	{

		for(;2*(x[i]-x[j+1])>t;j++)

			k=min(k,f[j]-2*x[j+1]);

		f[i]=min(k+2*x[i],f[j]+t);

	}

	cout<<f[n]+m<<"\n";

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cmath>

#include<cstring>

#include<algorithm>

#define fo(i,a,b) for(int i=a;i<=b;i++)

#define fod(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long ll;

const int N=1e5+10,inf=(1<<30);

ll f[N],p[N];int n,e,t;

int main()

{

    scanf("%d%d%d",&n,&e,&t);

    fo(i,1,n) scanf("%lld",&p[i]);

    memset(f,63,sizeof(f));f[0]=0;

    ll mn=inf;

    for(int i=1,j=0;i<=n;i++) {

        for(;t<=(p[i]-p[j+1])<<1;j++)

            mn=min(mn,f[j]-2*p[j+1]);

            if(j<i) f[i]=min(f[i],f[j]+t);

            f[i]=min(f[i],mn+2*p[i]);

    }

    printf("%lld\n",f[n]+e);

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.790639502747311x):
#include<bits/stdc++.h>

using namespace std;

int n,m,t,x[100010];

long long f[100010],k=1e18;

int main()

{

	scanf("%d%d%d",&n,&m,&t);

	for(int i=1;i<=n;i++)

		scanf("%d",&x[i]);

	for(int i=1,j=0;i<=n;i++)

	{

		for(;2*(x[i]-x[j+1])>t;j++)

			k=min(k,f[j]-2*x[j+1]);

		f[i]=min(k+2*x[i],f[j]+t);

	}

	cout<<f[n]+m<<"\n";

	return 0;

}
// Slower C++ solution:
#include <stdio.h>

#include <string.h>

#define INF 1000001



int main(void){

	int i, j, n ,c, small1, small2;

	int dp1[1000000],dp2[1000000];

	scanf("%d",&n);

	while(n != 0){

		for(i = 0;i <= n;i++)

			dp1[i] = dp2[i] = INF;

		dp1[0] = dp2[0] = 0;

		for(i = 0;i < n;i++){

			small1 = dp1[n];

			if(small1 > dp1[i] + 1 && dp1[i] != INF){

				for(j = 1,c = j * (j + 1) * (j + 2);c / 6 + i <= n;j++,c = j * (j + 1) * (j + 2)){

					if(dp1[c / 6 + i] > dp1[i] + 1 && dp1[i] != INF){

						dp1[c / 6 + i] = dp1[i] + 1;

					}

				}

			}

		}

		for(i = 0;i < n;i++){

			small2 = dp2[n];

			if(small2 > dp2[i] + 1 && dp2[i] != INF){

				for(j = 1,c = j * (j + 1) * (j + 2);c / 6 + i <= n;j++,c = j * (j + 1) * (j + 2)){

					if(dp2[c / 6 + i] > dp2[i] + 1 && (c / 6) % 2 == 1 && dp2[i] != INF)

						dp2[c / 6 + i] = dp2[i] + 1;

				}

			}

		}

		printf("%d %d\n",dp1[n],dp2[n]);

		scanf("%d",&n);

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.9068147352747247x):
#include <stdio.h>

#include <stdlib.h>



int n;



void solve(int *min,int flag,int c){

	int i;

	static int sum = 0, count = 0;

	if(count + 1 < *min && sum < n){

		for(i = 0;((i + 1) * (i + 2) * (i + 3)) / 6 + sum <= n && i < c;i++);

		while(i > 0){

			if(flag == 1 && i * (i + 1) * (i + 2) / 6 % 2 == 0){

				i--;

				continue;

			}

			sum += i * (i + 1) * (i + 2) / 6;

			count++;

			solve(min,flag,i);

			sum -= i * (i + 1) * (i + 2) / 6;

			count--;

			i--;

		}

	}

	else if(sum == n){

		if(count < *min)

			*min = count;

	}

	return;

}



int main(void){

	int min;

	scanf("%d",&n);

	while(n != 0){

		min = n;

		solve(&min,0,0x7FFFFFFF);

		printf("%d ",min);

		min = n;

		solve(&min,1,0x7FFFFFFF);

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

		scanf("%d",&n);

	}

	return 0;

}
// Slower C++ solution:
#include<stdio.h>

#define N 1000000



int all[N+1],odd[N+1];

int pollock[1000];

int num;



int BackTrack(int n,int type){

  int i,tmp,ans = N+1;

  if(type && odd[n]<=N)return odd[n];

  if(!type && all[n]<=N)return all[n];

  //if(n==0)return 0;



  for(i=num-1;i>=0;i--){

    //printf("%d\n",pollock[i]);

    if(pollock[i]>n)continue;

    if(type && !(pollock[i]&1) )continue;

    tmp = BackTrack(n-pollock[i],type);

    if(ans > tmp+1)ans = tmp+1;

  }



  if(type)odd[n] = ans;

  if(!type)all[n] = ans;

  return ans;

}



int main(){

  int i,n,tmp;



  for(i=0;i<=N;i++)all[i] = odd[i] = N+1;

  all[0] = odd[0] = 0;



  for(num=1;;num++){

    tmp = num*(num+1)*(num+2)/6;

    if(tmp>N)break;

    pollock[num-1] = tmp;

  }

  num--;

  while(scanf("%d",&n) && n){

    printf("%d %d\n",BackTrack(n,0),BackTrack(n,1));

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 8.597060525360204x):
#include <iostream>

#include <vector>



using namespace std;



int m;

int f(int n) { return n*(n+1)*(n+2)/6; }

vector<int> l1, l2;



void r(int n, int step, vector<int> &l, int p) {

  if(step+1 >= m) return;

 

  for(int i=p; i>=0; i--) {

    int n2 = n-l[i];

    if(n2<0) continue;

    if(n2==0) {

      m = step+1;

      return;

    }

    if(n2>0) {

      r(n2, step+1, l, i);

    }

  }

  

}



int main() {

  while(1) {

    vector<int> l1, l2;

    int n;



     cin >> n;

     if(n==0) break;

    

    // not over

    for(int i=1; true; i++) {

      int mm = f(i);

      if(mm>n) break;

      l1.push_back(mm);

      if(mm&1) l2.push_back(mm);

    }



    m = n;

    r(n, 0, l1, l1.size()-1);

    cout << m;



    cout << ' ';

    

    m = n;

    r(n, 0, l2, l2.size()-1);

    cout << m;



    cout << "\n";



    

  }

  return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

using namespace std;



int main()

{

    long long n, m;

    cin >> n >> m;

    if(n == 2 || m == 2) cout << 0;

    else if(min(n, m) == 1){

        int maximum = max(n, m);

        cout << (maximum == 1 ? 1 : maximum - 2);

    } else 

        cout << (m-2)*(n-2);

    

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.308882993294506x):
#include <stdio.h>

#include <algorithm>

using namespace std;



int main()

{

    long long n, m;

    scanf("%lld %lld", &n, &m);

    if(n == 2 || m == 2) printf("0");

    else if(min(n, m) == 1){

        int maximum = max(n, m);

        printf("%lld", maximum == 1 ? 1 : maximum - 2);

    } else 

        printf("%lld", (m-2)*(n-2));

    

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

using namespace std;



int main()

{

    long long n, m, down = 0;

    cin >> n >> m;

    if (n > m)

    {

        swap(n, m);

    }

    if (n == 1)

    {

        if (m == 1)

        {

            down = 1;

        }

        else

        {

            down = m - 2;

        }

    }

    else

    {

        down = (n - 2) * (m - 2);

    }

    cout << down;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.260301206419676x):
#include<stdio.h>

#define ll long long

#define fup(i,a,b) for(int i=a;i<=b;++i)



void Main()

{

    ll n,m;

    scanf("%lld%lld",&n,&m);

    ll s;

    if(n>1&&m>1)s=m+m+n+n-4;

    else if(m==1&&n==1)s=0;

    else s=2;

    printf("%lld",n*m-s);

}

int main()

{

Main();

return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define ll long long

vector <ll > v;

string st1 ,st2,st3;

ll a,b,cnt,degit;







int  main()

{

    cin>>a>>b;



    cout<<abs(a*b-((a*2)+(b*2)-4));

}












// Faster C++ solution for the same problem (measured speedup: 5.265703085565176x):
#include<stdio.h>

#define ll long long

#define fup(i,a,b) for(int i=a;i<=b;++i)



void Main()

{

    ll n,m;

    scanf("%lld%lld",&n,&m);

    ll s;

    if(n>1&&m>1)s=m+m+n+n-4;

    else if(m==1&&n==1)s=0;

    else s=2;

    printf("%lld",n*m-s);

}

int main()

{

Main();

return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int n,re,sum;

    cin>>n;

    re=n;

    sum=0;

    while(re>0)

    {

        sum+=re%10;

        re/=10;

    }

    if(n%sum==0)

    {

        printf("Yes\n");

        //printf("S")

    }

    else printf("No\n");

    return  0;

}


// Faster C++ solution for the same problem (measured speedup: 5.246361075986601x):
#include<stdio.h>

long int alp(long int n)

{

    long int s=0,p;

    while (n!=0)

    {

        p=n%10;

        s+=p;

        n/=10;

    }

    return s;

}

int main()

{

    long int n,p;

    scanf ("%ld",&n);

    p=alp(n);

    if (n%p==0)

    {

        printf ("Yes\n");

    }

    else if (n%p!=0)

    {

        printf ("No\n");

    }





    return 0;

}
// Slower C++ solution:
#include<iostream>

using namespace std;

const int maxn = 1e6+10;

int m,n;

int main()

{

	cin>>n;

	int j=n;

	long long ans=0;

	while(n)

	{

		ans+=n%10;

		n/=10;

	}

	if(j%ans==0) cout<<"Yes";

	else cout<<"No";

}

// Faster C++ solution for the same problem (measured speedup: 5.299292098400259x):
#include<stdio.h>

long int alp(long int n)

{

    long int s=0,p;

    while (n!=0)

    {

        p=n%10;

        s+=p;

        n/=10;

    }

    return s;

}

int main()

{

    long int n,p;

    scanf ("%ld",&n);

    p=alp(n);

    if (n%p==0)

    {

        printf ("Yes\n");

    }

    else if (n%p!=0)

    {

        printf ("No\n");

    }





    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    int n,re,sum;

    cin>>n;

    re=n;

    sum=0;

    while(re>0)

    {

        sum+=re%10;

        re/=10;

    }

    if(n%sum==0)

    {

        printf("Yes\n");

        //printf("S")

    }

    else printf("No\n");

    return  0;

}


// Faster C++ solution for the same problem (measured speedup: 5.258045255542005x):
#include<stdio.h>

#include<string.h>



int main()

{

	long long int n, num, sum = 0;

	scanf("%lld", &n);

	

	num = n;

	while(num != 0)

	{

		sum += num % 10;

		num /= 10;

	}

	

	if(n % sum == 0) printf("Yes\n");

	else printf("No\n");

}
// Slower C++ solution:
#include<iostream>

using namespace std;

const int maxn = 1e6+10;

int m,n;

int main()

{

	cin>>n;

	int j=n;

	long long ans=0;

	while(n)

	{

		ans+=n%10;

		n/=10;

	}

	if(j%ans==0) cout<<"Yes";

	else cout<<"No";

}

// Faster C++ solution for the same problem (measured speedup: 5.311094160724495x):
#include<stdio.h>

#include<string.h>



int main()

{

	long long int n, num, sum = 0;

	scanf("%lld", &n);

	

	num = n;

	while(num != 0)

	{

		sum += num % 10;

		num /= 10;

	}

	

	if(n % sum == 0) printf("Yes\n");

	else printf("No\n");

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

long long N;

int main(){

	scanf("%lld",&N);

long long sum=0,m;

m=N;

while(N){

	sum+=N%10;

	N/=10;

}

if(m%sum==0)

printf("Yes\n");

else

printf("No\n");







}

// Faster C++ solution for the same problem (measured speedup: 5.257143667463269x):
#include<stdio.h>

#include<string.h>



int main()

{

	long long int n, num, sum = 0;

	scanf("%lld", &n);

	

	num = n;

	while(num != 0)

	{

		sum += num % 10;

		num /= 10;

	}

	

	if(n % sum == 0) printf("Yes\n");

	else printf("No\n");

}
// Slower C++ solution:
#include <iostream>



using namespace std;



int main(){

  int n, sum=0;

  cin >> n;

  int aux = n;

  while(n>0){

    sum+=n%10;

    n/=10;

  }

  if(aux%sum==0)

    cout << "Yes" << endl;

  else

    cout << "No" << endl;

  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.321747528469435x):
#include<stdio.h>

#include<string.h>



int main()

{

	long long int n, num, sum = 0;

	scanf("%lld", &n);

	

	num = n;

	while(num != 0)

	{

		sum += num % 10;

		num /= 10;

	}

	

	if(n % sum == 0) printf("Yes\n");

	else printf("No\n");

}
// Slower C++ solution:
#include <bits/stdc++.h>



#define ll long long



using namespace std;



int sum(int a){

    if(a < 10) return a;

    return sum(a/10) + a%10;    

}



int main(){

    int a, b, c;



    cin >> a;



    if(!(a%sum(a))) cout << "Yes\n";

    else cout << "No\n";



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.312442064756116x):
#include<stdio.h>

#include<string.h>



int main()

{

	long long int n, num, sum = 0;

	scanf("%lld", &n);

	

	num = n;

	while(num != 0)

	{

		sum += num % 10;

		num /= 10;

	}

	

	if(n % sum == 0) printf("Yes\n");

	else printf("No\n");

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;



int digits_sum(int N)

{

	int sum = 0;

	

	while  (N > 0)

	{

		int d = N % 10;

		N /= 10;

		

		sum += d;

	}

	

	return sum;

}



int main(){

    int n;

    cin>>n;

    

    if(n % digits_sum(n) == 0)

        cout<<"Yes";

    else

        cout<<"No";



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.312119642529283x):
#include<stdio.h>

#include<string.h>



int main()

{

	long long int n, num, sum = 0;

	scanf("%lld", &n);

	

	num = n;

	while(num != 0)

	{

		sum += num % 10;

		num /= 10;

	}

	

	if(n % sum == 0) printf("Yes\n");

	else printf("No\n");

}