[TASK]:
You will be given lines of pseudocode, your task is to write the corresponding C++ code. The pseudocode will provide detailed description of the c++ code line by line. The pseudocode is garanteed to be correct and complete.

[INSTRUCTION]:
The following libraries are already included in the code.
```cpp
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <fstream>
#include <climits>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <bitset>
using namespace std;
```
Do not include them in your code again. Please surround your code with ```cpp and ``` markers. Note that the code should correspond to the pseudocode line by line.

[PSEUDOCODE]:
edges=array of 1004 by 1004 int
degree=array of 1004 int
function dfs (get int index, int cap, pointer to int visited, pointer to int numedges, pointer to int numver, int n, return nothing)
    visited[index]=1
    for i=0 to n exclusive
        if edges[index][i] is 1
            if visited[i] is 0
                add degree[i] to numedges[cap]
                increment numver[cap]
                dfs(i, cap, visited, numedges, numver, n)
            end of the block
        end of the block
    end of the block
end of the block
define the main function
    n,m,k=int
    read n,m,k
    cap=array of k int
    for i=0 to k exclusive
        read cap[i]
        decrement cap[i]
    end of the block
    a,b=int
    visited = array of n int
    for i=0 to n exclusive
        visited[i]=0
        degree[i]=0
    end of the block
    for i=0 to m exclusive
        read a,b
        decrement a
        decrement b
        edges[a][b]=1
        edges[b][a]=1
        increment degree[a]
        increment degree[b]
    end of the block
    numedges = array of k+1 int
    numver = array of k+1 int
    for i=0 to k-1 exclusive
        numedges[i]=0
        numver[i]=0
    end of the block
    count=0
    for i=0 to k exclusive
        dfs(cap[i], i, visited, numedges, numver, n)
        add degree[cap[i]] to numedges[i]
        increment numver[i]
    end of the block
    for i=0 to n exclusive
        if visited[i] is 0
            dfs(i, k, visited, numedges, numver, n)
            add degree[i] to numedges[k]
            increment numver[k]
        end of the block
    end of the block
    maxm=0
    maxindex=0
    ans=0
    for i=0 to k exclusive
        if numver[i] > maxm
            maxm=numver[i]
            maxindex=i
        end of the block
    end of the block
    for i=0 to k exclusive
        if i is maxindex continue
        xx=numver[i]*(numver[i]-1)
        divide xx by 2
        add (xx-numedges[i]/2) to ans
    end of the block
    xx=numver[maxindex]+numver[k]
    x2=(xx*(xx-1))/2
    subtract numedges[maxindex]/2 from x2
    subtract numedges[k]/2 from x2
    add x2 to ans
    print ans
    return to indicate successful execution
end of the block

[CODE]:

int edges[1004][1004];
int degree[1004];
void dfs(int index, int cap, int *visited, int *numedges, int *numver, int n) {
    visited[index] = 1;
    for (int i = 0; i < n; i++) {
        if (edges[index][i] == 1) {
            if (visited[i] == 0) {
                numedges[cap] += degree[i];
                numver[cap]++;
                dfs(i, cap, visited, numedges, numver, n);
            }
        }
    }
}
int main() {
    int n, m, k;
    cin >> n >> m >> k;
    int cap[k];
    for (int i = 0; i < k; i++) {
        cin >> cap[i];
        cap[i]--;
    }
    int a, b;
    int visited[n];
    for (int i = 0; i < n; i++) {
        visited[i] = 0;
        degree[i] = 0;
    }
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        a--;
        b--;
        edges[a][b] = 1;
        edges[b][a] = 1;
        degree[a]++;
        degree[b]++;
    }
    int numedges[k + 1];
    int numver[k + 1];
    for (int i = 0; i < k + 1; i++) {
        numedges[i] = 0;
        numver[i] = 0;
    }
    int count = 0;
    for (int i = 0; i < k; i++) {
        dfs(cap[i], i, visited, numedges, numver, n);
        numedges[i] += degree[cap[i]];
        numver[i] += 1;
    }
    for (int i = 0; i < n; i++) {
        if (visited[i] == 0) {
            dfs(i, k, visited, numedges, numver, n);
            numedges[k] += degree[i];
            numver[k]++;
        }
    }
    int maxm = 0;
    int maxindex = 0;
    long long ans = 0;
    for (int i = 0; i < k; i++) {
        if (numver[i] > maxm) {
            maxm = numver[i];
            maxindex = i;
        }
    }
    for (int i = 0; i < k; i++) {
        if (i == maxindex) continue;
        long long xx = numver[i] * (numver[i] - 1);
        xx /= 2;
        ans += (xx - numedges[i] / 2);
    }
    long long xx = numver[maxindex] + numver[k];
    long long x2 = (xx * (xx - 1)) / 2;
    x2 -= numedges[maxindex] / 2;
    x2 -= numedges[k] / 2;
    ans += x2;
    cout << ans << endl;
    return 0;
}