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

#include<cstdio>

#include<algorithm>

#include<cmath>

//#define int long long

using namespace std;

const int maxn=5e5+1000;

typedef long long ll;

int n,m;

const int mod=998244353;

int fr[maxn],ans;

inline int ksm(int num,int t){

	int res=1;

	for(;t;t>>=1,num=1ll*num*num%mod){

		if(t&1)res=1ll*res*num%mod;

	}

	return res;

}

inline int c(int m,int n){

	return 1ll*fr[n]*ksm((1ll*fr[m]*fr[n-m])%mod,mod-2)%mod;	

}

int main(){

	ios::sync_with_stdio(0);

	cin>>n>>m;

	fr[0]=fr[1]=1;

	for(int i=2;i<maxn;i++)fr[i]=1ll*fr[i-1]*i%mod;	

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

		ans=(ans+1ll*ksm(-1,i)*(1ll*c(i,n)*c(i,m)%mod*fr[i]%mod*ksm(m+1,n-i)%mod*ksm(n+1,m-i)%mod)%mod)%mod;	

	}

	ans=(ans%mod+mod)%mod;

	cout<<ans;

	return 0;

}

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

#include <cstdio>

#include <cstring>

#include <algorithm>

#define ll long long

using namespace std;

inline int read()

{

	int x = 0, f = 1; char ch = getchar();

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

	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}

	return x * f;

}

const int N = 5e5 + 1000,mod = 998244353;

int n,m,mx,mn;

ll ans,jc[N],jcinv[N],inv[N];

ll ksm(ll x,int y){ll res = 1; for(;y;y >>= 1,x = x * x % mod) if(y & 1) res = res * x % mod; return res;}

ll C(int x,int y){if(y < 0 || y > x) return 0; return jc[x] * jcinv[y] % mod * jcinv[x - y] % mod;}

int main()

{

	n = read(); m = read(); mx = max(m,n); mn = min(m,n);

	jc[0] = jc[1] = inv[0] = inv[1] = jcinv[0] = jcinv[1] = 1;

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

	{

		jc[i] = jc[i - 1] * i % mod;

		inv[i] = (mod - mod / i) * inv[mod % i] % mod;

		jcinv[i] = jcinv[i - 1] * inv[i] % mod;

	}

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

	{

		if(i & 1) ans = (ans + mod - C(n,i) * C(m,i) % mod * ksm(m + 1,n - i) % mod * ksm(n + 1,m - i) % mod * jc[i] % mod) % mod;

		else ans = (ans + C(n,i) * C(m,i) % mod * ksm(m + 1,n - i) % mod * ksm(n + 1,m - i) % mod * jc[i] % mod) % mod;

	}

	cout << ans << "\n";

	return 0;

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

#include<cstdio>

#include<algorithm>

#include<cmath>

//#define int long long

using namespace std;

const int maxn=5e5+1000;

typedef long long ll;

int n,m;

const int mod=998244353;

int fr[maxn],ans;

inline int ksm(int num,int t){

	int res=1;

	for(;t;t>>=1,num=1ll*num*num%mod){

		if(t&1)res=1ll*res*num%mod;

	}

	return res;

}

inline int c(int m,int n){

	return 1ll*fr[n]*ksm((1ll*fr[m]*fr[n-m])%mod,mod-2)%mod;	

}

int main(){

	ios::sync_with_stdio(0);

	cin>>n>>m;

	fr[0]=fr[1]=1;

	for(int i=2;i<maxn;i++)fr[i]=1ll*fr[i-1]*i%mod;	

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

		ans=(ans+1ll*ksm(-1,i)*(1ll*c(i,n)*c(i,m)%mod*fr[i]%mod*ksm(m+1,n-i)%mod*ksm(n+1,m-i)%mod)%mod)%mod;	

	}

	ans=(ans%mod+mod)%mod;

	cout<<ans;

	return 0;

}

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

using namespace std;

#define re register int

#define F(x,y,z) for(re x=y;x<=z;x++)

#define FOR(x,y,z) for(re x=y;x>=z;x--)

typedef long long ll;

#define I inline void

#define IN inline int

const int Mod=998244353;

int n,m,ans,fac[505000],inv[505000],sum;

I add(int &x,int y){(x+=y)>=Mod?x-=Mod:0;}

IN Plus(int x,int y){(x+=y)>=Mod?x-=Mod:0;return x;}

IN C(int x,int y){return (ll)fac[x]*inv[y]%Mod*inv[x-y]%Mod;}

IN A(int x,int y){return (ll)fac[x]*inv[x-y]%Mod;}

IN Pow(int x,int y=Mod-2){

	re res=1;

	while(y){

		if(y&1)res=(ll)res*x%Mod;

		x=(ll)x*x%Mod;

		y>>=1;

	}

	return res;

}

int main(){

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

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

	fac[0]=1;F(i,1,m)fac[i]=(ll)fac[i-1]*i%Mod;

	inv[m]=Pow(fac[m]);FOR(i,m-1,0)inv[i]=(ll)inv[i+1]*(i+1)%Mod;	

	sum=Pow(n+1,m-n);

	FOR(k,n,0){

		if(k&1)add(ans,Mod-(ll)C(n,k)*A(m,k)%Mod*sum%Mod);

		else add(ans,(ll)C(n,k)*A(m,k)%Mod*sum%Mod);

		sum=(ll)sum*(n+1)%Mod*(m+1)%Mod;

	}

	cout<<ans;

	return 0;

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

#include <algorithm>

using namespace std;

int main() {

 

  int n;

  cin >> n;

  int a1[100005] = {};

  int m1 = 0;

  int p1 = 0;

  int a2[100005] = {};

  int m2 = 0;

  int p2 = 0;

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

    int tmp;

    cin >> tmp;

    if (i % 2 == 0) {

      a1[tmp]++;

      if (a1[tmp] > m1) {

        m1 = a1[tmp];

        p1 = tmp;

      }

    }

    if (i % 2 == 1) {

      a2[tmp]++;

      if (a2[tmp] > m2) {

        m2 = a2[tmp];

        p2 = tmp;

      }

    }

  }

  if (p1 == p2) {

    int M1 = 0;

    int M2 = 0;

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

      if (i == p1) continue;

      M1 = max(M1, a1[i]);

      M2 = max(M2, a2[i]);

    }

    cout << n - max(m1 + M2, m2 + M1) << endl;

  }

  else {

    cout << n - m1 - m2 << endl;

  }

  return 0;

}

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

#include<cstdio>

#include<algorithm>

#include<cstring>

#define N 200005

using namespace std;

int n,a[N];

int mp1[N],mp2[N];

int mx=0,pos=0,mn=0;

int mx2=0,pos2=0,mn2=0;

int main(){

scanf("%d",&n);

for(int i=1;i<=n;i++)scanf("%d",a+i);

for(int i=1;i<=n;i+=2){mp1[a[i]]++;if(mp1[a[i]]>mx)mx=mp1[a[i]],pos=a[i];else if(mp1[a[i]]>mn)mn=mp1[a[i]];}

for(int i=2;i<=n;i+=2){mp2[a[i]]++;if(mp2[a[i]]>mx2)mx2=mp2[a[i]],pos2=a[i];else if(mp2[a[i]]>mn2)mn2=mp2[a[i]];}

// cout<<mx<<" "<<pos<<" "<<mx2<<" "<<pos2<<endl;

if(pos!=pos2)  printf("%d\n",n-mx-mx2);

else   printf("%d\n",n-max(mx+mn2,mx2+mn));

return 0;

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

#include <algorithm>

using namespace std;

int main() {

 

  int n;

  cin >> n;

  int a1[100005] = {};

  int m1 = 0;

  int p1 = 0;

  int a2[100005] = {};

  int m2 = 0;

  int p2 = 0;

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

    int tmp;

    cin >> tmp;

    if (i % 2 == 0) {

      a1[tmp]++;

      if (a1[tmp] > m1) {

        m1 = a1[tmp];

        p1 = tmp;

      }

    }

    if (i % 2 == 1) {

      a2[tmp]++;

      if (a2[tmp] > m2) {

        m2 = a2[tmp];

        p2 = tmp;

      }

    }

  }

  if (p1 == p2) {

    int M1 = 0;

    int M2 = 0;

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

      if (i == p1) continue;

      M1 = max(M1, a1[i]);

      M2 = max(M2, a2[i]);

    }

    cout << n - max(m1 + M2, m2 + M1) << endl;

  }

  else {

    cout << n - m1 - m2 << endl;

  }

  return 0;

}

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

using namespace std;

typedef long long ll;

int x[100005],y[100005];

int main()

{

    int j1=0,j2=0,o1=0,o2=0,a,b,c,d1=-1,d2=-1;

    cin>>a;

    for(b=0;b<a;b++)

    {

        scanf("%d",&c);

        if(b%2==0)

        {

            x[c]++;

            if(x[c]>j1)

            {

                if(c!=d2)

                {

                    j2=j1;

                    d2=c;

                }

                j1=x[c];



            }

            else if(x[c]>j2)

            {

                j2=x[c];

            }



        }

        else

        {

            y[c]++;

            if(y[c]>o1)

            {



                if(d1!=c)

                {

                    d1=c;

                    o2=o1;

                }

                o1=y[c];



            }

            else if(y[c]>o2)

            {

                o2=y[c];

            }

        }

    }

    if(d1==d2)

        cout<<min(a-j1-o2,a-j2-o1);

    else

        cout<<a-j1-o1;

    return 0;

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

#include <algorithm>

using namespace std;

int main() {

 

  int n;

  cin >> n;

  int a1[100005] = {};

  int m1 = 0;

  int p1 = 0;

  int a2[100005] = {};

  int m2 = 0;

  int p2 = 0;

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

    int tmp;

    cin >> tmp;

    if (i % 2 == 0) {

      a1[tmp]++;

      if (a1[tmp] > m1) {

        m1 = a1[tmp];

        p1 = tmp;

      }

    }

    if (i % 2 == 1) {

      a2[tmp]++;

      if (a2[tmp] > m2) {

        m2 = a2[tmp];

        p2 = tmp;

      }

    }

  }

  if (p1 == p2) {

    int M1 = 0;

    int M2 = 0;

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

      if (i == p1) continue;

      M1 = max(M1, a1[i]);

      M2 = max(M2, a2[i]);

    }

    cout << n - max(m1 + M2, m2 + M1) << endl;

  }

  else {

    cout << n - m1 - m2 << endl;

  }

  return 0;

}

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

#include<algorithm>

using namespace std;

const int MAXN=1e6+5;

int n;

int a[MAXN],num[MAXN];

struct rec{

	int x,pos;

};

rec c1[MAXN],c2[MAXN];

bool comp(const rec &x,const rec &y){

	return x.x>y.x;

}

int main(){

	scanf("%d",&n);

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

		scanf("%d",&a[i]); num[i]=a[i];

	}

	sort(num+1,num+1+n);

	int nn=unique(num+1,num+1+n)-num-1;

	for (int i=1;i<=n;++i) a[i]=lower_bound(num+1,num+1+nn,a[i])-num;

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

		c1[i].pos=i; c2[i].pos=i;

	}

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

		if (i%2==1) ++c1[a[i]].x; else ++c2[a[i]].x;

	

	sort(c1+1,c1+1+n,comp); sort(c2+1,c2+1+n,comp);

	if (c1[1].pos==c2[1].pos) printf("%d",min(n-c1[1].x-c2[2].x,n-c1[2].x-c2[1].x)); else printf("%d",n-c1[1].x-c2[1].x);

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

#include<cstdio>

#include<algorithm>

#include<cstring>

#define N 200005

using namespace std;

int n,a[N];

int mp1[N],mp2[N];

int mx=0,pos=0,mn=0;

int mx2=0,pos2=0,mn2=0;

int main(){

scanf("%d",&n);

for(int i=1;i<=n;i++)scanf("%d",a+i);

for(int i=1;i<=n;i+=2){mp1[a[i]]++;if(mp1[a[i]]>mx)mx=mp1[a[i]],pos=a[i];else if(mp1[a[i]]>mn)mn=mp1[a[i]];}

for(int i=2;i<=n;i+=2){mp2[a[i]]++;if(mp2[a[i]]>mx2)mx2=mp2[a[i]],pos2=a[i];else if(mp2[a[i]]>mn2)mn2=mp2[a[i]];}

// cout<<mx<<" "<<pos<<" "<<mx2<<" "<<pos2<<endl;

if(pos!=pos2)  printf("%d\n",n-mx-mx2);

else   printf("%d\n",n-max(mx+mn2,mx2+mn));

return 0;

}

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

#include<algorithm>

using namespace std;

const int MAXN=1e6+5;

int n;

int a[MAXN],num[MAXN];

struct rec{

	int x,pos;

};

rec c1[MAXN],c2[MAXN];

bool comp(const rec &x,const rec &y){

	return x.x>y.x;

}

int main(){

	scanf("%d",&n);

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

		scanf("%d",&a[i]); num[i]=a[i];

	}

	sort(num+1,num+1+n);

	int nn=unique(num+1,num+1+n)-num-1;

	for (int i=1;i<=n;++i) a[i]=lower_bound(num+1,num+1+nn,a[i])-num;

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

		c1[i].pos=i; c2[i].pos=i;

	}

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

		if (i%2==1) ++c1[a[i]].x; else ++c2[a[i]].x;

	

	sort(c1+1,c1+1+n,comp); sort(c2+1,c2+1+n,comp);

	if (c1[1].pos==c2[1].pos) printf("%d",min(n-c1[1].x-c2[2].x,n-c1[2].x-c2[1].x)); else printf("%d",n-c1[1].x-c2[1].x);

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

using namespace std;

typedef long long ll;

int x[100005],y[100005];

int main()

{

    int j1=0,j2=0,o1=0,o2=0,a,b,c,d1=-1,d2=-1;

    cin>>a;

    for(b=0;b<a;b++)

    {

        scanf("%d",&c);

        if(b%2==0)

        {

            x[c]++;

            if(x[c]>j1)

            {

                if(c!=d2)

                {

                    j2=j1;

                    d2=c;

                }

                j1=x[c];



            }

            else if(x[c]>j2)

            {

                j2=x[c];

            }



        }

        else

        {

            y[c]++;

            if(y[c]>o1)

            {



                if(d1!=c)

                {

                    d1=c;

                    o2=o1;

                }

                o1=y[c];



            }

            else if(y[c]>o2)

            {

                o2=y[c];

            }

        }

    }

    if(d1==d2)

        cout<<min(a-j1-o2,a-j2-o1);

    else

        cout<<a-j1-o1;

    return 0;

}




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

#include<algorithm>

using namespace std;

const int MAXN=1e6+5;

int n;

int a[MAXN],num[MAXN];

struct rec{

	int x,pos;

};

rec c1[MAXN],c2[MAXN];

bool comp(const rec &x,const rec &y){

	return x.x>y.x;

}

int main(){

	scanf("%d",&n);

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

		scanf("%d",&a[i]); num[i]=a[i];

	}

	sort(num+1,num+1+n);

	int nn=unique(num+1,num+1+n)-num-1;

	for (int i=1;i<=n;++i) a[i]=lower_bound(num+1,num+1+nn,a[i])-num;

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

		c1[i].pos=i; c2[i].pos=i;

	}

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

		if (i%2==1) ++c1[a[i]].x; else ++c2[a[i]].x;

	

	sort(c1+1,c1+1+n,comp); sort(c2+1,c2+1+n,comp);

	if (c1[1].pos==c2[1].pos) printf("%d",min(n-c1[1].x-c2[2].x,n-c1[2].x-c2[1].x)); else printf("%d",n-c1[1].x-c2[1].x);

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



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

using namespace std;



int main() {

    int N;

    cin >> N;

    vector<int> A(N), cnt1(100001), cnt2(100001);

    set<int> S;

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

        cin >> A[i];

        S.insert(A[i]);

        if (i & 1) {

            cnt2[A[i]]++;

        } else {

            cnt1[A[i]]++;

        }

    }

    if (S.size() == 1) {

        cout << N / 2 << endl;

        return 0;

    }

    if (max_element(all(cnt1)) - cnt1.begin() == max_element(all(cnt2)) - cnt2.begin()) {

        sort(all(cnt1), greater<int>());

        sort(all(cnt2), greater<int>());

        cout << min(N - (cnt1[0] + cnt2[1]), N - (cnt1[1] + cnt2[0])) << endl;

        return 0;

    }

    cout << N - (*max_element(all(cnt1)) + *max_element(all(cnt2))) << endl;



}

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



using namespace std;

#define pb push_back

#define mp make_pair

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

#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int,int> pii;

constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};



template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}



void solve() {

    int N;

    cin >> N;

    vector<int> A(N);

    for(int i = 0; i < N; i++) cin >> A[i];



    if (N == 2) {

        if (A[0] == A[1]) cout << 1 << endl;

        else cout << 0 << endl;

        return;    

    }



    vector<int> c1(100001), c2(100001);

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

        if (i % 2 == 0) {

            c1[A[i]]++;

        } else {

            c2[A[i]]++;

        }

    }



    int m1 = max_element(all(c1)) - c1.begin();

    int m2 = max_element(all(c2)) - c2.begin();



    if (m1 != m2) {

        cout << N - c1[m1] - c2[m2] << endl;

        return;

    } else {

        sort(c1.rbegin(), c1.rend());

        sort(c2.rbegin(), c2.rend());

        if (c1[1] < c2[1]) {

            cout << N - c1[0] - c2[1] << endl;

        } else {

            cout << N - c2[0] - c1[1] << endl;

        }

    }

}



int main() {

    std::cin.tie(0);

    std::ios::sync_with_stdio(false);

    cout.setf(ios::fixed);

    cout.precision(16);

    solve();

    return 0;

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



using namespace std;



using ll = long long;

using ld = long double;



int main() {

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

    cout << setprecision(10) << setiosflags(ios::fixed);



    int n;

    cin >> n;



    vector<ld> x(n), y(n);

    vector<char> d(n);

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

        cin >> x[i] >> y[i] >> d[i];



    auto f = [&](const ld t) {

        pair<ld, ld> dx, dy;

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

            ld vx = x[i], vy = y[i];



            if (d[i] == 'R') vx += t;

            else if (d[i] == 'L') vx -= t;

            else if (d[i] == 'U') vy += t;

            else if (d[i] == 'D') vy -= t;



            if (i == 0) {

                dx = make_pair(vx, vx);

                dy = make_pair(vy, vy);

            }

            else {

                dx.first = min(dx.first, vx);

                dx.second = max(dx.second, vx);

                dy.first = min(dy.first, vy);

                dy.second = max(dy.second, vy);

            }

        }

        return (dx.second - dx.first) * (dy.second - dy.first);

    };



    ld min_v = f(0), lb = 0, ub = 1e9;

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

        const ld t1 = (2.0 * lb + ub) / 3.0;

        const ld t2 = (lb + 2.0 * ub) / 3.0;



        min_v = min(min_v, f(t1));

        min_v = min(min_v, f(t2));



        if (f(t1) > f(t2)) lb = t1;

        else ub = t2;

    }



    cout << min_v << endl;



    return 0;

}


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



using namespace std;



using ll = long long;

using ld = long double;



int main() {

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

    cout << setprecision(10) << setiosflags(ios::fixed);



    int n;

    cin >> n;



    vector<double> x(n), y(n);

    vector<char> d(n);

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

        cin >> x[i] >> y[i] >> d[i];



    auto f = [&](const ld t) {

        pair<double, double> dx, dy;

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

            double vx = x[i], vy = y[i];



            if (d[i] == 'R') vx += t;

            else if (d[i] == 'L') vx -= t;

            else if (d[i] == 'U') vy += t;

            else if (d[i] == 'D') vy -= t;



            if (i == 0) {

                dx = make_pair(vx, vx);

                dy = make_pair(vy, vy);

            }

            else {

                dx.first = min(dx.first, vx);

                dx.second = max(dx.second, vx);

                dy.first = min(dy.first, vy);

                dy.second = max(dy.second, vy);

            }

        }

        return (dx.second - dx.first) * (dy.second - dy.first);

    };



    double min_v = f(0), lb = 0, ub = 1e9;

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

        const double t1 = (2.0 * lb + ub) / 3.0;

        const double t2 = (lb + 2.0 * ub) / 3.0;



        min_v = min(min_v, f(t1));

        min_v = min(min_v, f(t2));



        if (f(t1) > f(t2)) lb = t1;

        else ub = t2;

    }



    cout << min_v << endl;



    return 0;

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



using namespace std;



using ll = long long;

using ld = long double;



int main() {

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

    cout << setprecision(10) << setiosflags(ios::fixed);



    int n;

    cin >> n;



    vector<ld> x(n), y(n);

    vector<char> d(n);

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

        cin >> x[i] >> y[i] >> d[i];



    auto f = [&](const ld t) {

        pair<ld, ld> dx, dy;

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

            ld vx = x[i], vy = y[i];



            if (d[i] == 'R') vx += t;

            else if (d[i] == 'L') vx -= t;

            else if (d[i] == 'U') vy += t;

            else if (d[i] == 'D') vy -= t;



            if (i == 0) {

                dx = make_pair(vx, vx);

                dy = make_pair(vy, vy);

            }

            else {

                dx.first = min(dx.first, vx);

                dx.second = max(dx.second, vx);

                dy.first = min(dy.first, vy);

                dy.second = max(dy.second, vy);

            }

        }

        return (dx.second - dx.first) * (dy.second - dy.first);

    };



    ld min_v = f(0), lb = 0, ub = 1e9;

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

        const ld t1 = (2.0 * lb + ub) / 3.0;

        const ld t2 = (lb + 2.0 * ub) / 3.0;



        min_v = min(min_v, f(t1));

        min_v = min(min_v, f(t2));



        if (f(t1) > f(t2)) lb = t1;

        else ub = t2;

    }



    cout << min_v << endl;



    return 0;

}


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



using namespace std;



using ll = long long;

using ld = long double;



int main() {

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

    cout << setprecision(10) << setiosflags(ios::fixed);



    int n;

    cin >> n;



    vector<double> x(n), y(n), dx(n), dy(n);

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

        char d;

        cin >> x[i] >> y[i] >> d;



        if (d == 'R') dx[i] = 1;

        else if (d == 'L') dx[i] = -1;

        else if (d == 'U') dy[i] = 1;

        else if (d == 'D') dy[i] = -1;

    }



    const double INF = numeric_limits<double>::max();

    const double NINF = numeric_limits<double>::lowest();



    auto f = [&](const ld t) {

        pair<double, double> seg_x(INF, NINF), seg_y(INF, NINF);



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

            double vx = x[i] + t * dx[i], vy = y[i] + t * dy[i];



            seg_x.first = min(seg_x.first, vx);

            seg_x.second = max(seg_x.second, vx);

            seg_y.first = min(seg_y.first, vy);

            seg_y.second = max(seg_y.second, vy);

        }

        return (seg_x.second - seg_x.first) * (seg_y.second - seg_y.first);

    };



    double min_v = f(0), lb = 0, ub = 1e9;

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

        const double t1 = (2.0 * lb + ub) / 3.0;

        const double t2 = (lb + 2.0 * ub) / 3.0;



        min_v = min(min_v, f(t1));

        min_v = min(min_v, f(t2));



        if (f(t1) > f(t2)) lb = t1;

        else ub = t2;

    }



    cout << min_v << endl;



    return 0;

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



using namespace std;



typedef long long ll;



const int N(2e5 + 9);



int T, n, m, ans;



struct A

{

    int x, y;

    char d;

}a[N];



long double calc(long double t)

{

    long double minx = 1e19, maxx = -1e19, miny = 1e19, maxy = -1e19;

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

    {

        minx = min(minx, t * (a[i].d == 'L' ? -1 : a[i].d == 'R') + a[i].x);

        maxx = max(maxx, t * (a[i].d == 'L' ? -1 : a[i].d == 'R') + a[i].x);

        miny = min(miny, t * (a[i].d == 'D' ? -1 : a[i].d == 'U') + a[i].y);

        maxy = max(maxy, t * (a[i].d == 'D' ? -1 : a[i].d == 'U') + a[i].y);

    }

    return (maxx - minx) * (maxy - miny);

}



int main()

{

    cin>>n;

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

    {

        cin>>a[i].x>>a[i].y>>a[i].d;

    }

    long double l = 0, r = 1e18, midl, midr;

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

    {

        midl = (2 * l + r) / 3;

        midr = (2 * r + l) / 3;

        if (calc(midl) < calc(midr))

        {

            r = midr;

        }

        else l = midl;

    }

    cout<<fixed<<setprecision(16)<<calc(l)<<endl;



    return 0;

}


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

using namespace std;

const double oo = 1e18;

 

int n, x[100100], y[100100];

char d[100100];

 

double calc(double t)

{

  double xMax = -oo, xMin = oo, yMax = -oo, yMin = oo;

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

  {

    double curX = x[i], curY = y[i];

    if (d[i] == 'U') curY += t;

    else if (d[i] == 'D') curY -= t;

    else if (d[i] == 'R') curX += t;

    else curX -= t;

    xMax = max(xMax, curX);

    xMin = min(xMin, curX);

    yMax = max(yMax, curY);

    yMin = min(yMin, curY);

  }

  return (xMax - xMin) * (yMax - yMin);

}

 

int main()

{

  ios::sync_with_stdio(0);

  

  cin >> n;

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

    cin >> x[i] >> y[i] >> d[i];

 

  double ans = calc(0), low = 0, high = 1e9;

  for (int turn = 0; turn < 150; turn++)

  {

    double mid1 = (low * 2 + high) / 3, v1 = calc(mid1);

    double mid2 = (low + high * 2) / 3, v2 = calc(mid2);

    if (v1 < v2) high = mid2;

    else low = mid1;

  }

 

  ans = min(ans, calc(low));

  cout << fixed << setprecision(9) << ans << endl;

}