malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, k, x;       cin >> n >> k;       char s;       string str;       int p = n / k, q = n % k;       for (int i = 0; i < k; ++i) {         x = i + 97;         s = x;         if (i == k - 1) p = p + q;         for (int j = 0; j < p; ++j) str += s;       }       cout << str << endl;     }   }
#include<bits/stdc++.h>   using namespace std;   typedef long long ll;   const int maxn=405;   const int P=998244353;   ll dp[2][maxn][maxn][3][3],sum[maxn][maxn];   int cur,las,n,c[26];   void add(ll &dpp,ll add) {    add%=P;    while(add<0) add+=P;    dpp+=add;    while(dpp>=P) dpp-=P;   }   int main() {    scanf( %d ,&n);    for(int i=0;i<26;++i)     scanf( %d ,&c[i]);    dp[0][0][0][0][0]=1;    las=1;cur=0;    for(int i=1;i<=n;++i) {     swap(las,cur);     for(int j=0;j<=i;++j)      for(int k=0;k<=i;++k)       for(int l=0;l<3;++l)        for(int m=0;m<3;++m)         dp[cur][j][k][l][m]=0;     for(int j=0;j<=i;++j)      for(int k=0;k<=i;++k)       for(int l=0;l<3;++l)        for(int m=0;m<3;++m) {         if(!dp[las][j][k][l][m])continue;         add(dp[cur][j][k][m][0],1LL*dp[las][j][k][l][m]*((l||(i<=2))?24:23)%P);         if(l!=1) add(dp[cur][j+1][k][m][1],dp[las][j][k][l][m]);         if(l!=2) add(dp[cur][j][k+1][m][2],dp[las][j][k][l][m]);        }    }     for(int i=0;i<=n;++i)     for(int j=0;j<=n;++j)      for(int k=0;k<3;++k)       for(int kk=0;kk<3;++kk)        add(sum[i][j],dp[cur][i][j][k][kk]);    for(int i=n;i>=0;--i)     for(int j=n;j>=0;--j)      add(sum[i][j],sum[i+1][j]+sum[i][j+1]-sum[i+1][j+1]);    ll res=1;    for(int i=1;i<=n;++i)     res=res*((i<=2)?26:25)%P;    for(int i=0;i<26;++i)     add(res,-sum[c[i]+1][0]);    for(int i=0;i<26;++i)     for(int j=i+1;j<26;++j)      add(res,sum[c[i]+1][c[j]+1]);    res+=P;    res%=P;    printf( %lld n ,res);   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     a = abs(a), b = abs(b);     if (a < b) swap(a, b);     return b ? gcd(b, a % b) : a;   }   vector<vector<int> > adj;   set<int> st;   const int dx[] = {0, 0, -1, 1};   const int dy[] = {-1, 1, 0, 0};   long long n, ary[300000 + 5] = {4, 8, 15, 16, 23, 42}, dp[300000 + 5];   int main(void) {     ios::sync_with_stdio(false), cin.tie(NULL);     cin >> n;     for (int i = 0, j, x; i < n; ++i) {       cin >> x;       j = lower_bound(ary, ary + 6, x) - ary;       if (j == 0)         dp[0] += 1;       else if (dp[j - 1]) {         dp[j - 1] -= 1;         dp[j] += 1;       }     }     cout << n - dp[5] * 6;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v[100001];   int n, cost[100001];   int gr, nod, gr2;   void DFS(int x, int t, int val) {     for (int i = 1; i <= v[x][0]; i++) {       if (v[x][i] != t) {         if (val == 0) {           DFS(v[x][i], x, cost[v[x][i]]);         } else {           if (val != cost[v[x][i]]) {             gr++;             if (nod != x) gr2++;             nod = x;           }           DFS(v[x][i], x, cost[v[x][i]]);         }       }     }   }   int main() {     int a, b, i, j;     cin >> n;     for (i = 1; i <= n; i++) {       v[i].push_back(0);     }     for (i = 1; i < n; i++) {       cin >> a >> b;       v[a][0]++;       v[b][0]++;       v[a].push_back(b);       v[b].push_back(a);     }     for (i = 1; i <= n; i++) cin >> cost[i];     DFS(1, 0, 0);     if (gr2 <= 2) {       if (gr == 0) {         cout <<  YES               <<   n               << 1;       } else {         gr = 0;         DFS(nod, 0, 0);         if (gr != 0) {           cout <<  NO ;         } else {           cout <<  YES ;           cout <<   n  << nod;         }       }     } else {       cout <<  NO ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Ans[1001], A[1001], B[1001], C[1001], D[1001], E[1001];   int value(int Arr[], int i, int j, int k) {     return (Arr[j] - Arr[i]) * (Arr[k] - Arr[i]);   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> A[i] >> B[i] >> C[i] >> D[i] >> E[i];     }     int index = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (j != i) {           for (int k = 0; k < n; k++) {             if (k != i && k != j) {               if ((value(A, i, j, k) + value(B, i, j, k) + value(C, i, j, k) +                    value(D, i, j, k) + value(E, i, j, k)) > 0) {                 Ans[i] = -1;                 break;               }             }           }         }       }     }     int count = 0;     for (int i = 0; i < n; i++) {       if (Ans[i] != -1) {         count++;       }     }     cout << count << endl;     for (int i = 0; i < n; i++) {       if (Ans[i] != -1) {         cout << i + 1 << endl;         count++;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int T;     cin >> T;     while (T--) {       int N;       cin >> N;       vector<int> a(N);       ;       for (int& x : a) cin >> x;       int ans = (a[0] == 1);       for (int i = 1; i < N; ++i) {         if (a[i] == 0) continue;         int j = i;         while (j < N && a[j] == 1) ++j;         ans += (j - i) / 3;         i = j - 1;       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using Vi = vector<int>;   using Pii = pair<int, int>;   int uplg(int n) { return 32 - __builtin_clz(n); }   int uplg(ll n) { return 64 - __builtin_clzll(n); }   void run();   int main() {     cin.sync_with_stdio(0);     cin.tie(0);     cout << fixed << setprecision(12);     run();     cout << flush;     _Exit(0);   }   ll ch2(ll n) { return n * (n - 1) / 2; }   ll ch3(ll n) { return n * (n - 1) * (n - 2) / 6; }   void run() {     int n;     double p;     cin >> n >> p;     constexpr ll SCALE = 10000;     ll pScaled = llround(p * SCALE);     ll low = pScaled * ch3(n) * 2;     for (int a = (0); a < (n + 1); a++) {       ll cur = (ch3(a) * 2 + ch2(a) * (n - a) * 2 + a * ch2(n - a)) * SCALE;       if (cur >= low) {         cout << a <<   n ;         return;       }     }     assert(0);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string q[41];     long long n, p, i, count = 1, check = 1;     cin >> n >> p;     for (i = 0; i < n; i++) cin >> q[i];     for (i = n - 2; i >= 0; i--) {       if (q[i] ==  halfplus ) {         count = count * 2 + 1;         check++;       } else         count = count * 2;     }     cout << p * count - (p / 2) * check << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve();   const int N = 10000005;   long long i, j, n, s;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     while (t--) {       solve();       cout <<   n ;     }     return 0;   }   void solve() {     cin >> n;     for (i = 1; i <= n; i = i * 10) {       s += n - i + 1;     }     cout << s;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007;   int main() {     long long dp[3001][100][2] = {0};     long long n, l;     cin >> n >> l;     vector<long long> a(n), b(n);     for (long long i = 0; i < n; ++i) {       cin >> a[i] >> b[i];       dp[a[i]][i][0] = 1;       dp[b[i]][i][1] = 1;     }     for (long long i = 1; i <= l; ++i) {       for (long long j = 0; j < n; ++j) {         for (long long k = 0; k < n; ++k) {           if (j != k) {             if (a[j] == b[k] && i - a[j] >= 0) {               dp[i][j][0] = (dp[i][j][0] + dp[i - a[j]][k][0]) % mod;             }             if (a[j] == a[k] && a[k] != b[k] && i - a[j] >= 0) {               dp[i][j][0] = (dp[i][j][0] + dp[i - a[j]][k][1]) % mod;             }             if (b[j] == b[k] && a[j] != b[j] && i - b[j] >= 0) {               dp[i][j][1] = (dp[i][j][1] + dp[i - b[j]][k][0]) % mod;             }             if (b[j] == a[k] && a[j] != b[j] && a[k] != b[k] && i - b[j] >= 0) {               dp[i][j][1] = (dp[i][j][1] + dp[i - b[j]][k][1]) % mod;             }           }         }       }     }     long long res = 0;     for (long long i = 0; i < n; ++i) {       res = (res + dp[l][i][0]) % mod;       if (a[i] != b[i]) res = (res + dp[l][i][1]) % mod;     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int par[100005], val[100005];   int lefm[100005], rim[100005];   int root = 0;   vector<vector<int> > adjl;   int n;   void pre(int node) {     if (adjl[node].size() == 0) {       lefm[node] = val[node];       rim[node] = val[node];       return;     }     for (int i = (0); i < (adjl[node].size()); ++i) {       pre(adjl[node][i]);       if (val[adjl[node][i]] < val[node])         lefm[node] = lefm[adjl[node][i]];       else         rim[node] = rim[adjl[node][i]];     }   }   double res[100005];   pair<int, int> qu[100005];   void query(int node, int left, int right, long long cost, int dep) {     if (adjl[node].size() == 0) {       for (int i = (left); i < (right); ++i) res[qu[i].second] += cost * 1. / dep;       return;     }     int ind = lower_bound(qu + left, qu + right, make_pair(val[node], 0)) - qu;     if (ind > left && adjl[node].size() == 2)       query(adjl[node][0], left, ind, cost + lefm[adjl[node][1]], dep + 1);     if (ind < right && adjl[node].size() == 2)       query(adjl[node][1], ind, right, cost + rim[adjl[node][0]], dep + 1);   }   int main() {     int x, y, k;     scanf( %d , &n);     adjl.clear();     adjl.resize(n);     for (int i = (0); i < (n); ++i) {       scanf( %d %d , &x, &y);       x--;       val[i] = y;       par[i] = x;       if (x >= 0) adjl[x].push_back(i);       if (x < 0) root = i;     }     for (int i = (0); i < (adjl.size()); ++i) {       if (adjl[i].size() == 2)         if (val[adjl[i][0]] > val[adjl[i][1]]) swap(adjl[i][0], adjl[i][1]);       if (adjl[i].size() == 1) throw 2;     }     pre(root);     scanf( %d , &k);     for (int i = (0); i < (k); ++i) scanf( %d , &qu[i].first), qu[i].second = i;     sort(qu, qu + k);     query(root, 0, k, 0, 0);     for (int i = (0); i < (k); ++i) printf( %.12lf n , res[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long double judge1(long long k, long long d, long long t) {     long double ans;     long double unit = k + (d - k) * 1.0 / 2;     ans = floor(t / unit) * d;     long double res = t * 1.0 - floor(t / unit) * unit;     if (res <= k) {       ans += res;       return ans;     } else {       ans += k;       res -= k;     }     ans += (res * 2);     return ans;   }   long double judge2(long long k, long long d, long long t) {     long double ans;     ans = t;     return ans;   }   long double judge3(long long k, long long d, long long t) {     long double ans;     long double unitt = (k / d + 1) * d * 1.0;     long double unitw = k + (unitt - k) / 2.0;     ans += floor(t / unitw) * unitt;     long double res = t - floor(t / unitw) * unitw;     if (fabs(res - k) <= 1e-9 || res < k) {       ans += res;       return ans;     } else {       ans += k;       res -= k;     }     ans += (res * 2.0);     return ans;   }   int main() {     ios::sync_with_stdio(false);     long long k, d, t;     while (cin >> k >> d >> t) {       long double ans;       if (k < d)         ans = judge1(k, d, t);       else if (k % d == 0)         ans = judge2(k, d, t);       else         ans = judge3(k, d, t);       cout << fixed << setprecision(1) << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, k;     cin >> n >> k;     vector<bool> pref(1 << n);     for (int i = 0; i < k; i++) {       int x;       cin >> x;       pref[x - 1] = true;     }     const int oo = -1;     vector<vector<vector<int>>> dp(         4, vector<vector<int>>(n + 1, vector<int>(1 << n, oo)));     for (int i = 0; i < (1 << n); i += 2) {       if (pref[i] && pref[i + 1])         dp[3][1][i] = 1;       else if (pref[i] || pref[i + 1])         dp[1][1][i] = dp[2][1][i] = 1;       else         dp[0][1][i] = 0;     }     for (int i = 2; i <= n; i++)       for (int j = 0; j < (1 << n); j += (1 << i))         for (int p = 0; p < 4; p++)           for (int q = 0; q < 4; q++)             if (dp[p][i - 1][j] != -1 && dp[q][i - 1][j + (1 << (i - 1))] != -1) {               int t = dp[p][i - 1][j] + dp[q][i - 1][j + (1 << (i - 1))];               int upper = ((p & 2) > 0) + ((q & 2) > 0);               int lower = ((p & 1) + (q & 1));               if (upper == 2) {                 t += (lower > 0) + 2;                 dp[3][i][j] = max(dp[3][i][j], t);                 if (lower < 2) dp[2][i][j] = max(dp[2][i][j], t);               } else if (upper == 1) {                 t += (lower > 0) + 1;                 if (lower == 0) {                   dp[2][i][j] = max(dp[2][i][j], t);                   dp[1][i][j] = max(dp[1][i][j], t + 1);                   dp[0][i][j] = max(dp[0][i][j], t + 1);                 }                 if (lower == 1) {                   dp[3][i][j] = max(dp[3][i][j], t + 1);                   dp[2][i][j] = max(dp[2][i][j], t + 1);                   dp[1][i][j] = max(dp[1][i][j], t + 1);                   dp[0][i][j] = max(dp[0][i][j], t + 1);                 }                 if (lower == 2) {                   dp[3][i][j] = max(dp[3][i][j], t + 1);                   dp[2][i][j] = max(dp[2][i][j], t + 1);                   dp[1][i][j] = max(dp[1][i][j], t + 1);                 }               } else if (upper == 0) {                 t += (lower > 0);                 if (lower == 0) dp[0][i][j] = max(dp[0][i][j], t);                 if (lower == 1) {                   dp[1][i][j] = max(dp[1][i][j], t + 1);                   dp[0][i][j] = max(dp[0][i][j], t + 1);                 }                 if (lower == 2) {                   dp[1][i][j] = max(dp[1][i][j], t + 1);                   dp[0][i][j] = max(dp[0][i][j], t + 1);                 }               }             }     int ans = 0;     for (int p = 0; p < 4; p++) ans = max(dp[p][n][0] + (p > 0), ans);     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int l[2005], r[2005];   long long k, w[2005];   long long s[2005][2005];   long long f[2005];   long long h[2005];   long long up(long long x) { return (x / k + (x % k > 0)); }   int main() {     cin >> n >> k;     for (int i = (1); i <= (n); i++) cin >> l[i] >> r[i] >> w[i];     for (int i = (1); i <= (n); i++) h[i] = -1;     for (int i = (1); i <= (n); i++)       for (int j = (1); j <= (n); j++) s[i][j] = -1;     for (int i = (1); i <= (n); i++) {       long long start = k;       long long has = 0;       for (int j = (i); j <= (n); j++) {         if (start >= w[j]) {           if (l[j] < l[j + 1]) s[i][j] = has + start;           has += w[j];           start -= w[j];           if (j == n) h[i] = has;         } else {           long long t = up(w[j] - start) + 1;           if (t > r[j] - l[j] + 1) break;           if (l[j] + t - 1 < l[j + 1]) s[i][j] = has + (t - 1) * k + start;           has += w[j];           if (j == n) h[i] = has;           start = start + (t - 1) * k - w[j];         }       }     }     for (int i = (1); i <= (n - 1); i++) {       f[i] = -1;       for (int j = (i - 1); j >= (0); j--) {         if (s[j + 1][i] >= 0 && f[j] >= 0)           if (f[i] < 0 || f[j] + s[j + 1][i] < f[i]) f[i] = f[j] + s[j + 1][i];       }     }     long long ans = -1;     for (int i = (0); i <= (n - 1); i++)       if (f[i] >= 0 && h[i + 1] >= 0) {         if (ans < 0 || f[i] + h[i + 1] < ans) ans = f[i] + h[i + 1];       }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 310;   int n, a[maxn];   int main() {     scanf( %d , &n);     for (int i = (1); i <= (n); ++i) scanf( %d , &a[i]);     for (int i = (1); i <= (n - 1); ++i) {       for (int j = (1); j <= (a[i]); ++j) printf( PRL );       printf( R );     }     for (int j = (1); j <= (a[n]); ++j) printf( LRP );   }
#include <bits/stdc++.h>   using namespace std;   long long n, h, ok;   long long cal(long long dep, long long pos, int tag) {     if (ok) return 0;     if (dep == 0) {       ok = 1;       return 0;     }     long long tmp;     if (!tag) {       if (pos > (1LL << (dep - 1)))         tmp = (1LL << dep) + cal(dep - 1, pos - (1LL << (dep - 1)), 0);       else         tmp = 1LL + cal(dep - 1, pos, 1);     } else {       if (pos > (1LL << (dep - 1)))         tmp = 1LL + cal(dep - 1, pos - (1LL << (dep - 1)), 0);       else         tmp = (1LL << dep) + cal(dep - 1, pos, 1);     }     return tmp;   }   int main() {     while (cin >> h >> n) {       ok = 0;       cout << cal(h, n, 0) << endl;     }   }
#include <bits/stdc++.h>   long long a[100][100];   using namespace std;   struct DynamicDisjointSetDS {     std::unordered_map<int, int> parent, degree;     int N;     DynamicDisjointSetDS(int n) { N = n; }     int getParent(int vertex) {       if (parent.find(vertex) != parent.end()) {         if (parent[vertex] != vertex) {           parent[vertex] = getParent(parent[vertex]);           return parent[vertex];         }       } else {         parent.insert(make_pair(vertex, vertex));         degree.insert(make_pair(vertex, 1));       }       return vertex;     }     void Union(int vertexA, int vertexB) {       int x = getParent(vertexA);       int y = getParent(vertexB);       if (x == y) return;       if (degree[x] > degree[y]) {         parent[y] = x;         degree[x] = degree[x] + degree[y];       } else {         parent[x] = y;         degree[y] = degree[y] + degree[x];       }     }     int GetTotalComponent() {       unordered_set<int> total;       for (auto itr = parent.begin(); itr != parent.end(); itr++) {         total.insert(getParent(itr->first));       }       return N - parent.size() + total.size();     }   };   int main() {     using namespace std;     long long n, m, q;     cin >> n >> m >> q;     unordered_set<long long> s, s2;     for (long long i = 1; i <= n; i++) {       s.insert(i);     }     for (long long i = 1; i <= m; i++) {       s2.insert(i);     }     DynamicDisjointSetDS ds(m + 1);     vector<vector<long long>> v(m + 1);     while (q--) {       long long r, c;       cin >> r >> c;       v[c].push_back(r);       s.erase(r);       s2.erase(c);     }     for (vector<long long> v2 : v) {       for (long long i = 1; i < v2.size(); i++) {         ds.Union(v2[i], v2[i - 1]);       }     }     unordered_set<long long> sc;     for (long long i = 1; i <= n; i++) {       sc.insert(ds.getParent(i));     }     cout << (s2.size() + sc.size() - 1) << endl;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int f = 1, x = 0;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -f;       c = getchar();     }     while (c >=  0  && c <=  9 ) x = x * 10 + c -  0 , c = getchar();     return f * x;   }   inline int lowbit(int x) { return x & (-x); }   inline int modadd(int x, int y) {     return (x + y >= 1000000007 ? x + y - 1000000007 : x + y);   }   inline int sgn(int x) { return (x < 0 ? -1 : (x > 0 ? 1 : 0)); }   template <typename T>   T gcd(T a, T b) {     return (!b) ? a : gcd(b, a % b);   }   int poww(int a, int b) {     int res = 1;     while (b > 0) {       if (b & 1) res = 1ll * res * a % 1000000007;       a = 1ll * a * a % 1000000007, b >>= 1;     }     return res;   }   const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};   const int ddx[] = {-1, -1, -1, 0, 0, 1, 1, 1},             ddy[] = {-1, 0, 1, -1, 1, -1, 0, 1};   int n, a[100005];   void init() {     n = read();     for (int i = 1; i <= n; ++i) a[i] = read();   }   bool check1() {     long long tot = 0;     for (int i = n - 1; i >= 1; --i) {       if (a[i] < tot) return false;       if (a[i] > a[i + 1]) tot += a[i] - a[i + 1];     }     return true;   }   bool check2() {     long long tot = 0;     for (int i = 2; i <= n; ++i) {       if (a[i] < tot) return false;       if (a[i] > a[i - 1]) tot += a[i] - a[i - 1];     }     return true;   }   void solve() {     if (check1())       printf( YES n );     else if (check2())       printf( YES n );     else       printf( NO n );   }   int main() {     int T = read();     while (T--) {       init();       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct grp {     long long to, wt, edgeCode;     char type;   };   struct Node {     long long x, dis;   };   struct comp {     inline bool operator()(const Node& n1, const Node& n2) const {       if (n1.dis != n2.dis) return n1.dis < n2.dis;       return n1.x < n2.x;     }   };   void dijkstra(long long n, vector<vector<grp> >& edges, vector<long long>& dis,                 vector<bool>& visited, vector<pair<long long, long long> >& par) {     set<Node, comp> myset;     for (long long i = 1; i <= n; ++i) {       Node node;       node.x = i, node.dis = dis[i];       myset.insert(node);     }     while (myset.size()) {       set<Node>::iterator it = myset.begin();       Node node = *it;       myset.erase(it);       visited[node.x] = true;       for (long long i = 0; i < edges[node.x].size(); ++i) {         grp& edge = edges[node.x][i];         if (visited[edge.to]) {           continue;         }         long long newDis = dis[node.x] + edge.wt;         if (newDis < dis[edge.to] ||             (newDis == dis[edge.to] && edge.type ==  r )) {           Node prevNode, newNode;           prevNode.x = edge.to, prevNode.dis = dis[edge.to];           newNode.x = edge.to, newNode.dis = newDis;           dis[edge.to] = newDis;           par[edge.to] = {node.x, edge.edgeCode};           myset.erase(myset.find(prevNode));           myset.insert(newNode);         }       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long n, m, k;     cin >> n >> m >> k;     vector<vector<grp> > edges(n + 1);     long long edgeCode = 0;     for (long long i = 0; i < m; i++) {       long long x, y, w;       cin >> x >> y >> w;       grp g;       g.to = y, g.wt = w, g.type =  r , g.edgeCode = edgeCode++;       edges[x].push_back(g);       g.to = x, g.edgeCode = edgeCode++;       edges[y].push_back(g);     }     vector<pair<long long, long long> > trainPaths(k);     for (long long i = 0; i < k; ++i) {       long long y, w;       cin >> y >> w;       trainPaths[i] = {y, edgeCode};       grp g;       g.to = y, g.wt = w, g.type =  t , g.edgeCode = edgeCode++;       edges[1].push_back(g);     }     vector<long long> dis(n + 1, 100000000000000000);     vector<bool> visited(n + 1, false);     vector<pair<long long, long long> > par(n + 1, {-1, -1});     dis[1] = 0;     dijkstra(n, edges, dis, visited, par);     long long ans = 0;     for (long long i = 0; i < k; ++i) {       long long dest = trainPaths[i].first, edgeCode = trainPaths[i].second;       if (par[dest].first == 1 && par[dest].second == edgeCode) {         continue;       }       ++ans;     }     cout << ans << endl;     return 0;   }