Language: C++





#include<iostream>
#include<vector>
#include<map>
#include<sstream>
#include<algorithm>
using namespace std;




typedef pair<int,string> P;
bool compare(P a, P b){
&#160; if(a.first==b.first)return a.second<b.second;
&#160; return a.first>b.first;
}




int main()
{
&#160; int n;
&#160; string line;
&#160; char k;
&#160; while(cin>>n,n){
&#160; &#160; map<string,int>word;
&#160; &#160; vector<P>ans;
&#160; &#160; for(int i=0;i<n;i++){
&#160; &#160; &#160; cin.ignore();
&#160; &#160; &#160; getline(cin,line);
&#160; &#160; &#160; stringstream ss(line);
&#160; &#160; &#160; string w;
&#160; &#160; &#160; while(ss>>w)word[w]++;;
&#160; &#160; }
&#160; &#160; cin>>k;
&#160; &#160; for(map<string,int>::iterator it=word.begin();it!=word.end();it++)if(it->first[0]==k)ans.push_back(P(it->second,it->first));
&#160; &#160; sort(ans.begin(),ans.end(),compare);
&#160; &#160; int cnt=0;
&#160; &#160; for(int i=0;i<ans.size();i++){
&#160; &#160; &#160; if(i)cout<<" ";
&#160; &#160; &#160; cout<<ans[i].second;
&#160; &#160; &#160; cnt++;
&#160; &#160; }
&#160; &#160; if(!cnt)cout<<"NA";
&#160; &#160; cout<<endl;
&#160; }
}

Compiler output:
a.cc:17:2: error: stray '#' in program
   17 | &#160; if(a.first==b.first)return a.second<b.second;
      |  ^
a.cc:18:2: error: stray '#' in program
   18 | &#160; return a.first>b.first;
      |  ^
a.cc:26:2: error: stray '#' in program
   26 | &#160; int n;
      |  ^
a.cc:27:2: error: stray '#' in program
   27 | &#160; string line;
      |  ^
a.cc:28:2: error: stray '#' in program
   28 | &#160; char k;
      |  ^
a.cc:29:2: error: stray '#' in program
   29 | &#160; while(cin>>n,n){
      |  ^
a.cc:30:2: error: stray '#' in program
   30 | &#160; &#160; map<string,int>word;
      |  ^
a.cc:30:9: error: stray '#' in program
   30 | &#160; &#160; map<string,int>word;
      |         ^
a.cc:31:2: error: stray '#' in program
   31 | &#160; &#160; vector<P>ans;
      |  ^
a.cc:31:9: error: stray '#' in program
   31 | &#160; &#160; vector<P>ans;
      |         ^
a.cc:32:2: error: stray '#' in program
   32 | &#160; &#160; for(int i=0;i<n;i++){
      |  ^
a.cc:32:9: error: stray '#' in program
   32 | &#160; &#160; for(int i=0;i<n;i++){
      |         ^
a.cc:33:2: error: stray '#' in program
   33 | &#160; &#160; &#160; cin.ignore();
      |  ^
a.cc:33:9: error: stray '#' in program
   33 | &#160; &#160; &#160; cin.ignore();
      |         ^
a.cc:33:16: error: stray '#' in program
   33 | &#160; &#160; &#160; cin.ignore();
      |                ^
a.cc:34:2: error: stray '#' in program
   34 | &#160; &#160; &#160; getline(cin,line);
      |  ^
a.cc:34:9: error: stray '#' in program
   34 | &#160; &#160; &#160; getline(cin,line);
      |         ^
a.cc:34:16: error: stray '#' in program
   34 | &#160; &#160; &#160; getline(cin,line);
      |                ^
a.cc:35:2: error: stray '#' in program
   35 | &#160; &#160; &#160; stringstream ss(line);
      |  ^
a.cc:35:9: error: stray '#' in program
   35 | &#160; &#160; &#160; stringstream ss(line);
      |         ^
a.cc:35:16: error: stray '#' in program
   35 | &#160; &#160; &#160; stringstream ss(line);
      |                ^
a.cc:36:2: error: stray '#' in program
   36 | &#160; &#160; &#160; string w;
      |  ^
a.cc:36:9: error: stray '#' in program
   36 | &#160; &#160; &#160; string w;
      |         ^
a.cc:36:16: error: stray '#' in program
   36 | &#160; &#160; &#160; string w;
      |                ^
a.cc:37:2: error: stray '#' in program
   37 | &#160; &#160; &#160; while(ss>>w)word[w]++;;
      |  ^
a.cc:37:9: error: stray '#' in program
   37 | &#160; &#160; &#160; while(ss>>w)word[w]++;;
      |         ^
a.cc:37:16: error: stray '#' in program
   37 | &#160; &#160; &#160; while(ss>>w)word[w]++;;
      |                ^
a.cc:38:2: error: stray '#' in program
   38 | &#160; &#160; }
      |  ^
a.cc:38:9: error: stray '#' in program
   38 | &#160; &#160; }
      |         ^
a.cc:39:2: error: stray '#' in program
   39 | &#160; &#160; cin>>k;
      |  ^
a.cc:39:9: error: stray '#' in program
   39 | &#160; &#160; cin>>k;
      |         ^
a.cc:40:2: error: stray '#' in program
   40 | &#160; &#160; for(map<string,int>::iterator it=word.begin();it!=word.end();it++)if(it->first[0]==k)ans.push_back(P(it->second,it->first));
      |  ^
a.cc:40:9: error: stray '#' in program
   40 | &#160; &#160; for(map<string,int>::iterator it=word.begin();it!=word.end();it++)if(it->first[0]==k)ans.push_back(P(it->second,it->first));
      |         ^
a.cc:41:2: error: stray '#' in program
   41 | &#160; &#160; sort(ans.begin(),ans.end(),compare);
      |  ^
a.cc:41:9: error: stray '#' in program
   41 | &#160; &#160; sort(ans.begin(),ans.end(),compare);
      |         ^
a.cc:42:2: error: stray '#' in program
   42 | &#160; &#160; int cnt=0;
      |  ^
a.cc:42:9: error: stray '#' in program
   42 | &#160; &#160; int cnt=0;
      |         ^
a.cc:43:2: error: stray '#' in program
   43 | &#160; &#160; for(int i=0;i<ans.size();i++){
      |  ^
a.cc:43:9: error: stray '#' in program
   43 | &#160; &#160; for(int i=0;i<ans.size();i++){
      |         ^
a.cc:44:2: error: stray '#' in program
   44 | &#160; &#160; &#160; if(i)cout<<" ";
      |  ^
a.cc:44:9: error: stray '#' in program
   44 | &#160; &#160; &#160; if(i)cout<<" ";
      |         ^
a.cc:44:16: error: stray '#' in program
   44 | &#160; &#160; &#160; if(i)cout<<" ";
      |                ^
a.cc:45:2: error: stray '#' in program
   45 | &#160; &#160; &#160; cout<<ans[i].second;
      |  ^
a.cc:45:9: error: stray '#' in program
   45 | &#160; &#160; &#160; cout<<ans[i].second;
      |         ^
a.cc:45:16: error: stray '#' in program
   45 | &#160; &#160; &#160; cout<<ans[i].second;
      |                ^
a.cc:46:2: error: stray '#' in program
   46 | &#160; &#160; &#160; cnt++;
      |  ^
a.cc:46:9: error: stray '#' in program
   46 | &#160; &#160; &#160; cnt++;
      |         ^
a.cc:46:16: error: stray '#' in program
   46 | &#160; &#160; &#160; cnt++;
      |                ^
a.cc:47:2: error: stray '#' in program
   47 | &#160; &#160; }
      |  ^
a.cc:47:9: error: stray '#' in program
   47 | &#160; &#160; }
      |         ^
a.cc:48:2: error: stray '#' in program
   48 | &#160; &#160; if(!cnt)cout<<"NA";
      |  ^
a.cc:48:9: error: stray '#' in program
   48 | &#160; &#160; if(!cnt)cout<<"NA";
      |         ^
a.cc:49:2: error: stray '#' in program
   49 | &#160; &#160; cout<<endl;
      |  ^
a.cc:49:9: error: stray '#' in program
   49 | &#160; &#160; cout<<endl;
      |         ^
a.cc:50:2: error: stray '#' in program
   50 | &#160; }
      |  ^
a.cc: In function 'bool compare(P, P)':
a.cc:17:3: error: lvalue required as unary '&' operand
   17 | &#160; if(a.first==b.first)return a.second<b.second;
      |   ^~~
a.cc:18:3: error: lvalue required as unary '&' operand
   18 | &#160; return a.first>b.first;
      |   ^~~
a.cc: In function 'int main()':
a.cc:26:3: error: lvalue required as unary '&' operand
   26 | &#160; int n;
      |   ^~~
a.cc:27:3: error: lvalue required as unary '&' operand
   27 | &#160; string line;
      |   ^~~
a.cc:28:3: error: lvalue required as unary '&' operand
   28 | &#160; char k;
      |   ^~~
a.cc:29:3: error: lvalue required as unary '&' operand
   29 | &#160; while(cin>>n,n){
      |   ^~~
a.cc:30:3: error: lvalue required as unary '&' operand
   30 | &#160; &#160; map<string,int>word;
      |   ^~~
a.cc:30:10: error: lvalue required as unary '&' operand
   30 | &#160; &#160; map<string,int>word;
      |          ^~~
a.cc:31:3: error: lvalue required as unary '&' operand
   31 | &#160; &#160; vector<P>ans;
      |   ^~~
a.cc:31:10: error: lvalue required as unary '&' operand
   31 | &#160; &#160; vector<P>ans;
      |          ^~~
a.cc:32:3: error: lvalue required as unary '&' operand
   32 | &#160; &#160; for(int i=0;i<n;i++){
      |   ^~~
a.cc:32:10: error: lvalue required as unary '&' operand
   32 | &#160; &#160; for(int i=0;i<n;i++){
      |          ^~~
a.cc:33:3: error: lvalue required as unary '&' operand
   33 | &#160; &#160; &#160; cin.ignore();
      |   ^~~
a.cc:33:10: error: lvalue required as unary '&' operand
   33 | &#160; &#160; &#160; cin.ignore();
      |          ^~~
a.cc:33:17: error: lvalue required as unary '&' operand
   33 | &#160; &#160; &#160; cin.ignore();
      |                 ^~~
a.cc:34:3: error: lvalue required as unary '&' operand
   34 | &#160; &#160; &#160; getline(cin,line);
      |   ^~~
a.cc:34:10: error: lvalue required as unary '&' operand
   34 | &#160; &#160; &#160; getline(cin,line);
      |          ^~~
a.cc:34:17: error: lvalue required as unary '&' operand
   34 | &#160; &#160; &#160; getline(cin,line);
      |                 ^~~
a.cc:35:3: error: lvalue required as unary '&' operand
   35 | &#160; &#160; &#160; stringstream ss(line);
      |   ^~~
a.cc:35:10: error: lvalue required as unary '&' operand
   35 | &#160; &#160; &#160; stringstream ss(line);
      |          ^~~
a.cc:35:17: error: lvalue required as unary '&' operand
   35 | &#160; &#160; &#160; stringstream ss(line);
      |                 ^~~
a.cc:36:3: error: lvalue required as unary '&' operand
   36 | &#160; &#160; &#160; string w;
      |   ^~~
a.cc:36:10: error: lvalue required as unary '&' operand
   36 | &#160; &#160; &#160; string w;
      |          ^~~
a.cc:36:17: error: lvalue required as unary '&' operand
   36 | &#160; &#160; &#160; string w;
      |                 ^~~
a.cc:37:3: error: lvalue required as unary '&' operand
   37 | &#160; &#160; &#160; while(ss>>w)word[w]++;;
      |   ^~~
a.cc:37:10: error: lvalue required as unary '&' operand
   37 | &#160; &#160; &#160; while(ss>>w)word[w]++;;
      |          ^~~
a.cc:37:17: error: lvalue required as unary '&' operand
   37 | &#160; &#160; &#160; while(ss>>w)word[w]++;;
      |                 ^~~
a.cc:38:3: error: lvalue required as unary '&' operand
   38 | &#160; &#160; }
      |   ^~~
a.cc:38:10: error: lvalue required as unary '&' operand
   38 | &#160; &#160; }
      |          ^~~
a.cc:39:3: error: lvalue required as unary '&' operand
   39 | &#160; &#160; cin>>k;
      |   ^~~
a.cc:39:10: error: lvalue required as unary '&' operand
   39 | &#160; &#160; cin>>k;
      |          ^~~
a.cc:40:3: error: lvalue required as unary '&' operand
   40 | &#160; &#160; for(map<string,int>::iterator it=word.begin();it!=word.end();it++)if(it->first[0]==k)ans.push_back(P(it->second,it->first));
      |   ^~~
a.cc:40:10: error: lvalue required as unary '&' operand
   40 | &#160; &#160; for(map<string,int>::iterator it=word.begin();it!=word.end();it++)if(it->first[0]==k)ans.push_back(P(it->second,it->first));
      |          ^~~
a.cc:41:3: error: lvalue required as unary '&' operand
   41 | &#160; &#160; sort(ans.begin(),ans.end(),compare);
      |   ^~~
a.cc:41:10: error: lvalue required as unary '&' operand
   41 | &#160; &#160; sort(ans.begin(),ans.end(),compare);
      |          ^~~
a.cc:42:3: error: lvalue required as unary '&' operand
   42 | &#160; &#160; int cnt=0;
      |   ^~~
a.cc:42:10: error: lvalue required as unary '&' operand
   42 | &#160; &#160; int cnt=0;
      |          ^~~
a.cc:43:3: error: lvalue required as unary '&' operand
   43 | &#160; &#160; for(int i=0;i<ans.size();i++){
      |   ^~~
a.cc:43:10: error: lvalue required as unary '&' operand
   43 | &#160; &#160; for(int i=0;i<ans.size();i+