Language: C++

#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<algorithm>
#define ll long long
#define lowbit(x) x&-x
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c==‘-‘)t=-1;
    do{s=s*10+c-‘0‘;}while(isdigit(c=getchar()));
    return s*t;
}
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a<b?b:a;}
int ab(int x){return x>0?x:-x;}
//int MO(int x){return x>=MOD?x-MOD:x;}
//void insert(int u,int v){tot++;e[tot].v=v;e[tot].from=first[u];first[u]=tot;}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f,maxn=200010;
 
int n,c[maxn],num[maxn];
bool vis[maxn];
char s[maxn];
vector<int>v[30];
void modify(int x,int k){for(int i=x;i<=n;i+=lowbit(i))c[i]+=k;}
int query(int x){int ans=0;for(int i=x;i>=1;i-=lowbit(i))ans+=c[i];return ans;}
int main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    for(int i=1;i<=n;i++)num[s[i]-‘a‘]++,v[s[i]-‘a‘].push_back(i);
    int ok=0;
    for(int i=0;i<26;i++){
        if(num[i]%2)ok++;
    }
    if(ok>1){printf("-1");return 0;}
    for(int i=1;i<=n+1;i++)modify(i,1);
    ll ans=0;
    for(int i=1;i<=n;i++)if(!vis[i]){
        int c=s[i]-‘a‘;
        int x=v[c][v[c].size()-1];
        if(i==x){
            ans+=(query(n)-query(i))/2;
        }
        else{
            ans+=(query(n)-query(x));
        }
        modify(i,-1);modify(x,-1);
        vis[i]=vis[x]=1;
        v[c].erase(v[c].end()-1);
    }
    printf("%lld",ans);
    return 0;
}

Compiler output:
a.cc:15:39: error: extended character ‘ is not valid in an identifier
   15 |     while(!isdigit(c=getchar()))if(c==‘-‘)t=-1;
      |                                       ^
a.cc:15:41: error: extended character ‘ is not valid in an identifier
   15 |     while(!isdigit(c=getchar()))if(c==‘-‘)t=-1;
      |                                         ^
a.cc:16:17: error: extended character ‘ is not valid in an identifier
   16 |     do{s=s*10+c-‘0‘;}while(isdigit(c=getchar()));
      |                 ^
a.cc:16:17: error: extended character ‘ is not valid in an identifier
a.cc:36:35: error: extended character ‘ is not valid in an identifier
   36 |     for(int i=1;i<=n;i++)num[s[i]-‘a‘]++,v[s[i]-‘a‘].push_back(i);
      |                                   ^
a.cc:36:35: error: extended character ‘ is not valid in an identifier
a.cc:36:49: error: extended character ‘ is not valid in an identifier
   36 |     for(int i=1;i<=n;i++)num[s[i]-‘a‘]++,v[s[i]-‘a‘].push_back(i);
      |                                                 ^
a.cc:36:49: error: extended character ‘ is not valid in an identifier
a.cc:45:20: error: extended character ‘ is not valid in an identifier
   45 |         int c=s[i]-‘a‘;
      |                    ^
a.cc:45:20: error: extended character ‘ is not valid in an identifier
a.cc: In function 'int read()':
a.cc:15:39: error: '\U00002018' was not declared in this scope
   15 |     while(!isdigit(c=getchar()))if(c==‘-‘)t=-1;
      |                                       ^
a.cc:16:17: error: '\U000020180\U00002018' was not declared in this scope
   16 |     do{s=s*10+c-‘0‘;}while(isdigit(c=getchar()));
      |                 ^~~
a.cc: In function 'int main()':
a.cc:36:35: error: '\U00002018a\U00002018' was not declared in this scope
   36 |     for(int i=1;i<=n;i++)num[s[i]-‘a‘]++,v[s[i]-‘a‘].push_back(i);
      |                                   ^~~
a.cc:45:20: error: '\U00002018a\U00002018' was not declared in this scope
   45 |         int c=s[i]-‘a‘;
      |                    ^~~