Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const double pi=acos(-1);
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;
vector<bool> seen,finished;
int pos = -1;
int ca=0;
int f=0;
void dfs(const Graph &G, int v, int p) {
    seen[v] = true;
    for (auto nv : G[v]) {
        if (nv == p) continue;
        if (finished[nv]) continue;
      if (seen[nv] && !finished[nv]) {
            pos = nv;f++; 
            return;
        }
      dfs(G, nv, v);
 
        // サイクル検出したならば真っ直ぐに抜けていく
        if (pos != -1) {
        return;}}
      finished[v] = true;
}
    
mint calc(long long N, long long K) {
    mint res = 1;
    for (long long n = 0; n < K; ++n) {
        res *= (N - n);
        res /= (n + 1);
    }
    return res;
}
struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
 
    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }
 
    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
 
    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
int main(){
ll n; cin>>n;
ll a[100]={};
ll b[100]={};
string s;
rep(i,n){
cin>>s;
ll l = s.size();
ll f = 0;
ll ca = 0;
ll cb = 0;
rep(k,l){
if(s.at(k)=="."){
for(ll m = k+1; m<l; m++){
if(s.at(m)=="0"){
if(m==k+1){
for(ll q = k-1; q>=0; q--;){
if(s.at(q)!="0"){
b[k-q-1]++;
f = 4;
break;}
}
if(f!=4){
ca++;
f = 5;
break;}
}
a[m-k-1]++;
f=2;
break;}
}
if(f==0){
a[l-k-1]++;
f++;}
if(f == 0){
reverse(all(s));
rep(k,l){
if(s.at(k)=="0"&&k==l-1){
ca++;
f = 6;
break;
}
if(s.at(k)!="0"){
b[k+1]++;
f = 7;
break;}
}
if(f == 0){
cb++;}
}
ll ans = 0;
ans += ca*(ca-1)/2;
ans += ca*(n-ca);
ll cc = 0;
rep(i,20){
cc+=b[i];}
ans+=(cc+cb)*(cc+cb-1)/2;
ll rui[20]={};
ll caa = 0;
for(ll i=0; i<15; i++){
caa+=a[i];
rui[i]=caa;}
for(ll i=0; i<12; i++){
ans+=b[i]*rui[i];}
cout << ans << endl;}

Compiler output:
a.cc: In function 'int main()':
a.cc:145:11: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  145 | if(s.at(k)=="."){
      |    ~~~~~~~^~~~~
a.cc:147:11: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  147 | if(s.at(m)=="0"){
      |    ~~~~~~~^~~~~
a.cc:149:26: error: expected ')' before ';' token
  149 | for(ll q = k-1; q>=0; q--;){
      |    ~                     ^
      |                          )
a.cc:149:27: error: expected primary-expression before ')' token
  149 | for(ll q = k-1; q>=0; q--;){
      |                           ^
a.cc:170:11: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  170 | if(s.at(k)=="0"&&k==l-1){
      |    ~~~~~~~^~~~~
a.cc:175:11: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
  175 | if(s.at(k)!="0"){
      |    ~~~~~~~^~~~~
a.cc:197:22: error: expected '}' at end of input
  197 | cout << ans << endl;}
      |                      ^
a.cc:144:9: note: to match this '{'
  144 | rep(k,l){
      |         ^
a.cc:197:22: error: expected '}' at end of input
  197 | cout << ans << endl;}
      |                      ^
a.cc:138:9: note: to match this '{'
  138 | rep(i,n){
      |         ^
a.cc:197:22: error: expected '}' at end of input
  197 | cout << ans << endl;}
      |                      ^
a.cc:133:11: note: to match this '{'
  133 | int main(){
      |           ^