#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
#include <limits>
#include <unordered_map>
using namespace std;
// int cnt = 0;

int min_distance(vector<pair<int, int>> &dist, vector<int> &vis, int n)
{
    int mini = 100000;
    int min_index = -1;

    for (int v = 1; v <= n; v++)
    {
        if (vis[v] == 0 && dist[v].first <= mini)
        {
            mini = dist[v].first, min_index = v;
        }
    }
    return min_index;
}
void dijkstra(vector<vector<int>> &graph, int src, int n, vector<pair<int, int>> &dist)
{
    vector<int> vis(n + 1, 0);

    for (int i = 1; i <= n; i++)
        dist[i].first = 100000;
    dist[src].first = 0;

    for (int count = 0; count < n; count++)
    {
        int u = min_distance(dist, vis, n);
        if (u == -1)
            break;

        vis[u] = 1;

        for (int v = 1; v <= n; v++)
        {
            if (vis[v] == 0 && graph[u][v] != 100000 &&
                dist[u].first != 100000 && dist[u].first + graph[u][v] < dist[v].first)
            {
                dist[v].first = dist[u].first + graph[u][v];
            }
        }
    }
}

void add_edge(vector<vector<int>> &adj, int u, int v, int l)
{
    if (u >= 1 && u < adj.size() && v >= 1 && v < adj.size())
    {
        adj[u][v] = l;
        adj[v][u] = l;
    }
}

void func(vector<vector<int>> &adj1, vector<pair<int, int>> &dist1, vector<int> &adj2, int n, int cnt)
{
    // int cnt = 0;
    //  for (int i = 0; i < dist1.size(); i++)
    // {
    //     cout << i << " " << dist1[i] << endl;
    // }
    // cout<<n<<"is n"<<endl;
    for (int i = 1; i <= n; i++)
    {
        cout << adj2[i] << "is my adj of " << i << endl;
        cout << dist1[i].first << "is my dist1 of " << i << endl;
        if (adj2[i] != 100000)
        {
            if (dist1[i].first <= adj2[i])
            {
                cnt++;
                cout << cnt << "in func and i is " << i << endl;
            }
            else
            {
                dist1[i].first = adj2[i];

                if (dist1[i].second == 1)
                {
                    cnt++;
                    cout << "aaaa";
                }
                
                    dist1[i].second = 1;

                add_edge(adj1, 1, i, dist1[i].first);

                cout << "changed dist of " << i << " is " << dist1[i].first << endl;
                dijkstra(adj1, 1, n, dist1);
            }
        }
    }
    cout << cnt;
    //<< endl
    // << endl;
}

int main()
{
    int cnt = 0;
    int n, m, k;
    cin >> n >> m >> k;
    vector<vector<int>> adj1(n + 1, vector<int>(n + 1, 100000));
    // vector<vector<int>> adj2(n + 1, vector<int>(n + 1, 100000));
    vector<int> adj2(n, 100000);
    vector<pair<int, int>> dist1(n + 1, {100000, 0});
    // vector<int> dist1(n + 1, 100000);
    //, dist2(n + 1, 100000);
    dist1[1].first = 0;
    for (int i = 0; i < m; i++)
    {
        int u, v, l;
        cin >> u >> v >> l;
        if (adj1[u][v] != 100000)
        {
            if (adj1[u][v] > l)
            {
                add_edge(adj1, u, v, l);
            }
        }
        else
        {
            add_edge(adj1, u, v, l);
        }
    }

    for (int i = 0; i < k; i++)
    {
        int v, l;
        cin >> v >> l;
        if (adj2[v] != 100000)
        {
            cnt++;
            if (adj2[v] > l)
            {
                adj2[v] = l;
            }
        }
        else if (v == 1)
        {
            cnt++;
        }
        else
            adj2[v] = l;
        //  add_edge(adj2, 0, v, l);
    }

    dijkstra(adj1, 1, n, dist1);
    // dijkstra(adj2, 1, n, dist2);
    cout << "initially the shortest paths are" << endl
         << endl;

    for (int i = 0; i < dist1.size(); i++)
    {
        cout << i << " " << dist1[i].first << endl;
    }
    cout << endl
         << endl;
    func(adj1, dist1, adj2, n, cnt);

    for (int i = 0; i < dist1.size(); i++)
    {
        cout << i << " " << dist1[i].first << endl;
    }
    return 0;
}

modify this code to answer these test cases
// Test cases


// 1 will be connected to all the nodes via normal connection.
/*



3 2 2
1 2 3
2 3 4
3 10
3 8

// ans=2


4 5 2 
1 2 2 
1 4 9
1 3 3
2 4 4
3 4 5
3 4
4 5

// ans =1 

3 3 3
1 2 5
1 3 100
2 3 1
2 4
3 2
3 1

//ans 2



4 4 2
1 2 5
2 3 4
3 4 1
1 4 10
2 1
4 8

// ans= 1

*/


/*
basic cases:

5 6 3
1 4 5
4 5 2
2 4 7
3 1 4
1 5 10
3 2 6
5 3
2 1
4 3

// ans = 0



4 4 1
2 3 2
2 4 8
4 3 1
1 4 5
3 7
// ans = 1

3 3 3
1 2 1
2 3 1
1 3 1
2 1
2 2
3 1
3

// ans 3 

4 5 2
1 2 2
1 4 9
1 3 3
2 4 4
3 4 5
3 4
4 5


// ans = 1





4 4 2
2 3 2
2 4 8
4 3 3
1 4 5
3 7
2 9

// ans = 1




4 4 2
1 2 5
2 3 4
3 4 1
1 4 10
2 1
4 8
// ans = 1


3 3 3
1 2 5
1 3 100
2 3 1
2 4
3 2
3 1
// ans = 2





\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

// Good testcases

5 6 3
1 4 5
4 5 2
2 4 7
3 1 4
1 5 10
3 2 6
2 1
4 3
5 5

// ans = 1


6 16 19
4 1 6
2 2 19
3 1 14
3 6 14
6 5 17
6 4 2
4 6 7
2 1 7
3 5 4
6 6 13
5 4 7
2 3 6
1 2 19
4 6 14
4 2 16
2 6 13
5  9
1  3
4  12
2  12
4  18
3  17
1  1
4  8
3  15
6  15
3  17
1  18
6  11
1  10
3  16
3  11
5  20
5  3
4  7


// ans = 18




3 9 8
1 1 14
1 3 1
2 2 12
3 1 15
3 1 19
3 3 15
1 3 7
3 1 8
1 2 6
2  18
3  1
2  13
3  2
3  5
1  20
2  8
3  5


// ans = 8

6 5 4
4 4 20
1 4 15 
5 3 14
5 5 12
2 6 19
6 3
4 10
1 18
4 4
// ans = 2



8 5 6
1 8 20
3 7 11
5 6 14
2 6 17
7 4 11
8 6
7 19
5 8
6 7
2 13
3 19
// ans = 0


10 10 10
9 8 2
8 8 9
2 8 17
1 1 1
6 6 10
10 8 11
3 9 18
7 1 5
3 2 17
5 5 10
3 16
1 20
8 13
3 7
5 12
1 10
10 14
10 3
4 1
3 3
// ans = 5


10 9 5
9 7 4
1 5 18
6 6 7
7 2 9
2 6 3
8 10 9
10 4 6
6 5 14
5 9 11
2 18
7 1
2 12
5 7
2 4
// ans = 2
*/