Language: C++

#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <regex>
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using dbl = double;
using pii = pair<int,int>;
using pl4 = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpl4 = vector<pl4>;
using vvpl4 = vector<vpl4>;
using vd = vector<dbl>;
using vvd = vector<vd>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back()
#define sz size()
#define be begin()
#define en end()
#define asn assign
#define emp empty()
#define ft front()
#define bk back()
#define clr clear()
#define ins insert
#define ers erase
#define res resize

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).be,(a).en)
#define rSORT(a) sort((a).rbegin(),(a).rend())
#define UNIQUE(a) (a).erase(unique((a).be,(a).en),(a).en)
#define PREVP(a) prev_permutation((a).be,(a).en)
#define NEXTP(a) next_permutation((a).be,(a).en)
#define BINS(a,b) binary_search((a).be,(a).en,(b))
#define LOWB(a,b) (lower_bound((a).be,(a).en,(b))-(a).be)
#define UPB(a,b) (upper_bound((a).be,(a).en,(b))-(a).be)
#define CNT(a,b) count((a).be,(a).en,b)
#define SUM(a) accumulate((a).be,(a).en,0)
#define REV(a) reverse((a).be,(a).en)
#define REGS(a,b) regex_search((a),regex(b))
#define REGM(a,b) regex_match((a),regex(b))
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define say(a) cout <<(a);
#define sal(a) cout <<(a)<<endl;
#define sak cout <<endl;
#define dbg(a) cout <<(#a)<<": "<<(a)<<endl;
#define c2l(a) ((ll)(a-48))
#define a2l(a) ((ll)(a-97))
#define A2l(a) ((ll)(a-65))
#define l2c(a) ((char)(a+48))
#define l2a(a) ((char)(a+97))
#define l2A(a) ((char)(a+65))
#define DigN2(a) ((llabs(a)==0)?(1):((ll)(log2(double(llabs(a))))+1))
#define DigN10(a) ((llabs(a)==0)?(1):((ll)(log10(double(llabs(a))))+1))
#define Dig2(a,b) (((a)>>(b))&1)
#define Dig10(a,b) (ll)(((a)/((ll)(pow(10.0,(double)(b)))))%10)
#define Pow2(a) (1<<(a))
#define llin(a) ll (a);cin >>(a);
#define stin(a) string (a);cin >>(a);
#define rdn(a,b) ((a)/(b))
#define rou(a,b) ((((double(a)/double(b))-((a)/(b)))<0.5)?((a)/(b)):(((a)/(b))+1))
#define rup(a,b) ((((a)%(b))==0)?((a)/(b)):(((a)/(b))+1))
#define min(a,b) ((a<b)?(a):(b))
#define max(a,b) ((a>b)?(a):(b))
#define powll(a,b) (ll)(pow((double)(a),(double)(b)))

#define int ll

const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1LL << 60;
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

pl4 Bezout(ll a,ll b){
    if(b!=0){
        pl4 xy;
        xy=Bezout(b,a%b);
        return mp(xy.se,xy.fi-((a/b)*xy.se));
    }
    if(b==0){
        return mp(1,0);
    }
}
pl4 Bez(ll a,ll b,ll c){
    pl4 xy;
    ll x,y,z,gc;
    xy=Bezout(a,b);
    gc=gcd(a,b);
    if(c%gc!=0) return mp(-1,-1);
    x=xy.fi*(c/gc);y=xy.se*(c/gc);
    if(x<0) z=rup(-x,(b/gc));
    if(x>=0) z=-x/(b/gc);
    x+=z*(b/gc);
    y-=z*(a/gc);
    return mp(x,y);
}

void salv(vll v){
    say("{");
    FOR(i,0,v.sz-1){
        say(v[i]);
        if(i!=v.sz-1) say(",");
    }
    sal("}")
}

ll DigS10(ll n){
    ll m=0;
    FOR(i,0,DigN10(n)-1){
        m+=(ll)((llabs(n)%(ll)(pow(10.0,(double)(i+1))))/(ll)(pow(10.0,(double)i)));
    }
    return m;
}

ll isP(ll n){
    if(n<=1) return 0;
    FOR(i,2,(ll)sqrt(n)){
        if(n%i==0) return 0;
    }
    return 1;
}

vll FactM(1,1);
vll FactMI(1,1);

ll PowM(ll a,ll b){
    ll ans=1,x=(a%MOD);
    FOR(i,0,DigN2(b)-1){
        if(Dig2(b,i)==1) ans=(ans*x)%MOD;
        if(i!=(DigN2(b)-1)) x=(x*x)%MOD;
    }
    return ans;
}

void CFactM(ll n){
    if(FactM.sz<=n){
        FOR(i,FactM.sz,n){
            FactM.pb((FactM[i-1]*(i%MOD))%MOD);
        }
    }
    return;
}

void CFactMI(ll n){
    CFactM(n);
    if(FactMI.sz<(n+1)) FactMI.res(n+1,-1);
    if(FactMI[n]==-1) FactMI[n]=PowM(FactM[n],MOD-2);
    rFOR(i,1,n-1){
        if(FactMI[i]!=-1) break;
        FactMI[i]=((FactMI[i+1]*((i+1)%MOD))%MOD);
    }
    return;
}

ll CombM(ll n,ll k){
    if((n<0)||(k<0)) return 0;
    if(n<k) return 0;
    if(n+1>FactMI.sz) CFactMI(n);
    return ((((FactMI[k]*FactMI[n-k])%MOD)*FactM[n])%MOD);
}

signed main() {

    llin(N);
    if(DigS10(N)==1) sal(10);
    if(DigS10(N)!=1) sal(DigS10(N));
    
}



#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <regex>
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using dbl = double;
using pii = pair<int,int>;
using pl4 = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpl4 = vector<pl4>;
using vvpl4 = vector<vpl4>;
using vd = vector<dbl>;
using vvd = vector<vd>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back()
#define sz size()
#define be begin()
#define en end()
#define asn assign
#define emp empty()
#define ft front()
#define bk back()
#define clr clear()
#define ins insert
#define ers erase
#define res resize

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).be,(a).en)
#define rSORT(a) sort((a).rbegin(),(a).rend())
#define UNIQUE(a) (a).erase(unique((a).be,(a).en),(a).en)
#define PREVP(a) prev_permutation((a).be,(a).en)
#define NEXTP(a) next_permutation((a).be,(a).en)
#define BINS(a,b) binary_search((a).be,(a).en,(b))
#define LOWB(a,b) (lower_bound((a).be,(a).en,(b))-(a).be)
#define UPB(a,b) (upper_bound((a).be,(a).en,(b))-(a).be)
#define CNT(a,b) count((a).be,(a).en,b)
#define SUM(a) accumulate((a).be,(a).en,0)
#define REV(a) reverse((a).be,(a).en)
#define REGS(a,b) regex_search((a),regex(b))
#define REGM(a,b) regex_match((a),regex(b))
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define say(a) cout <<(a);
#define sal(a) cout <<(a)<<endl;
#define sak cout <<endl;
#define dbg(a) cout <<(#a)<<": "<<(a)<<endl;
#define c2l(a) ((ll)(a-48))
#define a2l(a) ((ll)(a-97))
#define A2l(a) ((ll)(a-65))
#define l2c(a) ((char)(a+48))
#define l2a(a) ((char)(a+97))
#define l2A(a) ((char)(a+65))
#define DigN2(a) ((llabs(a)==0)?(1):((ll)(log2(double(llabs(a))))+1))
#define DigN10(a) ((llabs(a)==0)?(1):((ll)(log10(double(llabs(a))))+1))
#define Dig2(a,b) (((a)>>(b))&1)
#define Dig10(a,b) (ll)(((a)/((ll)(pow(10.0,(double)(b)))))%10)
#define Pow2(a) (1<<(a))
#define llin(a) ll (a);cin >>(a);
#define stin(a) string (a);cin >>(a);
#define rdn(a,b) ((a)/(b))
#define rou(a,b) ((((double(a)/double(b))-((a)/(b)))<0.5)?((a)/(b)):(((a)/(b))+1))
#define rup(a,b) ((((a)%(b))==0)?((a)/(b)):(((a)/(b))+1))
#define min(a,b) ((a<b)?(a):(b))
#define max(a,b) ((a>b)?(a):(b))
#define powll(a,b) (ll)(pow((double)(a),(double)(b)))

#define int ll

const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1LL << 60;
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

pl4 Bezout(ll a,ll b){
    if(b!=0){
        pl4 xy;
        xy=Bezout(b,a%b);
        return mp(xy.se,xy.fi-((a/b)*xy.se));
    }
    if(b==0){
        return mp(1,0);
    }
}
pl4 Bez(ll a,ll b,ll c){
    pl4 xy;
    ll x,y,z,gc;
    xy=Bezout(a,b);
    gc=gcd(a,b);
    if(c%gc!=0) return mp(-1,-1);
    x=xy.fi*(c/gc);y=xy.se*(c/gc);
    if(x<0) z=rup(-x,(b/gc));
    if(x>=0) z=-x/(b/gc);
    x+=z*(b/gc);
    y-=z*(a/gc);
    return mp(x,y);
}

void salv(vll v){
    say("{");
    FOR(i,0,v.sz-1){
        say(v[i]);
        if(i!=v.sz-1) say(",");
    }
    sal("}")
}

ll DigS10(ll n){
    ll m=0;
    FOR(i,0,DigN10(n)-1){
        m+=(ll)((llabs(n)%(ll)(pow(10.0,(double)(i+1))))/(ll)(pow(10.0,(double)i)));
    }
    return m;
}

ll isP(ll n){
    if(n<=1) return 0;
    FOR(i,2,(ll)sqrt(n)){
        if(n%i==0) return 0;
    }
    return 1;
}

vll FactM(1,1);
vll FactMI(1,1);

ll PowM(ll a,ll b){
    ll ans=1,x=(a%MOD);
    FOR(i,0,DigN2(b)-1){
        if(Dig2(b,i)==1) ans=(ans*x)%MOD;
        if(i!=(DigN2(b)-1)) x=(x*x)%MOD;
    }
    return ans;
}

void CFactM(ll n){
    if(FactM.sz<=n){
        FOR(i,FactM.sz,n){
            FactM.pb((FactM[i-1]*(i%MOD))%MOD);
        }
    }
    return;
}

void CFactMI(ll n){
    CFactM(n);
    if(FactMI.sz<(n+1)) FactMI.res(n+1,-1);
    if(FactMI[n]==-1) FactMI[n]=PowM(FactM[n],MOD-2);
    rFOR(i,1,n-1){
        if(FactMI[i]!=-1) break;
        FactMI[i]=((FactMI[i+1]*((i+1)%MOD))%MOD);
    }
    return;
}

ll CombM(ll n,ll k){
    if((n<0)||(k<0)) return 0;
    if(n<k) return 0;
    if(n+1>FactMI.sz) CFactMI(n);
    return ((((FactMI[k]*FactMI[n-k])%MOD)*FactM[n])%MOD);
}

signed main() {

    llin(N);
    if(DigS10(N)==1) sal(10);
    if(DigS10(N)!=1) sal(DigS10(N));
    
}





Compiler output:
a.cc:214:7: error: conflicting declaration 'using pii = struct std::pair<long long int, long long int>'
  214 | using pii = pair<int,int>;
      |       ^~~
a.cc:16:7: note: previous declaration as 'using pii = struct std::pair<int, int>'
   16 | using pii = pair<int,int>;
      |       ^~~
a.cc:216:7: error: conflicting declaration 'using vi = class std::vector<long long int>'
  216 | using vi = vector<int>;
      |       ^~
a.cc:18:7: note: previous declaration as 'using vi = class std::vector<int>'
   18 | using vi = vector<int>;
      |       ^~
a.cc:290:10: error: redefinition of 'const ll MOD'
  290 | const ll MOD = 1e9+7;
      |          ^~~
a.cc:92:10: note: 'const ll MOD' previously defined here
   92 | const ll MOD = 1e9+7;
      |          ^~~
a.cc:292:10: error: redefinition of 'const ll INF'
  292 | const ll INF = 1LL << 60;
      |          ^~~
a.cc:94:10: note: 'const ll INF' previously defined here
   94 | const ll INF = 1LL << 60;
      |          ^~~
a.cc:293:14: error: redefinition of 'const std::string alp'
  293 | const string alp = "abcdefghijklmnopqrstuvwxyz";
      |              ^~~
a.cc:95:14: note: 'const std::string alp' previously declared here
   95 | const string alp = "abcdefghijklmnopqrstuvwxyz";
      |              ^~~
a.cc:294:14: error: redefinition of 'const std::string ALP'
  294 | const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
      |              ^~~
a.cc:96:14: note: 'const std::string ALP' previously declared here
   96 | const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
      |              ^~~
a.cc:296:4: error: redefinition of 'll gcd(ll, ll)'
  296 | ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
      |    ^~~
a.cc:98:4: note: 'll gcd(ll, ll)' previously defined here
   98 | ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
      |    ^~~
a.cc:297:4: error: redefinition of 'll lcm(ll, ll)'
  297 | ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
      |    ^~~
a.cc:99:4: note: 'll lcm(ll, ll)' previously defined here
   99 | ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
      |    ^~~
a.cc:299:5: error: redefinition of 'pl4 Bezout(ll, ll)'
  299 | pl4 Bezout(ll a,ll b){
      |     ^~~~~~
a.cc:101:5: note: 'pl4 Bezout(ll, ll)' previously defined here
  101 | pl4 Bezout(ll a,ll b){
      |     ^~~~~~
a.cc:309:5: error: redefinition of 'pl4 Bez(ll, ll, ll)'
  309 | pl4 Bez(ll a,ll b,ll c){
      |     ^~~
a.cc:111:5: note: 'pl4 Bez(ll, ll, ll)' previously defined here
  111 | pl4 Bez(ll a,ll b,ll c){
      |     ^~~
a.cc:323:6: error: redefinition of 'void salv(vll)'
  323 | void salv(vll v){
      |      ^~~~
a.cc:125:6: note: 'void salv(vll)' previously defined here
  125 | void salv(vll v){
      |      ^~~~
a.cc:332:4: error: redefinition of 'll DigS10(ll)'
  332 | ll DigS10(ll n){
      |    ^~~~~~
a.cc:134:4: note: 'll DigS10(ll)' previously defined here
  134 | ll DigS10(ll n){
      |    ^~~~~~
a.cc:340:4: error: redefinition of 'll isP(ll)'
  340 | ll isP(ll n){
      |    ^~~
a.cc:142:4: note: 'll isP(ll)' previously defined here
  142 | ll isP(ll n){
      |    ^~~
a.cc:348:5: error: redefinition of 'vll FactM'
  348 | vll FactM(1,1);
      |     ^~~~~
a.cc:150:5: note: 'vll FactM' previously declared here
  150 | vll FactM(1,1);
      |     ^~~~~
a.cc:349:5: error: redefinition of 'vll FactMI'
  349 | vll FactMI(1,1);
      |     ^~~~~~
a.cc:151:5: note: 'vll FactMI' previously declared here
  151 | vll FactMI(1,1);
      |     ^~~~~~
a.cc:351:4: error: redefinition of 'll PowM(ll, ll)'
  351 | ll PowM(ll a,ll b){
      |    ^~~~
a.cc:153:4: note: 'll PowM(ll, ll)' previously defined here
  153 | ll PowM(ll a,ll b){
      |    ^~~~
a.cc:360:6: error: redefinition of 'void CFactM(ll)'
  360 | void CFactM(ll n){
      |      ^~~~~~
a.cc:162:6: note: 'void CFactM(ll)' previously defined here
  162 | void CFactM(ll n){
      |      ^~~~~~
a.cc:369:6: error: redefinition of 'void CFactMI(ll)'
  369 | void CFactMI(ll n){
      |      ^~~~~~~
a.cc:171:6: note: 'void CFactMI(ll)' previously defined here
  171 | void CFactMI(ll n){
      |      ^~~~~~~
a.cc:380:4: error: redefinition of 'll CombM(ll, ll)'
  380 | ll CombM(ll n,ll k){
      |    ^~~~~
a.cc:182:4: note: 'll CombM(ll, ll)' previously defined here
  182 | ll CombM(ll n,ll k){
      |    ^~~~~
a.cc:387:8: error: redefinition of 'int main()'
  387 | signed main() {
      |        ^~~~
a.cc:189:8: note: 'int main()' previously defined here
  189 | signed main() {
      |        ^~~~
a.cc: In function 'pl4 Bezout(ll, ll)':
a.cc:110:1: warning: control reaches end of non-void function [-Wreturn-type]
  110 | }
      | ^
a.cc: In function 'pl4 Bezout(ll, ll)':
a.cc:308:1: warning: control reaches end of non-void function [-Wreturn-type]
  308 | }
      | ^