func_code_string: #include <bits/stdc++.h>   using namespace std;   bool const TO_FILE = false;   string const FILENAME =   ;   void prepare() {     if (TO_FILE) {       freopen((FILENAME +  .in ).c_str(),  r , stdin);       freopen((FILENAME +  .out ).c_str(),  w , stdout);     }   }   void solve() {     int n, m, k;     cin >> n >> m >> k;     map<int, pair<int, int>> apps;     map<pair<int, int>, int> apps2;     int curScr = 0;     int curPos = 0;     for (int i = 0; i < n; i++) {       int app;       cin >> app;       apps[app] = make_pair(curScr, curPos);       apps2[make_pair(curScr, curPos)] = app;       if (++curPos == k) {         curPos = 0;         curScr++;       }     }     long long res = m;     for (int i = 0; i < m; i++) {       int curApp, prevApp;       cin >> curApp;       int curScr = apps[curApp].first;       int curPos = apps[curApp].second;       int prevScr, prevPos;       if (curScr == 0 && curPos == 0)         continue;       else if (curPos == 0) {         prevScr = curScr - 1;         prevPos = k - 1;         prevApp = apps2[make_pair(prevScr, prevPos)];       } else {         prevScr = curScr;         prevPos = curPos - 1;         prevApp = apps2[make_pair(prevScr, prevPos)];       }       apps[curApp] = make_pair(prevScr, prevPos);       apps2[make_pair(prevScr, prevPos)] = curApp;       apps[prevApp] = make_pair(curScr, curPos);       apps2[make_pair(curScr, curPos)] = prevApp;       res += curScr;     }     cout << res;   }   int main() {     prepare();     solve();     return 0;   }   