stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <string>

#include <stack>

#include <exception>



using namespace std;



int main(){

    string S; cin >> S;

    stack<char> ST;



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

        try {

            if (ST.empty()) throw "empty stack!";

            if (ST.top() != S[i]) ST.pop();

            else                  ST.push(S[i]);

        } catch (const char *error) {

            ST.push(S[i]);

        }

    }



    cout << S.size()-ST.size() << endl;

    return 0;

}


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

}
// Slower C++ solution:
#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;

}


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

}
// Slower C++ solution:
#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]);

	}

		



}

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

}
// Slower C++ solution:


  #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; 

} 


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

}
// Slower C++ solution:
#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;

}


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

}
// Slower C++ solution:
#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;

}

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

}
// Slower C++ solution:
#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;

}

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

}
// Slower C++ solution:
#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;

}

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

}
// Slower C++ solution:
#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;

}




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

}
// Slower C++ solution:
#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;

}


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

}
// Slower C++ solution:
#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;

}

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

}
// Slower C++ solution:
#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;



}

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



}
// Slower C++ solution:
#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;

}


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

}