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

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

#define per(i,a,b) for(int i=a;i>=b;i--)

#define gpf(...) fprintf(stderr,__VA_ARGS__)

using namespace std;

typedef long long ll;

const ll md = 1e9 + 7;

const int N = 1000000;

ll n, m, k;

ll fac[N], inv[N], m3[N];



ll fm(ll x, ll y){

	ll res = 1;

	while (y){

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

		y /= 2;

		x = (x * x) % md;

	}

	return res;

}



ll C(int x, int y){

	if (y < 0) return 0;

	if (x < y) return 0;

	ll res = ((fac[x] * inv[x - y]) % md * inv[y]) % md;

	return res;

}



int main(){

	scanf("%lld%lld%lld", &n, &m, &k);

	fac[0] = 1;

	rep(i, 1, n + m + k) fac[i] = (fac[i - 1] * i) % md;

	rep(i, 1, n + m + k) inv[i] = fm(fac[i], md - 2);

	m3[0] = 1;

	rep(i, 1, n + m + k) m3[i] = (m3[i - 1] * 3) % md;

	inv[0] = 1;

	ll ans = 0;

	ll t = 1;

	rep(i, 0, m + k){

		ll tt = C(n + i - 1, n - 1) * t % md;

		tt = tt * m3[m + k - i] % md;

		ans = (ans + tt) % md;

		t = ((t * 2 + md - C(i, m)) % md + md - C(i, i - k)) % md;

	}

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

	return 0;

}

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

using namespace std;



typedef long long ll;



const int maxn = 9e5 + 5;

const int mod = 1e9 + 7;



int n, m, k, Q;

ll ans;

ll f[maxn], fac[maxn], inv[maxn], bin[maxn];



ll power(ll b, int k)

{

    ll res = 1;

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

        if(k & 1)

            res = res * b % mod;

    return res;

}



ll C(int n, int m)

{

    if(m > n)

        return 0;

    return fac[n] * inv[m] % mod * inv[n - m] % mod;

}



int main()

{

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

    Q = m + k;

    f[0] = fac[0] = bin[0] = inv[0] = 1;

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

    {

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

        inv[i] = power(fac[i], mod - 2);

    }

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

    {

        f[i] = ((f[i - 1] << 1) - C(i - 1, m) - C(i - 1, k) + (mod << 1)) % mod;

        bin[i] = bin[i - 1] * 3 % mod;

    }

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

    {

        ll tmp = C(i + n - 1, n - 1) * f[i] % mod * bin[Q - i] % mod;

        ans += tmp;

        if(ans >= mod)

            ans -= mod;

    }

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

    return 0;

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



#define mo 1000000007



using namespace std;



int fac[900030],inv[900030],Pow3[900030];



int power(int x,int m)

{

	int nowans=1;

	while(m)

	{

		if(m&1)nowans=1ll*nowans*x%mo;

		x=1ll*x*x%mo;

		m>>=1;

	}

	return nowans;

}



inline int C(int n,int m)

{

	if(n<m)return 0;

	return (int)(1ll*fac[n]*inv[m]%mo*inv[n-m]%mo);

}



int main()

{

	int n,m,k,N;

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

	N=n+m+k;

	Pow3[0]=1;

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

		Pow3[i]=3ll*Pow3[i-1]%mo;

	fac[0]=1;

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

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

	inv[N]=power(fac[N],mo-2);

	for(int i=N;i;i--)

		inv[i-1]=1ll*inv[i]*i%mo;

	int ans=0,nowans=1;

	for(int l=n+1;l<=N+1;l++)

	{

		ans+=1ll*C(l-2,n-1)*nowans%mo*Pow3[N+1-l]%mo;

		if(ans>=mo)ans-=mo;

		nowans=nowans*2%mo;

		nowans-=(C(l-(n+1),m)+C(l-(n+1),k))%mo;

		if(nowans<0)nowans+=mo;

	}

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

}

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

using namespace std;



typedef long long ll;



const int maxn = 9e5 + 5;

const int mod = 1e9 + 7;



int n, m, k, Q;

ll ans;

ll f[maxn], fac[maxn], inv[maxn], bin[maxn];



ll power(ll b, int k)

{

    ll res = 1;

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

        if(k & 1)

            res = res * b % mod;

    return res;

}



ll C(int n, int m)

{

    if(m > n)

        return 0;

    return fac[n] * inv[m] % mod * inv[n - m] % mod;

}



int main()

{

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

    Q = m + k;

    f[0] = fac[0] = bin[0] = inv[0] = 1;

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

    {

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

        inv[i] = power(fac[i], mod - 2);

    }

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

    {

        f[i] = ((f[i - 1] << 1) - C(i - 1, m) - C(i - 1, k) + (mod << 1)) % mod;

        bin[i] = bin[i - 1] * 3 % mod;

    }

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

    {

        ll tmp = C(i + n - 1, n - 1) * f[i] % mod * bin[Q - i] % mod;

        ans += tmp;

        if(ans >= mod)

            ans -= mod;

    }

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

    return 0;

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

using namespace std;

const long long mod=1e9+7;

long long jc[6060606],_jc[6060606];

long long pow(long long n,long long k)

{

	long long ret=1;

	while(k>0)

	{

		if(k&1)

			ret=ret*n%mod;

		n=n*n%mod;

		k/=2;

	}

	return ret;

}

long long C(int n,int m)

{

	return jc[n]*_jc[m]%mod*_jc[n-m]%mod;

}

int main()

{

	int n,m,k;

	cin>>n>>m>>k;

	jc[0]=1;

	_jc[0]=1;

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

	{

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

		_jc[i]=pow(jc[i],mod-2);

	}

	long long tmp=1,ans=0;

	for(int i=0;i<=m+k;i++)

	{

		ans=(ans+C(n+i-1,i)*tmp%mod*pow(3,m+k-i)%mod)%mod;

		tmp*=2;

		if(i+1>k)

			tmp-=C(i,i-k); 

		if(i+1>m)

			tmp-=C(i,m);

		tmp+=2*mod;

		tmp%=mod;

	}

	cout<<ans<<endl;

	return 0;

}

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

using namespace std;



typedef long long ll;



const int maxn = 9e5 + 5;

const int mod = 1e9 + 7;



int n, m, k, Q;

ll ans;

ll f[maxn], fac[maxn], inv[maxn], bin[maxn];



ll power(ll b, int k)

{

    ll res = 1;

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

        if(k & 1)

            res = res * b % mod;

    return res;

}



ll C(int n, int m)

{

    if(m > n)

        return 0;

    return fac[n] * inv[m] % mod * inv[n - m] % mod;

}



int main()

{

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

    Q = m + k;

    f[0] = fac[0] = bin[0] = inv[0] = 1;

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

    {

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

        inv[i] = power(fac[i], mod - 2);

    }

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

    {

        f[i] = ((f[i - 1] << 1) - C(i - 1, m) - C(i - 1, k) + (mod << 1)) % mod;

        bin[i] = bin[i - 1] * 3 % mod;

    }

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

    {

        ll tmp = C(i + n - 1, n - 1) * f[i] % mod * bin[Q - i] % mod;

        ans += tmp;

        if(ans >= mod)

            ans -= mod;

    }

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

    return 0;

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

#include<iostream>

#include<cstdio>

#include<cstdlib>

using namespace std;



typedef long long ll;

const int maxn = 900010,rhl = 1000000007;

int N,M,K; ll jie[maxn],inv[maxn],mi[maxn];



inline ll qsm(ll a,int b)

{

	ll ret = 1;

	for (;b;b >>= 1,(a *= a) %= rhl) if (b&1) (ret *= a) %= rhl;

	return ret;

}



inline int gi()

{

	char ch; int ret = 0,f = 1;

	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');

	if (ch == '-') f = -1,ch = getchar();

	do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');

	return ret*f;

}



inline ll C(int n,int m) { if (n < m||m < 0) return 0; return jie[n]*inv[m]%rhl*inv[n-m]%rhl; }



int main()

{

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

	//freopen("H.out","w",stdout);

	N = gi(); M = gi(); K = gi();

	jie[0] = mi[0] = 1;

	for (int i = 1;i <= N+M+K;++i)

	{

		mi[i] = mi[i-1]*3LL; while (mi[i] >= rhl) mi[i] -= rhl;

		jie[i] = jie[i-1]*(ll)i; if (jie[i] >= rhl) jie[i] %= rhl;

	}

	inv[N+M+K] = qsm(jie[N+M+K],rhl-2);

	for (int i = N+M+K;i;--i)

	{

		inv[i-1] = inv[i]*(ll)i;

		if (inv[i-1] >= rhl) inv[i-1] %= rhl;

	}

	ll sum = 1,ans = 0;

	for (int i = 0;i <= M+K;++i)

	{

		ll tm = C(N+i-1,i)*mi[M+K-i]%rhl;

		ans += tm*sum%rhl; if (ans >= rhl) ans %= rhl;

		sum <<= 1; if (sum >= rhl) sum -= rhl;

		sum -= C(i,i-K)+C(i,M); while (sum < 0) sum += rhl;

	}

	cout << ans << endl;

	return 0;

}


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

using namespace std;



typedef long long ll;



const int maxn = 9e5 + 5;

const int mod = 1e9 + 7;



int n, m, k, Q;

ll ans;

ll f[maxn], fac[maxn], inv[maxn], bin[maxn];



ll power(ll b, int k)

{

    ll res = 1;

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

        if(k & 1)

            res = res * b % mod;

    return res;

}



ll C(int n, int m)

{

    if(m > n)

        return 0;

    return fac[n] * inv[m] % mod * inv[n - m] % mod;

}



int main()

{

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

    Q = m + k;

    f[0] = fac[0] = bin[0] = inv[0] = 1;

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

    {

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

        inv[i] = power(fac[i], mod - 2);

    }

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

    {

        f[i] = ((f[i - 1] << 1) - C(i - 1, m) - C(i - 1, k) + (mod << 1)) % mod;

        bin[i] = bin[i - 1] * 3 % mod;

    }

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

    {

        ll tmp = C(i + n - 1, n - 1) * f[i] % mod * bin[Q - i] % mod;

        ans += tmp;

        if(ans >= mod)

            ans -= mod;

    }

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

    return 0;

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

using namespace std;



const int Mod = 1e9 + 7;

const int N = 9e5 + 10;



int n, m, k;

long long fac[N], vfac[N];



long long mpow( long long a, int b ) {

	long long rt;

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

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

	return rt;

}

void init( int n ) {

	fac[0] = 1;

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

		fac[i] = (fac[i-1] * i) % Mod;

	vfac[n]  = mpow( fac[n], Mod - 2 );

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

		vfac[i] = vfac[i+1] * (i + 1) % Mod;

}

long long comb( int n, int m ) {

	return fac[n] * vfac[n-m] % Mod * vfac[m] % Mod;

}

int main() {

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

	if( m < k )

	   	swap( m, k );

	init( m + k + n );

	long long sum = 0;

	long long ans = 0;

	for( int s = 0; s <= m + k; s++ ) {

		if( s == 0 ) 

			sum = 1;

		else if( s <= k ) 

			sum = (sum<<1) % Mod;

		else if( s <= m ) 

			sum = ((sum<<1) + Mod - comb(s-1,s-k-1)) % Mod;

		else 

			sum = ((sum<<1) + Mod - comb(s-1,s-k-1) + Mod - comb(s-1,m)) % Mod;

		long long sub = sum * comb(n-1+s,n-1) % Mod * mpow(3,m+k-s) % Mod;

		ans = (ans + sub) % Mod;

	}

	cout << ans << endl;

}




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

using namespace std;



typedef long long ll;



const int maxn = 9e5 + 5;

const int mod = 1e9 + 7;



int n, m, k, Q;

ll ans;

ll f[maxn], fac[maxn], inv[maxn], bin[maxn];



ll power(ll b, int k)

{

    ll res = 1;

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

        if(k & 1)

            res = res * b % mod;

    return res;

}



ll C(int n, int m)

{

    if(m > n)

        return 0;

    return fac[n] * inv[m] % mod * inv[n - m] % mod;

}



int main()

{

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

    Q = m + k;

    f[0] = fac[0] = bin[0] = inv[0] = 1;

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

    {

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

        inv[i] = power(fac[i], mod - 2);

    }

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

    {

        f[i] = ((f[i - 1] << 1) - C(i - 1, m) - C(i - 1, k) + (mod << 1)) % mod;

        bin[i] = bin[i - 1] * 3 % mod;

    }

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

    {

        ll tmp = C(i + n - 1, n - 1) * f[i] % mod * bin[Q - i] % mod;

        ans += tmp;

        if(ans >= mod)

            ans -= mod;

    }

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

    return 0;

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

using namespace std;



const int Mod = 1e9 + 7;

const int N = 9e5 + 10;



int n, m, k;

long long fac[N], vfac[N];



long long mpow( long long a, int b ) {

	long long rt;

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

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

	return rt;

}

void init( int n ) {

	fac[0] = 1;

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

		fac[i] = (fac[i-1] * i) % Mod;

	vfac[n]  = mpow( fac[n], Mod - 2 );

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

		vfac[i] = vfac[i+1] * (i + 1) % Mod;

}

long long comb( int n, int m ) {

	return fac[n] * vfac[n-m] % Mod * vfac[m] % Mod;

}

int main() {

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

	if( m < k ) swap( m, k );

	init( m + k + n );

	long long sum = 0, ans = 0;

	for( int s = 0; s <= m + k; s++ ) {

		if( s == 0 ) 

			sum = 1;

		 else if( s <= k ) 

			sum = (sum<<1) % Mod;

	 else if( s <= m ) 

			sum = ((sum<<1) + Mod - comb(s-1,s-k-1)) % Mod;

		 else 

			sum = ((sum<<1) + Mod - comb(s-1,s-k-1) + Mod - comb(s-1,m)) % Mod;

		

		long long sub = sum * comb(n-1+s,n-1) % Mod * mpow(3,m+k-s) % Mod;

		ans = (ans + sub) % Mod;

	}

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

}




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

using namespace std;



typedef long long ll;



const int maxn = 9e5 + 5;

const int mod = 1e9 + 7;



int n, m, k, Q;

ll ans;

ll f[maxn], fac[maxn], inv[maxn], bin[maxn];



ll power(ll b, int k)

{

    ll res = 1;

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

        if(k & 1)

            res = res * b % mod;

    return res;

}



ll C(int n, int m)

{

    if(m > n)

        return 0;

    return fac[n] * inv[m] % mod * inv[n - m] % mod;

}



int main()

{

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

    Q = m + k;

    f[0] = fac[0] = bin[0] = inv[0] = 1;

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

    {

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

        inv[i] = power(fac[i], mod - 2);

    }

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

    {

        f[i] = ((f[i - 1] << 1) - C(i - 1, m) - C(i - 1, k) + (mod << 1)) % mod;

        bin[i] = bin[i - 1] * 3 % mod;

    }

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

    {

        ll tmp = C(i + n - 1, n - 1) * f[i] % mod * bin[Q - i] % mod;

        ans += tmp;

        if(ans >= mod)

            ans -= mod;

    }

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

    return 0;

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

#include <stdlib.h>

#include <string.h>

#include <iostream>

using namespace std;



const int MOD = 1e9 + 7;



int n, m, k;

int pow1[1010101], pow2[1010101];

int fac[1010101], rev[1010101], ifac[1010101];



int c(int a, int b)

{

	long long ret = fac[b];

	ret = ret * ifac[a];

	ret %= MOD;

	ret = ret * ifac[b - a];

	ret %= MOD;

	return (int)ret;

}



int main()

{

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

	pow1[0] = fac[0] = ifac[0] = rev[0] = pow2[0] = 1;

	ifac[1] = rev[1] = 1;

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

	{

		pow1[i] = pow1[i - 1] * 3ll % MOD;

		pow2[i] = pow2[i - 1] * 2 % MOD;

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

		if(i >= 2)

		{

			rev[i] = MOD - 1ll * (MOD / i) * rev[MOD % i] % MOD;

			ifac[i] = 1ll * ifac[i - 1] * rev[i] % MOD;

		}

	}

	if(m > k)

		swap(m, k);

	int ans = 0;

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

	{

		ans += 1ll * pow2[i] * c(i, i + n - 1) % MOD * pow1[m + k - i] % MOD;

		if(ans >= MOD)

			ans -= MOD;

	}

	int lst = pow2[m];

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

	{

		lst = lst<<1;

		lst -= c(m, i - 1);

		if(lst >= MOD)

			lst -= MOD;

		if(i > k)

			lst -= c(i - k - 1, i - 1);

		while(lst < 0)

			lst += MOD;

		while(lst >= MOD)

			lst -= MOD;

		ans += 1ll * lst * c(i, i + n - 1) % MOD * pow1[m + k - i] % MOD;

		if(ans >= MOD)

			ans -= MOD;

	}

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

	

	return 0;

}

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

#include <cstdlib>

#include <algorithm>



typedef long long LL;



const int maxn = 1e6 + 20;

const int mod = 1e9 + 7;



int N, M, K, sum;

LL fac[maxn];

LL inv[maxn];

LL pw[maxn];

 

LL powermod(LL x,LL y)

{

	LL z = 1;

	

	while(y)

	{

		if(y & 1) z = z * x % mod;

		x = x * x % mod, y >>= 1;

	}

	

	return z;

}

LL combine(LL x,LL y)

{

	if(y < 0 || y > x) return 0;

	return fac[x] * inv[y] % mod * inv[x - y] % mod;

}

int main()

{

	scanf("%d%d%d", &N, &M, &K);

	sum = N + M + K;

	

	pw[0] = fac[0] = inv[0] = 1;

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

	{

		pw[i] = pw[i - 1] * 3 % mod;

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

	}

	

	inv[sum] = powermod(fac[sum], mod - 2);

	for(int i = sum - 1; i >= 1; i--)

	{

		inv[i] = inv[i + 1] * (i + 1) % mod;

	}

	

	LL s = 1, ans = 0;

	

	for(int i = 0; i <= M + K; i++)

	{

		ans += s * combine(N - 1 + i, N - 1) % mod * pw[M + K - i] % mod;

		s = s * 2 - combine(i, M) - combine(i, K);

		s = (s % mod + mod) % mod;

	}

	ans %= mod;

	

	printf("%d", (int) ans);

	return 0;

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

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

#define per(i,a,b) for(int i=a;i>=b;i--)

#define gpf(...) fprintf(stderr,__VA_ARGS__)

using namespace std;

typedef long long ll;

const ll md = 1e9 + 7;

const int N = 1000000;

ll n, m, k;

ll fac[N], inv[N], m3[N];



ll fm(ll x, ll y){

	ll res = 1;

	while (y){

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

		y /= 2;

		x = (x * x) % md;

	}

	return res;

}



ll C(int x, int y){

	if (y < 0) return 0;

	if (x < y) return 0;

	ll res = ((fac[x] * inv[x - y]) % md * inv[y]) % md;

	return res;

}



int main(){

	scanf("%lld%lld%lld", &n, &m, &k);

	fac[0] = 1;

	rep(i, 1, n + m + k) fac[i] = (fac[i - 1] * i) % md;

	rep(i, 1, n + m + k) inv[i] = fm(fac[i], md - 2);

	m3[0] = 1;

	rep(i, 1, n + m + k) m3[i] = (m3[i - 1] * 3) % md;

	inv[0] = 1;

	ll ans = 0;

	ll t = 1;

	rep(i, 0, m + k){

		ll tt = C(n + i - 1, n - 1) * t % md;

		tt = tt * m3[m + k - i] % md;

		ans = (ans + tt) % md;

		t = ((t * 2 + md - C(i, m)) % md + md - C(i, i - k)) % md;

	}

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

	return 0;

}

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

#include <cstdlib>

#include <algorithm>



typedef long long LL;



const int maxn = 1e6 + 20;

const int mod = 1e9 + 7;



int N, M, K, sum;

LL fac[maxn];

LL inv[maxn];

LL pw[maxn];

 

LL powermod(LL x,LL y)

{

	LL z = 1;

	

	while(y)

	{

		if(y & 1) z = z * x % mod;

		x = x * x % mod, y >>= 1;

	}

	

	return z;

}

LL combine(LL x,LL y)

{

	if(y < 0 || y > x) return 0;

	return fac[x] * inv[y] % mod * inv[x - y] % mod;

}

int main()

{

	scanf("%d%d%d", &N, &M, &K);

	sum = N + M + K;

	

	pw[0] = fac[0] = inv[0] = 1;

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

	{

		pw[i] = pw[i - 1] * 3 % mod;

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

	}

	

	inv[sum] = powermod(fac[sum], mod - 2);

	for(int i = sum - 1; i >= 1; i--)

	{

		inv[i] = inv[i + 1] * (i + 1) % mod;

	}

	

	LL s = 1, ans = 0;

	

	for(int i = 0; i <= M + K; i++)

	{

		ans += s * combine(N - 1 + i, N - 1) % mod * pw[M + K - i] % mod;

		s = s * 2 - combine(i, M) - combine(i, K);

		s = (s % mod + mod) % mod;

	}

	ans %= mod;

	

	printf("%d", (int) ans);

	return 0;

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



#define mo 1000000007



using namespace std;



int fac[900030],inv[900030],Pow3[900030];



int power(int x,int m)

{

	int nowans=1;

	while(m)

	{

		if(m&1)nowans=1ll*nowans*x%mo;

		x=1ll*x*x%mo;

		m>>=1;

	}

	return nowans;

}



inline int C(int n,int m)

{

	if(n<m)return 0;

	return (int)(1ll*fac[n]*inv[m]%mo*inv[n-m]%mo);

}



int main()

{

	int n,m,k,N;

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

	N=n+m+k;

	Pow3[0]=1;

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

		Pow3[i]=3ll*Pow3[i-1]%mo;

	fac[0]=1;

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

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

	inv[N]=power(fac[N],mo-2);

	for(int i=N;i;i--)

		inv[i-1]=1ll*inv[i]*i%mo;

	int ans=0,nowans=1;

	for(int l=n+1;l<=N+1;l++)

	{

		ans+=1ll*C(l-2,n-1)*nowans%mo*Pow3[N+1-l]%mo;

		if(ans>=mo)ans-=mo;

		nowans=nowans*2%mo;

		nowans-=(C(l-(n+1),m)+C(l-(n+1),k))%mo;

		if(nowans<0)nowans+=mo;

	}

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

}

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

#include <cstdlib>

#include <algorithm>



typedef long long LL;



const int maxn = 1e6 + 20;

const int mod = 1e9 + 7;



int N, M, K, sum;

LL fac[maxn];

LL inv[maxn];

LL pw[maxn];

 

LL powermod(LL x,LL y)

{

	LL z = 1;

	

	while(y)

	{

		if(y & 1) z = z * x % mod;

		x = x * x % mod, y >>= 1;

	}

	

	return z;

}

LL combine(LL x,LL y)

{

	if(y < 0 || y > x) return 0;

	return fac[x] * inv[y] % mod * inv[x - y] % mod;

}

int main()

{

	scanf("%d%d%d", &N, &M, &K);

	sum = N + M + K;

	

	pw[0] = fac[0] = inv[0] = 1;

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

	{

		pw[i] = pw[i - 1] * 3 % mod;

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

	}

	

	inv[sum] = powermod(fac[sum], mod - 2);

	for(int i = sum - 1; i >= 1; i--)

	{

		inv[i] = inv[i + 1] * (i + 1) % mod;

	}

	

	LL s = 1, ans = 0;

	

	for(int i = 0; i <= M + K; i++)

	{

		ans += s * combine(N - 1 + i, N - 1) % mod * pw[M + K - i] % mod;

		s = s * 2 - combine(i, M) - combine(i, K);

		s = (s % mod + mod) % mod;

	}

	ans %= mod;

	

	printf("%d", (int) ans);

	return 0;

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

using namespace std;

const long long mod=1e9+7;

long long jc[6060606],_jc[6060606];

long long pow(long long n,long long k)

{

	long long ret=1;

	while(k>0)

	{

		if(k&1)

			ret=ret*n%mod;

		n=n*n%mod;

		k/=2;

	}

	return ret;

}

long long C(int n,int m)

{

	return jc[n]*_jc[m]%mod*_jc[n-m]%mod;

}

int main()

{

	int n,m,k;

	cin>>n>>m>>k;

	jc[0]=1;

	_jc[0]=1;

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

	{

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

		_jc[i]=pow(jc[i],mod-2);

	}

	long long tmp=1,ans=0;

	for(int i=0;i<=m+k;i++)

	{

		ans=(ans+C(n+i-1,i)*tmp%mod*pow(3,m+k-i)%mod)%mod;

		tmp*=2;

		if(i+1>k)

			tmp-=C(i,i-k); 

		if(i+1>m)

			tmp-=C(i,m);

		tmp+=2*mod;

		tmp%=mod;

	}

	cout<<ans<<endl;

	return 0;

}

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

#include <cstdlib>

#include <algorithm>



typedef long long LL;



const int maxn = 1e6 + 20;

const int mod = 1e9 + 7;



int N, M, K, sum;

LL fac[maxn];

LL inv[maxn];

LL pw[maxn];

 

LL powermod(LL x,LL y)

{

	LL z = 1;

	

	while(y)

	{

		if(y & 1) z = z * x % mod;

		x = x * x % mod, y >>= 1;

	}

	

	return z;

}

LL combine(LL x,LL y)

{

	if(y < 0 || y > x) return 0;

	return fac[x] * inv[y] % mod * inv[x - y] % mod;

}

int main()

{

	scanf("%d%d%d", &N, &M, &K);

	sum = N + M + K;

	

	pw[0] = fac[0] = inv[0] = 1;

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

	{

		pw[i] = pw[i - 1] * 3 % mod;

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

	}

	

	inv[sum] = powermod(fac[sum], mod - 2);

	for(int i = sum - 1; i >= 1; i--)

	{

		inv[i] = inv[i + 1] * (i + 1) % mod;

	}

	

	LL s = 1, ans = 0;

	

	for(int i = 0; i <= M + K; i++)

	{

		ans += s * combine(N - 1 + i, N - 1) % mod * pw[M + K - i] % mod;

		s = s * 2 - combine(i, M) - combine(i, K);

		s = (s % mod + mod) % mod;

	}

	ans %= mod;

	

	printf("%d", (int) ans);

	return 0;

}