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

using namespace std;

using ll = long long;

int main(){

    int N,A,B,C;

    cin >> N >> A >> B >> C;

    int l[8] = {};

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

    int d[8];

    int ans = 100000000;

    

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

        d[0] = i;

        for(int j = 0; j < 4; j++){

            d[1] = j;

            for(int k = 0; k < 4; k++){

                d[2] = k;

                for(int m = 0; m < 4; m++){

                    d[3] = m;

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

                        d[4] = n;

                        for(int o = 0; o < 4; o++){

                            d[5] = o;

                            for(int p = 0; p < 4; p++){

                                d[6] = p;

                                for(int q = 0; q < 4; q++){

                                    d[7] = q;

                                    int a = 0,b = 0,c = 0,interim = 0;

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

                                        if(d[z] == 0){

                                            a += l[z];

                                            interim += 10;

                                        }

                                        else if(d[z] == 1){

                                            b += l[z];

                                            interim += 10;

                                        }

                                        else if(d[z] == 3){

                                            c += l[z];

                                            interim += 10;

                                        }

                                    }

                                    if(a == 0 || b == 0 || c == 0) continue;

                                    interim += (abs(A-a) + abs(B-b) + abs(C-c) - 30);

                                    if(ans > interim)

                                        ans = interim;

                                }

                            }

                        }

                    }

                }

            }

        }

    }

    cout << ans << "\n";

    return 0;

}




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

using namespace std;

using ll = long long;

int N,A,B,C;

int l[8];

int ans = 100000000;

void dfs(int depth,int a,int b,int c,int cost){

    if(depth == N){

        if(a != 0 && b != 0 && c != 0)

            ans = min(ans,cost + (abs(A-a) + abs(B-b) + abs(C-c) - 30));

    return ;

    }

    dfs(depth+1,a+l[depth],b,c,cost+10);

    dfs(depth+1,a,b+l[depth],c,cost+10);

    dfs(depth+1,a,b,c+l[depth],cost+10);

    dfs(depth+1,a,b,c,cost);

}

int main(){

    cin >> N >> A >> B >> C;

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

    dfs(0,0,0,0,0);

    cout << ans << "\n";

    return 0;

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

#include <vector>

#include <string>

#include <cmath>

#include <algorithm>

#include <tuple>

#include <map>

using namespace std;

typedef long long ll;

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

#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)

#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)



int N, A, B, C;

int seq[4] = {0, 1, 2, 3};

int ANS = 100000;



int calcMP(map<int, int> m)

{

  if (m[1] == 0 || m[2] == 0 || m[3] == 0)

    return 10000;

  return abs(A - m[1]) + abs(B - m[2]) + abs(C - m[3]);

}



int dfs(int depth, int l[], map<int, int> m, int mp)

{

  if (depth == 0)

  {

    mp += calcMP(m);

    return mp;

  }



  for (auto s : seq)

  {

    int tmp = mp;

    map<int, int> mm = m;

    if (mm[s] == 0)

    {

      mm[s] = l[depth - 1];

    }

    else

    {

      mm[s] += l[depth - 1];

      if (s != 0)

        tmp += 10;

    }

    tmp = dfs(depth - 1, l, mm, tmp);

    ANS = min(ANS, tmp);

  }



  return ANS;

}



int main()

{

  cin >> N >> A >> B >> C;

  int l[N];

  rep(i, N) cin >> l[i];

  int mp = 0;



  map<int, int> m{

      {0, 0}, {1, 0}, {2, 0}, {3, 0}};



  dfs(N, l, m, mp);



  cout << ANS;

}

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

#include <vector>

#include <string>

#include <cmath>

#include <algorithm>

#include <tuple>

#include <map>

using namespace std;

typedef long long ll;

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

#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)

#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)



int N, A, B, C;

int seq[4] = {0, 1, 2, 3};

int ANS = 100000;

int l[8];



int calcMP(vector<int> m)

{

  if (m[1] == 0 || m[2] == 0 || m[3] == 0)

    return 10000;

  return abs(A - m[1]) + abs(B - m[2]) + abs(C - m[3]);

}



int dfs(int depth, vector<int> m, int mp)

{

  if (depth == 0)

  {

    mp += calcMP(m);

    return mp;

  }



  for (auto s : seq)

  {

    int tmp = mp;

    vector<int> mm = m;

    if (s != 0)

    {

      if (mm[s] == 0)

      {

        mm[s] = l[depth - 1];

      }

      else

      {

        tmp += 10;

        mm[s] += l[depth - 1];

      }

    }

    tmp = dfs(depth - 1, mm, tmp);

    ANS = min(ANS, tmp);

  }



  return ANS;

}



int main()

{

  cin >> N >> A >> B >> C;

  rep(i, N) cin >> l[i];

  int mp = 0;



  vector<int> m(4, 0);



  dfs(N, m, mp);



  cout << ANS;

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

using namespace std;

#define ll long long int

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

#define rrep(i,n) for( int i = n; i >= 0; i-- )

#define REP(i,s,t) for( int i = s; i <= t; i++ )

#define RREP(i,s,t) for( int i = s; i >= t; i-- )

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000





int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int N, A[3];

    cin >> N >> A[0] >> A[1] >> A[2];

    int l[8];

    rep(i, N) cin >> l[i];

    int ans = INF;

    int pattern = 1;

    rep(i, N) pattern *= 4;

    rep(bit, pattern) {

        int tmp = bit;

        vector<int> v[3];

        int sum[3] = {};

        rep(i, N) {

            if(tmp % 4 != 3) {

                v[tmp % 4].push_back(l[i]);

                sum[tmp % 4] += l[i];

            }

            tmp /= 4;

        }

        bool ok = true;

        rep(i, 3) if(v[i].size() == 0) ok = false;

        if(!ok) continue;

        int cost = 0;

        rep(i, 3) {

            cost += abs(sum[i] - A[i]);

            cost += (v[i].size() - 1) * 10;

        }

        ans = min(ans, cost);

    }

    cout << ans << endl;





    return 0;

}


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

#include <fstream>

#include <set>

#include <map>

#include <string>

#include <vector>

#include <queue>

#include <deque>

#include <stack>

#include <functional>

#include <algorithm>

#include <climits>

#include <cmath>

#include <iomanip>

using namespace std;

#define ll long long int

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

#define rrep(i,n) for( int i = n; i >= 0; i-- )

#define REP(i,s,t) for( int i = s; i <= t; i++ )

#define RREP(i,s,t) for( int i = s; i >= t; i-- )

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000





int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    int N, A[3];

    cin >> N >> A[0] >> A[1] >> A[2];

    int l[8];

    rep(i, N) cin >> l[i];

    int ans = INF;

    int pattern = (1 << (N * 2));

    rep(k, pattern) {

        int cnt[3] = {};

        int bit = k;

        int sum[3] = {};

        rep(i, N) {

            int c = bit % 4;

            bit /= 4;

            if(c == 3) continue;

            cnt[c]++;

            sum[c] += l[i];

            

        }

        bool ok = true;

        int tmp = 0;

        rep(i, 3) {

            if(cnt[i] == 0) ok = false;

            tmp += (cnt[i] - 1) * 10;

            tmp += abs(A[i] - sum[i]);

        }

        if(!ok) continue;

        ans = min(ans, tmp);

    }

    cout << ans << endl;



    return 0;

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

 

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

#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)

#define ALL(a) (a).begin(),(a).end()



using namespace std;

using ll  = long long;

using pll = pair<ll, ll>;



const ll MOD  = 1e9 + 7;

const ll LINF = 1LL << 62;

const int INF = 1e9 + 7;



ll n, a, b, c;

vector<ll> l(10);



//long to binary

string ternary(ll n){

    if(n == 2)return "2";

    else if(n == 1)return "1";

    else if(n == 0)return "0";



    return ternary(n/3)  + ternary(n%3);

}



ll dfs(ll n_i, string ter, vector<ll> cost, vector<ll> len){

    if(n_i >= n){

        //無から竹は作れない

        if(len[0]*len[1]*len[2] == 0){

            return INF;

        }

        //合成魔法は使う本数−１*10のコストがかかる

        rep(i, 3)cost[i] = 10 * max((ll)0, cost[i]-1);

        ll res = cost[0] + cost[1] + cost[2];



        //合成した後の誤差は延長，短縮魔法を使う

        res += abs(a - len[0]) + abs(b - len[1]) + abs(c - len[2]);

        return res;

    }



    string ter_bit = "012"; 

    ll res = INF;

    //使わない場合

    res = min(res, dfs(n_i+1, ter, cost, len));

    rep(i, 3){

        if(ter[n_i] == ter_bit[i]){

            //合成する場合

            cost[i]++;

            len[i] += l[n_i];

            res = min(res, dfs(n_i+1, ter, cost, len));

        }

    }



    return res;

}



int main(){

    cin >> n >> a >> b >> c;

    

    rep(i, n)cin >> l[i];



    ll ans = INF;

    vector<ll> cost(3, 0), len(3, 0);

    rep(i, pow(3, n)){

        //3進数，０〜２が竹A~Cに対応

        string ter = ternary(i);

        while(ter.size() != n)ter = '0' + ter;

        ans = min(ans, dfs(0, ter, cost, len));

    }



    cout << ans << endl;

}

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

 

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

#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)

#define ALL(a) (a).begin(),(a).end()



using namespace std;

using ll  = long long;

using pll = pair<ll, ll>;



const ll MOD  = 1e9 + 7;

const ll LINF = 1LL << 62;

const int INF = 1e9 + 7;



ll n, a, b, c;

vector<ll> l(10);



ll dfs(ll n_i, ll l_a, ll l_b, ll l_c){

    if(n_i >= n){

        //無から竹は作れない

        if(l_a*l_b*l_c == 0){

            return INF;

        }

        //合成魔法は使う本数−１*10のコストがかかる

        //合成した後の誤差は延長，短縮魔法を使う

        ll res = abs(a - l_a) + abs(b - l_b) + abs(c - l_c) - 30;

        return res;

    }



    ll res = INF;

    //使わない場合

    res = min(res, dfs(n_i+1, l_a, l_b, l_c));

    //A~Bいずれかに使う場合

    res = min(res, dfs(n_i+1, l_a+l[n_i], l_b, l_c) + 10);

    res = min(res, dfs(n_i+1, l_a, l_b+l[n_i], l_c) + 10);

    res = min(res, dfs(n_i+1, l_a, l_b, l_c+l[n_i]) + 10);



    return res;

}



int main(){

    cin >> n >> a >> b >> c;

    

    rep(i, n)cin >> l[i];



    cout << dfs(0, 0, 0, 0) << endl;

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

using namespace std;



int main() {

	int a[3][3];

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

		for (int j = 0 ; j < 3; j++) {

			cin >> a[i][j];

		}

	}

	int b[3]{};

	for (b[0] = 0; b[0] <= 100; b[0]++) {

		for (b[1] = 0; b[1] <= 100; b[1]++) {

			for (b[2] = 0; b[2] <= 100; b[2]++) {

				int c[3] = {a[0][0] - b[0], a[0][1] - b[0], a[0][2] - b[0]};

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

					for (int j = 0; j < 3; j++) {

						if (a[i][j] != b[i] + c[j]) {

							goto next;

						}

					}

				}

				cout << "Yes" << endl;

				return 0;

				next:;

			}

		}

	}

	cout << "No" << endl;

	return 0;

}

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

using namespace std;



int main() {

	int a[3][3];

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

		for (int j = 0 ; j < 3; j++) {

			cin >> a[i][j];

		}

	}

	int x[3]{}, y[3];

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

		y[i] = a[0][i];

	}

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

		x[i] = a[i][0] - y[0];

	}

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

		for (int j = 0; j < 3; j++) {

			if (a[i][j] != x[i] + y[j]) {

				cout << "No" << endl;

				return 0;

			}

		}

	}

	cout << "Yes" << endl;

	return 0;

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

using namespace std;



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

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

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

#define allg(a) (a).begin(), (a).end(), greater<int>()



using vi = vector<int>;

using vvi = vector<vi>;

using vs = vector<string>;



const int INF = 1001001001;

const int MOD = 1000000007;

const long long INFL = (1LL << 60);

const double EPS = 1e-9;



int main() {

  int c[3][3];

  rep(i, 3) rep(j, 3) cin >> c[i][j];



  string res = "No";

  rep(k, 101) rep(m, 101) rep(n, 101) {

    int a[3], b[3];

    a[0] = k, a[1] = m, a[2] = n;

    b[0] = c[0][0] - a[0], b[1] = c[1][1] - a[1], b[2] = c[2][2] - a[2];

    bool skip = false;

    rep(i, 3) if (b[i] < 0) skip = true;

    if (skip) continue;

    int cnt = 0;

    rep(i, 3) rep(j, 3) {

      if (c[i][j] != a[i] + b[j]) continue;

      cnt++;

    }

    if (cnt == 9) {

      res = "Yes";

      goto RES;

    }

  }



RES:

  cout << res << endl;

}

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

using namespace std;



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

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

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

#define allg(a) (a).begin(), (a).end(), greater<int>()



using vi = vector<int>;

using vvi = vector<vi>;

using vs = vector<string>;



const int INF = 1001001001;

const int MOD = 1000000007;

const long long INFL = (1LL << 60);

const double EPS = 1e-9;



int main() {

  int c[3][3];

  rep(i, 3) rep(j, 3) cin >> c[i][j];



  string res = "No";

  rep(k, 101) rep(m, 101) rep(n, 101) {

    int a[3], b[3];

    a[0] = k, a[1] = m, a[2] = n;

    b[0] = c[0][0] - a[0], b[1] = c[1][1] - a[1], b[2] = c[2][2] - a[2];

    int cnt = 0;

    rep(i, 3) rep(j, 3) {

      if (c[i][j] != a[i] + b[j]) continue;

      cnt++;

    }

    if (cnt == 9) {

      res = "Yes";

      goto RES;

    }

  }



RES:

  cout << res << endl;

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

using namespace std;



int main(void){

    int c[3][3];

    int tr[3][3]={};

    int a[3]={};

    bool ans=false;

    int con=0;

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

        cin >> c[i][0]>>c[i][1]>>c[i][2];

    }

    for(a[0]=0;a[0]<=100;a[0]++){

        for (a[1] = 0; a[1] <= 100; a[1]++){

            for (a[2] = 0; a[2] <= 100; a[2]++){

                con=0;

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

                    

                    for(int j=0;j<3;j++){

                        tr[i][j]=c[i][j]-a[j];

                    }

                    if(tr[i][0]==tr[i][1] and tr[i][1]==tr[i][2]){

                        con++;

                    }

                }

                

                if(con==3){

                    ans=true;

                    goto fin;

                }

                

            }

        }

    }

    fin:

    if(ans){

        cout <<"Yes"<<endl;

    }else{

        cout <<"No"<<endl;

    }

}

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

using ll = long long;

using namespace std;

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

#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)

#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)

#define rreps(i,n) for(int i=((int)(n));i>0;i--)

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

#define F first

#define S second

#define mp make_pair

#define pb push_back

#define solve(a) ((a)?"Yes":"No")

typedef vector<long long> V;

typedef vector<V> VV;

typedef pair<long long , long long> P;

typedef vector<P> VP;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}

const long long INFLL = 1LL<<62;

const int INF = 1<<30;

const double PI=acos(-1);

int main(){

	VV c(3,V(3));

	V isum(3,0);

	V jsum(3,0);

	int ans=1;

	rep(i,3){

		rep(j,3){

			cin>>c[i][j];

			isum[i]+=c[i][j];

			jsum[j]+=c[i][j];

		}

	}

	ll mi=min(isum[0],min(isum[1],isum[2]));

	ll mj = min(jsum[0],min( jsum[1], jsum[2]));

	rep(i,3){

		isum[i]-=mi;

		jsum[i]-=mj;

		if(isum[i]%3!=0 or jsum[i]%3!=0){

			ans=0;

		}

	}

	cout<<solve(ans)<<endl;

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

using namespace std;

int a[3],b[3][3],c[3][3];

int main(){

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

        for(int j=0;j<3;++j){

            cin>>c[i][j];

        }

    }

    for(a[0]=0;a[0]<=100;++a[0]){

        for(a[1]=0;a[1]<=100;++a[1]){

            for(a[2]=0;a[2]<=100;++a[2]){

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

                    for(int j=0;j<3;++j){

                        b[j][i]=c[i][j]-a[i];

                    }

                }

                bool ok=true;

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

                    for(int j=1;j<3;++j){

                        if(b[i][j]!=b[i][0]){

                            ok=false;

                        }

                    }

                }

                if(ok){

                    cout<<"Yes"<<endl;

                    return 0;

                }

            }

        }

    }

    cout<<"No"<<endl;

    return 0;

}

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

#include<iomanip>

#include<cmath>

#include<cstdio>

#include<cstdlib>

#include<cstring>

#include<algorithm>

#include<set>

#include<map>

#include<queue>

#include<stack>

#include<vector>

#include<cctype>

#define szxb 13

#define F(a,b,c) for(register int (a)=(b);(a)<=(c);(a)++)

#define PDXD(a,b) (!(a-b))

#define PDBXD(a,b) (!(!(a-b)))

#define CON continue;

#define GO goto endreturn;

using namespace std;

int a[szxb][szxb];

int main()

{

	F(i,1,3){F(j,1,3){scanf("%d",&a[i][j]);}}

	int a1,a2,a3,b1,b2,b3,c1,c2,c3;

	F(i,0,100){a1=(a[1][1]-i);a2=(a[1][2]-i);a3=(a[1][3]-i);F(j,0,100){b1=(a[2][1]-j);b2=(a[2][2]-j);b3=(a[2][3]-j);if((PDBXD(a1,b1))||(PDBXD(a2,b2))||(PDBXD(a3,b3))){CON;}F(k,0,100){c1=(a[3][1]-k);c2=(a[3][2]-k);c3=(a[3][3]-k);if((PDXD(a1,c1))&&(PDXD(a2,c2))&&(PDXD(a3,c3))){printf("Yes");GO;}}}}

	printf("No");

	endreturn:return putchar(10),0;

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

#include <cstdio>

#include <algorithm>

#include <vector>

#include <queue>

#include <set>

#include <map>

using namespace std;

#define int long long

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

const int mo = 1e9 + 7;

int grid[3][3];

void solve()

{

    int c[3][3];

    rep(i,3)rep(j,3)cin>>c[i][j];

    int a[3],b[3];

    for(a[0]=0;a[0]<=100;a[0]++)

    {

        for(a[1]=0;a[1]<=100;a[1]++)

        {

            for(a[2]=0;a[2]<=100;a[2]++)

            {

                b[0]=c[0][0]-a[0];

                b[1]=c[0][1]-a[0];

                b[2]=c[0][2]-a[0];

                

                bool ok=1;

                rep(i,3)

                {

                    rep(j,3)

                    {

                        ok&=c[i][j]==a[i]+b[j];

                    }

                }

                if(ok)

                {

                    cout<<"Yes"<<endl;

                    return ;

                }

            }

        }

    }

    cout<<"No"<<endl;

}

main()

{

    cin.tie(0);

    ios::sync_with_stdio(0);

    solve();

    return 0;

}

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

#include <cstdio>

#include <algorithm>

#include <vector>

#include <queue>

#include <set>

#include <map>

using namespace std;

#define int long long

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

const int mo = 1e9 + 7;

int d[3][3];

void solve()

{

    rep(i,3)rep(j,3)cin>>d[i][j];

    int a=d[0][2]-d[0][1],b=d[1][2]-d[1][1],c=d[2][2]-d[2][1];

    if(a!=b||b!=c){puts("No");return;}

    a=d[0][1]-d[0][0],b=d[1][1]-d[1][0],c=d[2][1]-d[2][0];

    if(a!=b||b!=c){puts("No");return;}

    a=d[2][2]-d[1][2],b=d[2][1]-d[1][1],c=d[2][0]-d[1][0];

    if(a!=b||b!=c){puts("No");return;}

    a=d[1][2]-d[0][2],b=d[1][1]-d[0][1],c=d[1][0]-d[0][0];

    if(a!=b||b!=c){puts("No");return;}

    puts("Yes");

}

main()

{

    cin.tie(0);

    ios::sync_with_stdio(0);

    solve();

    return 0;

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

#include <cstring>

#include <vector>

#include <map>

#include <string>

#include <algorithm>



 

using namespace std;



typedef long long ll;

typedef long double ld;

#define L(ID) ((ID*2)+1)

#define R(ID) ((ID*2)+2)

#define M(L,R) ((L+R)/2)

#define forr(start,end) for(int i = start; i < end; i++)

#define gap ' '

 

const int MAXN = 1e5 + 5;



ll largest(ll a, ll b){

	return (a<b)?b:a;

}

ll smallest(ll a, ll b){

	if(a < b)return a;

	return b;

}



int main(){

	int c[3][3];

	int a[3];

	int b[3];

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

		for(int j = 0; j < 3; ++j){

			cin >> c[i][j];

		}	

	}

	for(a[0] = 0; a[0] <= 100; a[0]++){

		for(a[1] = 0; a[1] <= 100; a[1]++){

			for(a[2] = 0; a[2] <= 100; a[2]++){

				b[0] = c[0][0] - a[0];

        		b[1] = c[0][1] - a[0];

        		b[2] = c[0][2] - a[0];

        		bool correct = true;

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

        			for(int j = 0; j < 3; ++j){

        				correct &= c[i][j] == a[i] + b[j];

         			}

        		}

        		if(correct){

        			cout << "Yes" << endl;

        			return 0;

        		}

			}

		}

	}

	cout << "No" << endl;



    return 0;

}


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

#include <cstring>

#include <vector>

#include <map>

#include <string>

#include <algorithm>



 

using namespace std;



typedef long long ll;

typedef long double ld;

#define L(ID) ((ID*2)+1)

#define R(ID) ((ID*2)+2)

#define M(L,R) ((L+R)/2)

#define forr(start,end) for(int i = start; i < end; i++)

#define gap ' '

 

const int MAXN = 1e5 + 5;



ll largest(ll a, ll b){

	return (a<b)?b:a;

}

ll smallest(ll a, ll b){

	if(a < b)return a;

	return b;

}



int main(){

	int c[3][3];

	int a[3];

	int b[3];

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

		for(int j = 0; j < 3; ++j){

			cin >> c[i][j];

		}	

	}

	for(a[0] = 0; a[0] <= 100; a[0]++){

		for(a[1] = 0; a[1] <= 100; a[1]++){

			for(a[2] = 0; a[2] <= 100; a[2]++){

				b[0] = c[0][0] - a[0];

        		b[1] = c[0][1] - a[0];

        		b[2] = c[0][2] - a[0];

        		bool correct = true;

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

        			for(int j = 0; j < 3; ++j){

        				if(c[i][j] != a[i] + b[j]){

        					correct = false;

        				}

         			}

        		}

        		if(correct){

        			cout << "Yes" << endl;

        			return 0;

        		}

			}

		}

	}

	cout << "No" << endl;



    return 0;

}