stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include <vector>

#include <iostream>

#include <string.h>

#include <set>

#include <algorithm>

#include <cmath>

#include <queue>

using namespace std;



typedef double LD;

typedef long long LL;

typedef pair<int, int> PII;

#define MP make_pair

#define PB push_back

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)

#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)

#define REP(i, t) FOR(i,0,t)

#define ALL(a) a.begin(), a.end()

#define SZ(a) (int)((a).size())



const LL MOD = 1000000007;

const int INF = 1e9;

const LL LINF = 1LL * INF * INF;

const int MAXN = 100007;

const LD EPS = 1e-7;



int A[MAXN], D[MAXN], Dep[MAXN], n, k;

vector <int> G[MAXN], G1[MAXN];

queue <int> Q;

bool used[MAXN];



void dfs(int v)

{

	used[v] = true;

	REP(i, SZ(G1[v]))

	{

		int to = G1[v][i];

		if (!used[to])

		{

			dfs(to);

			Dep[v] = max(Dep[v], (Dep[to] + 1) % k);

		}

	}

}



int main()

{

	ios_base::sync_with_stdio(0);

	//freopen("In.txt", "r", stdin);

	int ans = 0, e = 0;

	cin >> n >> k;

	REP(i, n)

	{

		cin >> A[i];

		--A[i];

	}

	if (A[0] != 0)

	{

		A[0] = 0;

		ans = 1;

	}

	FOR(i, 1, n)

		G[A[i]].push_back(i);

	used[0] = true;

	D[0] = 0;

	Q.push(0);

	while(!Q.empty())

	{

		int v = Q.front();

		Q.pop();

		e = max(e, D[v]);

		REP(i, SZ(G[v]))

		{

			int to = G[v][i];

			if (!used[to])

			{

				used[to] = true;

				D[to] = D[v] + 1;

				G1[v].push_back(to);

				Q.push(to);

			}

		}

	}

	memset(used, 0, MAXN);

	dfs(0);

	REP(i, n)

	{

		if (D[i] > 1 && Dep[i] == k - 1)

			++ans;

	}

	cout << ans;

	//cout << endl; system("pause");

	return 0;

}

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

using namespace std;

struct edge

{

	int v,p;

}e[100010];

int n,k,a[100010],top,head[100010],cnt;

void addedge(int u,int v)

{

	e[++top]=(edge){v,head[u]};

	head[u]=top;	

}

int dfs(int u,int dep)

{

	int ret=dep;

	for(int i=head[u];i;i=e[i].p)

	{

		ret=max(ret,dfs(e[i].v,dep+1));

	}

	if(a[u]!=1&&ret-dep==k-1)

	{

		cnt++;

		return 0;

	}

	return ret;

}

int main()

{

	scanf("%d%d",&n,&k);

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

	{

		scanf("%d",a+i);

	}

	if(a[1]!=1)cnt++;

	a[1]=1;

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

	{

		addedge(a[i],i);

	}

	dfs(1,0);

	cout<<cnt<<endl;

	return 0;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include <vector>

#include <iostream>

#include <string.h>

#include <set>

#include <algorithm>

#include <cmath>

#include <queue>

using namespace std;



typedef double LD;

typedef long long LL;

typedef pair<int, int> PII;

#define MP make_pair

#define PB push_back

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)

#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)

#define REP(i, t) FOR(i,0,t)

#define ALL(a) a.begin(), a.end()

#define SZ(a) (int)((a).size())



const LL MOD = 1000000007;

const int INF = 1e9;

const LL LINF = 1LL * INF * INF;

const int MAXN = 100007;

const LD EPS = 1e-7;



int A[MAXN], D[MAXN], Dep[MAXN], n, k;

vector <int> G[MAXN], G1[MAXN];

queue <int> Q;

bool used[MAXN];



void dfs(int v)

{

	used[v] = true;

	REP(i, SZ(G1[v]))

	{

		int to = G1[v][i];

		if (!used[to])

		{

			dfs(to);

			Dep[v] = max(Dep[v], (Dep[to] + 1) % k);

		}

	}

}



int main()

{

	ios_base::sync_with_stdio(0);

	//freopen("In.txt", "r", stdin);

	int ans = 0, e = 0;

	cin >> n >> k;

	REP(i, n)

	{

		cin >> A[i];

		--A[i];

	}

	if (A[0] != 0)

	{

		A[0] = 0;

		ans = 1;

	}

	FOR(i, 1, n)

		G[A[i]].push_back(i);

	used[0] = true;

	D[0] = 0;

	Q.push(0);

	while(!Q.empty())

	{

		int v = Q.front();

		Q.pop();

		e = max(e, D[v]);

		REP(i, SZ(G[v]))

		{

			int to = G[v][i];

			if (!used[to])

			{

				used[to] = true;

				D[to] = D[v] + 1;

				G1[v].push_back(to);

				Q.push(to);

			}

		}

	}

	memset(used, 0, MAXN);

	dfs(0);

	REP(i, n)

	{

		if (D[i] > 1 && Dep[i] == k - 1)

			++ans;

	}

	cout << ans;

	//cout << endl; system("pause");

	return 0;

}

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

#include <vector>

using namespace std;



const int MAXN = 1e5 + 10;



vector <int> Adj[MAXN];

int N, K;

int fa[MAXN], dep[MAXN];

int answer;



void DFS(int cur)

{

	dep[cur] = 1;

	for(int x : Adj[cur])

		DFS(x), dep[cur] = max(dep[cur], dep[x] + 1);



	if(fa[cur] != 1 && dep[cur] == K)

		answer++, dep[cur] = 0;

}



int main()

{

	cin >> N >> K;

	cin >> fa[1];



	if(fa[1] != 1)	//Loop

		fa[1] = 1, answer ++;



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

	{

		cin >> fa[i] ;

		Adj[fa[i]].push_back(i);

	}

	DFS(1);



	cout << answer << endl ;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include <vector>

#include <iostream>

#include <string.h>

#include <set>

#include <algorithm>

#include <cmath>

#include <queue>

using namespace std;



typedef double LD;

typedef long long LL;

typedef pair<int, int> PII;

#define MP make_pair

#define PB push_back

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)

#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)

#define REP(i, t) FOR(i,0,t)

#define ALL(a) a.begin(), a.end()

#define SZ(a) (int)((a).size())



const LL MOD = 1000000007;

const int INF = 1e9;

const LL LINF = 1LL * INF * INF;

const int MAXN = 100007;

const LD EPS = 1e-7;



int A[MAXN], D[MAXN], Dep[MAXN], n, k;

vector <int> G[MAXN], G1[MAXN];

queue <int> Q;

bool used[MAXN];



void dfs(int v)

{

	used[v] = true;

	REP(i, SZ(G1[v]))

	{

		int to = G1[v][i];

		if (!used[to])

		{

			dfs(to);

			Dep[v] = max(Dep[v], (Dep[to] + 1) % k);

		}

	}

}



int main()

{

	ios_base::sync_with_stdio(0);

	//freopen("In.txt", "r", stdin);

	int ans = 0, e = 0;

	cin >> n >> k;

	REP(i, n)

	{

		cin >> A[i];

		--A[i];

	}

	if (A[0] != 0)

	{

		A[0] = 0;

		ans = 1;

	}

	FOR(i, 1, n)

		G[A[i]].push_back(i);

	used[0] = true;

	D[0] = 0;

	Q.push(0);

	while(!Q.empty())

	{

		int v = Q.front();

		Q.pop();

		e = max(e, D[v]);

		REP(i, SZ(G[v]))

		{

			int to = G[v][i];

			if (!used[to])

			{

				used[to] = true;

				D[to] = D[v] + 1;

				G1[v].push_back(to);

				Q.push(to);

			}

		}

	}

	memset(used, 0, MAXN);

	dfs(0);

	REP(i, n)

	{

		if (D[i] > 1 && Dep[i] == k - 1)

			++ans;

	}

	cout << ans;

	//cout << endl; system("pause");

	return 0;

}

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



#define f first 

#define s second 

#define pb push_back               

#define mp make_pair 



using namespace std;                    



typedef long long ll;

typedef pair<int, int> pii;

typedef pair<long long, long long> pll;



const int N = (int)1e5 + 123, mod = (int)1e9 + 7, inf = (int)1e9;



vector< int> g[N];

int n, k, a[N], ans;

int dfs(int v){

	int mx = 0;

	for(auto to : g[v]){

		int x = dfs(to) + 1;

		if(x == k && v != 1)

			ans++;	

		else

			mx = max(mx, x);



	}

	return mx;

}

int main(){    

	cin >> n >> k;

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

		cin >> a[i];

	}

	if(a[1] != 1 )

		a[1] = 1, ans ++;

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

		g[a[i]].pb(i);

	dfs(1);

	cout << ans;

	return 0;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include <vector>

#include <iostream>

#include <string.h>

#include <set>

#include <algorithm>

#include <cmath>

#include <queue>

using namespace std;



typedef double LD;

typedef long long LL;

typedef pair<int, int> PII;

#define MP make_pair

#define PB push_back

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)

#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)

#define REP(i, t) FOR(i,0,t)

#define ALL(a) a.begin(), a.end()

#define SZ(a) (int)((a).size())



const LL MOD = 1000000007;

const int INF = 1e9;

const LL LINF = 1LL * INF * INF;

const int MAXN = 100007;

const LD EPS = 1e-7;



int A[MAXN], D[MAXN], Dep[MAXN], n, k;

vector <int> G[MAXN], G1[MAXN];

queue <int> Q;

bool used[MAXN];



void dfs(int v)

{

	used[v] = true;

	REP(i, SZ(G1[v]))

	{

		int to = G1[v][i];

		if (!used[to])

		{

			dfs(to);

			Dep[v] = max(Dep[v], (Dep[to] + 1) % k);

		}

	}

}



int main()

{

	ios_base::sync_with_stdio(0);

	//freopen("In.txt", "r", stdin);

	int ans = 0, e = 0;

	cin >> n >> k;

	REP(i, n)

	{

		cin >> A[i];

		--A[i];

	}

	if (A[0] != 0)

	{

		A[0] = 0;

		ans = 1;

	}

	FOR(i, 1, n)

		G[A[i]].push_back(i);

	used[0] = true;

	D[0] = 0;

	Q.push(0);

	while(!Q.empty())

	{

		int v = Q.front();

		Q.pop();

		e = max(e, D[v]);

		REP(i, SZ(G[v]))

		{

			int to = G[v][i];

			if (!used[to])

			{

				used[to] = true;

				D[to] = D[v] + 1;

				G1[v].push_back(to);

				Q.push(to);

			}

		}

	}

	memset(used, 0, MAXN);

	dfs(0);

	REP(i, n)

	{

		if (D[i] > 1 && Dep[i] == k - 1)

			++ans;

	}

	cout << ans;

	//cout << endl; system("pause");

	return 0;

}

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

using namespace std;



const int N = 1e5 + 100, inF = N;



int n, k, ans, out[N], dis[N];

bool mark[N];

vector<int> in[N];



void dfs(int v, bool change = false) {

	mark[v] = change;

	for (int u: in[v]) 

		if(mark[u] == false) {

			dis[u] = dis[v] + 1;

			dfs(u, change);

		}

}



int main() {

	ios::sync_with_stdio(false), cin.tie(0);

	cin >> n >> k;

	cin >> out[0];

	ans += (out[0] != 1);

	

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

		cin >> out[i];

		in[--out[i]].push_back(i);

	}

	dfs(0);

	vector<int> vec(n);

	iota(vec.begin(), vec.end(), 0);

	sort(vec.begin(), vec.end(), [](int a, int b) {

		return dis[a] > dis[b];

	});

	for (int u: vec) {

		if(mark[u] || dis[u] <= k)

			continue;

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

			u = out[u];

		ans++;

		dfs(u, true);

	}

	cout << ans;

	return 0;

}///////////////////////////////////////
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include <vector>

#include <iostream>

#include <string.h>

#include <set>

#include <algorithm>

#include <cmath>

#include <queue>

using namespace std;



typedef double LD;

typedef long long LL;

typedef pair<int, int> PII;

#define MP make_pair

#define PB push_back

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)

#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)

#define REP(i, t) FOR(i,0,t)

#define ALL(a) a.begin(), a.end()

#define SZ(a) (int)((a).size())



const LL MOD = 1000000007;

const int INF = 1e9;

const LL LINF = 1LL * INF * INF;

const int MAXN = 100007;

const LD EPS = 1e-7;



int A[MAXN], D[MAXN], Dep[MAXN], n, k;

vector <int> G[MAXN], G1[MAXN];

queue <int> Q;

bool used[MAXN];



void dfs(int v)

{

	used[v] = true;

	REP(i, SZ(G1[v]))

	{

		int to = G1[v][i];

		if (!used[to])

		{

			dfs(to);

			Dep[v] = max(Dep[v], (Dep[to] + 1) % k);

		}

	}

}



int main()

{

	ios_base::sync_with_stdio(0);

	//freopen("In.txt", "r", stdin);

	int ans = 0, e = 0;

	cin >> n >> k;

	REP(i, n)

	{

		cin >> A[i];

		--A[i];

	}

	if (A[0] != 0)

	{

		A[0] = 0;

		ans = 1;

	}

	FOR(i, 1, n)

		G[A[i]].push_back(i);

	used[0] = true;

	D[0] = 0;

	Q.push(0);

	while(!Q.empty())

	{

		int v = Q.front();

		Q.pop();

		e = max(e, D[v]);

		REP(i, SZ(G[v]))

		{

			int to = G[v][i];

			if (!used[to])

			{

				used[to] = true;

				D[to] = D[v] + 1;

				G1[v].push_back(to);

				Q.push(to);

			}

		}

	}

	memset(used, 0, MAXN);

	dfs(0);

	REP(i, n)

	{

		if (D[i] > 1 && Dep[i] == k - 1)

			++ans;

	}

	cout << ans;

	//cout << endl; system("pause");

	return 0;

}

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

#include <iostream>

#include <cstring>

#include <vector>

using namespace std;



const int MAX_N = 1e5 + 5, inf = 1e9 + 7;

int n, k, ans;

bool mark[MAX_N];

int nxt[MAX_N];

int dis[MAX_N];

vector <int> topo;

vector <int> child[MAX_N];



void dfs (int v) {

	mark[v] = true;

	if (!mark[nxt[v]])

		dfs(nxt[v]);



	topo.push_back(v);

}



int dfs2 (int v = 0) {

	int tmp = dis[v];

	for (int u: child[v])

		tmp = max(tmp, dfs2(u));





	if (!v)

		return 0;



	if (tmp - dis[v] == k - 1 && nxt[v]) {

		ans++;

		nxt[v] = 0;

		dis[v] = 1;

		return -inf;

	}



	return tmp;

}



int main() {

	ios::sync_with_stdio(false), cin.tie(0);

	cin >> n >> k;

	int cnt = 0;

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

		cin >> nxt[i];

		nxt[i]--;



		if (i) {

			child[nxt[i]].push_back(i);

			cnt += nxt[i] != 0;

		}

	}

	if (nxt[0] != 0) {

		ans++;

		nxt[0] = 0;

	}



	if (k == 1) {

		ans += cnt;

		cout << ans << "\n";

		return 0;

	}



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

		if (!mark[i])

			dfs(i);



	for (int v: topo)

		dis[v] = 1 + dis[nxt[v]];





	dfs2();

	cout << ans << "\n";

	return 0;

}
// Slower C++ solution:
#define _CRT_SECURE_NO_WARNINGS

#include <vector>

#include <iostream>

#include <string.h>

#include <set>

#include <algorithm>

#include <cmath>

#include <queue>

using namespace std;



typedef double LD;

typedef long long LL;

typedef pair<int, int> PII;

#define MP make_pair

#define PB push_back

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)

#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)

#define REP(i, t) FOR(i,0,t)

#define ALL(a) a.begin(), a.end()

#define SZ(a) (int)((a).size())



const LL MOD = 1000000007;

const int INF = 1e9;

const LL LINF = 1LL * INF * INF;

const int MAXN = 100007;

const LD EPS = 1e-7;



int A[MAXN], D[MAXN], Dep[MAXN], n, k;

vector <int> G[MAXN], G1[MAXN];

queue <int> Q;

bool used[MAXN];



void dfs(int v)

{

	used[v] = true;

	REP(i, SZ(G1[v]))

	{

		int to = G1[v][i];

		if (!used[to])

		{

			dfs(to);

			Dep[v] = max(Dep[v], (Dep[to] + 1) % k);

		}

	}

}



int main()

{

	ios_base::sync_with_stdio(0);

	//freopen("In.txt", "r", stdin);

	int ans = 0, e = 0;

	cin >> n >> k;

	REP(i, n)

	{

		cin >> A[i];

		--A[i];

	}

	if (A[0] != 0)

	{

		A[0] = 0;

		ans = 1;

	}

	FOR(i, 1, n)

		G[A[i]].push_back(i);

	used[0] = true;

	D[0] = 0;

	Q.push(0);

	while(!Q.empty())

	{

		int v = Q.front();

		Q.pop();

		e = max(e, D[v]);

		REP(i, SZ(G[v]))

		{

			int to = G[v][i];

			if (!used[to])

			{

				used[to] = true;

				D[to] = D[v] + 1;

				G1[v].push_back(to);

				Q.push(to);

			}

		}

	}

	memset(used, 0, MAXN);

	dfs(0);

	REP(i, n)

	{

		if (D[i] > 1 && Dep[i] == k - 1)

			++ans;

	}

	cout << ans;

	//cout << endl; system("pause");

	return 0;

}

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



using namespace std;



const int N = 123456;



int n, k, answer, a[N], d[N];

vector<int> adj[N];



void dfs(int x) {

  for (auto y : adj[x]) {

    dfs(y);

    d[x] = max(d[x], d[y] + 1);

  }

  if (x > 1 && d[x] == k - 1 && a[x] != 1) {

    ++answer;

    d[x] = -1;

  }

}



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  cout.tie(0);

  cin >> n >> k >> a[1];

  if (a[1] != 1) {

    ++answer;

  }

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

    cin >> a[i];

    adj[a[i]].push_back(i);

  }

  dfs(1);

  cout << answer << '\n';

  return 0;

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

  using namespace std;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  #define endl "\n"

  #define int long long

  #define all(v) v.begin(),v.end()

  #define rep(i,a,b) for(int i = a; i <=b; i++)

  #define f first

  #define s second

  #define PB push_back

  #define MP make_pair

  #pragma comment(linker, "/STACK:2000000")

  #pragma comment(linker, "/HEAP:2000000")

  #define db long double

  #define trace1(x)                cerr<<#x<<": "<<x<<endl

  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl

  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl

  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl

  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl

  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

  #define cases int testcases;cin>>testcases; while(testcases--)

  #define MOD 1000000007

  int deg[200005]={0};

  vector<int> adj[200005];

  bool vis[200005];

  vector<int>v; 

  int32_t main()

  {        

    IOS



    int a,b;

    cin>>a>>b;

    

    if(a==b)

    {

      cout<<"1";

    }

    else if((a+b)%2==0)

    {

      cout<<(a+b)/2;

    }

    else

    {

      cout<<"IMPOSSIBLE";

    }

    return 0;

} 

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

  using namespace std;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  #define endl "\n"

  #define int long long

  #define all(v) v.begin(),v.end()

  #define rep(i,a,b) for(int i = a; i <=b; i++)

  #define f first

  #define s second

  #define PB push_back

  #define MP make_pair

  #pragma comment(linker, "/STACK:2000000")

  #pragma comment(linker, "/HEAP:2000000")

  #define db long double

  #define trace1(x)                cerr<<#x<<": "<<x<<endl

  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl

  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl

  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl

  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl

  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

  #define cases int testcases;cin>>testcases; while(testcases--)

  #define MOD 1000000007

  int32_t main()

  {        

    IOS

    int a,b;

    cin>>a>>b;

    if(a==b)

    {

      cout<<"1";

    }

    else if((a+b)%2==0)

    {

      cout<<(a+b)/2;

    }

    else

    {

      cout<<"IMPOSSIBLE";

    }

    return 0;

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

using namespace std;

int main ()





{



    long long int a,b,i,j,k,c,temp;



    cin>>a>>b;

    if(a>b)



    {

        temp=a;

        a=b;

        b=temp;

    }







    for(i=a; i<=b; i++)



    {





        if(abs(a-i)==abs(b-i))

        {



            c=1;

            break;

        }

        else

            c=0;



    }



    if(c==0)

        cout<<"IMPOSSIBLE"<<endl;

    else if(c==1)

        cout<<i<<endl;











    return 0;

}


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

#include <cstring>

#include <algorithm>

using namespace std;

int main()

{

    // freopen("a.in","r",stdin);

    // freopen("k.out","w",stdout);

    int a,b;

    scanf("%d %d",&a,&b);

    if((a+b)%2) printf("IMPOSSIBLE");

    else printf("%d",(a+b)/2);

    return 0;



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

using namespace std;

int main()

{

 int a,b,c,d;

 cin >> a >> b;

 c=a+b;

 d=c/2;

 if(c%2!=0){

    cout << "IMPOSSIBLE";

 }

 else {

    cout << d;

 }

 return 0;

}


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

#include <cstring>

#include <algorithm>

using namespace std;

int main()

{

    // freopen("a.in","r",stdin);

    // freopen("k.out","w",stdout);

    int a,b;

    scanf("%d %d",&a,&b);

    if((a+b)%2) printf("IMPOSSIBLE");

    else printf("%d",(a+b)/2);

    return 0;



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

#include <math.h>



using namespace std;



int main(){



    

    long long a,b,min,max,num=0;



    cin>>a;

    cin>>b;



    if(a<b){

        min = a;

        max = b;

    }else{

        min = b;

        max = a;

    }



    for (int i = min+1; i <= max; i++)

    {   

        if(abs(a-i) == abs(b-i)){

            num = i;

        }

    }



    if(num != 0){

        cout<<num<<endl;

    }else{

        cout<<"IMPOSSIBLE"<<endl;

    }

    

}


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



 int main() {

        double n,a,b;

        scanf("%lf %lf",&a,&b);

        n = (a+b)/2.0;

        if(floor(n)==ceil(n))

        printf("%.0lf\n",n);

        else

        printf("IMPOSSIBLE\n");

        

     

        

        return 0;

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

#include <math.h>



using namespace std;



int main(){



    

    long long a,b,min,max,num=0;



    cin>>a;

    cin>>b;



    if(a<b){

        min = a;

        max = b;

    }else{

        min = b;

        max = a;

    }



    for (int i = min+1; i <= max; i++)

    {   

        if(abs(a-i) == abs(b-i)){

            num = i;

        }

    }



    if(num != 0){

        cout<<num<<endl;

    }else{

        cout<<"IMPOSSIBLE"<<endl;

    }

    

}


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

using namespace std;



int main(void){

    int a, b;

    cin>>a>>b;

    int k= (a+b)/2;

    cout<<( abs(a-k)==abs(b-k) ? to_string(k) : "IMPOSSIBLE")<<endl;

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

using namespace std;

int main ()





{



    long long int a,b,i,j,k,c,temp;



    cin>>a>>b;

    if(a>b)



    {

        temp=a;

        a=b;

        b=temp;

    }







    for(i=a; i<=b; i++)



    {





        if(abs(a-i)==abs(b-i))

        {



            c=1;

            break;

        }

        else

            c=0;



    }



    if(c==0)

        cout<<"IMPOSSIBLE"<<endl;

    else if(c==1)

        cout<<i<<endl;











    return 0;

}


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

#include<math.h>

int main()

{

    int a,b,k;

    int c=0;

    scanf("%d%d",&a,&b);



 if((a+b)%2==0)



      {

           k=(a+b)/2;

          printf("%d",k);

      }

 else

       {

           printf("IMPOSSIBLE");

       }





return 0;

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

using namespace std;

int main()

{

 int a,b,c,d;

 cin >> a >> b;

 c=a+b;

 d=c/2;

 if(c%2!=0){

    cout << "IMPOSSIBLE";

 }

 else {

    cout << d;

 }

 return 0;

}


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

#include<math.h>

int main()

{

    int a,b,k;

    int c=0;

    scanf("%d%d",&a,&b);



 if((a+b)%2==0)



      {

           k=(a+b)/2;

          printf("%d",k);

      }

 else

       {

           printf("IMPOSSIBLE");

       }





return 0;

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

#include <math.h>



using namespace std;



int main(){



    

    long long a,b,min,max,num=0;



    cin>>a;

    cin>>b;



    if(a<b){

        min = a;

        max = b;

    }else{

        min = b;

        max = a;

    }



    for (int i = min+1; i <= max; i++)

    {   

        if(abs(a-i) == abs(b-i)){

            num = i;

        }

    }



    if(num != 0){

        cout<<num<<endl;

    }else{

        cout<<"IMPOSSIBLE"<<endl;

    }

    

}


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

#include<math.h>

int main()

{

    int a,b,k;

    int c=0;

    scanf("%d%d",&a,&b);



 if((a+b)%2==0)



      {

           k=(a+b)/2;

          printf("%d",k);

      }

 else

       {

           printf("IMPOSSIBLE");

       }





return 0;

}