Language: C++

/*==========================================================================*/
/*
    FILE DESCRIPTION: True Template

    AUTHOR:    Yoseph Guttman
    GROUP:     The NULL workgroup
    PROJECT:   The project
    PART:      Main

    COPYRIGHT: (C) 2020 The NULL workgroup. All Rights Reserved.
*/
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//#undef _GLIBCXX_DEBUG
 
using namespace std;
 
#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
/*#define IO ios::sync_with_stdio(0);*/

typedef long long ll;
typedef unsigned long long ull;

typedef string sg; 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL_SIM
	~debug() { cerr << endl; }
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) {
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
	}
#else
	sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
//typedef int tp;
//typedef tree<tp,null_type,less<tp>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// tp a;
// T.insert(a), T.erase(a), T.size()
// T.order_of_key(a) -- number of elements strictly less than a
// *T.find_by_order(k) -- k-th element in increasing order
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
//#else
//#define debug(...) 42
#endif

int main()
{
#ifdef LOCAL_IN
	freopen("in", "rt", stdin);
#endif
	
 	IO; int n; cin >> n;
	vi A(n), B(n), C(n-1);
	FOR (i,0,n)
		cin >> A[i];
	FOR (i,0,n)
		cin >> B[i];
	FOR (i,0,n - 1)
		cin >> C[i];
	int ans = 0;
	debug(A,B,C);
	for (int i = 1; i <= n; ++i) {
		ans += B[A[i-1]-1];
		debug(i,n);
		if (i != n)
			ans += C[i-1];
		debug(ans);
	}

	cout << ans << "\n";

#ifdef LOCAL_IN
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:216:20: error: no matching function for call to 'debug::debug(vi&, vi&, vi&)'
  216 |         debug(A,B,C);
      |                    ^
a.cc:86:8: note: candidate: 'constexpr debug::debug()'
   86 | struct debug {
      |        ^~~~~
a.cc:86:8: note:   candidate expects 0 arguments, 3 provided
a.cc:86:8: note: candidate: 'constexpr debug::debug(const debug&)'
a.cc:86:8: note:   candidate expects 1 argument, 3 provided
a.cc:86:8: note: candidate: 'constexpr debug::debug(debug&&)'
a.cc:86:8: note:   candidate expects 1 argument, 3 provided
a.cc:219:26: error: no matching function for call to 'debug::debug(int&, int&)'
  219 |                 debug(i,n);
      |                          ^
a.cc:86:8: note: candidate: 'constexpr debug::debug()'
   86 | struct debug {
      |        ^~~~~
a.cc:86:8: note:   candidate expects 0 arguments, 2 provided
a.cc:86:8: note: candidate: 'constexpr debug::debug(const debug&)'
a.cc:86:8: note:   candidate expects 1 argument, 2 provided
a.cc:86:8: note: candidate: 'constexpr debug::debug(debug&&)'
a.cc:86:8: note:   candidate expects 1 argument, 2 provided