stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long 

#define maxn 500005

#define INF 0x3f3f3f3f

using namespace std;



int n;

int a[maxn];

struct Node{

    int x, y;

    Node():x(0), y(0){}

    Node(int xx, int yy): x(xx), y(yy){}

};

vector<Node> ans;

bool vis[maxn];

int main(){

    scanf("%d", &n);

    int da = 0, xiao = 0;

    for(int i = 1; i <= n; i++){

        scanf("%d", &a[i]);

        if(a[i] >= 0) da++;

        else

            xiao++;

    }

    if(!xiao){

        sort(a + 1, a + 1 + n);

        int p = a[1];

        for(int i = 2; i <= n - 1; i++){

            ans.push_back(Node(p, a[i]));

            p -= a[i];

        }

        ans.push_back(Node(a[n], p));

        printf("%d\n", a[n] - p);

    }

    else if(!da){

        sort(a + 1, a + 1 + n);

        int p = a[n];

        for(int i = n - 1; i >= 2; i--){

            ans.push_back(Node(p, a[i]));

            p -= a[i];

        }

        ans.push_back(Node(p, a[1]));

        printf("%d\n", p - a[1]);

    }

    else{

        int fu = INF, z = INF;

        sort(a + 1, a + 1 + n);

        memset(vis, false, sizeof(vis));

        for(int i = 1; i <= n; i++){

            if(a[i] < 0 && fu == INF){

                fu = a[i];

                vis[i] = true;

                break;

            }

        }

        for(int i = n; i >= 1; i--){

            if(a[i] >= 0 && z == INF){

                z = a[i];

                vis[i] = true;

                break;

            }

        }

        for(int i = 1; i <= n; i++){

            if(!vis[i]){

                if(a[i] >= 0){

                    ans.push_back(Node(fu, a[i]));

                    fu -= a[i];

                }

                else{

                    ans.push_back(Node(z, a[i]));

                    z -= a[i];

                }

            }

        }

        ans.push_back(Node(z, fu));

        printf("%d\n", z - fu);       

    }

    for (int i = 0; i < ans.size(); i++) {

        printf("%d %d\n", ans[i].x, ans[i].y);

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 6.128900192655436x):
#include <cstdio>

#include <cstring>

#include <cmath>

#include <algorithm>

using namespace std;

const int SIZEN = 100010;

typedef long long LL;

int N;

LL a[SIZEN] = {0};

int main(){

	scanf("%d",&N);

	for(int i = 1;i <= N;i++)scanf("%lld",&a[i]);

	sort(a + 1,a + 1 + N);

	LL ans = 0;

	if(a[1] >= 0){

		for(int i = 2;i <= N;i++)ans += a[i];

		ans -= a[1];

		printf("%lld\n",ans);

		for(int i = 2;i < N;i++){

			printf("%lld %lld\n",a[1],a[i]);

			a[1] -= a[i];

		}

		printf("%lld %lld\n",a[N],a[1]);

	}

	else if(a[N] <= 0){

		for(int i = 1;i < N;i++)ans += a[i];

		ans = a[N] - ans;	

		printf("%lld\n",ans);

		for(int i = 1;i < N;i++){

			printf("%lld %lld\n",a[N],a[i]);

			a[N] -= a[i];

		}

	}

	else{

		for(int i = 1;i <= N;i++)ans += abs(a[i]);

		printf("%lld\n",ans);

		for(int i = 2;i < N;i++){

			if(a[i] < 0)printf("%lld %lld\n",a[N],a[i]),a[N] -= a[i];

			else printf("%lld %lld\n",a[1],a[i]),a[1] -= a[i];

		}

		printf("%lld %lld\n",a[N],a[1]);

	}

	return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <iostream>

#include <cmath>

#include <cstring>

#include <sstream>

#include <algorithm>

#include <cstdlib>

#include <map>

#include <queue>

#include <utility>

#include <vector>

#include <set>

#include <memory.h>

#include <iomanip>

#include <bitset>

#include <list>

#include <stack>

#include <deque>

#include <numeric>

#include <complex>



using namespace std;



#define mod 1000000007



int main()

{

	int n;

	cin >> n;

	int a[100001] = {};

	for(int i = 0; i < n; i++){

		cin >> a[i];

	}

	sort(a, a + n);



	if(n == 2){

		cout << a[1] - a[0] << endl;

		cout << a[1] << " " << a[0] << endl;

		return 0;

	}



	long long int suma[100001] = {};

	for(int i = 1; i <= n; i++){

		suma[i] = suma[i - 1] + a[i - 1];

	}

	long long int ans = -mod;

	int max_i = 0;

	for(int i = 1; i < n; i++){

		long long int tmp = (suma[n] - suma[i]) - suma[i];

		if(tmp > ans){

			ans = tmp;

			max_i = i;

		}

	}

	// cout << max_i << endl;

	// 0 ... max_i - 1 まではマイナス

	// max_i, ... , n - 1 はプラス

	cout << ans << endl;

	if(max_i == n - 1){

		long long int now = a[n - 1];

		for(int i = n - 2; i >= 0; i--){

			cout << now << " " << a[i] << endl;

			now -= a[i];

		}

		return 0;

	}

	cout << a[0] << " " << a[max_i] << endl;

	long long int now = a[0] - a[max_i];

	for(int i = max_i + 1; i < n - 1; i++){

		cout << now << " " << a[i] << endl;

		now -= a[i];

	}

	cout << a[n - 1] << " " << now << endl;

	now = a[n - 1] - now;

	for(int i = max_i - 1; i >= 1; i--){

		cout << now << " " << a[i] << endl;

		now -= a[i];

	}



}

// Faster C++ solution for the same problem (measured speedup: 1.570289351634975x):
#include <memory.h>



#include <algorithm>

#include <bitset>

#include <cmath>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <deque>

#include <iomanip>

#include <iostream>

#include <list>

#include <map>

#include <numeric>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <utility>

#include <vector>



using namespace std;



#define MOD 1000000007

#define INIT -1



int main() {

	int n;

	cin >> n;

	int a[100000];

	for (int i = 0; i < n; i++) {

		cin >> a[i];

	}

	sort(a, a + n);

	int suma[100010] = {};

	for (int i = 1; i <= n; i++) {

		suma[i] = suma[i - 1] + a[i - 1];

	}

	int ans = -MOD;

	int idx = -1;

	for (int i = 1; i < n; i++) {

		int tmp = suma[n] - suma[i] - suma[i];

		if (tmp > ans) {

			ans = tmp;

			idx = i;

		}

	}

	cout << ans << endl;

	int now = a[idx - 1];

	for (int i = idx; i < n - 1; i++) {

		cout << now << " " << a[i] << endl;

		now -= a[i];

	}

	cout << a[n - 1] << " " << now << endl;

	now = a[n - 1] - now;

	for (int i = 0; i < idx - 1; i++) {

		cout << now << " " << a[i] << endl;

		now -= a[i];

	}

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

using namespace std;



int main()

{

    int n;

    int a[100010]={};

    cin>>n;

    long long ans=0;

    for(int i=0;i<n;i++)

    {

        cin>>a[i];

    }

    sort(a,a+n);

    ans-=a[0];

    for(int i=1;i<n-1;i++)

    {

        ans+=abs(a[i]);

    }

    ans+=a[n-1];

    cout<<ans<<endl;

    int cnt=0;

    for(int i=1;i<n-1;i++)

    {

        if(a[i]<0) cnt++;

        else

        {

            cout<<a[0]<<" "<<a[i]<<endl;

            a[0]-=a[i];

        }



    }



    cout<<a[n-1]<<" "<<a[0]<<endl;

    a[n-1]-=a[0];



    for(int i=1;i<=cnt;i++)

    {

        cout<<a[n-1]<<" "<<a[i]<<endl;

        a[n-1]-=a[i];

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.4053903722385563x):
#include <iostream>

#include <algorithm>

#include <cmath>



using namespace std;



const int maxn = 1e5+5 ;

int arr[maxn] ;

int main()

{

    int n ;

    cin >> n ;

    int l = 0 ;

    for (int i = 0 ; i < n ; i++) {

        cin >> arr[i] ;

        if (arr[i]<0)  l++ ;

    }

    sort(arr,arr+n) ;

    int ans = 0 ;

    for(int i = 1 ; i < n-1 ; i++) ans += abs(arr[i]) ;

    ans-=arr[0] ;

    ans+=arr[n-1] ;

    cout << ans << endl ;

    if (l==0) l = 1 ;

    else if (l==n) l=n-1 ;

    for(int i = l ; i < n-1 ; i++) {

        cout << arr[0] << " "<< arr[i] <<endl;

        arr[0] -=arr[i] ;

    }

    for(int i = 0 ; i < l ; i++) {

        cout << arr[n-1] << " " <<arr[i] << endl ;

        arr[n-1] -=arr[i] ;

    }

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<memory.h>

#include<stdio.h>

#include<algorithm>

using namespace std;



int n;

int a[100005];

int maxnum,minnum;

int ans1[100005];

int ans2[100005];



int main(){

    //cin>>n;

    scanf("%d",&n);

    for(int i=0;i<n;i++){

        //cin>>a[i];

        scanf("%d",&a[i]);

    }

    sort(a,a+n);

    minnum=a[0];

    maxnum=a[n-1];

    for(int i=1;i<n-1;i++){

        if(a[i]<0){

            ans1[i]=maxnum;

            ans2[i]=a[i];

            maxnum-=a[i];

        }

        else{

            ans1[i]=minnum;

            ans2[i]=a[i];

            minnum-=a[i];

        }

    }

    cout<<maxnum-minnum<<endl;

    for(int i=1;i<n-1;i++){

        //cout<<ans1[i]<<" "<<ans2[i]<<endl;

        printf("%d %d\n",ans1[i],ans2[i]);

    }

    //cout<<maxnum<<" "<<minnum<<endl;

    printf("%d %d\n",maxnum,minnum);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.205995857250859x):
#include <cstdio>

#include <cstring>

#include <algorithm>

#define SIZE 100100

using namespace std;



long long rec[SIZE];



int main()

{

    int n,t,i;

    int tmp,pos;

    long long ans=0;

    scanf("%d",&n);

    for(i=0;i<n;i++)

        scanf("%lld",rec+i);

    sort(rec,rec+n);

    if(rec[0]<0)

    {

        ans=rec[n-1];

        for(i=n-2;rec[i]>0;i--)

            ans+=rec[i];

        for(pos=i;i>=0;i--)

            ans-=rec[i];

        printf("%lld\n",ans);

        for(i=pos+1;i<n-1;i++)

        {

            printf("%lld %lld\n",rec[0],rec[i]);

            rec[0]-=rec[i];

        }

        for(i=0;i<=pos;i++)

        {

            printf("%lld %lld\n",rec[n-1],rec[i]);

            rec[n-1]-=rec[i];

        }

    }

    else

    {

        if(n==1)

            ans=rec[0];

        else

            ans=-rec[0];

        for(i=1;i<n;i++)

            ans+=rec[i];

        printf("%lld\n",ans);

        for(i=1;i<n-1;i++)

        {

            printf("%lld %lld\n",rec[0],rec[i]);

            rec[0]-=rec[i];

        }

        if(n>1)

        printf("%lld %lld\n",rec[n-1],rec[0]);

    }



    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <cmath>

#include <complex>

#include <vector>

#include <cstdio>

using namespace std;



typedef complex<double> P;



const double eps = 1.0e-7;

const double pi = acos(-1);



bool equals(double a, double b) { return abs(a-b) < eps; }

bool equals(P a, P b) {

  return equals(a.real(),b.real()) && equals(a.imag(),b.imag());

}



namespace std {

  bool operator < (const P& a, const P& b) {

    if(!equals(a.real(),b.real())) return a.real() < b.real();

    if(!equals(a.imag(),b.imag())) return a.imag() < b.imag();

    return false;

  }

}



P rotate(P p, double rad) {

  return P(cos(rad)*p.real() - sin(rad)*p.imag(),

	   sin(rad)*p.real() + cos(rad)*p.imag());

}



double solve(int N) {

  const static double r2 = 1.0/(2.0*(1.0-cos(pi*2.0/3.0)));

  vector<P> ps;

  vector<P> tri;

  tri.push_back(P(1.0,0.0));

  tri.push_back(rotate(P(1.0,0.0),pi*2.0/3.0));

  tri.push_back(rotate(P(1.0,0.0),-pi*2.0/3.0));

  double d = pi*2.0/(double)N;

  for(int i = 0; i < N; ++i) {

    for(int j = 0; j < tri.size(); ++j) {

      ps.push_back(rotate(tri[j],pi*2.0*i/(double)N));

    }

  }



  sort(ps.begin(), ps.end());

  int n = ps.size();

  for(int i = 1; i < ps.size(); ++i)

    n -= equals(ps[i-1],ps[i]);



  double rad = pi*2.0/(double)n;

  double rad2 = (pi*(n-2)/(double)n - pi/3.0)/2.0;

  double l2 = 2.0 * r2 * (1.0-cos(rad));

  return r2*pi - n*( (rad-sin(rad))*r2/2.0 + tan(rad2)*l2/4.0 );

}



int main() {

  int n;

  while(scanf("%d",&n) != EOF && n) printf("%.6f\n", solve(n));

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.437150685955546x):
#include <cstdio>

#include <cmath>



using namespace std;



const double eps = 1.0e-7;

const double pi = acos(-1);



bool equals(double a, double b) { return abs(a-b) < eps; }



int main() {

  const static double rr = 1.0/(2.0*(1.0-cos(pi*2.0/3.0)));

  double N;

  while(scanf("%lf",&N) != EOF && N) {

    double n;

    for(n = 1; n < N && !equals(0,fmod(3*n,N)); n+=1);

    n *= 3;

    printf("%.6f\n",

	   rr*pi - n*( (pi*2/n-sin(pi*2/n))*rr/2.0

		       + tan((pi*(n-2)/n-pi/3.0)/2.0)*2*rr*(1-cos(pi*2/n))/4.0 ));

  }

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define rep(i,n)for(int i=0;i<n;i++)

using namespace std;



vector<int>E[100000], pr[100000];

int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;

bool b[200000], ok[100000];



void bfs(int u) {

	queue<int>que;

	que.push(u);

	while (!que.empty()) {

		int p = que.front(); que.pop();

		for (int v : E[p]) {

			if (d[v] == d[p] + 1 && !ok[v]) {

				ok[v] = true; cnt++; que.push(v);

			}

		}

	}

}

int main() {

	int n, m, q; scanf("%d%d%d", &n, &m, &q);

	rep(i, m) {

		scanf("%d%d", &u[i], &v[i]);

		u[i]--; v[i]--;

		E[u[i]].push_back(v[i]); E[v[i]].push_back(u[i]);

	}

	queue<int>que;

	memset(d, -1, sizeof(d));

	d[0] = 0; que.push(0);

	while (!que.empty()) {

		int p = que.front(); que.pop();

		for (int i : E[p]) {

			if (d[i] == -1) {

				d[i] = d[p] + 1; que.push(i);

			}

		}

	}

	rep(i, m) {

		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);

	}

	rep(i, n)E[i].clear();

	rep(i, q) {

		scanf("%d", &r[i]); r[i]--;

		b[r[i]] = true;

	}

	ok[0] = true;

	rep(i, m) {

		if (!b[i]) {

			if (d[v[i]] - d[u[i]] == 1) {

				E[u[i]].push_back(v[i]);

			}

		}

	}

	bfs(0);

	for (int i = q - 1; i >= 0; i--) {

		ans[i] = n - cnt;

		if (d[v[r[i]]] - d[u[r[i]]] == 1 && !ok[v[r[i]]]) {

			E[u[r[i]]].push_back(v[r[i]]);

			if (ok[u[r[i]]]) {

				cnt++; ok[v[r[i]]] = true;

				bfs(v[r[i]]);

			}

		}

	}

	rep(i, q)printf("%d\n", ans[i]);

}

// Faster C++ solution for the same problem (measured speedup: 1.7406500166437824x):
#include<bits/stdc++.h>

#define rep(i,n)for(int i=0;i<n;i++)

using namespace std;



vector<int>E[100000];

int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;

bool b[200000], ok[100000];



void bfs(int u) {

	queue<int>que;

	que.push(u);

	while (!que.empty()) {

		int p = que.front(); que.pop();

		for (int v : E[p]) {

			if (d[v] == d[p] + 1 && !ok[v]) {

				ok[v] = true; cnt++; que.push(v);

			}

		}

	}

}

int main() {

	int n, m, q; scanf("%d%d%d", &n, &m, &q);

	rep(i, m) {

		scanf("%d%d", &u[i], &v[i]);

		u[i]--; v[i]--;

		E[u[i]].push_back(v[i]); E[v[i]].push_back(u[i]);

	}

	queue<int>que;

	memset(d, -1, sizeof(d));

	d[0] = 0; que.push(0);

	while (!que.empty()) {

		int p = que.front(); que.pop();

		for (int i : E[p]) {

			if (d[i] == -1) {

				d[i] = d[p] + 1; que.push(i);

			}

		}

	}

	rep(i, m) {

		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);

	}

	rep(i, n)E[i].clear();

	rep(i, q) {

		scanf("%d", &r[i]); r[i]--;

		b[r[i]] = true;

	}

	ok[0] = true;

	rep(i, m) {

		if (!b[i]) {

			if (d[v[i]] - d[u[i]] == 1) {

				E[u[i]].push_back(v[i]);

			}

		}

	}

	bfs(0);

	for (int i = q - 1; i >= 0; i--) {

		ans[i] = n - cnt;

		if (d[v[r[i]]] - d[u[r[i]]] == 1 && !ok[v[r[i]]]) {

			E[u[r[i]]].push_back(v[r[i]]);

			if (ok[u[r[i]]]) {

				cnt++; ok[v[r[i]]] = true;

				bfs(v[r[i]]);

			}

		}

	}

	rep(i, q)printf("%d\n", ans[i]);

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define rep(i,n)for(int i=0;i<n;i++)

using namespace std;



vector<int>E[100000], pr[100000];

int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;

bool b[200000], ok[100000];



void bfs(int u) {

	queue<int>que;

	que.push(u);

	while (!que.empty()) {

		int p = que.front(); que.pop();

		for (int v : E[p]) {

			if (d[v] == d[p] + 1 && !ok[v]) {

				ok[v] = true; cnt++; que.push(v);

			}

		}

	}

}

int main() {

	int n, m, q; scanf("%d%d%d", &n, &m, &q);

	rep(i, m) {

		scanf("%d%d", &u[i], &v[i]);

		u[i]--; v[i]--;

		E[u[i]].push_back(v[i]); E[v[i]].push_back(u[i]);

	}

	queue<int>que;

	memset(d, -1, sizeof(d));

	d[0] = 0; que.push(0);

	while (!que.empty()) {

		int p = que.front(); que.pop();

		for (int i : E[p]) {

			if (d[i] == -1) {

				d[i] = d[p] + 1; que.push(i);

			}

		}

	}

	rep(i, m) {

		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);

	}

	rep(i, n)E[i].clear();

	rep(i, q) {

		scanf("%d", &r[i]); r[i]--;

		b[r[i]] = true;

	}

	ok[0] = true;

	rep(i, m) {

		if (!b[i]) {

			if (d[v[i]] - d[u[i]] == 1) {

				E[u[i]].push_back(v[i]);

			}

		}

	}

	bfs(0);

	for (int i = q - 1; i >= 0; i--) {

		ans[i] = n - cnt;

		if (d[v[r[i]]] - d[u[r[i]]] == 1 && !ok[v[r[i]]]) {

			E[u[r[i]]].push_back(v[r[i]]);

			if (ok[u[r[i]]]) {

				cnt++; ok[v[r[i]]] = true;

				bfs(v[r[i]]);

			}

		}

	}

	rep(i, q)printf("%d\n", ans[i]);

}

// Faster C++ solution for the same problem (measured speedup: 1.7435209845162807x):
#include<bits/stdc++.h>

#define rep(i,n)for(int i=0;i<n;i++)

using namespace std;



void reader(int *x) {

	int k = getchar(); *x = k - '0';

	while (true) {

		k = getchar();

		if (k < '0' || k > '9') break;

		*x = ((*x) << 1) + ((*x) << 3) + k - '0';

	}

}

vector<int>E[100000];

int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;

bool b[200000], ok[100000];



void bfs(int u) {

	queue<int>que;

	que.push(u);

	while (!que.empty()) {

		int p = que.front(); que.pop();

		for (int v : E[p]) {

			if (d[v] == d[p] + 1 && !ok[v]) {

				ok[v] = true; cnt++; que.push(v);

			}

		}

	}

}

int main() {

	int n, m, q; reader(&n); reader(&m); reader(&q);

	rep(i, m) {

		reader(&u[i]); reader(&v[i]);

		u[i]--; v[i]--;

		E[u[i]].push_back(v[i]); E[v[i]].push_back(u[i]);

	}

	queue<int>que;

	memset(d, -1, sizeof(d));

	d[0] = 0; que.push(0);

	while (!que.empty()) {

		int p = que.front(); que.pop();

		for (int i : E[p]) {

			if (d[i] == -1) {

				d[i] = d[p] + 1; que.push(i);

			}

		}

	}

	rep(i, m) {

		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);

	}

	rep(i, n)E[i].clear();

	rep(i, q) {

		reader(&r[i]); r[i]--;

		b[r[i]] = true;

	}

	ok[0] = true;

	rep(i, m) {

		if (!b[i]) {

			if (d[v[i]] - d[u[i]] == 1) {

				E[u[i]].push_back(v[i]);

			}

		}

	}

	bfs(0);

	for (int i = q - 1; i >= 0; i--) {

		ans[i] = n - cnt;

		if (d[v[r[i]]] - d[u[r[i]]] == 1 && !ok[v[r[i]]]) {

			E[u[r[i]]].push_back(v[r[i]]);

			if (ok[u[r[i]]]) {

				cnt++; ok[v[r[i]]] = true;

				bfs(v[r[i]]);

			}

		}

	}

	rep(i, q)printf("%d\n", ans[i]);

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define rep(i,n)for(int i=0;i<n;i++)

using namespace std;



vector<int>E[100000], pr[100000];

int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;

bool b[200000], ok[100000];



void bfs(int u) {

	queue<int>que;

	que.push(u);

	while (!que.empty()) {

		int p = que.front(); que.pop();

		for (int v : E[p]) {

			if (d[v] == d[p] + 1 && !ok[v]) {

				ok[v] = true; cnt++; que.push(v);

			}

		}

	}

}

int main() {

	int n, m, q; scanf("%d%d%d", &n, &m, &q);

	rep(i, m) {

		scanf("%d%d", &u[i], &v[i]);

		u[i]--; v[i]--;

		E[u[i]].push_back(v[i]); E[v[i]].push_back(u[i]);

	}

	queue<int>que;

	memset(d, -1, sizeof(d));

	d[0] = 0; que.push(0);

	while (!que.empty()) {

		int p = que.front(); que.pop();

		for (int i : E[p]) {

			if (d[i] == -1) {

				d[i] = d[p] + 1; que.push(i);

			}

		}

	}

	rep(i, m) {

		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);

	}

	rep(i, n)E[i].clear();

	rep(i, q) {

		scanf("%d", &r[i]); r[i]--;

		b[r[i]] = true;

	}

	ok[0] = true;

	rep(i, m) {

		if (!b[i]) {

			if (d[v[i]] - d[u[i]] == 1) {

				E[u[i]].push_back(v[i]);

			}

		}

	}

	bfs(0);

	for (int i = q - 1; i >= 0; i--) {

		ans[i] = n - cnt;

		if (d[v[r[i]]] - d[u[r[i]]] == 1 && !ok[v[r[i]]]) {

			E[u[r[i]]].push_back(v[r[i]]);

			if (ok[u[r[i]]]) {

				cnt++; ok[v[r[i]]] = true;

				bfs(v[r[i]]);

			}

		}

	}

	rep(i, q)printf("%d\n", ans[i]);

}

// Faster C++ solution for the same problem (measured speedup: 1.7432350710925382x):
#include<bits/stdc++.h>

#define rep(i,n)for(int i=0;i<n;i++)

using namespace std;



void reader(int *x) {

	int k = getchar(); *x = k - '0';

	while (true) {

		k = getchar();

		if (k < '0' || k > '9') break;

		*x = ((*x) << 1) + ((*x) << 3) + k - '0';

	}

}

vector<int>E[100000];

int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;

bool b[200000], ok[100000];



void bfs(int u) {

	queue<int>que;

	que.push(u);

	while (!que.empty()) {

		int p = que.front(); que.pop();

		for (int v : E[p]) {

			if (d[v] == d[p] + 1 && !ok[v]) {

				ok[v] = true; cnt++; que.push(v);

			}

		}

	}

}

int main() {

	int n, m, q; reader(&n); reader(&m); reader(&q);

	rep(i, m) {

		reader(&u[i]); reader(&v[i]);

		u[i]--; v[i]--;

		E[u[i]].push_back(v[i]); E[v[i]].push_back(u[i]);

	}

	queue<int>que;

	memset(d, -1, sizeof(d));

	d[0] = 0; que.push(0);

	while (!que.empty()) {

		int p = que.front(); que.pop();

		for (int i : E[p]) {

			if (d[i] == -1) {

				d[i] = d[p] + 1; que.push(i);

			}

		}

	}

	rep(i, m) {

		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);

	}

	rep(i, n)E[i].clear();

	rep(i, q) {

		reader(&r[i]); r[i]--;

		b[r[i]] = true;

	}

	ok[0] = true;

	rep(i, m) {

		if (!b[i]) {

			if (d[v[i]] - d[u[i]] == 1) {

				E[u[i]].emplace_back(v[i]);

			}

		}

	}

	bfs(0);

	for (int i = q - 1; i >= 0; i--) {

		ans[i] = n - cnt;

		if (d[v[r[i]]] - d[u[r[i]]] == 1 && !ok[v[r[i]]]) {

			E[u[r[i]]].emplace_back(v[r[i]]);

			if (ok[u[r[i]]]) {

				cnt++; ok[v[r[i]]] = true;

				bfs(v[r[i]]);

			}

		}

	}

	rep(i, q)printf("%d\n", ans[i]);

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define rep(i,n)for(int i=0;i<n;i++)

using namespace std;



vector<int>E[100000], pr[100000];

int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;

bool b[200000], ok[100000];



void bfs(int u) {

	queue<int>que;

	que.push(u);

	while (!que.empty()) {

		int p = que.front(); que.pop();

		for (int v : E[p]) {

			if (d[v] == d[p] + 1 && !ok[v]) {

				ok[v] = true; cnt++; que.push(v);

			}

		}

	}

}

int main() {

	int n, m, q; scanf("%d%d%d", &n, &m, &q);

	rep(i, m) {

		scanf("%d%d", &u[i], &v[i]);

		u[i]--; v[i]--;

		E[u[i]].push_back(v[i]); E[v[i]].push_back(u[i]);

	}

	queue<int>que;

	memset(d, -1, sizeof(d));

	d[0] = 0; que.push(0);

	while (!que.empty()) {

		int p = que.front(); que.pop();

		for (int i : E[p]) {

			if (d[i] == -1) {

				d[i] = d[p] + 1; que.push(i);

			}

		}

	}

	rep(i, m) {

		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);

	}

	rep(i, n)E[i].clear();

	rep(i, q) {

		scanf("%d", &r[i]); r[i]--;

		b[r[i]] = true;

	}

	ok[0] = true;

	rep(i, m) {

		if (!b[i]) {

			if (d[v[i]] - d[u[i]] == 1) {

				E[u[i]].push_back(v[i]);

			}

		}

	}

	bfs(0);

	for (int i = q - 1; i >= 0; i--) {

		ans[i] = n - cnt;

		if (d[v[r[i]]] - d[u[r[i]]] == 1 && !ok[v[r[i]]]) {

			E[u[r[i]]].push_back(v[r[i]]);

			if (ok[u[r[i]]]) {

				cnt++; ok[v[r[i]]] = true;

				bfs(v[r[i]]);

			}

		}

	}

	rep(i, q)printf("%d\n", ans[i]);

}

// Faster C++ solution for the same problem (measured speedup: 1.7416797316402972x):
#include<bits/stdc++.h>

#define S 100000

#define rep(i,n)for(int i=0;i<n;i++)

using namespace std;vector<int>E[S];int u[2*S],v[2*S],r[2*S],ans[2*S],d[S],cnt=1,b[2*S],ok[S]{1};queue<int>que;void bfs(int u, int t) {que.push(u); while (!que.empty()) {int p = que.front(); que.pop(); for (int v : E[p]) {if (t) {if (d[v] > d[p] && !ok[v]) {ok[v] = 1; cnt++; que.push(v);}}else if (!~d[v]) {d[v] = d[p] + 1; que.push(v);}}}}int main(){int n,m,q;scanf("%d%d%d",&n,&m,&q);rep(i, m){scanf("%d%d",&u[i],&v[i]);u[i]--;v[i]--;E[u[i]].push_back(v[i]);E[v[i]].push_back(u[i]);}memset(d,-1,sizeof(d));d[0]=0;bfs(0,0);rep(i,m){if(d[u[i]]>d[v[i]])swap(u[i],v[i]);}rep(i,n)E[i].clear();rep(i,q){scanf("%d",&r[i]);r[i]--;b[r[i]]=1;}rep(i,m){if(!b[i]){if(d[v[i]]>d[u[i]]){E[u[i]].push_back(v[i]);}}}bfs(0,1);for(int i=q-1;i>=0;i--){ans[i]=n-cnt;if(d[v[r[i]]]>d[u[r[i]]]&&!ok[v[r[i]]]){E[u[r[i]]].push_back(v[r[i]]);if(ok[u[r[i]]]){cnt++;ok[v[r[i]]]=1;bfs(v[r[i]],1);}}}rep(i,q)printf("%d\n",ans[i]);}