Language: C++

#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;


//bit全探索
vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


//最大公約数
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}


//UnionFind木(ランクなし)
struct UnionFind{
    vector<int>par;
    UnionFind(int N) : par(N){
        rep(i,N)par[i] = i;
    }
    int root(int x){
        if(par[x] == x)return x;
        return par[x] = root(par[x]);
    }
    void unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry)return;
        par[rx] = ry;
    }
    bool same(int x,int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


//コンビネーション(パスカルの三角形)
ll COMB(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v[n][r];
}


//エラトステネスの篩
vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}


// UnionFind木(サイズ持ち)
class UnionFind {
    public : 

        vector<int> par;

        UnionFind(int N){
            par = vector<int>(N, -1);
        }

        int parent(int x){
            return par[x];
        }

        int root(int x){
            if(par[x] < 0)return x;
            return par[x] = root(par[x]);
        }

        int size(int x){
            return -par[root(x)];
        }

        void connect(int x, int y){
            int rx = root(x);
            int ry = root(y);
            if(rx == ry)return;

            if(size(rx) < size(ry))swap(rx, ry);

            par[rx] += par[ry];
            par[ry] = rx;

            return;
        }

        bool same(int x, int y){
            return root(x) == root(y);
        }
};


//Combination MOD
const ll MOD = INF + 7;
vector<ll> fac(300000);
vector<ll> fac_inv(300000);

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n & 1)ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;

    ll tmp = fac_inv[a - b] * fac_inv[b] % MOD;
    return tmp * fac[a] % MOD;
}

//int main(){}の中
fac[0] = 1;
fac_inv[0] = 1;
for(ll i = 0; i < 300000; i++){
    fac[i + 1] = fac[i] * (i + 1) % MOD;
    fac_inv[i + 1] = fac_inv[i] * mpow(i + 1, MOD - 2) % MOD;
}

Compiler output:
a.cc:107:7: error: redefinition of 'class UnionFind'
  107 | class UnionFind {
      |       ^~~~~~~~~
a.cc:50:8: note: previous definition of 'class UnionFind'
   50 | struct UnionFind{
      |        ^~~~~~~~~
a.cc:172:1: error: 'fac' does not name a type
  172 | fac[0] = 1;
      | ^~~
a.cc:173:1: error: 'fac_inv' does not name a type
  173 | fac_inv[0] = 1;
      | ^~~~~~~
a.cc:174:1: error: expected unqualified-id before 'for'
  174 | for(ll i = 0; i < 300000; i++){
      | ^~~
a.cc:174:15: error: 'i' does not name a type
  174 | for(ll i = 0; i < 300000; i++){
      |               ^
a.cc:174:27: error: 'i' does not name a type
  174 | for(ll i = 0; i < 300000; i++){
      |                           ^