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

#include<algorithm>

using namespace std;

bool dp[1000001];

bool isprime(int& x){

  for(int i = 2 ; i * i <= x ; i++ ) if( x % i == 0) return true;

  return false;

}

int solve(int i){

  while(true){ if(dp[i] && !isprime(i)) return i; i--; }

}

int main(){

  int n,x,data[30],ans;

  while(cin >> n >> x , n){

    fill_n(dp,1000001,false); dp[0] = true;

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

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

      if(dp[i]) for(int j = 0 ; j < n ; j++ )

        if(i + data[j] <= x) dp[i+data[j]] = true;

    }

    if(1 < (ans = solve(x))) cout << ans << endl;

    else cout << "NA" << endl;

  }

}

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

#include<algorithm>

using namespace std;

bool dp[1000001];

bool isprime(int& x){

  for(int i = 2 ; i * i <= x ; i++ ) if( x % i == 0) return true;

  return x == 1;

}

int solve(int i){

  while(true){ if(dp[i] && !isprime(i)) return i; i--; }

}

int main(){

  int n,x,data[30],ans; dp[0] = true;

  while(cin >> n >> x , n){

    for(int i = 1 ; i <= x ; i++ ) dp[i] = false;

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

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

      if(dp[i]) for(int j = 0 ; j < n ; j++ )

        if(i + data[j] <= x) dp[i+data[j]] = true;

    }

    if(ans = solve(x)) cout << ans << endl;

    else cout << "NA" << endl;

  }

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

#include<algorithm>

using namespace std;

bool dp[1000001];

bool isprime(int& x){

  for(int i = 2 ; i * i <= x ; i++ ) if( x % i == 0) return true;

  return false;

}

int solve(int i){

  while(true){ if(dp[i] && !isprime(i)) return i; i--; }

}

int main(){

  int n,x,data[30],ans;

  while(cin >> n >> x , n){

    fill_n(dp,1000001,false); dp[0] = true;

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

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

      if(dp[i]) for(int j = 0 ; j < n ; j++ )

        if(i + data[j] <= x) dp[i+data[j]] = true;

    }

    if(1 < (ans = solve(x))) cout << ans << endl;

    else cout << "NA" << endl;

  }

}

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

#include<algorithm>

using namespace std;

bool dp[1000001];

bool isprime(int& x){

  for(int i = 2 ; i * i <= x ; i++ ) if( x % i == 0) return true;

  return x == 1;

}

int solve(int i){

  while(true){

    if(dp[i] && !isprime(i)) return i;

    i--;

  }

}

int main(){

  int n,x,data,ans;

  dp[0] = true;

  while(cin >> n >> x , n){

    for(int i = 1 ; i <= x ; i++ ) dp[i] = false;

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

      cin >> data;

      for(int i = data ; i <= x ; i++ ) if(dp[i-data]) dp[i] = true;

    }

    if(ans = solve(x)) cout << ans << endl;

    else cout << "NA" << endl;

  }

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

#include<algorithm>

using namespace std;

bool dp[1000001];

bool isprime(int& x){

  for(int i = 2 ; i * i <= x ; i++ ) if( x % i == 0) return true;

  return x == 1;

}

int solve(int i){

  while(true){ if(dp[i] && !isprime(i)) return i; i--; }

}

int main(){

  int n,x,data[30],ans; dp[0] = true;

  while(cin >> n >> x , n){

    for(int i = 1 ; i <= x ; i++ ) dp[i] = false;

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

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

      if(dp[i]) for(int j = 0 ; j < n ; j++ )

        if(i + data[j] <= x) dp[i+data[j]] = true;

    }

    if(ans = solve(x)) cout << ans << endl;

    else cout << "NA" << endl;

  }

}

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

#include<algorithm>

using namespace std;

bool dp[1000001];

bool isprime(int& x){

  for(int i = 2 ; i * i <= x ; i++ ) if( x % i == 0) return true;

  return x == 1;

}

int solve(int i){

  while(true){

    if(dp[i] && !isprime(i)) return i;

    i--;

  }

}

int main(){

  int n,x,data,ans;

  dp[0] = true;

  while(cin >> n >> x , n){

    for(int i = 1 ; i <= x ; i++ ) dp[i] = false;

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

      cin >> data;

      for(int i = data ; i <= x ; i++ ) if(dp[i-data]) dp[i] = true;

    }

    if(ans = solve(x)) cout << ans << endl;

    else cout << "NA" << endl;

  }

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

#include <iostream>

#include <algorithm>



using namespace std;





int an[105];

int ans,a,b,c;



int main()

{

	cin >> a >> b >> c;

	an[a]++;

	an[b]++;

	an[c]++;

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

		ans = max(ans,an[i]);

	}

	cout << (3-ans+1) << endl;

	return 0;

}

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

int main(){

	int a,b,c;

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

	if(a != b && b != c && a != c) printf("3\n");

	else if(a == b && b == c) printf("1\n");

	else printf("2\n");

	return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 200005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

 vector<int> vi[maxii];

 vector<int>::iterator child;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];





int main()

{

   set<int>st;

   int a,b,c;

   cin>>a>>b>>c;

   st.insert(a);

   st.insert(b);

   st.insert(c);

   cout<<st.size();





}










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

using namespace std;

int main(){



    int a,b,c; cin >> a >> b >> c;



    int cnt = 0;

    if(a != b)cnt++;

    if(a != c)cnt++;

    if(b != c)cnt++;

    if(cnt != 0)cout << cnt;

    else cout << 1;



}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 200005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

 vector<int> vi[maxii];

 vector<int>::iterator child;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];





int main()

{

   set<int>st;

   int a,b,c;

   cin>>a>>b>>c;

   st.insert(a);

   st.insert(b);

   st.insert(c);

   cout<<st.size();





}










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

#include <string.h> 

using namespace std;

int main() {

    int a, b, c, d;

    cin >> a >> b >> c ;

    if (a == b&&b == c)

        cout << 1;

    else if (a != b && b != c && c != a)

        cout << 3;

    else 

        cout<<2;

    return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 200005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

 vector<int> vi[maxii];

 vector<int>::iterator child;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];





int main()

{

   set<int>st;

   int a,b,c;

   cin>>a>>b>>c;

   st.insert(a);

   st.insert(b);

   st.insert(c);

   cout<<st.size();





}










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

using namespace std;

int main()

{

    int a,b,c;

    cin>>a>>b>>c;

    if (a!=b&& b!=c&&a!=c)

        cout<<3;

    else if (a==b&&a==c)

        cout<<1;

    else if (a==c||a==b||b==c)

        cout<<2;



return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 200005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

 vector<int> vi[maxii];

 vector<int>::iterator child;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];





int main()

{

   set<int>st;

   int a,b,c;

   cin>>a>>b>>c;

   st.insert(a);

   st.insert(b);

   st.insert(c);

   cout<<st.size();





}










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

#include<set>

#include<vector>

#include<string>

#include<iterator>

#include<iomanip>

#include<cmath>

#include<map>

#include<string.h>

#include<algorithm>



using namespace std;

void ll(){

	std::ios_base::sync_with_stdio(0);

	cin.tie(NULL);

	cout.tie(0);

}



int main() {



	ll();

	 

	int a, b, c;

	cin >> a >> b >> c;

	if ((a != b&&a==c)||(a==b&&a!=c)||(b==c&&c!=a))

		cout << 2 << endl;

	else if (a != b&&a != c&&b != c)

		cout << 3 << endl;

	else if (a == b&&a == c)

		cout << 1 << endl;

	



}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 200005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

 vector<int> vi[maxii];

 vector<int>::iterator child;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];





int main()

{

   set<int>st;

   int a,b,c;

   cin>>a>>b>>c;

   st.insert(a);

   st.insert(b);

   st.insert(c);

   cout<<st.size();





}










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

using namespace std;

int main()

{

	int a, b, c, d;

	cin >> a >> b >> c;

	if (a == b && a == c)

		cout << 1;

	else if (a != b && a != c&&b!=c)

		cout << 3;

	else

		cout << 2;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 200005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

 vector<int> vi[maxii];

 vector<int>::iterator child;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];





int main()

{

   set<int>st;

   int a,b,c;

   cin>>a>>b>>c;

   st.insert(a);

   st.insert(b);

   st.insert(c);

   cout<<st.size();





}










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

#include <bits/c++io.h>

#include <algorithm>

#include <iomanip>

#include <math.h>

using namespace std;



int main()

{

int x,y,z,n=1;

cin>>x>>y>>z;

if(x!=y&&x!=z&&z!=y)

cout<<"3"<<endl;

else if(x==y&&x==z&&z==y)

cout<<"1"<<endl;

else

cout<<"2"<<endl;



 return 0;

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

#include<set>

using namespace std;

int main()

{

    set<int> s;

    int a;

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

    {

        cin>>a;

        s.insert(a);

    }

    cout<<s.size()<<endl;

    return 0;

}


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

int main()

{

	int a[3]={0};

	int i,j,x;

	int k=0;

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

	{

	scanf("%d",&x);

	a[i]=x;

	}

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

	{

		for(j=i+1;j<3;j++)

		{

			if(a[0]==a[1]&&a[1]==a[2])

			k=1;

		 	else if(a[i]!=a[j])

			k++;

			

		}

	}

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

	return 0;

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

#include<cstdio>

#include<algorithm>

#include<cmath>

using namespace std;

typedef long long ll;

const ll mod=998244353;

ll n,m,ny[1100000],jc[1100000];

ll c(ll n,ll m)

{

    return (ll)jc[n]*ny[m]%mod*ny[n-m]%mod;

}

 

int main()

{

    cin>>n>>m;

    if(n<=m)swap(n,m);

    jc[0]=jc[1]=ny[0]=ny[1]=1;

    for(int i=2;i<=n+m;i++)jc[i]=(ll)jc[i-1]*i%mod,ny[i]=(ll)(mod-mod/i)*ny[mod%i]%mod;

    for(int i=2;i<=n+m;i++)ny[i]=(ll)ny[i-1]*ny[i]%mod;

    ll ans=0;

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

    {

        ans+=(ll)c(n+m-i*2,n-i)%mod*c(i*2,i)%mod;

        ans%=mod;

    }

    ans=(ll)ans*ny[n+m]%mod*jc[n]%mod*jc[m]%mod*ny[2]%mod;

    ans+=n;

    ans%=mod;

     

    cout<<ans<<endl;

}


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

const int N=1000005,Mod=998244353;

int fac[N],inv[N];

inline int qpow(int a,int b){

	int ans=1;

	while (b){

		if (b&1) ans=(1ll*ans*a)%Mod;

		a=(1ll*a*a)%Mod,b>>=1;

	}

	return ans;

}

inline int Min(int a,int b){

	return a<b?a:b;

}

inline int Max(int a,int b){

	return a>b?a:b;

}

inline int C(int n,int m){

	return 1ll*fac[n]*inv[m]%Mod*inv[n-m]%Mod;

}

int main (){

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

	fac[0]=1;

	for (int i=1;i<=n+m;i++) fac[i]=1ll*fac[i-1]*i%Mod;

	inv[n+m]=qpow(fac[n+m],Mod-2);

	for (int i=n+m-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%Mod;

	int t=Min(n,m),ans=0;

	for (int i=1;i<=t;i++) ans=(1ll*ans+1ll*C(i*2,i)*C(n+m-2*i,n-i))%Mod;

	ans=1ll*ans*qpow(2,Mod-2)%Mod*qpow(C(n+m,n),Mod-2)%Mod;

	printf ("%d",(ans+Max(n,m))%Mod);

	return 0;

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

#include<cstdio>

#include<cstring>

#include<cmath>



using namespace std;

const int N=1000005;

const int MOD=998244353;

typedef long long LL;



int n,m,fac[N],inv[N];

int Ans1,Ans2;



//LL gcd(LL x,LL y) {

//	if(!y) return x;

//	return gcd(y,x%y);

//}

//

//struct Data{

//	LL x,y;

//	Data(LL _x=0,LL _y=0) {x=_x; y=_y;}

//	friend Data operator+(const Data A,const Data B){

//		Data ret; ret.y=A.y*B.y; ret.x=A.x*B.y+A.y*B.x;

//		LL tmp=gcd(ret.x,ret.y); ret.x/=tmp; ret.y/=tmp;

//		return ret;

//	}

//	friend Data operator*(const Data A,const Data B){

//		Data ret; ret.x=A.x*B.x; ret.y=A.y*B.y;

//		LL tmp=gcd(ret.x,ret.y); ret.x/=tmp; ret.y/=tmp;

//		return ret;

//	}

//}ans;



inline int fast_pow(int x,int y){

	int ret=1;

	for(;y;y>>=1){

		if(y&1) ret=(LL)ret*x%MOD;

		x=(LL)x*x%MOD;

	}

	return ret;

}



inline int C(int x,int y){

	return (LL)fac[x]*inv[y]%MOD*inv[x-y]%MOD;

}



int main(){

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

	if(n>m) swap(n,m); fac[0]=inv[0]=1;

	int i;

	for(i=1;i<=n+m;i+=4){

		fac[i]=1ll*fac[i-1]*i%MOD;

		fac[i+1]=1ll*fac[i]*(i+1)%MOD;

		fac[i+2]=1ll*fac[i+1]*(i+2)%MOD;

		fac[i+3]=1ll*fac[i+2]*(i+3)%MOD;

	}

	for(;i<=n+m;i++) fac[i]=fac[i-1]*i%MOD;

	inv[n+m]=fast_pow(fac[n+m],MOD-2);

	for(int i=n+m-1;~i;i--) inv[i]=1ll*inv[i+1]*(i+1)%MOD;

	Ans1=1ll*2*m*C(n+m,n)%MOD; Ans2=fast_pow(C(n+m,n)*2%MOD,MOD-2);

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

		Ans1=Ans1+1ll*C(n-i+m-i,n-i)*C(i+i,i)%MOD;	

		Ans1%=MOD;

	}

	printf("%lld\n",1ll*Ans1*Ans2%MOD);

//	ans=ans+Data(1,2)*Data(C(n-i+m-i,n-i)*C(i+i,i),C(n+m,n));

//	printf("%lld\n",1ll*ans.x*fast_pow(ans.y,MOD-2)%MOD);

	return 0;	

}

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

const int N=1000005,Mod=998244353;

int fac[N],inv[N];

inline int qpow(int a,int b){

	int ans=1;

	while (b){

		if (b&1) ans=(1ll*ans*a)%Mod;

		a=(1ll*a*a)%Mod,b>>=1;

	}

	return ans;

}

inline int Min(int a,int b){

	return a<b?a:b;

}

inline int Max(int a,int b){

	return a>b?a:b;

}

inline int C(int n,int m){

	return 1ll*fac[n]*inv[m]%Mod*inv[n-m]%Mod;

}

int main (){

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

	fac[0]=1;

	for (int i=1;i<=n+m;i++) fac[i]=1ll*fac[i-1]*i%Mod;

	inv[n+m]=qpow(fac[n+m],Mod-2);

	for (int i=n+m-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%Mod;

	int t=Min(n,m),ans=0;

	for (int i=1;i<=t;i++) ans=(1ll*ans+1ll*C(i*2,i)*C(n+m-2*i,n-i))%Mod;

	ans=1ll*ans*qpow(2,Mod-2)%Mod*qpow(C(n+m,n),Mod-2)%Mod;

	printf ("%d",(ans+Max(n,m))%Mod);

	return 0;

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

#include<cstdio>

#include<algorithm>

#include<cmath>

using namespace std;

typedef long long ll;

const ll mod=998244353;

ll n,m,ny[1100000],jc[1100000];

ll c(ll n,ll m)

{

    return (ll)jc[n]*ny[m]%mod*ny[n-m]%mod;

}

 

int main()

{

    cin>>n>>m;

    if(n<=m)swap(n,m);

    jc[0]=jc[1]=ny[0]=ny[1]=1;

    for(int i=2;i<=n+m;i++)jc[i]=(ll)jc[i-1]*i%mod,ny[i]=(ll)(mod-mod/i)*ny[mod%i]%mod;

    for(int i=2;i<=n+m;i++)ny[i]=(ll)ny[i-1]*ny[i]%mod;

    ll ans=0;

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

    {

        ans+=(ll)c(n+m-i*2,n-i)%mod*c(i*2,i)%mod;

        ans%=mod;

    }

    ans=(ll)ans*ny[n+m]%mod*jc[n]%mod*jc[m]%mod*ny[2]%mod;

    ans+=n;

    ans%=mod;

     

    cout<<ans<<endl;

}


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

#include<algorithm>

using namespace std;const int N=3*1e6+10;typedef long long ll;const ll mod=998244353;

inline ll po(ll a,ll p){ll r=1;for(;p;p>>=1,a=a*a%mod)if(p&1)r=r*a%mod;return r;}

int n;int m;ll fac[N];ll ifac[N];

inline ll c(int a,int b){return fac[a]*ifac[b]%mod*ifac[a-b]%mod;}

int main()

{

	scanf("%d%d",&n,&m);if(n<m)swap(n,m);

	fac[0]=1;for(int i=1;i<=n+m;i++)fac[i]=fac[i-1]*i%mod;ifac[0]=ifac[1]=1;

	for(int i=2;i<=n+m;i++)ifac[i]=(mod-mod/i)*ifac[mod%i]%mod;

	for(int i=1;i<=n+m;i++)(ifac[i]*=ifac[i-1])%=mod;

	ll tans=0;for(int i=1;i<=m;i++)

		(tans+=c(i+i-1,i)*c(n+m-i-i,n-i))%=mod;

	tans=(mod-tans)%mod;(tans+=(n-m)*c(m+n,m-1))%=mod;

	if(m!=n)

	{

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

			(tans+=c(m+i,i)*i%mod*c(n-i-1,m-i))%=mod;	

	}else (tans+=c(n+m,m)*m)%=mod;

	tans=tans*po(c(n+m,m),mod-2)%mod;

	tans=(n+m+mod-tans)%mod;

	printf("%lld\n",tans);return 0;

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

#include<cstdio>

#include<cstring>

#include<cmath>



using namespace std;

const int N=1000005;

const int MOD=998244353;

typedef long long LL;



int n,m,fac[N],inv[N];

int Ans1,Ans2;



//LL gcd(LL x,LL y) {

//	if(!y) return x;

//	return gcd(y,x%y);

//}

//

//struct Data{

//	LL x,y;

//	Data(LL _x=0,LL _y=0) {x=_x; y=_y;}

//	friend Data operator+(const Data A,const Data B){

//		Data ret; ret.y=A.y*B.y; ret.x=A.x*B.y+A.y*B.x;

//		LL tmp=gcd(ret.x,ret.y); ret.x/=tmp; ret.y/=tmp;

//		return ret;

//	}

//	friend Data operator*(const Data A,const Data B){

//		Data ret; ret.x=A.x*B.x; ret.y=A.y*B.y;

//		LL tmp=gcd(ret.x,ret.y); ret.x/=tmp; ret.y/=tmp;

//		return ret;

//	}

//}ans;



inline int fast_pow(int x,int y){

	int ret=1;

	for(;y;y>>=1){

		if(y&1) ret=(LL)ret*x%MOD;

		x=(LL)x*x%MOD;

	}

	return ret;

}



inline int C(int x,int y){

	return (LL)fac[x]*inv[y]%MOD*inv[x-y]%MOD;

}



int main(){

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

	if(n>m) swap(n,m); fac[0]=inv[0]=1;

	int i;

	for(i=1;i<=n+m;i+=4){

		fac[i]=1ll*fac[i-1]*i%MOD;

		fac[i+1]=1ll*fac[i]*(i+1)%MOD;

		fac[i+2]=1ll*fac[i+1]*(i+2)%MOD;

		fac[i+3]=1ll*fac[i+2]*(i+3)%MOD;

	}

	for(;i<=n+m;i++) fac[i]=fac[i-1]*i%MOD;

	inv[n+m]=fast_pow(fac[n+m],MOD-2);

	for(int i=n+m-1;~i;i--) inv[i]=1ll*inv[i+1]*(i+1)%MOD;

	Ans1=1ll*2*m*C(n+m,n)%MOD; Ans2=fast_pow(C(n+m,n)*2%MOD,MOD-2);

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

		Ans1=Ans1+1ll*C(n-i+m-i,n-i)*C(i+i,i)%MOD;	

		Ans1%=MOD;

	}

	printf("%lld\n",1ll*Ans1*Ans2%MOD);

//	ans=ans+Data(1,2)*Data(C(n-i+m-i,n-i)*C(i+i,i),C(n+m,n));

//	printf("%lld\n",1ll*ans.x*fast_pow(ans.y,MOD-2)%MOD);

	return 0;	

}

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

#include<algorithm>

using namespace std;const int N=3*1e6+10;typedef long long ll;const ll mod=998244353;

inline ll po(ll a,ll p){ll r=1;for(;p;p>>=1,a=a*a%mod)if(p&1)r=r*a%mod;return r;}

int n;int m;ll fac[N];ll ifac[N];

inline ll c(int a,int b){return fac[a]*ifac[b]%mod*ifac[a-b]%mod;}

int main()

{

	scanf("%d%d",&n,&m);if(n<m)swap(n,m);

	fac[0]=1;for(int i=1;i<=n+m;i++)fac[i]=fac[i-1]*i%mod;ifac[0]=ifac[1]=1;

	for(int i=2;i<=n+m;i++)ifac[i]=(mod-mod/i)*ifac[mod%i]%mod;

	for(int i=1;i<=n+m;i++)(ifac[i]*=ifac[i-1])%=mod;

	ll tans=0;for(int i=1;i<=m;i++)

		(tans+=c(i+i-1,i)*c(n+m-i-i,n-i))%=mod;

	tans=(mod-tans)%mod;(tans+=(n-m)*c(m+n,m-1))%=mod;

	if(m!=n)

	{

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

			(tans+=c(m+i,i)*i%mod*c(n-i-1,m-i))%=mod;	

	}else (tans+=c(n+m,m)*m)%=mod;

	tans=tans*po(c(n+m,m),mod-2)%mod;

	tans=(n+m+mod-tans)%mod;

	printf("%lld\n",tans);return 0;

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

#define N 1000005

#define p 998244353

#define int long long 

using namespace std;



inline void rd(int &x){

	x=0;char ch=0;int w=0;

	while(!isdigit(ch)) ch=getchar(),w|=ch=='-';

	while( isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();

	x=w?-x:x;

}



int n,m,ans;

int f[N],inv[N];



inline int POW(int a,int b=p-2,int ans=1){

	for(;b;b>>=1,a=a*a%p)

		if(b&1) ans=ans*a%p;

	return ans;

}



inline int C(int n,int m){

	return f[n]*inv[m]%p*inv[n-m]%p;

}

signed main(){

	cin>>n>>m;if(n<m) swap(n,m);

	for(int i=f[0]=inv[0]=1;i<=n+m;i++)

		f[i]=f[i-1]*i%p,inv[i]=POW(f[i]);

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

		ans=(ans+C(i<<1,i)*C(n-i+m-i,n-i))%p;

	ans=ans*inv[2]%p*POW(C(n+m,n))%p;

	cout<<(ans+n)%p;

}

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

#include <algorithm>



const int maxn = 1000005, P = 998244353;

int n, m, fac[maxn], ifac[maxn];



int power(int a, int x)

{

	int ans = 1;

	for (; x; x >>= 1, a = 1LL * a * a % P)

		if (x & 1)

			ans = 1LL * ans * a % P;

	return ans;

}

int binom(int n, int m)

{

	if (n < m || m < 0)

		return 0;

	return 1LL * fac[n] * ifac[m] % P * ifac[n - m] % P;

}



int main()

{

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

	if (n < m)

		std::swap(n, m);

	fac[0] = 1;

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

		fac[i] = 1LL * fac[i - 1] * i % P;

	ifac[n + m] = power(fac[n + m], P - 2);

	for (int i = n + m; i; --i)

		ifac[i - 1] = 1LL * ifac[i] * i % P;

	int ans = 0;

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

		ans = (ans + 1LL * binom(2 * i, i) * binom(n + m - 2 * i, n - i)) % P;

	ans = 1LL * ans * power(2 * binom(n + m, n) % P, P - 2) % P;

	ans = (ans + n) % P;

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

	return 0;

}