Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define f first
#define s second

typedef pair<int, int> P;
typedef pair<P, P> P2;
typedef pair<P2, string> P3;

int main(){
  int n;
  int W, H;
  
  while(cin >> n, n){
    cin >> W >> H;
    
    map<string, vector<P3> > page;
    vector<P3> link;
    string page_name;
    string now;
    int n_button, x1, x2, y1, y2;
    
    for(int i = 0 ; i < n ; i++){
      cin >> page_name >> n_button;
      if(i == 0) now = page_name;
      for(int j = 0 ; j < n_button ; j++){
	P3 tmp;
	cin >> tmp.f.f.f >> tmp.f.f.s >> tmp.f.s.f >> tmp.f.s.s >> tmp.s;
	link.push_back(tmp);
      }
      page.insert(make_pair(page_name, link));
    }
    
    int n_op, x, y;
    string op;
    vector<string> history;
    history.push_back(now);
    int n_now = 0;
    cin >> n_op;
    cin.ignore();
    while(n_op--){
      getline(cin, op);
      
      if(op[0] == 'c'){ // click
	string tmp1="", tmp2="";
	int i;
	for(i = 6 ; op[i] != ' ' ; i++) tmp1 += op[i];
	for( ; i < op.size() ; i++) tmp2 += op[i];
	
	x = atoi(tmp1.c_str());
	y = atoi(tmp2.c_str());
	
	for(i = 0 ; i < page[now].size() ; i++){
	  if((page[now][i].f.f.f <= x && x <= page[now][i].f.s.f) &&
	     (page[now][i].f.f.s <= y && y <= page[now][i].f.s.s)){
	    now = page[now][i].s;
	    history.push_back(now);
	    n_now++;
	  }
	}
      } // click end
    
      if(op == "show") cout << history[n_now] << endl;
      if(op == "back") n_now--;
      if(op == "forward") n_now++;
    }
  }
  return 0;
}
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define f first
#define s second

typedef pair<int, int> P;
typedef pair<P, P> P2;
typedef pair<P2, string> P3;

int main(){
  int n;
  int W, H;
  
  while(cin >> n, n){
    cin >> W >> H;
    
    map<string, vector<P3> > page;
    vector<P3> link;
    string page_name;
    string now;
    int n_button, x1, x2, y1, y2;
    
    for(int i = 0 ; i < n ; i++){
      cin >> page_name >> n_button;
      if(i == 0) now = page_name;
      for(int j = 0 ; j < n_button ; j++){
	P3 tmp;
	cin >> tmp.f.f.f >> tmp.f.f.s >> tmp.f.s.f >> tmp.f.s.s >> tmp.s;
	link.push_back(tmp);
      }
      page.insert(make_pair(page_name, link));
    }
    
    int n_op, x, y;
    string op;
    vector<string> history;
    history.push_back(now);
    int n_now = 0;
    cin >> n_op;
    cin.ignore();
    while(n_op--){
      getline(cin, op);
      
      if(op[0] == 'c'){ // click
	string tmp1="", tmp2="";
	int i;
	for(i = 6 ; op[i] != ' ' ; i++) tmp1 += op[i];
	for( ; i < op.size() ; i++) tmp2 += op[i];
	
	x = atoi(tmp1.c_str());
	y = atoi(tmp2.c_str());
	
	for(i = 0 ; i < page[now].size() ; i++){
	  if((page[now][i].f.f.f <= x && x <= page[now][i].f.s.f) &&
	     (page[now][i].f.f.s <= y && y <= page[now][i].f.s.s)){
	    now = page[now][i].s;
	    history.push_back(now);
	    n_now++;
	  }
	}
      } // click end
    
      if(op == "show") cout << history[n_now] << endl;
      if(op == "back") n_now--;
      if(op == "forward") n_now++;
    }
  }
  return 0;
}

Compiler output:
a.cc:95:5: error: redefinition of 'int main()'
   95 | int main(){
      |     ^~~~
a.cc:18:5: note: 'int main()' previously defined here
   18 | int main(){
      |     ^~~~