func_code_string: #include <bits/stdc++.h>   using namespace std;   struct event {     long long x, type;     event() {}     event(long long _x, long long _type) {       x = _x;       type = _type;     }   };   string a, b;   long long n;   long double ans = 0;   vector<long long> v[500];   vector<event> d[500];   bool operator<(const event& a, const event& b) {     return a.x < b.x || (a.x == b.x && a.type < b.type);   }   int main() {     cin >> n;     cin >> a >> b;     for (long long i = 0; i < n; i++) {       v[a[i]].push_back(i);       d[a[i]].push_back(event(i, 0));       d[b[i]].push_back(event(i, 1));     }     long long all = 0;     for (long long i = 1; i <= n; i++) {       all += i * i;     }     for (long long i = 0; i < 500; i++) {       sort(d[i].begin(), d[i].end());       long long x = 0, y = 0;       for (long long j = 0; j < d[i].size(); j++) {         event q = d[i][j];         y += (n - q.x) * (1 - q.type);       }       for (long long j = 0; j < d[i].size(); j++) {         event q = d[i][j];         if (!q.type) {           y -= n - q.x;           x += q.x + 1;         } else {           ans += (long double)((q.x + 1) * y) / (long double)all;           ans += (long double)((n - q.x) * x) / (long double)all;         }       }     }     cout.precision(18);     cout << ans;     return 0;   }   