func_code_string: #include <bits/stdc++.h>   using namespace std;   enum Type { Normal, HBox, VBox };   struct Widget {     char name[11];     long long width, height;     int border, spacing;     vector<int> sons;     Type type;   };   int wCnt;   Widget widgets[101];   map<string, int> name2id;   int str2int(char* start, char* end) {     int res = 0;     for (char* p = start; p != end; ++p) {       res = res * 10 + (*p -  0 );     }     return res;   }   void addWidget(char name[11], int width, int height, Type type) {     strcpy(widgets[wCnt].name, name);     widgets[wCnt].width = width;     widgets[wCnt].height = height;     widgets[wCnt].border = 0;     widgets[wCnt].spacing = 0;     widgets[wCnt].type = type;     name2id[name] = wCnt;     wCnt++;   }   bool isWidget(char buf[50]) {     if (strncmp(buf,  Widget , 6) == 0) {       char name[11];       int width, height;       int p1, p2, p3;       for (int i = 7; buf[i] !=   0 ; ++i) {         if (buf[i] ==  ( ) {           p1 = i;         } else if (buf[i] ==  , ) {           p2 = i;         } else if (buf[i] ==  ) ) {           p3 = i;         }       }       strncpy(name, buf + 7, p1 - 7);       name[p1 - 7] =   0 ;       width = str2int(buf + p1 + 1, buf + p2);       height = str2int(buf + p2 + 1, buf + p3);       addWidget(name, width, height, Normal);       return true;     } else {       return false;     }   }   bool isBox(char buf[50]) {     char name[11];     if (strncmp(buf,  HBox , 4) == 0) {       strcpy(name, buf + 5);       addWidget(name, 0, 0, HBox);       return true;     } else if (strncmp(buf,  VBox , 4) == 0) {       strcpy(name, buf + 5);       addWidget(name, 0, 0, VBox);       return true;     } else {       return false;     }   }   void operate(char buf[50]) {     char name[11];     int p1, p2, p3;     for (int i = 0; buf[i] !=   0 ; ++i) {       if (buf[i] ==  . ) {         p1 = i;       } else if (buf[i] ==  ( ) {         p2 = i;       } else if (buf[i] ==  ) ) {         p3 = i;       }     }     strncpy(name, buf, p1);     name[p1] =   0 ;     int idx = name2id[name];     if (strncmp(buf + p1 + 1,  pack , p2 - p1 - 1) == 0) {       char packName[11];       strncpy(packName, buf + p2 + 1, p3 - p2 - 1);       packName[p3 - p2 - 1] =   0 ;       int packIdx = name2id[packName];       widgets[idx].sons.push_back(packIdx);     } else if (strncmp(buf + p1 + 1,  set_border , p2 - p1 - 1) == 0) {       int border = str2int(buf + p2 + 1, buf + p3);       widgets[idx].border = border;     } else if (strncmp(buf + p1 + 1,  set_spacing , p2 - p1 - 1) == 0) {       int spacing = str2int(buf + p2 + 1, buf + p3);       widgets[idx].spacing = spacing;     }   }   void compBox(int idx) {     if (widgets[idx].sons.size() == 0 || widgets[idx].width != 0) {       return;     }     int sonSize = widgets[idx].sons.size();     for (int i = 0; i < sonSize; ++i) {       int sonIdx = widgets[idx].sons[i];       compBox(sonIdx);       if (widgets[idx].type == HBox) {         widgets[idx].width += widgets[sonIdx].width;         widgets[idx].height = max(widgets[idx].height, widgets[sonIdx].height);       } else if (widgets[idx].type == VBox) {         widgets[idx].width = max(widgets[idx].width, widgets[sonIdx].width);         widgets[idx].height += widgets[sonIdx].height;       }     }     widgets[idx].width += 2 * widgets[idx].border;     widgets[idx].height += 2 * widgets[idx].border;     if (widgets[idx].type == HBox) {       widgets[idx].width += (sonSize - 1) * widgets[idx].spacing;     } else if (widgets[idx].type == VBox) {       widgets[idx].height += (sonSize - 1) * widgets[idx].spacing;     }   }   void compSize() {     for (int i = 0; i < wCnt; ++i) {       if (widgets[i].type != Normal && widgets[i].width == 0 &&           widgets[i].sons.size() != 0) {         compBox(i);       }     }   }   bool cmp(Widget a, Widget b) {     return (strcmp(a.name, b.name) <= 0) ? true : false;   }   void clear() {     name2id.clear();     for (int i = 0; i < wCnt; ++i) {       widgets[i].sons.clear();     }   }   int main() {     int n;     while (scanf( %d , &n) != EOF) {       getchar();       wCnt = 0;       while (n--) {         char buf[50];         fgets(buf, 50, stdin);         int bufLen = strlen(buf);         buf[bufLen - 1] =   0 ;         if (isWidget(buf)) {           continue;         }         if (isBox(buf)) {           continue;         }         operate(buf);       }       compSize();       sort(widgets, widgets + wCnt, cmp);       for (int i = 0; i < wCnt; ++i) {         printf( %s %I64d %I64d n , widgets[i].name, widgets[i].width,                widgets[i].height);       }       clear();     }     return 0;   }   