[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]:
create integer array dx of size 8 containing {0, 0, 1, 1, 1, -1, -1, -1}
create int array dy of size 8 containing {1, -1, -1, 0, 1, -1, 0, 1}
let integer vector v of size 1005
make bool array vis of size 1005
create int flag = 0 and cnt and int array dd of size 1005
declare dfs taking in int s
    set vis[s] to true
    increment cnt
    if dd[s] is truthy, set flag to 1
    for i = 0 to size of v[s] exclusive
        if vis[v[s][i]] is falsy, call dfs(v[s][i])
    end of the block
    end function
end of the block
define the main function
    create ints n, m, k, a, and b
    create long long ints maxx = 0, ans = 0, and cnt1 = 0
    make long long vector vec
    read n, m, and k
    while k-- is truthy
        read a
        set dd[a] to 1
    end of the block
    create int ml = m
    while m1-- is falsy
        read a and b
        append b to v[a]
        append a to v[b]
    end of the block
    for i = 1 to n
        if vis[i] is falsy
            set cnt and flag to 0
            call dfs with argument i
            if flag is equal to 0
                set cnt1 to cnt1 + cnt
            else
                set maxx to (cnt < maxx ? maxx : cnt)
                append cnt to vec
            end of the block
        end of the block
    end of the block
    for i = 0 to size of vec exclusive
        if vec[i] is equal to maxx
            set cnt1 to cnt 1 + vec[i]
            set ans to ans + (cnt1 * (cnt1 - 1)) / 2
            increment maxx
        else do
            set ans to ans + (vec[i] * (vec[i] - 1)) / 2
        end of the block
    end of the block
    print the result of (ans - m)
    return to indicate successful execution
end of the block

[CODE]:

int dx[8] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy[8] = {1, -1, -1, 0, 1, -1, 0, 1};
vector<int> v[1005];
bool vis[1005];
int flag = 0, cnt, dd[1005];
void dfs(int s) {
    vis[s] = true;
    cnt++;
    if (dd[s]) flag = 1;
    for (int i = 0; i < v[s].size(); i++) {
        if (!vis[v[s][i]]) dfs(v[s][i]);
    }
    return;
}
int main() {
    int n, m, k, a, b;
    long long maxx = 0, ans = 0, cnt1 = 0;
    vector<long long> vec;
    cin >> n >> m >> k;
    while (k--) {
        cin >> a;
        dd[a] = 1;
    }
    int m1 = m;
    while (m1--) {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
            cnt = 0, flag = 0;
            dfs(i);
            if (flag == 0)
                cnt1 += cnt;
            else {
                maxx = (cnt < maxx ? maxx : cnt);
                vec.push_back(cnt);
            }
        }
    }
    for (int i = 0; i < vec.size(); i++) {
        if (vec[i] == maxx) {
            cnt1 += vec[i];
            ans += (cnt1 * (cnt1 - 1)) / 2;
            maxx++;
        } else {
            ans += (vec[i] * (vec[i] - 1)) / 2;
        }
    }
    cout << (ans - m) << endl;
    return 0;
}