Language: C++

string in;
int p;

void next(int& p){
  ++p;
  while(p<SZ(in) && in[p]!=')'){
    if(in[p]=='(')next(p);
    else ++p;
  }
  ++p;
}

ll get(int po,int re){
  ll le=0;
  if(in[po]!='(')return 1;
  ++po;
  while(po<SZ(in) && in[po]!=')'){
    if(isdigit(in[po])){
      ll t=0;
      while(isdigit(in[po]))t=t*10+in[po++]-'0';
      ll cle=get(po,re);
      if(cle==-1)return -1;
      le+=cle*t;
      if(in[po]=='(')next(po);
      else ++po;
    }else{
      ++le;
      ++po;
    }
    if(le>re)return -1;
  }
  return le;
}

char rec(int po,int re){
  while(po<SZ(in)){
    //cout<<po<<' '<<re<<endl;
    if(isdigit(in[po])){
      ll t=0;
      while(isdigit(in[po]))t=t*10+in[po++]-'0';
      ll len=get(po,re);
      //cout<<len<<endl;
      int de=0;
      if(in[po]=='(')++de;
      if(len==-1)return rec(po+de,re);
      else if(re<t*len)return rec(po+de,re%len);
      re-=t*len;
      //cout<<re<<endl;
      if(de)next(po);
      else ++po;
    }else{
      if(re==0)return in[po];
      ++po;
      --re;
    }
  }
  ++po;
  return '0';
}



main(){
  while(cin>>in>>p,in!="0")
    cout<<rec(0,p)<<endl;
}

Compiler output:
a.cc:1:1: error: 'string' does not name a type
    1 | string in;
      | ^~~~~~
a.cc: In function 'void next(int&)':
a.cc:6:14: error: 'in' was not declared in this scope; did you mean 'int'?
    6 |   while(p<SZ(in) && in[p]!=')'){
      |              ^~
      |              int
a.cc:6:11: error: 'SZ' was not declared in this scope
    6 |   while(p<SZ(in) && in[p]!=')'){
      |           ^~
a.cc: At global scope:
a.cc:13:1: error: 'll' does not name a type
   13 | ll get(int po,int re){
      | ^~
a.cc: In function 'char rec(int, int)':
a.cc:36:15: error: 'in' was not declared in this scope; did you mean 'int'?
   36 |   while(po<SZ(in)){
      |               ^~
      |               int
a.cc:36:12: error: 'SZ' was not declared in this scope
   36 |   while(po<SZ(in)){
      |            ^~
a.cc:38:8: error: 'isdigit' was not declared in this scope
   38 |     if(isdigit(in[po])){
      |        ^~~~~~~
a.cc:39:7: error: 'll' was not declared in this scope
   39 |       ll t=0;
      |       ^~
a.cc:40:29: error: 't' was not declared in this scope
   40 |       while(isdigit(in[po]))t=t*10+in[po++]-'0';
      |                             ^
a.cc:41:9: error: expected ';' before 'len'
   41 |       ll len=get(po,re);
      |         ^~~~
      |         ;
a.cc:45:10: error: 'len' was not declared in this scope
   45 |       if(len==-1)return rec(po+de,re);
      |          ^~~
a.cc:46:18: error: 't' was not declared in this scope
   46 |       else if(re<t*len)return rec(po+de,re%len);
      |                  ^
a.cc:47:11: error: 't' was not declared in this scope
   47 |       re-=t*len;
      |           ^
a.cc:47:13: error: 'len' was not declared in this scope
   47 |       re-=t*len;
      |             ^~~
a.cc: At global scope:
a.cc:63:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   63 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:64:9: error: 'cin' was not declared in this scope
   64 |   while(cin>>in>>p,in!="0")
      |         ^~~
a.cc:64:14: error: 'in' was not declared in this scope; did you mean 'int'?
   64 |   while(cin>>in>>p,in!="0")
      |              ^~
      |              int
a.cc:65:5: error: 'cout' was not declared in this scope
   65 |     cout<<rec(0,p)<<endl;
      |     ^~~~
a.cc:65:21: error: 'endl' was not declared in this scope
   65 |     cout<<rec(0,p)<<endl;
      |                     ^~~~