stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;



#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);

int main()

{



    FAST;

    stack<char>stck;



    string s;

    cin>>s;



    //string ans="";





    for(int i=0;i<s.size();i++){

        char ch;

        if(stck.empty()){

          ch=s[i];

        }else{

          ch=stck.top();

        }

        if(ch!=s[i]){

            stck.pop();

        }else{

           stck.push(s[i]);

        }



    }



    /*

    while(!stck.empty()){

        char c=stck.top();

        ans+=c;

        stck.pop();



    }*/





    //reverse(ans.begin(),ans.end());



    cout<<s.size()-stck.size()<<endl;







//     11111000000000





	return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<stack>

using namespace std;



char s[100005];

int main()

{

    int num=0;

    int i;

    stack<char>c;

    scanf("%s",s);

    int len=strlen(s);

    for(i=0;i<=len-1;i++)

    {

        if(c.empty()||c.top()==s[i])

            c.push(s[i]);

        else

        {

            c.pop();

            num+=2;

        }

    }

    printf("%d",num);

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<stdio.h>

#include<string.h>

#include<iostream>

using namespace std;

int main()

{

	char o[110], e[110];

	int i, j;

	int lo, le;

	scanf("%s", &o);

	scanf("%s", &e);

	lo = strlen(o);

	le = strlen(e);

	if(lo == le)

	{

		for(i = 0; i <= lo - 1; i++)

		{

			if(i != lo - 1)

			printf("%c%c", o[i], e[i]);

			else if(i == lo - 1)

				printf("%c%c\n", o[i], e[i]);

		}

	}

	else if(lo > le)

	{

		for(i = 0; i <= lo - 2; i++)

				printf("%c%c", o[i], e[i]);

				printf("%c\n", o[lo - 1]);

	}

		



}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int main(){

	char o[51],s[51];

	scanf("%s%s",o,s);

	int i,j,so=1,ss=1;

	while(o[so] != '\0'){so++;}

	while(s[ss] != '\0'){ss++;}

	if(so == ss){

		for(i = 0;i < so;i++){

			printf("%c",o[i]);

			printf("%c",s[i]);

		}

	}

	else if(so - ss == 1){

		for(j = 0;j < ss;j++){

			printf("%c",o[j]);

			printf("%c",s[j]);

		}

		printf("%c",o[so-1]);

	}

	printf("\n");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):


  #include <iostream> 

#include <cstdio> 

#include <cstring> 

using namespace std; 

int main()

{

 char a[50],b[50],c[100]; while(cin>>a>>b)

{

 int i,j; c[0]=a[0]; 

for(i=1,j=0;i<=100;i++)

{

 if(i%2!=0) {c[i]=b[j];j++;} 

else 

c[i]=a[j]; 

}

 cout<<c<<endl;

 } 

return 0; 

} 


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include<string.h>

int main()

{

    char a[50],b[50],c[100],m,k,i,s;

    scanf("%s",a);

    scanf("%s",b);

    k=strlen(a);

    m=strlen(b);

    s = k > m ? k : m;

    printf("%c%c",a[0],b[0]);

    for(i=1;i<=s;i++)

    {

        c[2*i-1]=a[i];

        c[2*i]=b[i];

    }

    if(k>m)

    {

        for(i=1;i<=2*(k-1)-1;i++)

           printf("%c",c[i]);

    }

    else

    {

        for(i=1;i<=2*(s-1);i++)

           printf("%c",c[i]);

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define inf 0x3f3f3f3f

#define ll long long

const int N=200005;

const int mod=1e9+7;

const double eps=1e-8;

const double PI = acos(-1.0);

#define lowbit(x) (x&(-x))

ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

ll qpow(ll a,ll b){ll res=1;while(b){if(b&1) res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

ll inv(ll a,ll p){return qpow(a,p-2);}

int main()

{

    std::ios::sync_with_stdio(false);

    string a,b;

    cin>>a>>b;

    int la=a.length(),lb=b.length();

    int i=0,j=0;

    while(i<la&&j<lb)

    {

        cout<<a[i++];

        cout<<b[j++];

    }

    while(i<la)

        cout<<a[i++];

    while(j<lb)

        cout<<b[j++];

    cout<<endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include<string.h>

int main()

{

    char a[50],b[50],c[100],m,k,i,s;

    scanf("%s",a);

    scanf("%s",b);

    k=strlen(a);

    m=strlen(b);

    s = k > m ? k : m;

    printf("%c%c",a[0],b[0]);

    for(i=1;i<=s;i++)

    {

        c[2*i-1]=a[i];

        c[2*i]=b[i];

    }

    if(k>m)

    {

        for(i=1;i<=2*(k-1)-1;i++)

           printf("%c",c[i]);

    }

    else

    {

        for(i=1;i<=2*(s-1);i++)

           printf("%c",c[i]);

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstring>

#include<cstdio>

#include<vector>

#include<queue>

#include<algorithm>

#include<list>

using namespace std;



const int maxn = 100000;

const int infly = (1<<29);



vector <int> G[maxn+5];

list <int> out;

bool c[maxn];

int N;

int indge[maxn];



void bfs(int s)

{

    queue <int> q;

    q.push(s);

    c[s] = true;



    while( !q.empty() )

    {

        int u = q.front();

        q.pop();

        out.push_back(u);



        for(int i = 0 ; i < G[u].size() ; i++)

        {

            int v = G[u][i];

            indge[v]--;

            if(indge[v] == 0 && !c[v])

            {

                c[v] = true;

                q.push(v);

            }

        }

    }

}



void tsort()

{

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

    {

        indge[i] = 0;

    }



    for(int u = 0; u < N ; u++)

    {

        for(int i = 0 ;i < G[u].size(); i++)

        {

            int v = G[u][i];

            indge[v]++;

        }

    }



    for(int u = 0; u < N ;u++)

    {

        if( indge[u] == 0 && !c[u])

        {

            bfs(u);

        }

    }



    for(list<int> ::iterator it = out.begin(); it != out.end() ;it++)

    {

        cout << *it << endl;

    }

}



int main()

{

    int s, t, M;



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



    for(int i = 0; i < N; i++) c[i] = false;



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

    {

        scanf("%d%d",&s,&t);

        G[s].push_back(t);

    }



    tsort();



    return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <queue>

using namespace std;



vector<vector<int>> adj;

vector<int> visited;

vector<int> ans;

vector<int> deg;

int v;



void topologicalOrder() {

  queue<int> q;

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

    if (deg[i] == 0) q.push(i);

  }

  while (!q.empty()) {

    int x = q.front();

    q.pop();

    ans.push_back(x);

    for (auto y : adj[x]) {

      if (visited[y] == 0) {

        deg[y]--;

        if (deg[y] == 0) {

          visited[y] = 1;

          q.push(y);

        }

      }

    }

  }

}



int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(0);

  

  int e;

  cin >> v >> e;

  adj.resize(v);

  visited.resize(v);

  deg.resize(v);

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

    int a, b;

    cin >> a >> b;

    adj[a].push_back(b);

    deg[b]++;

  }

  topologicalOrder();

  for (auto i : ans) {

    cout << i << endl;

  }

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<vector>

#include<algorithm>

#include<queue>

using namespace std;

const int maxn = 10001;



vector<int> G[maxn], ans;

int indegree[maxn], vis[maxn];

int n, e;

void BFS(int s)

{

    queue<int> Q;

    Q.push(s);

    vis[s] = 1;

    while(!Q.empty())

    {

        int top = Q.front();

        ans.push_back(top);

        vis[top] = 1;

        Q.pop();

        for(int i = 0; i < G[top].size(); i++)

        {

            indegree[G[top][i]]--;

            if(indegree[G[top][i]] == 0 && vis[G[top][i]] == 0)

            {

                Q.push(G[top][i]);

            }

        }

    }

}



void topologicalSort()

{

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

        if(indegree[u] == 0 && vis[u] == 0)

            BFS(u);

}



int main()

{

    cin >> n >> e;

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

    {

        vis[i] = 0;

        indegree[i] = 0;

    }

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

    {

        int x, y;

        cin >> x >>y;

        G[x].push_back(y);

        indegree[y]++;

    }

    topologicalSort();

    for(int i = 0; i < ans.size(); i++)

        cout << ans[i] <<endl;

    return 0;

}




// Optimized solution to the same problem (faster):
#include <iostream>

#include <queue>

using namespace std;



vector<vector<int>> adj;

vector<int> visited;

vector<int> ans;

vector<int> deg;

int v;



void topologicalOrder() {

  queue<int> q;

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

    if (deg[i] == 0) q.push(i);

  }

  while (!q.empty()) {

    int x = q.front();

    q.pop();

    ans.push_back(x);

    for (auto y : adj[x]) {

      if (visited[y] == 0) {

        deg[y]--;

        if (deg[y] == 0) {

          visited[y] = 1;

          q.push(y);

        }

      }

    }

  }

}



int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(0);

  

  int e;

  cin >> v >> e;

  adj.resize(v);

  visited.resize(v);

  deg.resize(v);

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

    int a, b;

    cin >> a >> b;

    adj[a].push_back(b);

    deg[b]++;

  }

  topologicalOrder();

  for (auto i : ans) {

    cout << i << endl;

  }

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <queue>

#include <vector>

#include <cstdio>

#include <algorithm>



int v,e,in[10005];

std::queue<int> q;

std::vector<int> g[10005];



int main()

{

    scanf("%d%d",&v,&e);

    while(e--)

    {

        int x,y;

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

        g[x].push_back(y);

        in[y]++;

    }

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

        if(!in[i])

            q.push(i);

    while(!q.empty())

    {

        int now=q.front();

        q.pop();

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

        for(std::vector<int>::iterator it=g[now].begin();it!=g[now].end();it++)

            if(!--in[*it])

                q.push(*it);

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include <iostream>

#include <queue>

using namespace std;



vector<vector<int>> adj;

vector<int> visited;

vector<int> ans;

vector<int> deg;

int v;



void topologicalOrder() {

  queue<int> q;

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

    if (deg[i] == 0) q.push(i);

  }

  while (!q.empty()) {

    int x = q.front();

    q.pop();

    ans.push_back(x);

    for (auto y : adj[x]) {

      if (visited[y] == 0) {

        deg[y]--;

        if (deg[y] == 0) {

          visited[y] = 1;

          q.push(y);

        }

      }

    }

  }

}



int main() {

  ios_base::sync_with_stdio(false);

  cin.tie(0);

  

  int e;

  cin >> v >> e;

  adj.resize(v);

  visited.resize(v);

  deg.resize(v);

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

    int a, b;

    cin >> a >> b;

    adj[a].push_back(b);

    deg[b]++;

  }

  topologicalOrder();

  for (auto i : ans) {

    cout << i << endl;

  }

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <algorithm>

#include <iostream>

#include <string>

#include <vector>

#include <queue>



using namespace std;



const int MAX=10000;



typedef long long ll;



int V, E;

vector<int> adj[MAX];

vector<int> ans;

int indeg[MAX], color[MAX];



void bfs(int s){

  queue<int> Q;

  Q.push(s);

  color[s]=1;

  while(Q.empty()==false){

    int u=Q.front(); Q.pop();

    ans.push_back(u);

    for(int i=0;i<adj[u].size();i++){

      int v=adj[u][i];

      indeg[v]--;

      if(indeg[v]==0 && color[v]==0){

        color[v]=1;

        Q.push(v);

      }

    }

  }

}



int main(){

  cin >> V >> E;

  //initialize

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

    indeg[i]=0;

    color[i]=0;

  }

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

    int s, t; cin >> s >> t;

    adj[s].push_back(t);

    indeg[t]++;

  }

  //topological sort

  for(int u=0;u<V;u++){

    if(indeg[u]==0 && color[u]==0) bfs(u);

  }

  for(int i=0;i<ans.size();i++) cout << ans[i] << endl;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



using namespace std;



using ll = long long;



// O(|V|+|E|)

class Graph{

    public:

    ll size;

    vector<vector<ll> > g;

    vector<bool> visited;

    vector<ll> indeg;



    // sorted by topological sort

    vector<ll> sorted;



    Graph(ll n){

        size = n;

        g = vector<vector<ll> >(size);

        visited = vector<bool>(size);

        indeg = vector<ll>(size);

    }



    void add_edge(ll x, ll y){

        g[x].push_back(y);  // x -> y

        indeg[y]++;

    }



    void bfs(ll s){

        queue<ll> Q; // v, dist

        visited[s] = true;

        Q.push(s);

        while(!Q.empty()){

            ll u = Q.front(); Q.pop();

            sorted.push_back(u);

            for(ll v: g[u]){

                indeg[v]--;

                if(indeg[v] == 0 && !visited[v]){

                    visited[v] = true;

                    Q.push(v);

                }

            }

        }

    }



    // O(|E|log|V|)

    vector<ll> topological_sort(){

        for(ll s=0;s<size;s++){

            if(indeg[s] == 0 && !visited[s]) bfs(s);

        }

        return sorted;

    }

};



// GRL_4_B: verified

int main(){

    ll V, E; cin >> V >> E;

    Graph graph(V); 

    for(ll i=0;i<E;i++){

        ll s, t; cin >> s >> t;

        graph.add_edge(s, t);

    }

    vector<ll> sorted = graph.topological_sort();

    for(ll v: sorted) cout << v << endl;

}




// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



long long INF = 1LL<<60;



long long P[110][11];



int main() {



  int N;

  cin >> N;



  vector<set<int>> F(10);

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

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

      int f;

      cin >> f;

      if (f == 1) {

        F[j].insert(i);

      }

    }

  }



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

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

      cin >> P[i][j];

    }

  }



  long long answer = 0 - INF;



  for(int bits = 1; bits < (1 << 10); bits++) {



    long long answer_ = 0;

    

    vector<int> count(N);



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

      if (bits >> i & 1) {

        set<int> stores = F[i];

        for (auto item:stores) {

          count[item]++;

        }

      }

    }



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

      answer_ += P[i][count[i]];

    }



    answer = max(answer, answer_);

    

  }



  cout << answer << endl;



  return 0;



}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



long long INF = 1LL<<60;



int F[110][11];

long long P[110][11];



int main() {



  int N;

  cin >> N;



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

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

      cin >> F[i][j];

    }

  }



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

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

      cin >> P[i][j];

    }

  }



  long long answer = 0 - INF;



  for(int bits = 1; bits < (1 << 10); bits++) {



    long long answer_ = 0;



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

      int count_ = 0;

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

        if (bits >> j & 1) {

          if (F[i][j] == 1) {

            count_++;

          }

        }

      }

      answer_ += P[i][count_];

    }



    answer = max(answer, answer_);

    

  }



  cout << answer << endl;



  return 0;



}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <sstream>

#include <string>

#include <bitset>

using namespace std;

int main(){

  int n;

  cin>>n;

  int f[n][10];int p[n][11];

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

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

      cin >> f[i][j];

    }

  }

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

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

      cin >> p[i][j];

    }

  }

  string s;int ans=-1000000000;int sum=0;int c[n];

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

    for(int l=0;l<n;l++) c[l]=0;

    stringstream jo;

    jo<< static_cast<std::bitset<10>>(i);

    s=jo.str();

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

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

        if(s[k]=='1'&&f[j][k]==1) c[j]++;

      }

    }

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

      sum+=p[i][c[i]];

    }

    ans=max(sum,ans);sum=0;

  }

  cout << ans <<endl;

}


// Optimized solution to the same problem (faster):
#include <iostream>

#include <algorithm>

using namespace std;

int main(){

  int n;

  cin>>n;

  int f[n][10];int p[n][11];

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

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

      cin >> f[i][j];

    }

  }

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

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

      cin >> p[i][j];

    }

  }

  int sum=0;int c[n];int ans=-1000000000;

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

    for(int l=0;l<n;l++) c[l]=0;

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

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

        if((((1<<k)&i)!=0)&&f[j][k]==1) c[j]++;

      }

    }

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

      sum+=p[i][c[i]];

    }

    ans=max(sum,ans);sum=0;

  }

  cout << ans <<endl;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

using namespace std;



typedef long long ll;

typedef pair<int,int> ii;

typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;



int main() {

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

	int N; cin>>N;

	vector<vector<int>> F(N,vector<int>(10,0));

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

		for (int j=0; j<10; j++)

			cin>>F[i][j];

	vector<vector<int>> P(N,vector<int>(11,0));

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

		for (int j=0; j<11; j++)

			cin>>P[i][j];

	int ans=INT_MIN;

	for (int bt=1; bt<(1<<10); bt++) {

		vector<int> ct(N,0);

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

			if(bt&(1<<i))

				for (int j=0; j<N; j++)

					ct[j]+=F[j][i];

		int ret=0;

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

			ret+=P[i][ct[i]];

		ans=max(ans,ret);

	}

	cout<<ans<<"\n";

	return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



#include <fstream>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>



typedef long long ll;

typedef long double ld;

using namespace std;

#define endl "\n"

#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace __gnu_pbds;

const int N=100+5, mxN=(1<<22);

int mod=1e9+7;

int n;

ll ans=-1e18;

int arr[N][11],cost[N][12];

void brutefor(int i, int mask)

{

    if(i==10)

    {

        if(mask==0)

            return;

  ll localans=0;

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

    {



        int co=0;

        for(int j=0;j<10;j++)

        {

            if(arr[x][j]==1&&((mask>>j)&1)==1)

            {

                co++;

            }



        }

        localans+=cost[x][co];



    }

    ans=max(ans,localans);







    }

    else

    {

        brutefor(i+1,mask);

        mask=(mask|(1<<i));

        brutefor(i+1,mask);







    }





}



int main()

{

    FIO

    cin>>n;

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

    {

        for(int j=0;j<10;j++)

        {

            cin>>arr[i][j];

        }



    }



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

    {

        for(int j=0;j<=10;j++)

        {

            cin>>cost[i][j];

        }



    }

     brutefor(0,0);

     cout<<ans;





    return 0;



}








// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<string>

using namespace std;



int n = 10;

int S[10];

int idx = 0;

int bit_array[1024][10];



int F[100][10];

int P[100][11];



void rec(int i) {

    if (i == n) {

        for (int j = 0; j < n; j++) bit_array[idx][j] = S[j];

        idx++;

        return;

    }



    rec(i + 1);

    S[i] = 1;

    rec(i + 1);

    S[i] = 0;



    return;

}



void makeCombination() {

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

        S[i] = 0;

    }

    rec(0);

    return;

}



int main() {

    makeCombination();



    int N, profit, open_num, max_prof = -1000000000;

    cin >> N;



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

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

            cin >> F[i][j];

        }

    }



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

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

            cin >> P[i][j];

        }

    }



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

        profit = 0;

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

            open_num = 0;

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

                if (bit_array[i][k] == 1 && F[j][k] == 1) open_num++;

            }

            profit += P[j][open_num];

        }

        max_prof = max(max_prof, profit);

    }



    cout << max_prof << endl;



    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int N ;

int F [100][14];

int P [100][15];

int main ()

{

scanf ("%d " ,& N );

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

{

for ( int j =0; j <10; j ++) scanf ("%d " ,& F [ i ][ j ]);

}

for ( int i =0; i < N ; i ++) for ( int j =0; j <11; j ++) scanf ("%d " ,& P [ i ][ j ]);

int res = -(1 << 30);

for ( int b =1; b <(1 << 10); b ++)

{

int cc =0;

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

{

int c =0;

for ( int j =0; j <10; j ++) if (( b >> j & 1)&& F [ i ][ j ]) c ++;

cc += P [ i ][ c ];

}

if ( res < cc ) res = cc ;

}

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

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<vector>

#include<algorithm>

#include<queue>

#include<map>

#include<stack>

#include<cmath>

#include<iomanip>

#include<set>

#include<numeric>

#include<sstream>

#include<random>

#include<cassert>

using namespace std;

typedef long long ll;

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

#define rrep(i, st, n) for (int i = st; i < n; ++i)

using pii = pair<int, int>;

const int inf = 1e9 + 7;

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

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

#define ceil(a, b) a / b + !!(a % b)



int ans = -inf;

int a[20];

int f[105][10];

int p[105][11];

int n;

void func() {

    

    rep(i, 20) {

        if (a[i] != 0) break;

        if (i == 19) return;

    }

    

    int score = 0;

    //rep(i, 10) cout << a[i] << " "; cout << endl;

    rep(i, 105) {

        int tmp = 0;

        rep(j, 10) if (a[j] == 1 && f[i][j] == 1) tmp++;

        score += p[i][tmp];

    }

    ans = max(ans, score);

}

void dfs(int pos) {

    if (pos == 10) {

        func();

        return;

    }

    a[pos] = 0; dfs(pos + 1);

    a[pos] = 1; dfs(pos + 1);

}

int main() {

    cin >> n;

    rep(i, n) rep(j, 10) cin >> f[i][j];

    rep(i, n) rep(j, 11) cin >> p[i][j];

    dfs(0);

    cout << ans << endl;

    

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define F first

#define S second

#define pii pair<int, int>

#define eb emplace_back

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

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

#define rep3(i, l, n) for (int i = l; i < n; ++i)

#define chmax(a, b) a = (a >= b ? a : b)

#define chmin(a, b) a = (a <= b ? a : b)

#define out(a) cout << a << endl

#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl

#define SZ(v) (int)v.size()

#define inf (int)(1e9+7)

#define abs(x) (x >= 0 ? x : -(x))



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    // 計算量の見積もり間違ってた

    int n;

    cin >> n;

    int f[n][10];

    int p[n][11];

    rep(i, n) rep(j, 10) cin >> f[i][j];

    rep(i, n) rep(j, 11) cin >> p[i][j];

    int ans = -inf;

    rep(i, (1 << 10)) {

        if (i == 0) continue;

        int c[n]; fill_n(c, n, 0); // いくつ営業するか

        rep(j, 10) {

            if (i & (1 << j)) { // 営業する時間帯

                rep(k, n) {

                    if (f[k][j]) {

                        c[k]++;

                    }

                }

            }

        }

        int sum = 0;

        rep(j, n) {

            sum += p[j][c[j]];

        }

        // out(sum);

        chmax(ans, sum);

    }

    out(ans);

}




// Fastest known solution for this problem: