stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

const int boss=1e5;

int n,m,vis[boss+10];

vector<int> lj[boss+10];

int dfs(int u,int fa)

{

if (lj[u].size()>2) return u;

for (int i:lj[u]) if (i!=fa) return dfs(i,u);

return u;

}

int main()

{

int i,u,v;

scanf("%d",&n);

for (i=1;i<n;i++) scanf("%d%d",&u,&v),u++,v++,lj[u].push_back(v),lj[v].push_back(u);

for (i=1;i<=n;i++) if (lj[i].size()==1) vis[dfs(i,0)]=1,m++;

for (i=1;i<=n;i++) if (vis[i]) m--;

printf("%d",max(m,1));

}

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

#include<cstdio>

using namespace std;

int d[101010];

struct Edge{

	int to,next;

}e[202020];

int cnt=0,head[101010];

void add(int u,int v)

{

	cnt++;

	e[cnt].to=v;

	e[cnt].next=head[u];

	head[u]=cnt;

}

int f[101010],g[101010];

int dis[101010];

void cal(int x,int fa)

{

	for(int i=head[x];i!=0;i=e[i].next)

	{

		int to=e[i].to;

		if(to!=fa)

		{

			dis[to]=dis[x]+1;

			cal(to,x);

		}

	}

}

void dfs(int x,int fa)

{

	int dd=0;

	for(int i=head[x];i!=0;i=e[i].next)

	{

		int to=e[i].to;

		if(to!=fa)

		{

			dfs(to,x);

			f[x]+=f[to];

			if(f[to]==0)

				dd++;

		}

	}

	if(dd>0)

		f[x]+=dd-1;

}

int main()

{

	int n;

	scanf("%d",&n);

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

	{

		int u,v;

		scanf("%d%d",&u,&v);

		u++;

		v++;

		d[u]++;

		d[v]++;

		add(u,v);

		add(v,u);

	}

	cal(1,1);

	int mx=1;

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

	if(dis[i]>dis[mx])

		mx=i;

	dfs(mx,mx);

	printf("%d\n",f[mx]+1);

	return 0;

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

using namespace std;

const int boss=1e5;

int n,m,vis[boss+10];

vector<int> lj[boss+10];

int dfs(int u,int fa)

{

if (lj[u].size()>2) return u;

for (int i:lj[u]) if (i!=fa) return dfs(i,u);

return u;

}

int main()

{

int i,u,v;

scanf("%d",&n);

for (i=1;i<n;i++) scanf("%d%d",&u,&v),u++,v++,lj[u].push_back(v),lj[v].push_back(u);

for (i=1;i<=n;i++) if (lj[i].size()==1) vis[dfs(i,0)]=1,m++;

for (i=1;i<=n;i++) if (vis[i]) m--;

printf("%d",max(m,1));

}

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

#include <cstdio>

#include <cstdlib>

#include <algorithm>

#include <cstring>



using namespace std;



#define N 100008



int n, top, ans;

int f[N], son[N], fa[N], vis[N];

struct road

{

    int next, to;

}r[2*N];



void build(int u, int v)

{

    r[++top].to = v;

    r[top].next = f[u];

    f[u] = top;

}



int dfs(int now, int fa)

{

    if (son[now] > 2)   return now;

    for (int i = f[now]; i; i = r[i].next)

    {

        if (r[i].to == fa) continue;

        now = dfs(r[i].to, now);

    }

    return now;

}



void solve()

{

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

    {

        if (son[i] == 1)

        {

            vis[dfs(i, -1)] = 1;

            ans++;

        }

    }

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

        if (vis[i] == 1)

            ans--;

    ans = max(ans, 1);

}



int main()

{

    int x, y;

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

    {

        top = ans = 0;

        memset(f, 0, sizeof(f));

        memset(vis, 0, sizeof(vis));

        memset(son, 0, sizeof(son));

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

        {

            scanf("%d%d", &x, &y);

            son[x]++;

            son[y]++;

            build(x, y);

            build(y, x);

        }

        solve();

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

    }

    return 0;

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

#include<vector>



using namespace std;



vector<int>g[100001];

int a[100001],ans;

void dfs(int u,int f){

	int z=0;

	for(int i=0;i<g[u].size();i++)

		if(g[u][i]!=f){

			dfs(g[u][i],u);

			z+=!a[g[u][i]];

			a[u]|=a[g[u][i]];

		}

	if(z>1)ans+=z-1,a[u]=1;

}

int main(){

	int n;

	scanf("%d",&n);

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

		int u,v;

		scanf("%d%d",&u,&v);

		u++;v++;

		g[u].push_back(v);

		g[v].push_back(u);

	}

	int o=1;

	while(o<=n&&g[o].size()!=1)o++;

	if(o>n){

		printf("1\n");

		return 0;

	}

	dfs(o,0);

	int haha=ans+1;

	for(int i=1;i<=10;i++){

		o++;

		while(o<=n&&g[o].size()!=1)o++;

		if(o>n)break;

		ans=0;

		for(int i=1;i<=n;i++)a[i]=0;

		dfs(o,0);

		haha=min(haha,ans+1);

	}

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

}


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

#include <cstdio>

#include <cstdlib>

#include <algorithm>

#include <cstring>



using namespace std;



#define N 100008



int n, top, ans;

int f[N], son[N], fa[N], vis[N];

struct road

{

    int next, to;

}r[2*N];



void build(int u, int v)

{

    r[++top].to = v;

    r[top].next = f[u];

    f[u] = top;

}



int dfs(int now, int fa)

{

    if (son[now] > 2)   return now;

    for (int i = f[now]; i; i = r[i].next)

    {

        if (r[i].to == fa) continue;

        now = dfs(r[i].to, now);

    }

    return now;

}



void solve()

{

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

    {

        if (son[i] == 1)

        {

            vis[dfs(i, -1)] = 1;

            ans++;

        }

    }

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

        if (vis[i] == 1)

            ans--;

    ans = max(ans, 1);

}



int main()

{

    int x, y;

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

    {

        top = ans = 0;

        memset(f, 0, sizeof(f));

        memset(vis, 0, sizeof(vis));

        memset(son, 0, sizeof(son));

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

        {

            scanf("%d%d", &x, &y);

            son[x]++;

            son[y]++;

            build(x, y);

            build(y, x);

        }

        solve();

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

    }

    return 0;

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

#include<vector>

using namespace std;

const int MAXN=100005;



vector<int> adj[MAXN];

int deg[MAXN];



int dfs(int u,int fa=-1)

{

	int res=0,temp;

	bool flag=false;

	for(int i=0;i<(int)adj[u].size();i++)

	{

		int v=adj[u][i];

		if(v==fa)

			continue;

		temp=dfs(v,u);

		if(temp==0&&flag==true)

			temp++;

		if(temp==0&&flag==false)

			flag=true;

		res+=temp;

	}

	return res;

}



int main()

{

	int N;

	scanf("%d",&N);

	for(int i=0,u,v;i<N-1;i++)

	{

		scanf("%d%d",&u,&v);

		deg[u]++;

		deg[v]++;

		adj[u].push_back(v);

		adj[v].push_back(u);

	}

	int root=-1;

	for(int i=0;i<N;i++)

		if(deg[i]>=3)

		{

			root=i;

			break;

		}

	if(root==-1)

		puts("1");

	else

		printf("%d\n",dfs(root));

	return 0;

}


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

#include <cstdio>

#include <cstdlib>

#include <algorithm>

#include <cstring>



using namespace std;



#define N 100008



int n, top, ans;

int f[N], son[N], fa[N], vis[N];

struct road

{

    int next, to;

}r[2*N];



void build(int u, int v)

{

    r[++top].to = v;

    r[top].next = f[u];

    f[u] = top;

}



int dfs(int now, int fa)

{

    if (son[now] > 2)   return now;

    for (int i = f[now]; i; i = r[i].next)

    {

        if (r[i].to == fa) continue;

        now = dfs(r[i].to, now);

    }

    return now;

}



void solve()

{

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

    {

        if (son[i] == 1)

        {

            vis[dfs(i, -1)] = 1;

            ans++;

        }

    }

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

        if (vis[i] == 1)

            ans--;

    ans = max(ans, 1);

}



int main()

{

    int x, y;

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

    {

        top = ans = 0;

        memset(f, 0, sizeof(f));

        memset(vis, 0, sizeof(vis));

        memset(son, 0, sizeof(son));

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

        {

            scanf("%d%d", &x, &y);

            son[x]++;

            son[y]++;

            build(x, y);

            build(y, x);

        }

        solve();

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

    }

    return 0;

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

#include<set>

#include<vector>

#include<algorithm>

#include<string>

#include<sstream>

#include<map>

#include<cstdio>

#include<cmath>

#include<cstring>

#include<queue>

#include<stack>

#include<utility> 

#include<fstream>

#include<cassert>

#include<cstdlib>

#include<deque>

#include<list>

#include<bitset>

#include<cassert>

#include<functional>

using namespace std;

int n,dp[100005];

vector<int> nei[100005];

void dfs(int v,int pa)

{

	int cnt=0;

	for(int i=0;i<nei[v].size();i++)

	{

		int u=nei[v][i];

		if(u==pa) continue;

		dfs(u,v);

		

		if(dp[u]==0) cnt++;else dp[v]+=dp[u];

	}

	if(cnt>1) dp[v]+=cnt-1;

	dp[v]=max(dp[v],0);

}

int main()

{

	cin>>n;

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

	{

		int x,y;

		scanf("%d %d",&x,&y);

		nei[x].push_back(y);

		nei[y].push_back(x);

	}

	bool flag=0;

	int ro=-1;

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

	{

		if(nei[i].size()>=3) ro=i; 

	}

	if(ro==-1)

	{

		cout<<1;

		return 0;

	}

	dfs(ro,-1);

	cout<<dp[ro];

}

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

#include<set>

#include<vector>

#include<algorithm>

#include<string>

#include<sstream>

#include<map>

#include<cstdio>

#include<cmath>

#include<cstring>

#include<queue>

#include<stack>

#include<utility> 

#include<fstream>

#include<cassert>

#include<cstdlib>

#include<deque>

#include<list>

#include<bitset>

#include<cassert>

#include<functional>

using namespace std;

int n,dp[100005],la[100005],pre[200005],va[200005],deg[100005];

//vector<int> nei[100005];

void dfs(int v,int pa)

{

	int cnt=0;

	for(int i=la[v];i!=-1;i=pre[i])

	{

		int u=va[i];

		if(u==pa) continue;

		dfs(u,v);

		if(dp[u]==0) cnt++;else dp[v]+=dp[u];

	}

	if(cnt>1) dp[v]+=cnt-1;

	dp[v]=max(dp[v],0);

}

int main()

{

	cin>>n;

	memset(la,-1,sizeof(la));

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

	{

		int x,y;

		scanf("%d %d",&x,&y);

		pre[2*i]=la[x];

		va[2*i]=y;

		la[x]=2*i;

		pre[2*i+1]=la[y];

		va[2*i+1]=x;

		la[y]=2*i+1;

		deg[x]++;deg[y]++;

	}

	bool flag=0;

	int ro=-1;

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

	{

		if(deg[i]>=3) ro=i; 

	}

	if(ro==-1)

	{

		cout<<1;

		return 0;

	}

	dfs(ro,-1);

	cout<<dp[ro];

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

using namespace std;



#define Omar45 ios_base::sync_with_stdio(false); cin.tie(NULL);

#define ll long long

#define pb push_back

#define F first

#define S second

#define endl '\n'

const ll mod = 1e9 + 7;

const ll maxN = 1e5 + 5;

const ll INF = 1e18;



int n, k, dp[maxN], val[maxN], arr[103];



int main() {

	Omar45

    int n, k; cin >> n >> k;

    vector <ll> arr(n);

    for (int i=0; i<n; i++) cin >> arr[i];

    vector < vector <ll> > dp(n+1, vector <ll> (k+1, 0));

    dp[0][0] = 1;

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

        ll sum = 0;

        for (int usedCandy = 0; usedCandy<k+1; usedCandy++) {

            sum += dp[child][usedCandy];

            if (usedCandy > arr[child])

                sum -= dp[child][usedCandy-arr[child]-1];

            sum = (sum + mod) %mod;

            dp[child+1][usedCandy] = (dp[child+1][usedCandy] % mod + sum % mod ) % mod;

        }

    }

    cout << dp[n][k] << endl;

}

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

#include <bits/stdc++.h>

using namespace std;



typedef vector<int> vi;

#define ll long long

#define PI 3.14159265359

//#define x first

//#define y second

#define point pair<int,int>

#define clr(x, val)	memset((x), (val), sizeof(x))



//you don't know math, unless you can do math!

int mod = 1e9 + 7;

int dp[109][100009];

int main(){

    cin.tie(0);

    cin.sync_with_stdio(0);



    int n,k;

    cin>>n>>k;



    vector<int> a(n);

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

        cin>>a[i];







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

        dp[i][0]= 1;



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

        int sums[k + 1];

        sums[0] = dp[i + 1][0];

        for(int j = 1; j <= k; j++)

            sums[j] = (sums[j - 1] + dp[i + 1][j])%mod;



        for(int j = 0; j <= k; j++){

            int sum  = sums[j];

            if(j - a[i] - 1 >= 0) sum = (sum - sums[j - a[i] - 1] + mod)%mod;



            dp[i][j] = sum;

            //dp[i][j] = dp[i + 1][j - x : 0 <= x <= a[i]]

        }

    }



    cout<<dp[0][k];

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

#define int long long

#define pb push_back

#define pii pair<int,int>

#define vi vector<int>

#define vii vector<pii>

#define all(a) (a).begin(),(a).end()

#define X first

#define Y second

#define inf 2e9+5

using namespace std;

const int mod=1e9+7;

void solve()

{

  int n,k; cin>>n>>k; int a[n];

  for(int i=0;i<n;i++)cin>>a[i];

  int dp[k+1]={0}; dp[0]=1;

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

  {

      int cnt=0;

      for(int j=k;j>=k-a[i];j--){cnt+=dp[j]; cnt%=mod;}

      for(int j=k;j>=0;j--)

      {

          int t=dp[j];

          dp[j]=cnt;

          cnt-=t;

          if(j-a[i]-1>=0)cnt+=dp[j-a[i]-1];

          cnt=(cnt+mod)%mod;

      }

  }

  cout<<dp[k];

  return;

}

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t; t=1;

    while(t--)solve();

    return 0;

}


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

#define ll long long

#define pb push_back

#define pii pair<int,int>

#define vi vector<int>

#define vii vector<pii>

#define all(a) (a).begin(),(a).end()

#define X first

#define Y second

using namespace std;

const int mod=1e9+7;

void solve()

{

    int n,k; cin>>n>>k;

    int a[n],b[k+1]; b[0]=1;

    for(int i=0;i<n;i++)cin>>a[i];

    int dp[k+1];

    memset(dp,0,sizeof(dp));

    dp[0]=1;

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

    {

        for(int j=1;j<=k;j++)b[j]=(dp[j]+b[j-1])%mod;

        for(int j=1;j<=k;j++)

        {

            if(j-a[i]-1<0)dp[j]=b[j];

            else dp[j]=(b[j]-b[j-a[i]-1]+mod)%mod;

        }

    }

    cout<<dp[k];

    return;

}

signed main()

{

    ios::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    int t; t=1;

    while(t--)solve();

    return 0;

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

#define FOR0(i,n) for(ll i=0;i<n;i++)

#define FOR1(i,n) for(ll i=1;i<=n;i++)

#define FORl(i,l,n) for(ll i=l;i<n;i++)

using namespace std;

#define pi pair<ll,ll>

#define pb push_back

#define ll long long

#define ld long double

#define ff first

#define ss second

#define mp make_pair

#define mst0(x) memset(x,0,sizeof(x));

#define vi vector<ll>

#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define endl '\n'

#define sp <<" "<<

#define intmax 1e14

#define M 1000000007



ll power(ll num,ll g,ll mod){

  if(g==0)return 1;

  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;

  return power((num*num)%mod,g/2,mod);

}

 

int main(){

	ll n, k;

	cin>>n>>k;

	vector<ll> vec(n);

	FOR0(i, n)	cin>>vec[i];

	vector< vector<ll> > dp(n, vector<ll> (k+1, 0));

	vector< vector<ll> > ps(n, vector<ll> (k+1, 0));

	ps[0][0] = 1;

	FOR0(i, k+1){

		if(i <= vec[0])

			dp[0][i] = 1;

		if(i > 0)

			ps[0][i] = (ps[0][i] + dp[0][i] + ps[0][i-1]) % M;

	}

	FOR1(i, n-1){

		FOR0(j, k+1)

			dp[i][j] = (j-vec[i]-1) >= 0 ? (ps[i-1][j] - ps[i-1][j - vec[i] - 1] + M) % M : ps[i-1][j] % M;

		FOR0(j, k+1){

			ps[i][j] = j==0 ? dp[i][j] : (dp[i][j] + ps[i][j-1]) % M;

		}

	}

	cout<<dp[n-1][k]<<"\n";

}

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

#define FOR0(i,n) for(ll i=0;i<n;i++)

#define FOR1(i,n) for(ll i=1;i<=n;i++)

#define FORl(i,l,n) for(ll i=l;i<n;i++)

using namespace std;

#define pi pair<ll,ll>

#define pb push_back

#define ll long long

#define ld long double

#define ff first

#define ss second

#define mp make_pair

#define mst0(x) memset(x,0,sizeof(x));

#define vi vector<ll>

#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define endl '\n'

#define sp <<" "<<

#define intmax 1e14

#define M 1000000007



ll power(ll num,ll g,ll mod){

  if(g==0)return 1;

  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;

  return power((num*num)%mod,g/2,mod);

}

 

int main(){

	ll n, k;

	cin>>n>>k;

	vector<ll> vec(k+1);

	vector<ll> temp(k+1);

	FOR1(i, k)	vec[i] = 0; vec[0] = 1;

	while(n--){

		ll a; cin>>a;

		ll sum = 0;

		FOR0(i, k+1){

			sum += vec[i];

			if(i-a-1 >= 0)

				sum -= vec[i-a-1];

			sum %= M;

			temp[i] = sum;

		}

		swap(vec, temp);

	}

	cout<<(vec[k] + M) % M<<"\n";

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

using namespace std;

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

#define all(x) begin(x), end(x)

#define rall(x) rbegin(x), rend(x)

#define sz(x) (int)(x).size()

#define int long long

typedef long long ll;

typedef pair<int, int> ii;

typedef vector<int> vi;

typedef vector<bool> vb;

typedef vector<vi> vvi;



signed main() {

  const int MOD = 1e9+7;

  cin.tie(0)->sync_with_stdio(0);

  cin.exceptions(cin.failbit);

  int n, k; cin >> n >> k;

  vi v(n); for(int& i: v) cin >> i;

  vector<vi> dp(n+1, vi(k+1));

  dp[0][0] = 1;

  vi p(k+2, 1); p[0] = 0;

  vi nxt(k+2);

  rep(i,1,n+1){

    nxt.assign(k+2,0);

    rep(j,0,k+1){

      dp[i][j] = (p[j+1] - p[j-min(j, v[i-1])]) % MOD;

      nxt[j+1] = (nxt[j] + dp[i][j]) % MOD;

    }

    swap(p,nxt);

  }

  cout << (dp[n][k] + MOD) % MOD;

  return 0;

}


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

using namespace std;

#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 all(x) begin(x), end(x)

#define rall(x) rbegin(x), rend(x)

#define sz(x) (int)(x).size()

typedef long long ll;

typedef pair<int, int> ii;

typedef vector<int> vi;

typedef vector<bool> vb;

typedef vector<vi> vvi;



const int MOD = 1e9+7;



void addSelf(int &a, int b){

  a += b;

  if(a >= MOD) a -= MOD;

  if(a < 0) a += MOD;

}



int main() {

  cin.tie(0)->sync_with_stdio(0);

  cin.exceptions(cin.failbit);

  int n,k; cin >> n >> k;

  vi dp(k+1); dp[0] = 1;

  rep(i,0,n){

    int up; cin >> up;

    vi delta(k+1);

    rrep(j,k,0){

      int a = j + 1;

      int b = j + min(up, k-j);

      int tmp = dp[j];

      if(a <= b){

        addSelf(delta[a], tmp);

        if(b+1 <= k)

          addSelf(delta[b+1], -tmp);

      }

    }

    int inc = 0;

    rep(j,1,k+1){

      addSelf(inc, delta[j]);

      addSelf(dp[j],inc);

    }

  }

  cout << dp[k];

}
// Slower C++ solution:
#pragma GCC optimize(2)

#include<bits/stdc++.h>

#define LL long long

#define int LL

const LL inf=0x3f3f3f3f;

using namespace std;

template<typename tp> inline void read(tp &x)

{

	x=0; char c=getchar(); bool f=0;

	for(;c<'0'||c>'9';f|=(c=='-'),c = getchar());

	for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c = getchar());

	if(f) x=-x;

}

int n,m;

signed main()

{

	read(n),read(m);

	printf("%lld\n",n*m-n-m+1);

	return 0;

}

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

using namespace std;

int main()

{

	int n,m;

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

	printf("%d",n*m-(n+m-1));

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

#include <cstdio>

#include <cstring>

#include <cmath>

#include <algorithm>

using namespace std;

typedef long long LL;

inline LL in()

{

    LL x = 0, flag = 1; char ch = getchar();

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

    while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();

    return x * flag;

}

LL n, m;

int main()

{

    n = in();

    m = in();

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

    return 0;

}

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



int main(){

	int a,b;

	scanf("%d%d",&a,&b);

	printf("%d",(a-1)*(b-1));

	return 0;

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

using namespace std;



int main () {

	int A, B;

	cin>>A>>B;

	cout<<(A*B)-(A+B-1)<<endl;

}




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

int main()

{

    int A,B,area,lenth=1,road;



    scanf("%d %d",&A,&B);

    road=(A*lenth)+(B*lenth)-lenth*lenth;



    area=(A*B)-road;

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

  





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

using namespace std;



int main (){

    int A,B;

    

    cin >> A >>B;



    cout << A*B-1*B-1*A+1<< endl;



    return 0;



}

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

int main()

{

    int A,B,area,lenth=1,road;



    scanf("%d %d",&A,&B);

    road=(A*lenth)+(B*lenth)-lenth*lenth;



    area=(A*B)-road;

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

  





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



using namespace std;



int main()



{

int A,B;

scanf("%d%d",&A,&B);



int ans,rd,area;



area=A*B;

rd=A*1+B*1-1;

ans=area-rd;

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

printf(" \n");



}


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

int main()

{

    int A,B,area,lenth=1,road;



    scanf("%d %d",&A,&B);

    road=(A*lenth)+(B*lenth)-lenth*lenth;



    area=(A*B)-road;

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

  





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

#include<string>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;



int main()

{

	string s;

	cin>>s;

	int len=s.length();

	while(len>0)

	{

		if(len>=5)

		{

			if(s.substr(len-5,5)=="dream"||s.substr(len-5,5)=="erase")

			{

				len-=5;

				continue;

			}

		}

		if(len>=6)

		{

			if(s.substr(len-6,6)=="eraser")

			{

				len-=6;

				continue;

			}

		}

		if(len>=7)

		{

			if(s.substr(len-7,7)=="dreamer")

			{

				len-=7;

				continue;

			}

		}

		if(len!=0)

		{

			cout<<"NO"<<endl;

			return 0;

		}

	}



	cout<<"YES"<<endl;

	return 0;

}

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

#include <cstring>



char str[100010];

bool vis[100010] = {1};

int main() {

	scanf("%s", str);

	for (int i = 0; str[i]; ++i) {

		if (vis[i]) {

			if (strncmp(str + i, "dreamer", 7) == 0)

				vis[i + 7] = 1;

			if (strncmp(str + i, "eraser", 6) == 0)

				vis[i + 6] = 1;

			if (strncmp(str + i, "dream", 5) == 0)

				vis[i + 5] = 1;

			if (strncmp(str + i, "erase", 5) == 0)

				vis[i + 5] = 1;

		}

	}

	puts(vis[strlen(str)] ? "YES" : "NO");

	return 0;

}