//Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and 
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
// same ids are connected.
// prefix 的格式要求是 acm-[一级标题编号].[二级标题编号][该代码片段的英文简称]
// description 的格式要求是 "插入 [该代码片段的中文名]"

{
    "杜教筛": {
        "prefix": "acm-7.1map",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "#include<cmath>",
            "#include<map>",
            "#define Re register int",
            "#define LL long long",
            "using namespace std;",
            "const int N23=1664511+3,N=2147483647;",
            "int x,T,cnt,pan[N23],pri[N23],phi[N23],miu[N23];",
            "int TO,Smiu[N23];LL Sphi[N23];",
            "map<int,int>Smiu_;map<int,LL>Sphi_;",
            "inline void in(Re &x){",
            "\tRe fu=0;x=0;char ch=getchar();",
            "\twhile(ch<'0'||ch>'9')fu|=ch=='-',ch=getchar();",
            "\twhile(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();",
            "\tx=fu?-x:x;",
            "}",
            "inline void get_(Re N){",
            "\tmiu[1]=phi[1]=pan[1]=1;",
            "\tfor(Re i=2;i<=N;++i){",
            "\t\tif(!pan[i])pri[++cnt]=i,miu[i]=-1,phi[i]=i-1;",
            "\t\tfor(Re j=1;j<=cnt&&pri[j]<=N/i;++j){",
            "\t\t\tpan[i*pri[j]]=1;",
            "\t\t\tif(i%pri[j])miu[i*pri[j]]=-miu[i],phi[i*pri[j]]=phi[i]*phi[pri[j]];",
            "\t\t\telse{miu[i*pri[j]]=0,phi[i*pri[j]]=phi[i]*pri[j];break;}",
            "\t\t}",
            "\t}",
            "\tfor(Re i=1;i<=N;++i)Smiu[i]=Smiu[i-1]+miu[i],Sphi[i]=Sphi[i-1]+phi[i];",
            "}",
            "inline LL get_Sphi(Re n){",
            "\tif(n<=TO)return Sphi[n];",
            "\tif(Sphi_[n])return Sphi_[n];",
            "\tLL ans=(LL)n*(n+1)>>1;",
            "\tfor(Re l=2,r;l<=n;l=r+1){",
            "\t\tr=n/(n/l);",
            "\t\tans-=(LL)(r-l+1)*get_Sphi(n/l);",
            "\t}",
            "\treturn Sphi_[n]=ans;",
            "}",
            "inline int get_Smiu(Re n){",
            "\tif(n<=TO)return Smiu[n];",
            "\tif(Smiu_[n])return Smiu_[n];",
            "\tRe ans=1;",
            "\tfor(Re l=2,r;l<=n;l=r+1){",
            "\t\tr=n/(n/l);",
            "\t\tans-=(r-l+1)*get_Smiu(n/l);",
            "\t}",
            "\treturn Smiu_[n]=ans;",
            "}",
            "int main(){",
            "//\tfreopen(\"123.txt\",\"r\",stdin);",
            "\tin(T),get_(TO=N23-3);",
            "\twhile(T--)in(x),printf(\"%lld %d\\n\",get_Sphi(x),get_Smiu(x));",
            "}",
            ""
        ],
        "description": "插入 杜教筛"
    }
}