Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MAXN 500010
struct _node
{
    int u,v,w;
    bool operator < (const _node &b) const
    {
        return w<b.w;
    }
}no[MAXN];
struct _query
{
    int t,id;
    bool operator < (const _query &b) const
    {
        return t<b.t;
    }
}query[MAXN];
int fa[MAXN],ran[MAXN],ans[MAXN],sum;
int findfa(int n)
{
    if(fa[n]!=n)
        fa[n]=findfa(fa[n]);
    return fa[n];
}
inline void mul(int a,int b)
{
    a=findfa(a),b=findfa(b);
    int af=ran[a],bf=ran[b];
    if(a==b)    return ;
    if(af<bf)   swap(a,b);
    fa[b]=a,ran[a]+=ran[b];
    sum-=af*(af-1),sum-=bf*(bf-1);
    sum+=ran[a]*(ran[a]-1);
}
int main()
{
    //freopen(\\\"/home/moor/Code/input\\\",\\\"r\\\",stdin);
    int n,m,q;
    while(scanf(\\\"%d%d\\\",&n,&m)==2)
    {
        for(int i=0;i<m;++i)
            scanf(\\\"%d%d%d\\\",&no[i].u,&no[i].v,&no[i].w),++no[i].u,++no[i].v;
        for(int i=1;i<=n;++i)   fa[i]=i,ran[i]=1;
        sort(no,no+m);
        scanf(\\\"%d\\\",&q);
        for(int i=0;i<q;++i)    scanf(\\\"%d\\\",&query[i].t),query[i].id=i;
        sort(query,query+q);
        sum=0;
        int l=0;
        for(int i=0;i<q;++i)
        {
            while(l<m&&no[l].w<query[i].t)
                mul(no[l].u,no[l].v),++l;
            ans[query[i].id]=sum;
        }
        while(l<m)  mul(no[l].u,no[l].v),++l;
        for(int i=0;i<q;++i)    printf(\\\"%d\\\\n\\\",sum-ans[i]);
    }
    return 0;
}

Compiler output:
a.cc:44:17: error: stray '\' in program
   44 |     while(scanf(\\\"%d%d\\\",&n,&m)==2)
      |                 ^
a.cc:44:18: error: stray '\' in program
   44 |     while(scanf(\\\"%d%d\\\",&n,&m)==2)
      |                  ^
a.cc:44:19: error: stray '\' in program
   44 |     while(scanf(\\\"%d%d\\\",&n,&m)==2)
      |                   ^
a.cc:44:20: warning: missing terminating " character
   44 |     while(scanf(\\\"%d%d\\\",&n,&m)==2)
      |                    ^
a.cc:44:20: error: missing terminating " character
   44 |     while(scanf(\\\"%d%d\\\",&n,&m)==2)
      |                    ^~~~~~~~~~~~~~~~~~~~
a.cc:47:19: error: stray '\' in program
   47 |             scanf(\\\"%d%d%d\\\",&no[i].u,&no[i].v,&no[i].w),++no[i].u,++no[i].v;
      |                   ^
a.cc:47:20: error: stray '\' in program
   47 |             scanf(\\\"%d%d%d\\\",&no[i].u,&no[i].v,&no[i].w),++no[i].u,++no[i].v;
      |                    ^
a.cc:47:21: error: stray '\' in program
   47 |             scanf(\\\"%d%d%d\\\",&no[i].u,&no[i].v,&no[i].w),++no[i].u,++no[i].v;
      |                     ^
a.cc:47:22: warning: missing terminating " character
   47 |             scanf(\\\"%d%d%d\\\",&no[i].u,&no[i].v,&no[i].w),++no[i].u,++no[i].v;
      |                      ^
a.cc:47:22: error: missing terminating " character
   47 |             scanf(\\\"%d%d%d\\\",&no[i].u,&no[i].v,&no[i].w),++no[i].u,++no[i].v;
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:50:15: error: stray '\' in program
   50 |         scanf(\\\"%d\\\",&q);
      |               ^
a.cc:50:16: error: stray '\' in program
   50 |         scanf(\\\"%d\\\",&q);
      |                ^
a.cc:50:17: error: stray '\' in program
   50 |         scanf(\\\"%d\\\",&q);
      |                 ^
a.cc:50:18: warning: missing terminating " character
   50 |         scanf(\\\"%d\\\",&q);
      |                  ^
a.cc:50:18: error: missing terminating " character
   50 |         scanf(\\\"%d\\\",&q);
      |                  ^~~~~~~~~~~~
a.cc:51:39: error: stray '\' in program
   51 |         for(int i=0;i<q;++i)    scanf(\\\"%d\\\",&query[i].t),query[i].id=i;
      |                                       ^
a.cc:51:40: error: stray '\' in program
   51 |         for(int i=0;i<q;++i)    scanf(\\\"%d\\\",&query[i].t),query[i].id=i;
      |                                        ^
a.cc:51:41: error: stray '\' in program
   51 |         for(int i=0;i<q;++i)    scanf(\\\"%d\\\",&query[i].t),query[i].id=i;
      |                                         ^
a.cc:51:42: warning: missing terminating " character
   51 |         for(int i=0;i<q;++i)    scanf(\\\"%d\\\",&query[i].t),query[i].id=i;
      |                                          ^
a.cc:51:42: error: missing terminating " character
   51 |         for(int i=0;i<q;++i)    scanf(\\\"%d\\\",&query[i].t),query[i].id=i;
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:62:40: error: stray '\' in program
   62 |         for(int i=0;i<q;++i)    printf(\\\"%d\\\\n\\\",sum-ans[i]);
      |                                        ^
a.cc:62:41: error: stray '\' in program
   62 |         for(int i=0;i<q;++i)    printf(\\\"%d\\\\n\\\",sum-ans[i]);
      |                                         ^
a.cc:62:42: error: stray '\' in program
   62 |         for(int i=0;i<q;++i)    printf(\\\"%d\\\\n\\\",sum-ans[i]);
      |                                          ^
a.cc:62:43: warning: missing terminating " character
   62 |         for(int i=0;i<q;++i)    printf(\\\"%d\\\\n\\\",sum-ans[i]);
      |                                           ^
a.cc:62:43: error: missing terminating " character
   62 |         for(int i=0;i<q;++i)    printf(\\\"%d\\\\n\\\",sum-ans[i]);
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:46:9: error: expected primary-expression before 'for'
   46 |         for(int i=0;i<m;++i)
      |         ^~~
a.cc:46:9: error: expected '}' before 'for'
a.cc:45:5: note: to match this '{'
   45 |     {
      |     ^
a.cc:45:6: error: expected ')' before 'for'
   45 |     {
      |      ^
      |      )
   46 |         for(int i=0;i<m;++i)
      |         ~~~
a.cc:44:16: note: to match this '('
   44 |     while(scanf(\\\"%d%d\\\",&n,&m)==2)
      |                ^
a.cc:46:20: error: expected ')' before ';' token
   46 |         for(int i=0;i<m;++i)
      |                    ^
      |                    )
a.cc:44:10: note: to match this '('
   44 |     while(scanf(\\\"%d%d\\\",&n,&m)==2)
      |          ^
a.cc:46:21: error: 'i' was not declared in this scope
   46 |         for(int i=0;i<m;++i)
      |                     ^
a.cc:51:9: error: expected primary-expression before 'for'
   51 |         for(int i=0;i<q;++i)    scanf(\\\"%d\\\",&query[i].t),query[i].id=i;
      |         ^~~
a.cc:63:5: error: expected primary-expression before '}' token
   63 |     }
      |     ^
a.cc: At global scope:
a.cc:64:5: error: expected unqualified-id before 'return'
   64 |     return 0;
      |     ^~~~~~
a.cc:65:1: error: expected declaration before '}' token
   65 | }
      | ^