func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   int connected;   int par[N], sz[N];   struct DSU {     void init(int n) {       for (int i = 1; i <= n; i++) {         par[i] = i;         sz[i] = 1;       }       connected = n;     }     int getPar(int k) {       while (k != par[k]) {         par[k] = par[par[k]];         k = par[k];       }       return k;     }     int getSize(int k) { return sz[getPar(k)]; }     void unite(int u, int v) {       int par1 = getPar(u), par2 = getPar(v);       if (par1 == par2) return;       connected--;       if (sz[par1] > sz[par2]) swap(par1, par2);       sz[par2] += sz[par1];       sz[par1] = 0;       par[par1] = par[par2];     }   };   DSU dsu;   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long powermod(long long x, long long y) {     if (y == 0) return 1;     if (y % 2 == 0)       return (powermod(x, y / 2) * powermod(x, y / 2)) % 1000000007;     else       return (((powermod(x, y / 2) * powermod(x, y / 2)) % 1000000007) * x) %              1000000007;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     map<int, int> m1, m2;     int n;     cin >> n;     long long ans = 0;     for (int i = 0; i < 2 * n; i++) {       int x;       cin >> x;       if (m1.find(x) == m1.end())         m1[x] = i + 1;       else         m2[x] = i + 1;     }     int y = 1;     for (auto x : m1) {       ans += abs(y - x.second);       y = x.second;     }     y = 1;     for (auto x : m2) {       ans += abs(y - x.second);       y = x.second;     }     cout << ans;   }   