stablegradients/pie-gem5-pairs huggingface dataset:
// 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: 4.0918363515119625x):
#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>

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: 4.5350105739357955x):
#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>

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: 4.491559658553179x):
#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 <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;

}


// Faster C++ solution for the same problem (measured speedup: 2.0927723949321337x):
#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 <cstdio>

#include <iostream>

#include <algorithm>

#include <cstring>

#define MOD 1000000007

using namespace std;



int n, m, k;



int quickPow(int n, int m) {

	int res = 1;

	while (m) {

		if (m & 1) res = 1LL * res * n % MOD;

		m >>= 1;

		n = 1LL * n * n % MOD;

	}

	return res;

}



int main() {

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

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

	int ans = quickPow(3, m + k), tmp1 = 1, tmp2 = 1;

	for (int p = n + 1, e, u = 1, v = 1; p <= n + m + k; ++p) {

		e = quickPow(3, n + m + k - p);

		v = 1LL * v * (p - 1) % MOD * quickPow(p - n, MOD - 2) % MOD;

		if (p <= n + m) u = u * 2 % MOD;

		else if (p <= n + k) {

			tmp1 = p - n - 1 == m ? 1 : 1LL * tmp1 * (p - n - 1) % MOD * quickPow(p - n - m - 1, MOD - 2) % MOD;

			u = (2LL * u - tmp1 + MOD) % MOD;

		}

		else {		

			tmp1 = p - n - 1 == m ? 1 : 1LL * tmp1 * (p - n - 1) % MOD * quickPow(p - n - m - 1, MOD - 2) % MOD;

			tmp2 = p == (1 + n + k) ? 1 : 1LL * tmp2 * (p - 1 - n) % MOD * quickPow(p - n - 1 - k, MOD - 2) % MOD;

			u = (2LL * u - tmp1 - tmp2 + MOD + MOD) % MOD;

		}

		ans = (ans + 1LL * e * v % MOD * u % MOD) % MOD;

	}

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

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 6.133765427473034x):
#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: 1.2432733939872616x):
#include<bits/stdc++.h>

#define N 300005

#define mod 1000000007

#define ll long long

using namespace std;

ll up,n,m,k;

ll ans=0,fac[N*3],ifac[N*3],mul[N*3];

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

inline ll ksm(ll x,int p){

	ll ret=1;

	while(p){

		if(p&1)ret=ret*x%mod;

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

	}

	return ret;

}

int main(){

	cin>>n>>m>>k,up=n+m+k,fac[0]=mul[0]=ifac[1]=ifac[0]=1;

	for(ll i=2;i<=up;++i)ifac[i]=(mod-mod/i)*ifac[mod%i]%mod;

	for(ll i=1;i<=up;++i)mul[i]=mul[i-1]*3%mod,(ifac[i]*=ifac[i-1])%=mod,fac[i]=fac[i-1]*i%mod;

	if(m<k)m^=k,k^=m,m^=k;

	for(ll i=0,j=1;i<=m+k;++i){

		(ans+=calc(n-1+i,n-1)*mul[m+k-i]%mod*j%mod)%=mod;

		if(i<k)(j<<=1)%=mod;

		else if(i>=m)(j+=j-calc(i,k)-calc(i,i-m))%=mod;

		else (j+=j-calc(i,k))%=mod;

	}

	cout<<(ans+mod)%mod;

	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: 1.3602203997212148x):
#include<bits/stdc++.h>

#define N 300005

#define mod 1000000007

#define ll long long

using namespace std;

ll up,n,m,k;

ll ans=0,fac[N*3],ifac[N*3],mul[N*3];

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

inline ll ksm(ll x,int p){

	ll ret=1;

	while(p){

		if(p&1)ret=ret*x%mod;

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

	}

	return ret;

}

int main(){

	cin>>n>>m>>k,up=n+m+k,fac[0]=mul[0]=ifac[1]=ifac[0]=1;

	for(ll i=2;i<=up;++i)ifac[i]=(mod-mod/i)*ifac[mod%i]%mod;

	for(ll i=1;i<=up;++i)mul[i]=mul[i-1]*3%mod,(ifac[i]*=ifac[i-1])%=mod,fac[i]=fac[i-1]*i%mod;

	if(m<k)m^=k,k^=m,m^=k;

	for(ll i=0,j=1;i<=m+k;++i){

		(ans+=calc(n-1+i,n-1)*mul[m+k-i]%mod*j%mod)%=mod;

		if(i<k)(j<<=1)%=mod;

		else if(i>=m)(j+=j-calc(i,k)-calc(i,i-m))%=mod;

		else (j+=j-calc(i,k))%=mod;

	}

	cout<<(ans+mod)%mod;

	return 0;

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

#include <iostream>

#include <algorithm>

#include <cstring>

#define MOD 1000000007

using namespace std;



int n, m, k;



int quickPow(int n, int m) {

	int res = 1;

	while (m) {

		if (m & 1) res = 1LL * res * n % MOD;

		m >>= 1;

		n = 1LL * n * n % MOD;

	}

	return res;

}



int main() {

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

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

	int ans = quickPow(3, m + k), tmp1 = 1, tmp2 = 1;

	for (int p = n + 1, e, u = 1, v = 1; p <= n + m + k; ++p) {

		e = quickPow(3, n + m + k - p);

		v = 1LL * v * (p - 1) % MOD * quickPow(p - n, MOD - 2) % MOD;

		if (p <= n + m) u = u * 2 % MOD;

		else if (p <= n + k) {

			tmp1 = p - n - 1 == m ? 1 : 1LL * tmp1 * (p - n - 1) % MOD * quickPow(p - n - m - 1, MOD - 2) % MOD;

			u = (2LL * u - tmp1 + MOD) % MOD;

		}

		else {		

			tmp1 = p - n - 1 == m ? 1 : 1LL * tmp1 * (p - n - 1) % MOD * quickPow(p - n - m - 1, MOD - 2) % MOD;

			tmp2 = p == (1 + n + k) ? 1 : 1LL * tmp2 * (p - 1 - n) % MOD * quickPow(p - n - 1 - k, MOD - 2) % MOD;

			u = (2LL * u - tmp1 - tmp2 + MOD + MOD) % MOD;

		}

		ans = (ans + 1LL * e * v % MOD * u % MOD) % MOD;

	}

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

	return 0;

}

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

#define N 300005

#define mod 1000000007

#define ll long long

using namespace std;

ll up,n,m,k;

ll ans=0,fac[N*3],ifac[N*3],mul[N*3];

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

inline ll ksm(ll x,int p){

	ll ret=1;

	while(p){

		if(p&1)ret=ret*x%mod;

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

	}

	return ret;

}

int main(){

	cin>>n>>m>>k,up=n+m+k,fac[0]=mul[0]=ifac[1]=ifac[0]=1;

	for(ll i=2;i<=up;++i)ifac[i]=(mod-mod/i)*ifac[mod%i]%mod;

	for(ll i=1;i<=up;++i)mul[i]=mul[i-1]*3%mod,(ifac[i]*=ifac[i-1])%=mod,fac[i]=fac[i-1]*i%mod;

	if(m<k)m^=k,k^=m,m^=k;

	for(ll i=0,j=1;i<=m+k;++i){

		(ans+=calc(n-1+i,n-1)*mul[m+k-i]%mod*j%mod)%=mod;

		if(i<k)(j<<=1)%=mod;

		else if(i>=m)(j+=j-calc(i,k)-calc(i,i-m))%=mod;

		else (j+=j-calc(i,k))%=mod;

	}

	cout<<(ans+mod)%mod;

	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=(b)-1; i>=(a); i--)

#define debug(x) cout << #x << " => " << x << endl

using namespace std;

const int MAX_N = 7 + 300000;

const int MOD = 1e9 + 7;

///----------------------------------------------

int qpow(int a,int b) {

    int ret=1;

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

        if (b&1) ret=1ll*ret*a%MOD;

        a=1ll*a*a%MOD;

    }

    return ret;

}

///----------------------------------------------

int jc[MAX_N*3],jcr[MAX_N*3];

int C(int n,int m) {

    return 1ll*jc[n]*jcr[m]%MOD*jcr[n-m]%MOD;

}

///----------------------------------------------

int fb[MAX_N*3],fc[MAX_N*3];

int main() {



    ///read

    int n1,n2,n3; cin>>n1>>n2>>n3;

    int n=n1+n2+n3;



    ///prework

    jc[0]=1; rep(i,1,n+1) jc[i]=1ll*jc[i-1]*i%MOD;

    rep(i,0,n+1) jcr[i]=qpow(jc[i],MOD-2);

    rep(i,n2+1,n+1) fb[i]=(fb[i-1]+(fb[i-1]+C(i-1,n2))%MOD)%MOD;

    rep(i,n3+1,n+1) fc[i]=(fc[i-1]+(fc[i-1]+C(i-1,n3))%MOD)%MOD;



    ///work

    int ans=0;

    rep(i,n1,n+1) {

        int tmp=((qpow(2,i-n1)+MOD-fb[i-n1])%MOD+MOD-fc[i-n1])%MOD;

        tmp=1ll*tmp*qpow(3,n-i)%MOD;

        ans=(ans+1ll*tmp*C(i-1,n1-1)%MOD)%MOD;

    }

    cout << ans;



}




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

#define N 300005

#define mod 1000000007

#define ll long long

using namespace std;

ll up,n,m,k;

ll ans=0,fac[N*3],ifac[N*3],mul[N*3];

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

inline ll ksm(ll x,int p){

	ll ret=1;

	while(p){

		if(p&1)ret=ret*x%mod;

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

	}

	return ret;

}

int main(){

	cin>>n>>m>>k,up=n+m+k,fac[0]=mul[0]=ifac[1]=ifac[0]=1;

	for(ll i=2;i<=up;++i)ifac[i]=(mod-mod/i)*ifac[mod%i]%mod;

	for(ll i=1;i<=up;++i)mul[i]=mul[i-1]*3%mod,(ifac[i]*=ifac[i-1])%=mod,fac[i]=fac[i-1]*i%mod;

	if(m<k)m^=k,k^=m,m^=k;

	for(ll i=0,j=1;i<=m+k;++i){

		(ans+=calc(n-1+i,n-1)*mul[m+k-i]%mod*j%mod)%=mod;

		if(i<k)(j<<=1)%=mod;

		else if(i>=m)(j+=j-calc(i,k)-calc(i,i-m))%=mod;

		else (j+=j-calc(i,k))%=mod;

	}

	cout<<(ans+mod)%mod;

	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: 1.164977959528459x):
#include <bits/stdc++.h>

using namespace std;

int n,m,k,sum,ans,inv[900010],Pow[900010],Mod=1e9+7;

int Add(int aa,int bb) {return (aa+=bb)>Mod? aa-Mod:aa;}

int Sub(int aa,int bb) {return (aa-=bb)<0? aa+Mod:aa;}

int Mul(int aa,int bb) {return 1LL*aa*bb%Mod;}

int ksm(int aa,int bb)

{

	int an=1;

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

		if (bb&1) an=Mul(an,aa);

		aa=Mul(aa,aa);

    }

    return an;

}

int C(int N,int M)

{

	if (N<M) return 0;

	return Mul(Mul(Pow[N],inv[N-M]),inv[M]);

}

int main()

{

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

	Pow[0]=1;

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

	  Pow[i]=Mul(Pow[i-1],i);

    inv[n+m+k]=ksm(Pow[n+m+k],Mod-2);

    inv[0]=1;

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

      inv[i]=Mul(inv[i+1],i+1); 

	sum=1;ans=ksm(3,n+m+k-n);

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

	  sum=Sub(sum*2%Mod,C(i-1-n,m));

	  ans=Add(ans,Mul(Mul(C(i-1,n-1),sum),ksm(3,n+m+k-i)));

    }

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

		sum=Sub(sum*2%Mod,C(i-1-n,m));

		sum=Sub(sum,C(i-1-n,i-1-n-k));

		ans=Add(ans,Mul(Mul(C(i-1,n-1),sum),ksm(3,n+m+k-i)));

	}

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

}
// 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=(b)-1; i>=(a); i--)

#define debug(x) cout << #x << " => " << x << endl

using namespace std;

const int MAX_N = 7 + 300000;

const int MOD = 1e9 + 7;

///----------------------------------------------

int qpow(int a,int b) {

    int ret=1;

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

        if (b&1) ret=1ll*ret*a%MOD;

        a=1ll*a*a%MOD;

    }

    return ret;

}

///----------------------------------------------

int jc[MAX_N*3],jcr[MAX_N*3];

int C(int n,int m) {

    return 1ll*jc[n]*jcr[m]%MOD*jcr[n-m]%MOD;

}

///----------------------------------------------

int fb[MAX_N*3],fc[MAX_N*3];

int main() {



    ///read

    int n1,n2,n3; cin>>n1>>n2>>n3;

    int n=n1+n2+n3;



    ///prework

    jc[0]=1; rep(i,1,n+1) jc[i]=1ll*jc[i-1]*i%MOD;

    rep(i,0,n+1) jcr[i]=qpow(jc[i],MOD-2);

    rep(i,n2+1,n+1) fb[i]=(fb[i-1]+(fb[i-1]+C(i-1,n2))%MOD)%MOD;

    rep(i,n3+1,n+1) fc[i]=(fc[i-1]+(fc[i-1]+C(i-1,n3))%MOD)%MOD;



    ///work

    int ans=0;

    rep(i,n1,n+1) {

        int tmp=((qpow(2,i-n1)+MOD-fb[i-n1])%MOD+MOD-fc[i-n1])%MOD;

        tmp=1ll*tmp*qpow(3,n-i)%MOD;

        ans=(ans+1ll*tmp*C(i-1,n1-1)%MOD)%MOD;

    }

    cout << ans;



}




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

using namespace std;

int n,m,k,sum,ans,inv[900010],Pow[900010],Mod=1e9+7;

int Add(int aa,int bb) {return (aa+=bb)>Mod? aa-Mod:aa;}

int Sub(int aa,int bb) {return (aa-=bb)<0? aa+Mod:aa;}

int Mul(int aa,int bb) {return 1LL*aa*bb%Mod;}

int ksm(int aa,int bb)

{

	int an=1;

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

		if (bb&1) an=Mul(an,aa);

		aa=Mul(aa,aa);

    }

    return an;

}

int C(int N,int M)

{

	if (N<M) return 0;

	return Mul(Mul(Pow[N],inv[N-M]),inv[M]);

}

int main()

{

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

	Pow[0]=1;

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

	  Pow[i]=Mul(Pow[i-1],i);

    inv[n+m+k]=ksm(Pow[n+m+k],Mod-2);

    inv[0]=1;

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

      inv[i]=Mul(inv[i+1],i+1); 

	sum=1;ans=ksm(3,n+m+k-n);

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

	  sum=Sub(sum*2%Mod,C(i-1-n,m));

	  ans=Add(ans,Mul(Mul(C(i-1,n-1),sum),ksm(3,n+m+k-i)));

    }

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

		sum=Sub(sum*2%Mod,C(i-1-n,m));

		sum=Sub(sum,C(i-1-n,i-1-n-k));

		ans=Add(ans,Mul(Mul(C(i-1,n-1),sum),ksm(3,n+m+k-i)));

	}

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

}