stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int l,sum=0;

const int maxn=1e5+10;

char t[maxn];

int main()

{

	while(scanf("%s",t)!=EOF)

	{

	   l=strlen(t);

	   for(int i=1;i<l-1;i++)

		  if(t[i-1]!=t[i+1]) sum++;

	   if(sum==0)

	   {

		printf("Second\n");

		continue;

	    }

	   if(t[0]!=t[l-1])

	   {

		  printf("%s\n",l%2?"First":"Second");

       }

       else

	   {

		  printf("%s\n",l%2?"Second":"First");

	   }

	}

	

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>

char s[100005];

int len;

int main(){

    scanf("%s", s), len = strlen(s);

    if (s[0] == s[len - 1]) puts(len & 1 ? "Second" : "First");

    else puts(len & 1 ? "First" : "Second");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

char s[1000001];

long long a=0,b=0;

int main()

{

    cin>>s;

    a=strlen(s)-2;

    for (int i=0,j=strlen(s)-1;i<j;i++,j--)

    {

        if (s[i]==s[j])

        b++;

    }

    if (b==(a+2)/2)

    cout<<"Second"<<endl;

    else

    {

    if (s[0]==s[strlen(s)-1])

    {

        a=a-1;

        if (a%2==0)

        cout<<"Second"<<endl;

        else

        cout<<"First"<<endl;

    }

    else

    {

    if (a%2==0)

    cout<<"Second"<<endl;

    else

    cout<<"First"<<endl;	

    }

    }

    return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>

char s[100005];

int len;

int main(){

    scanf("%s", s), len = strlen(s);

    if (s[0] == s[len - 1]) puts(len & 1 ? "Second" : "First");

    else puts(len & 1 ? "First" : "Second");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstring>

using namespace std;

int main()

{

	//freopen("xx.in","r",stdin);

	string s;

	cin>>s;

	int len=s.length();

	if(s[0]^s[len-1])

	{

		if(len&1) cout<<"First"<<endl;

		else cout<<"Second"<<endl;

	}

	else

	{

		if(len&1) cout<<"Second"<<endl;

		else cout<<"First"<<endl;

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<queue>

#include<cmath>

using namespace std;

char s[100001];

int main()

{

    scanf("%s",s);

    int len=strlen(s);

    if(s[0]==s[len-1])

    {

        if(len%2==1)

    printf("Second");

        else

    printf("First");

    }

    else

    {

        if(len%2==1)

    printf("First");

        else

    printf("Second");

    }

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<iomanip>

#include<cstring>

#include<cstdio>

#include<cmath>

#include<algorithm>

#include<set>

using namespace std;

string s;

int main() {

    cin>>s;

    int n=s.length();

    s=' '+s;

    if(s[1]==s[n]){

    	if(n%2==1)puts("Second");

    	else puts("First");

	}

	else {

		if(n%2==0)puts("Second");

    	else puts("First");

	}

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<queue>

#include<cmath>

using namespace std;

char s[100001];

int main()

{

    scanf("%s",s);

    int len=strlen(s);

    if(s[0]==s[len-1])

    {

        if(len%2==1)

    printf("Second");

        else

    printf("First");

    }

    else

    {

        if(len%2==1)

    printf("First");

        else

    printf("Second");

    }

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

using namespace std;

string s;

int main()

{

	cin>>s;

	int l=s.length();

	if(s[0]==s[l-1])

	{

		if(l%2==0) cout<<"First"<<endl;

		else cout<<"Second"<<endl;

	}

	else

	{

		if(l%2==0) cout<<"Second"<<endl;

		else cout<<"First"<<endl;

	}

	return 0;

} 

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<queue>

#include<cmath>

using namespace std;

char s[100001];

int main()

{

    scanf("%s",s);

    int len=strlen(s);

    if(s[0]==s[len-1])

    {

        if(len%2==1)

    printf("Second");

        else

    printf("First");

    }

    else

    {

        if(len%2==1)

    printf("First");

        else

    printf("Second");

    }

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

string s;

int main()

{

	cin>>s;

	if(s[0]==s[s.size()-1]){

		if(s.size()%2==0){

			cout<<"First"<<endl;

		}

		else{

			cout<<"Second"<<endl;

		}

	}

	else{

		if(s.size()%2!=0){

			cout<<"First"<<endl;

		}

		else{

			cout<<"Second"<<endl;

		}

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<queue>

#include<cmath>

using namespace std;

char s[100001];

int main()

{

    scanf("%s",s);

    int len=strlen(s);

    if(s[0]==s[len-1])

    {

        if(len%2==1)

    printf("Second");

        else

    printf("First");

    }

    else

    {

        if(len%2==1)

    printf("First");

        else

    printf("Second");

    }

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <iostream>

#include <algorithm>

#include <set>

#include <queue>

using namespace std;

char s[100005];

int main(){

	int n,i,j,k,o,p,l;

	scanf("%s",s+1);

	n=strlen(s+1);

	int ok=1;

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

	if(s[i]!=s[i-2]){ok=0;break;}

	if(ok==1)printf("Second");

	else{

	if(s[1]==s[n]){

	if(n%2==0)printf("First");

	else printf("Second");

	}

	else{

	if(n%2==1)printf("First");

	else printf("Second");

	}

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<queue>

#include<cmath>

using namespace std;

char s[100001];

int main()

{

    scanf("%s",s);

    int len=strlen(s);

    if(s[0]==s[len-1])

    {

        if(len%2==1)

    printf("Second");

        else

    printf("First");

    }

    else

    {

        if(len%2==1)

    printf("First");

        else

    printf("Second");

    }

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

string s;

int main(){

    cin>>s;int l=s.size();

    if(s[0]==s[l-1]) if(l&1) puts("Second");else puts("First");

    else if(!(l&1)) puts("Second");else puts("First");

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<queue>

#include<cmath>

using namespace std;

char s[100001];

int main()

{

    scanf("%s",s);

    int len=strlen(s);

    if(s[0]==s[len-1])

    {

        if(len%2==1)

    printf("Second");

        else

    printf("First");

    }

    else

    {

        if(len%2==1)

    printf("First");

        else

    printf("Second");

    }

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <map>



using namespace std;



char str[110000];



int main()

{

	cin>>str;

	int flag = 1;

	int len;

	len = strlen(str);

	for(int i = 0;i < len - 2;i++)

	{

		if(str[i] != str[i+2])

		{

			flag = 0;

			break;

		}

	}

	if(flag)

		cout<<"Second"<<endl;

	else if(str[0] == str[len-1] && len % 2)

		cout<<"Second"<<endl;

	else if(len % 2)

		cout<<"First"<<endl;

	else if(str[0] == str[len-1] && len % 2 == 0)

		cout<<"First"<<endl;

	else

		cout<<"Second"<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

#include <algorithm>

using namespace std;

const int N = 1e5 + 10;

char s[N];



int main()

{

	scanf("%s",s);

	int len = strlen(s);

	int cnt = len - 2;

	if (s[0] == s[len - 1])

	{

		if (cnt % 2) puts("Second");

		else puts("First");

	}

	else

	{

		if (cnt % 2 == 0) puts("Second");

		else puts("First");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



int main () {

    char str[100005];

    scanf("%s", str);

    int len=strlen(str);

    if(str[0]==str[len-1]) {

        if(len&1) puts("Second");

        else puts("First");

    } else {

        if(len&1) puts("First");

        else puts("Second");

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

#include <algorithm>

using namespace std;

const int N = 1e5 + 10;

char s[N];



int main()

{

	scanf("%s",s);

	int len = strlen(s);

	int cnt = len - 2;

	if (s[0] == s[len - 1])

	{

		if (cnt % 2) puts("Second");

		else puts("First");

	}

	else

	{

		if (cnt % 2 == 0) puts("Second");

		else puts("First");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <cstring>

#include <algorithm>

#define ms(x) memset(x, 0, sizeof(x))

#define inf 0x3f3f3f3f

using namespace std;

int main()

{

    char s[123456];

    int cnt[27], book[27];

    while(scanf("%s",s)!=EOF){

        ms(cnt);

        int len = strlen(s), s1 = 0, s2 = 0;

        if(s[0] == s[len-1]) len--;

        if(len%=2) {printf("First\n");}

        else printf("Second\n");

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

#include <algorithm>

using namespace std;

const int N = 1e5 + 10;

char s[N];



int main()

{

	scanf("%s",s);

	int len = strlen(s);

	int cnt = len - 2;

	if (s[0] == s[len - 1])

	{

		if (cnt % 2) puts("Second");

		else puts("First");

	}

	else

	{

		if (cnt % 2 == 0) puts("Second");

		else puts("First");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

 

int main()

{

    string s;

    cin>>s;

    int len = s.length();

    if(s[0] == s[len-1])

        if(len&1)printf("Second\n");

        else printf("First\n");

    else

        if(len&1)printf("First\n");

        else printf("Second\n");

}

// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

#include <algorithm>

using namespace std;

const int N = 1e5 + 10;

char s[N];



int main()

{

	scanf("%s",s);

	int len = strlen(s);

	int cnt = len - 2;

	if (s[0] == s[len - 1])

	{

		if (cnt % 2) puts("Second");

		else puts("First");

	}

	else

	{

		if (cnt % 2 == 0) puts("Second");

		else puts("First");

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>//打表做法，危险动作，请勿效仿 

#include<cstdio>

#include<cstring>

using namespace std;

char s[1000005];

bool bo;

long long ji;

int main(){

	scanf("%s",&s);

	long long len=strlen(s);

	for(long long i=0;i<len-1;i++){

		if(s[i]!=s[i+1])bo=1;

	}

	if(bo=1){

		if(s[0]!=s[len-1])

			ji=len-2;

		else ji=len-3;

	}

	else ji=0;

	if(ji%2==1)cout<<"First";

	else cout<<"Second";

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

using namespace std;

char s[1000005];

bool bo;

long long ji;

int main(){

 	scanf("%s",&s);

 	long long len=strlen(s);

 	for(long long i=0;i<len-1;i++)

	 {

 	 	if(s[i]!=s[i+1])

		bo=1;

	}

	if(bo==1)

	{

		if(s[0]!=s[len-1])

 		ji=len-2;

 		else ji=len-3;

	}

	else ji=0;

 	if(ji%2==1)printf("First"); 

 	else printf("Second");

			return 0;

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

char s[1000001];

long long a=0,b=0;

int main()

{

	cin>>s;

	a=strlen(s);

	for (int i=0,j=strlen(s)-1;i<j;i++,j--)

	{

		if (s[i]==s[j])

		b++;

	}

	if (b==(a+2)/2)

	cout<<"Second";

	else

	{

	if (s[0]==s[strlen(s)-1])

	{

		a=a-1;

		if (a%2==0)

		cout<<"Second";

		else

		cout<<"First";

	}

	else

	{

	if (a%2==0)

	cout<<"Second";

	else

	cout<<"First";	

	}

	}

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

using namespace std;

char s[1000005];

bool bo;

long long ji;

int main(){

 	scanf("%s",&s);

 	long long len=strlen(s);

 	for(long long i=0;i<len-1;i++)

	 {

 	 	if(s[i]!=s[i+1])

		bo=1;

	}

	if(bo==1)

	{

		if(s[0]!=s[len-1])

 		ji=len-2;

 		else ji=len-3;

	}

	else ji=0;

 	if(ji%2==1)printf("First"); 

 	else printf("Second");

			return 0;

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

  }

}

// Optimized solution to the same problem (faster):
#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;

  }

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

  }

}

// Optimized solution to the same problem (faster):
#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;

  }

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):


#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();





}










// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;	

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#include<cstdio>



const int mod=998244353,N=1000005;



int fexp(int a,int b)

{

	int x=1;

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

		if(b&1)x=1LL*x*a%mod;

	return x;

}



int n,m,ans,fac[N],ifac[N];



int main()

{

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

	n+=m;

	fac[0]=1;

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

	ifac[n]=fexp(fac[n],mod-2);

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

	n-=m;

	if(n<m){int k=n;n=m;m=k;}

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

		ans=(ans+1LL*fac[x+x]*ifac[x]%mod*ifac[x]%mod*fac[n-x+m-x]%mod*ifac[n-x]%mod*ifac[m-x])%mod;

	ans=1LL*ans*ifac[2]%mod*ifac[n+m]%mod*fac[n]%mod*fac[m]%mod;

	printf("%d",(ans+n)%mod);

	return 0;

}


// Fastest known solution for this problem: