Language: C++

#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <algorithm>
using nameapace::std;
int n;

struct item{
    string name;
    int cost;
    vector<string> used;
    int size;
} ;

item list[100];
int memo[100];

int getCost(int v)
{
    if(memo[v]!=-1)return memo[v];
    int i, j;
    int ans;
    
    if (list[v].size == 0){
        return (list[v].cost);
    }
    else {
        ans = 0;
        for (i = 0; i < list[v].size; i++){
            for (j = 0; j < n; j++){
                if (list[v].used[i]== list[j].name){
                    ans += getCost(j);
                }
            }
        }
        list[v].cost = min(list[v].cost,ans);
    }
    return (list[v].cost);
}

int main(void)
{
    int i, j, k;
    int m, kk;
    string key, temp;
    int look, sum;
    
    while (1){
        scanf("%d", &n);
        
        if (n == 0){
            break;
        }
        for(i=0;i<n;i++)memo[i]=-1;
        for (i = 0; i < n; i++){
            cin >> list[i].name >> list[i].cost;
            list[i].size = 0;
        }
        
        cin >> m;
        for (i = 0; i < m; i++){
            cin >> key;
            for (j = 0; j < n; j++){
                if (key==list[j].name){
                    look = j;
                }
            }
            cin >> kk;
            list[look].size = kk;
            for (j = 0; j < kk; j++){
                cin >> temp;
                for (k = 0; k < n; k++){
                    if (temp==list[k].name){
                        list[look].used[j]=temp;
                    }
                }
            }
        }
        cin >> key;
        for (j = 0; j < n; j++){
            if (strcmp(key, list[j].name) == 0){
                look = j;
            }
        }
        
        cout << getCost(look);
        
    }
    
    return (0);
}

Compiler output:
a.cc:6:7: error: 'nameapace' has not been declared
    6 | using nameapace::std;
      |       ^~~~~~~~~
a.cc:10:5: error: 'string' does not name a type; did you mean 'stdin'?
   10 |     string name;
      |     ^~~~~~
      |     stdin
a.cc:12:5: error: 'vector' does not name a type
   12 |     vector<string> used;
      |     ^~~~~~
a.cc: In function 'int getCost(int)':
a.cc:32:29: error: 'struct item' has no member named 'used'
   32 |                 if (list[v].used[i]== list[j].name){
      |                             ^~~~
a.cc:32:47: error: 'struct item' has no member named 'name'
   32 |                 if (list[v].used[i]== list[j].name){
      |                                               ^~~~
a.cc:37:24: error: 'min' was not declared in this scope; did you mean 'std::min'?
   37 |         list[v].cost = min(list[v].cost,ans);
      |                        ^~~
      |                        std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc: In function 'int main()':
a.cc:46:5: error: 'string' was not declared in this scope
   46 |     string key, temp;
      |     ^~~~~~
a.cc:46:5: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from a.cc:3:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:57:13: error: 'cin' was not declared in this scope
   57 |             cin >> list[i].name >> list[i].cost;
      |             ^~~
a.cc:57:28: error: 'struct item' has no member named 'name'
   57 |             cin >> list[i].name >> list[i].cost;
      |                            ^~~~
a.cc:61:9: error: 'cin' was not declared in this scope
   61 |         cin >> m;
      |         ^~~
a.cc:63:20: error: 'key' was not declared in this scope
   63 |             cin >> key;
      |                    ^~~
a.cc:65:34: error: 'struct item' has no member named 'name'
   65 |                 if (key==list[j].name){
      |                                  ^~~~
a.cc:72:24: error: 'temp' was not declared in this scope; did you mean 'tm'?
   72 |                 cin >> temp;
      |                        ^~~~
      |                        tm
a.cc:74:39: error: 'struct item' has no member named 'name'
   74 |                     if (temp==list[k].name){
      |                                       ^~~~
a.cc:75:36: error: 'struct item' has no member named 'used'
   75 |                         list[look].used[j]=temp;
      |                                    ^~~~
a.cc:80:16: error: 'key' was not declared in this scope
   80 |         cin >> key;
      |                ^~~
a.cc:82:37: error: 'struct item' has no member named 'name'
   82 |             if (strcmp(key, list[j].name) == 0){
      |                                     ^~~~
a.cc:82:17: error: 'strcmp' was not declared in this scope
   82 |             if (strcmp(key, list[j].name) == 0){
      |                 ^~~~~~
a.cc:5:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <vector>
  +++ |+#include <cstring>
    5 | #include <algorithm>
a.cc:87:9: error: 'cout' was not declared in this scope
   87 |         cout << getCost(look);
      |         ^~~~