stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>

//#include<boost/multiprecision/cpp_int.hpp>

//#include<boost/multiprecision/cpp_dec_float.hpp>

//namespace mp=boost::multiprecision;

//#define mulint mp::cpp_int

//#define mulfloat mp::cpp_dec_float_100

using namespace std;

struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

#define max3(a,b,c) max(a,max(b,c))

#define min3(a,b,c) min(a,min(b,c))

//constexpr int MOD=1000000007;

constexpr int MOD=998244353;

#define INF (1<<30)

#define LINF (lint)(1LL<<56)

#define endl "\n"

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

#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)

#define Flag(x) (1<<(x))

#define Flagcount(x) __builtin_popcount(x)

#define pint pair<int,int>

#define pdouble pair<double,double>

#define plint pair<lint,lint>

#define fi first

#define se second

typedef long long lint;

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

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

const int MAX_N=2e5+5;



int main(void){

    lint n,m,d;

    cin >> n >> m >> d;

    cout << (d?2:1)*(n-d)*(m-1)/pow(n,2) << endl;

}

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

int main(){float n,m,d;scanf("%f%f%f",&n,&m,&d);printf("%lf",(d?2:1)*(n-d)*(m-1)/n/n);}
// Slower C++ solution:
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>

//#include<boost/multiprecision/cpp_int.hpp>

//#include<boost/multiprecision/cpp_dec_float.hpp>

//namespace mp=boost::multiprecision;

//#define mulint mp::cpp_int

//#define mulfloat mp::cpp_dec_float_100

using namespace std;

struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

#define max3(a,b,c) max(a,max(b,c))

#define min3(a,b,c) min(a,min(b,c))

//constexpr int MOD=1000000007;

constexpr int MOD=998244353;

#define INF (1<<30)

#define LINF (lint)(1LL<<56)

#define endl "\n"

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

#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)

#define Flag(x) (1<<(x))

#define Flagcount(x) __builtin_popcount(x)

#define pint pair<int,int>

#define pdouble pair<double,double>

#define plint pair<lint,lint>

#define fi first

#define se second

typedef long long lint;

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

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

const int MAX_N=2e5+5;



int main(void){

    lint n,m,d;

    cin >> n >> m >> d;

    cout << (d?2:1)*(n-d)*(m-1)/pow(n,2) << endl;

}

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

int main(){float n,m,d;scanf("%f%f%f",&n,&m,&d);printf("%f",(d?2:1)*(n-d)*(m-1)/n/n);}
// Slower C++ solution:
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>

//#include<boost/multiprecision/cpp_int.hpp>

//#include<boost/multiprecision/cpp_dec_float.hpp>

//namespace mp=boost::multiprecision;

//#define mulint mp::cpp_int

//#define mulfloat mp::cpp_dec_float_100

using namespace std;

struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

#define max3(a,b,c) max(a,max(b,c))

#define min3(a,b,c) min(a,min(b,c))

//constexpr int MOD=1000000007;

constexpr int MOD=998244353;

#define INF (1<<30)

#define LINF (lint)(1LL<<56)

#define endl "\n"

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

#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)

#define Flag(x) (1<<(x))

#define Flagcount(x) __builtin_popcount(x)

#define pint pair<int,int>

#define pdouble pair<double,double>

#define plint pair<lint,lint>

#define fi first

#define se second

typedef long long lint;

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

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

const int MAX_N=2e5+5;



int main(void){

    lint n,m,d;

    cin >> n >> m >> d;

    cout << (d?2:1)*(n-d)*(m-1)/pow(n,2) << endl;

}

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

main(){float n,m,d;scanf("%f%f%f",&n,&m,&d);printf("%f",(d?2:1)*(n-d)*(m-1)/n/n);}
// Slower C++ solution:
#include<bits/stdc++.h> //Ithea Myse Valgulious

namespace chtholly{

typedef long long ll;

#define re0 register int

#define rec register char

#define rel register ll

#define gc getchar

#define pc putchar

#define p32 pc(' ')

#define pl puts("")

/*By Citrus*/

inline int read(){

  int x=0,f=1;char c=gc();

  for (;!isdigit(c);c=gc()) f^=c=='-';

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return f?x:-x;

  }

template <typename mitsuha>

inline bool read(mitsuha &x){

  x=0;int f=1;char c=gc();

  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';

  if (!~c) return 0;

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return x=f?x:-x,1;

  }

template <typename mitsuha>

inline int write(mitsuha x){

  if (!x) return 0&pc(48);

  if (x<0) x=-x,pc('-');

  int bit[20],i,p=0;

  for (;x;x/=10) bit[++p]=x%10;

  for (i=p;i;--i) pc(bit[i]+48);

  return 0;

  }

inline char fuhao(){

  char c=gc();

  for (;isspace(c);c=gc());

  return c;

  }

}using namespace chtholly;

using namespace std;

 

int main(){

ll n=read(),m=read(),d=read();

printf("%.10lf",1.0*((d!=0)+1)*(n-d)*(m-1)/(n*n));

}

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



int main() {

	int n, m, d;

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

	double t;

	if (d == 0) t = n;

	else t = (n - d) << 1;

	t *= m - 1;

	t /= n;

	t /= n;

	printf("%.10lf\n", t);

	return 0;

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

#define int long long

const int inf = 1e18;

using namespace std;



template<typename tp> inline void read(tp &x) {

	x=0;char c=getchar();

	for(;c<'0'||c>'9';c=getchar());

	for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c=getchar());

}

const int N = 2e5 + 10 ; 

int x,y,z,n;

struct P {

	int a,b,c;

}p[N];

inline bool cmp(P a, P b) {

	return a.a-a.b<b.a-b.b;

}

int suma,sumb,sum,t1[N],t2[N],ans=0;

priority_queue<int,vector<int> , greater<int> > q;



main() {

	memset(t1,168,sizeof(t1));

	memset(t2,168,sizeof(t2));

	cin>>x>>y>>z;

	n=x+y+z;

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

		read(p[i].a);read(p[i].b);read(p[i].c);

		p[i].a-=p[i].c;

		p[i].b-=p[i].c;

		sum+=p[i].c;

	}

	sort(p+1,p+n+1,cmp);

	int ans=-inf;

	for(int k=1;k<=y;k++) q.push(p[k].b),sumb+=p[k].b,t1[k]=max(t1[k],sumb);

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

		int u=q.top();q.pop();

		sumb-=u;

		sumb+=max(u,p[k].b);

		t1[k]=max(t1[k],sumb);

		q.push(max(u,p[k].b));

	}

	while(!q.empty()) q.pop();

	for(int k=n;k>=n-x+1;k--) 

		q.push(p[k].a),suma+=p[k].a,t2[k]=max(t2[k],suma);

	for(int k=n-x;k>=1;k--) {

		int u=q.top();q.pop();

		suma-=u;

		suma+=max(u,p[k].a);

		t2[k]=max(t2[k],suma);

		q.push(max(u,p[k].a));

	}

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

//		printf("%d %d %d\n",p[i].a,p[i].b,p[i].c);

//	}

//	puts("____________");

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

//		printf("%d ",t1[i]);

//	}puts("____________");

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

//		printf("%d ",t2[i]);

//	}puts("____________");

	for(int k=y;k<=n-x;k++)

		ans=max(ans,t1[k]+t2[k+1]);

	cout<<ans+sum<<"\n";

}

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

using namespace std;

#define ll long long

#define N 100010

int n,X,Y,Z,a[N],b[N],c[N],id[N];

ll ans,tmp,s1[N],s2[N];

priority_queue<int,vector<int>,greater<int> >q;

inline char gc(){

    static char *S,*T,buf[1<<16];

    if(T==S){T=(S=buf)+fread(buf,1,1<<16,stdin);if(T==S) return EOF;}

    return *S++;

}

inline int read(){

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

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

    while('0'<=ch && ch<='9') x=x*10+ch-'0',ch=gc();

    return x*f;

}

inline bool cmp(int x,int y){return a[x]-b[x]>a[y]-b[y];}

int main(){

	X=read();Y=read();Z=read();n=X+Y+Z;

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

		a[i]=read();b[i]=read();c[i]=read();

		id[i]=i;tmp+=b[i];

	}

	sort(id+1,id+n+1,cmp);

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

		s1[i]=s1[i-1]+a[id[i]]-b[id[i]];

		q.push(a[id[i]]-c[id[i]]);

	}

	for(int i=X+1;i<=X+Z;++i){

		s1[i]=s1[i-1]+c[id[i]]-b[id[i]];

		if(a[id[i]]-c[id[i]]>q.top()){

			int x=q.top();q.pop();

			q.push(a[id[i]]-c[id[i]]);

			s1[i]+=-x+a[id[i]]-c[id[i]];

		}

	}

	while(!q.empty()) q.pop();

	for(int i=n;i>=n-Y+1;--i){

//		s2[i]=s2[i-1]+c[id[i]]-b[id[i]];

		q.push(b[id[i]]-c[id[i]]);

	}

	for(int i=n-Y;i>=X+1;--i){

		s2[i]=s2[i+1]+c[id[i]]-b[id[i]];

		if(b[id[i]]-c[id[i]]>q.top()){

			int x=q.top();q.pop();

			q.push(b[id[i]]-c[id[i]]);

			s2[i]+=-x+b[id[i]]-c[id[i]];

		}

	}

	for(int i=X;i<=X+Z;++i){

		ans=max(ans,tmp+s1[i]+s2[i+1]);

	}

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

	return 0;

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

#define int long long

const int inf = 1e18;

using namespace std;



template<typename tp> inline void read(tp &x) {

	x=0;char c=getchar();

	for(;c<'0'||c>'9';c=getchar());

	for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c=getchar());

}

const int N = 2e5 + 10 ; 

int x,y,z,n;

struct P {

	int a,b,c;

}p[N];

inline bool cmp(P a, P b) {

	return a.a-a.b<b.a-b.b;

}

int suma,sumb,sum,t1[N],t2[N],ans=0;

priority_queue<int,vector<int> , greater<int> > q;



main() {

	memset(t1,168,sizeof(t1));

	memset(t2,168,sizeof(t2));

	cin>>x>>y>>z;

	n=x+y+z;

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

		read(p[i].a);read(p[i].b);read(p[i].c);

		p[i].a-=p[i].c;

		p[i].b-=p[i].c;

		sum+=p[i].c;

	}

	sort(p+1,p+n+1,cmp);

	int ans=-inf;

	for(int k=1;k<=y;k++) q.push(p[k].b),sumb+=p[k].b,t1[k]=max(t1[k],sumb);

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

		int u=q.top();q.pop();

		sumb-=u;

		sumb+=max(u,p[k].b);

		t1[k]=max(t1[k],sumb);

		q.push(max(u,p[k].b));

	}

	while(!q.empty()) q.pop();

	for(int k=n;k>=n-x+1;k--) 

		q.push(p[k].a),suma+=p[k].a,t2[k]=max(t2[k],suma);

	for(int k=n-x;k>=1;k--) {

		int u=q.top();q.pop();

		suma-=u;

		suma+=max(u,p[k].a);

		t2[k]=max(t2[k],suma);

		q.push(max(u,p[k].a));

	}

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

//		printf("%d %d %d\n",p[i].a,p[i].b,p[i].c);

//	}

//	puts("____________");

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

//		printf("%d ",t1[i]);

//	}puts("____________");

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

//		printf("%d ",t2[i]);

//	}puts("____________");

	for(int k=y;k<=n-x;k++)

		ans=max(ans,t1[k]+t2[k+1]);

	cout<<ans+sum<<"\n";

}

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

using namespace std;



const int N = 1e5+7;

long long pref[N], suf[N];

int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);



    int x, y, z;

    cin>>x>>y>>z;



    int n = x+y+z;

    vector<pair<int, int>> v;

    long long ans = 0;

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

        int a, b, c;

        cin>>a>>b>>c;

        ans += a;

        v.push_back({b-a, c-a});

    }



    sort(v.begin(), v.end(), [](auto a, auto b) {return a.first-a.second > b.first - b.second;});



    priority_queue<int> pq;

    long long sum = 0;

    for (int i=0; i<y; i++) pq.push(-v[i].first), sum += v[i].first;

    pref[y-1] = sum;



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

        pq.push(-v[i].first);

        sum += v[i].first + pq.top();

        pq.pop();

        pref[i] = sum;

    }



    while(pq.size())    pq.pop();

    sum = 0;

    for (int i=0; i<z; i++)    pq.push(-v[n-i-1].second), sum += v[n-i-1].second;

    suf[n-z] = sum;



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

        pq.push(-v[n-i-1].second);

        sum += v[n-i-1].second + pq.top();

        pq.pop();

        suf[n-i-1] = sum;

    }



    long long mx = -1e18;

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

        mx = max(mx, pref[i]+suf[i+1]);

    }



    ans += mx;

    cout<<ans<<endl;

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

#define int long long

const int inf = 1e18;

using namespace std;



template<typename tp> inline void read(tp &x) {

	x=0;char c=getchar();

	for(;c<'0'||c>'9';c=getchar());

	for(;c>='0'&&c<='9';x=(x<<3)+(x<<1)+c-'0',c=getchar());

}

const int N = 2e5 + 10 ; 

int x,y,z,n;

struct P {

	int a,b,c;

}p[N];

inline bool cmp(P a, P b) {

	return a.a-a.b<b.a-b.b;

}

int suma,sumb,sum,t1[N],t2[N],ans=0;

priority_queue<int,vector<int> , greater<int> > q;



main() {

	memset(t1,168,sizeof(t1));

	memset(t2,168,sizeof(t2));

	cin>>x>>y>>z;

	n=x+y+z;

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

		read(p[i].a);read(p[i].b);read(p[i].c);

		p[i].a-=p[i].c;

		p[i].b-=p[i].c;

		sum+=p[i].c;

	}

	sort(p+1,p+n+1,cmp);

	int ans=-inf;

	for(int k=1;k<=y;k++) q.push(p[k].b),sumb+=p[k].b,t1[k]=max(t1[k],sumb);

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

		int u=q.top();q.pop();

		sumb-=u;

		sumb+=max(u,p[k].b);

		t1[k]=max(t1[k],sumb);

		q.push(max(u,p[k].b));

	}

	while(!q.empty()) q.pop();

	for(int k=n;k>=n-x+1;k--) 

		q.push(p[k].a),suma+=p[k].a,t2[k]=max(t2[k],suma);

	for(int k=n-x;k>=1;k--) {

		int u=q.top();q.pop();

		suma-=u;

		suma+=max(u,p[k].a);

		t2[k]=max(t2[k],suma);

		q.push(max(u,p[k].a));

	}

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

//		printf("%d %d %d\n",p[i].a,p[i].b,p[i].c);

//	}

//	puts("____________");

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

//		printf("%d ",t1[i]);

//	}puts("____________");

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

//		printf("%d ",t2[i]);

//	}puts("____________");

	for(int k=y;k<=n-x;k++)

		ans=max(ans,t1[k]+t2[k+1]);

	cout<<ans+sum<<"\n";

}

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

#define maxn 100010

using namespace std;

typedef long long ll;

template<typename T> inline void read(T &x)

{

    x=0;char c=getchar();bool flag=false;

    while(!isdigit(c)){if(c=='-')flag=true;c=getchar();}

    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}

    if(flag)x=-x;

}

ll n,x,y,z,sum,ans;

ll v1[maxn],v2[maxn];

struct node

{

	ll a,b,c;

}p[maxn];

bool cmp(const node &x,const node &y)

{

	if(x.a-x.b!=y.a-y.b) return x.a-x.b>y.a-y.b;

	if(x.a!=y.a) return x.a>y.a;

	return x.b>y.b;

}

priority_queue<ll,vector<ll>,greater<ll> > q;

int main()

{

	read(x),read(y),read(z),n=x+y+z;

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

	{

		read(p[i].a),read(p[i].b),read(p[i].c);

		sum+=p[i].c,p[i].a-=p[i].c,p[i].b-=p[i].c;

	}

	sort(p+1,p+n+1,cmp);

	for(int i=1;i<=x;++i) v1[x]+=p[i].a,q.push(p[i].a);

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

	{

		v1[i]=v1[i-1];

		if(p[i].a>q.top()) v1[i]+=p[i].a-q.top(),q.push(p[i].a),q.pop();

	}

	while(!q.empty()) q.pop();

	for(int i=n;i>=n-y+1;--i) v2[n-y+1]+=p[i].b,q.push(p[i].b);

	for(int i=n-y;i;--i)

	{

		v2[i]=v2[i+1];

		if(p[i].b>q.top()) v2[i]+=p[i].b-q.top(),q.push(p[i].b),q.pop();

	}

	for(int i=x;i<=n-y;++i) ans=max(ans,sum+v1[i]+v2[i+1]);

	printf("%lld",ans);

    return 0;

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

using namespace std;

const int maxn = 2e5 + 10;

const long long inf = 1e16;

long long pre[maxn], suf[maxn];

struct data {

  int a, b, c;

  data () {}

  bool operator < (data d) const {

    return b - a < d.b - d.a;

  }

} arr[maxn];

int t[maxn * 4];

long long sum[maxn * 4];

int rev[maxn];

int idx;



void add(int x, int c = 1, int b = 1, int e = idx) {

  if(b == e) {

    t[c] += 1;

    sum[c] += rev[b];

    return ;

  }

  int m = (b + e) >> 1;

  int l = c << 1;

  int r = l + 1;

  if(x <= m) add(x, l, b, m);

  else add(x, r, m + 1, e);

  t[c] = t[l] + t[r];

  sum[c] = sum[l] + sum[r];

}

long long get(int x, int c = 1, int b = 1, int e = idx) {

  if(b == e) {

    return 1LL * rev[b] * x;

  }

  int m = (b + e) >> 1;

  int l = c << 1;

  int r = l + 1;

  if(t[r] >= x) return get(x, r, m + 1, e);

  else return sum[r] + get(x - t[r], l, b, m);

}

int main() {

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

  int X, Y, Z;

  cin >> X >> Y >> Z;

  int n = X + Y + Z;

  map <int, int> cmp;

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

    cin >> arr[i].a >> arr[i].b >> arr[i].c;

    cmp[arr[i].c - arr[i].a];

    cmp[arr[i].c - arr[i].b];

  }

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

  for(auto &i : cmp) {

    i.second = ++idx;

    rev[idx] = i.first;

  }

  long long total = 0;

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

    int x = cmp[arr[i].c - arr[i].a];

    add(x);

    total += arr[i].a;

    if(i >= X) pre[i] = total + get(i - X);

    else pre[i] = -inf;

  }

  memset(t, 0, sizeof t);

  memset(sum, 0, sizeof sum);

  total = 0;

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

    int x = cmp[arr[i].c - arr[i].b];

    add(x);

    total += arr[i].b;

    if(n - i + 1 >= Y) suf[i] = total + get(n - i + 1 - Y);

    else suf[i] = -inf;

  }

  long long ans = -inf;

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

    ans = max(ans, pre[i] + suf[i + 1]);

  }

  cout << ans << endl;

  return 0;

}


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

using namespace std;



inline long long read()

{

	long long x=0,f=1,c=getchar();

	while(c<48) c=='-'&&(f=-1),c=getchar();

	while(c>47) x=x*10+c-'0',c=getchar();

	return x*f;

}



typedef long long ll;

const ll MAXN = 100005;

struct Node {ll a,b;} s[MAXN];

priority_queue<ll,vector<ll>,greater<ll> > q,ept;

ll lp[MAXN],rp[MAXN],ans;

ll n,x,y,z;



int main(int argc, char const *argv[])

{

	x=read(); y=read(); z=read(); n=x+y+z;

	for(ll i=1,k;i<=n;++i)

		ans+=(k=read()),s[i].a=read()-k,s[i].b=read()-k;

	sort(s+1,s+n+1,[](Node a,Node b)

	{return a.a-a.b>b.a-b.b;});

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

	{

		lp[i]=lp[i-1]+s[i].a; q.push(s[i].a);

		if(q.size()>y) lp[i]-=q.top(),q.pop();

	}

	for(ll i=(q=ept,n);i;--i)

	{

		rp[i]=rp[i+1]+s[i].b; q.push(s[i].b);

		if(q.size()>z) rp[i]-=q.top(),q.pop();

	}

	ll mx=-1000000000000000000ll;

	for(ll i=y;i<=n-z;++i)

		mx=max(mx,lp[i]+rp[i+1]);

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

	return 0;

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

using namespace std;



typedef long long ll;

const ll N = 1e5 + 100, inF = 1e17;

ll A, B, C, n, a[N], b[N], c[N], dex[N], up[N], down[N];



int main() {

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

	cin >> A >> B >> C;

	n = A + B + C;

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

		cin >> a[i] >> b[i] >> c[i];

	iota(dex, dex + n, 0);

	sort(dex, dex + n, [](int x, int y) {

		return c[x] - b[x] < c[y] - b[y];

	});

	// a - b

	fill(up, up + N, -inF);

	multiset<ll> st;

	ll now = 0;

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

		int ind = dex[i];

		st.insert(a[ind] - b[ind]);

		now += b[ind];

	}

	if(B)

		up[B - 1] = now;

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

		int ind = dex[i];

		if(B == 0) {

			now += a[ind];

			up[i] = now;

			continue;

		}

		if(a[ind] - b[ind] > (*st.rbegin()))

			now += a[ind];

		else {

			ll val = *st.rbegin();

			st.erase(st.find(val));

			now += val;

			now += b[ind];

			st.insert(a[ind] - b[ind]);

		}

		up[i] = now;

	}

	// a - c

	fill(down, down + N, -inF);

	st.clear();

	now = 0;

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

		int ind = dex[n - i -1];

		st.insert(a[ind] - c[ind]);

		now += c[ind];

	}

	down[n - C] = now;

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

		int ind = dex[n - i - 1];

		if(C == 0) {

			now += a[ind];

			down[i] = now;

			continue;

		}

		if(a[ind] - c[ind] > (*st.rbegin()))

			now += a[ind];

		else {

			ll val = *st.rbegin();

			st.erase(st.find(val));

			now += val;

			now += c[ind];

			st.insert(a[ind] - c[ind]);

		}

		down[n - i - 1] = now;

	}

	ll ans = 0;

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

		ans = max(ans, up[i] + down[i + 1]);

	cout << ans;

	return 0;

}

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

using namespace std;



using ll = long long;

using ii = pair<ll,int>;



const int N = 1e5+10;

int x, y, z;

struct data{

  int a, b, c;

  bool operator<(data o) const {

    return a - b < o.a - o.b;

  }

}seq[N];



ll pre[N], suf[N];

priority_queue<ii, vector<ii>, greater<ii>> q;



int main() { 

  scanf("%d %d %d", &x, &y, &z);

  for(int i = 0; i < x + y + z; i++) {

    scanf("%d %d %d", &seq[i].a, &seq[i].b, &seq[i].c);

  } sort(seq, seq + x + y + z);



  ll cur = 0;

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

    q.push({seq[i].b - seq[i].c, i});

    cur += seq[i].b;

  }

  pre[y - 1] = cur;

  for(int i = y; i < x + y + z; i++) {

    q.push({seq[i].b - seq[i].c, i});

    cur += seq[i].b;

    auto U = q.top(); q.pop();

    cur -= seq[U.second].b;

    cur += seq[U.second].c;

    pre[i] = cur;

  }

  while(!q.empty()) q.pop();

  cur = 0;

  for(int i = y + z; i < x + y + z; i++) {

    q.push({seq[i].a - seq[i].c, i});

    cur += seq[i].a;

  }

  suf[y + z] = cur;

  for(int i = y + z - 1; i >= 0; i--) {

    q.push({seq[i].a - seq[i].c, i});

    cur += seq[i].a;

    auto U = q.top(); q.pop();

    cur -= seq[U.second].a;

    cur += seq[U.second].c;

    suf[i] = cur;

  }

  ll ans = 0;

  for(int i = y - 1; i + 1 <= y + z; i++) {

    ans = max(ans, pre[i] + suf[i + 1]);

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

  return 0;

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

using namespace std;



struct Node{

	int p, q;

};



const int N = 1e5 + 10;



Node a[N];

long long sum[N];

priority_queue <int, vector <int>, greater <int> > pq;



bool cmp(const Node& x, const Node& y){

	return x.p - x.q < y.p - y.q;

}



int main(){

	int x, y, z, n, n1, n2, n3;

	long long ans, rec, maxx;

	scanf("%d %d %d",&x,&y,&z);

	n = x + y + z;

	ans = 0;

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

		scanf("%d %d %d",&n1,&n2,&n3);

		a[i].p = n1 - n3; a[i].q = n2 - n3;

		ans += n3;

	}

	sort(a + 1, a + n + 1, cmp);

	memset(sum, 0, sizeof(sum));

	rec = 0;

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

		pq.push(a[i].q);

		rec += a[i].q;

	}

	sum[y] = rec;

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

		if (a[i].q > pq.top()){

			rec += a[i].q - pq.top();

			pq.pop();

			pq.push(a[i].q);

		}

		sum[i] = rec;

	}

	while (!pq.empty()) pq.pop();

	rec = 0;

	for (int i = n; i >= n - x + 1; i--){

		pq.push(a[i].p);

		rec += a[i].p;

	}

	sum[n - x] += rec;

	for (int i = n - x; i > y; i--){

		if (a[i].p > pq.top()){

			rec += a[i].p - pq.top();

			pq.pop();

			pq.push(a[i].p);

		}

		sum[i - 1] += rec;

	}

	maxx = -1e18;

	for (int i = y; i <= n - x; i++) maxx = max(maxx, sum[i]);

	ans += maxx;

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

	return 0;

}

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

#include <iostream>

#include <set>

using namespace std;



const int MAXN = 1e5 + 10;

long long x, y, z, n, pre[MAXN], suf[MAXN], ans;

struct itm {

	int g, s, b;

};

itm t[MAXN];

bool cmp(itm a, itm b) {

	return a.g - a.s < b.g - b.s;

}

bool operator <(pair<int, itm> a, pair<int, itm> b) {

	return a.first < b.first;

}



multiset<pair<int, itm> > re;

long long res;



int main() {

	cin >> x >> y >> z;

	n = x + y + z;

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

		cin >> t[i].g >> t[i].s >> t[i].b;

	sort(t, t + n, cmp);

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

		re.insert({ t[i].b - t[i].s, t[i] });

		multiset<pair<int, itm> >::iterator it = re.end();

		res += t[i].s;

		it--;

		if (re.size() == y + 1) {

			res -= (*it).second.s;

			res += (*it).second.b;

			re.erase(it);

		}

		if (re.size() != y)

			pre[i] = -1;

		else

			pre[i] = res;

	}

	re.clear();

	res = 0;

	suf[n] = -1;

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

		re.insert({ t[i].b - t[i].g, t[i] });

		multiset<pair<int, itm> >::iterator it = re.end();

		res += t[i].g;

		it--;

		if (re.size() == x + 1) {

			res -= (*it).second.g;

			res += (*it).second.b;

			re.erase(it);

		}

		if (re.size() != x)

			suf[i] = -1;

		else

			suf[i] = res;

	}

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

		if (pre[i] == -1 || suf[i + 1] == -1)

			continue;

		ans = max(ans, pre[i] + suf[i + 1]);

	}

	cout << ans;

}