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



#define mx 100005



using namespace std;



vector<int> pa[mx], ch[mx];

stack<int> st;

int th[mx], n, m, a, b, rt, nm[mx], j;



int main(){

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

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

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

		pa[b].push_back(a);

		ch[a].push_back(b);

		nm[b]++;

	}

	for(rt = 1; !pa[rt].empty(); rt++);

	th[rt] = ++j;

	st.push(rt);

	while(!st.empty()){

		int i = st.top(); st.pop();

		for(int it : ch[i]){

			nm[it]--;

			if(!nm[it]){

				th[it] = ++j;

				st.push(it);

			}

		}

	}

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

		int ans = 0;

		for(int it : pa[i]) if(th[ans] < th[it]) ans = it;

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

	}

}


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



#define mx 100005



using namespace std;



int n, m, a, b, rt, pa[mx];

vector<int> ch[mx];

bool nt[mx], anc[mx] = {true};



 void search(int now){

	 anc[now] = true;

	 for(int i : ch[now]){

		 if(anc[pa[i]]) pa[i] = now;

		 if(nt[i]){

			 nt[i] = false;

			 search(i);

		 }

	 }

	 anc[now] = false;

 }



int main(){

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

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

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

		ch[a].push_back(b);

		nt[b] = true;

	}

	for(rt = 1; nt[rt]; rt++);

	search(rt);

	for(int i = 1; i <= n; i++) printf("%d\n", pa[i]);

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



#define mx 100005



using namespace std;



vector<int> pa[mx], ch[mx];

stack<int> st;

int th[mx], n, m, a, b, rt, nm[mx], j;



int main(){

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

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

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

		pa[b].push_back(a);

		ch[a].push_back(b);

		nm[b]++;

	}

	for(rt = 1; !pa[rt].empty(); rt++);

	th[rt] = ++j;

	st.push(rt);

	while(!st.empty()){

		int i = st.top(); st.pop();

		for(int it : ch[i]){

			nm[it]--;

			if(!nm[it]){

				th[it] = ++j;

				st.push(it);

			}

		}

	}

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

		int ans = 0;

		for(int it : pa[i]) if(th[ans] < th[it]) ans = it;

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

	}

}


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



#define mx 100005



using namespace std;



vector<int> ch[mx];

stack<int> st;

int n, m, a, b, rt, nm[mx], pa[mx];



int main(){

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

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

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

		ch[a].push_back(b);

		nm[b]++;

	}

	for(rt = 1; nm[rt]; rt++);

	st.push(rt);

	while(!st.empty()){

		int i = st.top(); st.pop();

		for(int it : ch[i]){

			if(!--nm[it]){

				pa[it] = i;

				st.push(it);

			}

		}

	}

	for(int i = 1; i <= n; i++) printf("%d\n", pa[i]);

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

using namespace std;



int n, m, r;

vector<int> t1[114514], t2[114514], t3(114514);



void bfs(int s) {

	queue<pair<int, int> > q;

	vector<int> d(114514, -1), v(114514, 0);

	q.push(make_pair(s, 0));

	

	t3[s] = -1;

	d[s] = 0;

	

	while (!q.empty()) {

		pair<int, int> p = q.front(); q.pop();

		

		for (int i = 0; i < t2[p.first].size(); i++) {

			bool flag = true;

			

			v[t2[p.first][i]]++;

			

			/*for (int j = 0; j < t1[t2[p.first][i]].size(); j++) {

				//cout << t2[p.first][i] << ':' << t1[t2[p.first][i]][j] << ':' << d[t1[t2[p.first][i]][j]] << ':' << endl;

				if (t1[t2[p.first][i]][j] != p.first && d[t1[t2[p.first][i]][j]] == -1) {

					flag = false;

					break;

				}

			}*/

			

			if (v[t2[p.first][i]] != t1[t2[p.first][i]].size()) continue;

			

			//cout << p.first << ' ' << t2[p.first][i] << endl;

			

			d[t2[p.first][i]] = p.second + 1;

			t3[t2[p.first][i]] = p.first;

			q.push(make_pair(t2[p.first][i], p.second + 1));

		}

	}

}



int main(void) {

	cin >> n >> m;

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

		int a, b;

		cin >> a >> b;

		a--; b--;

		t1[b].push_back(a);

		t2[a].push_back(b);

	}

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

		if (t1[i].size() == 0) r = i;

	}

	bfs(r);

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

		cout << t3[i] + 1<< endl;

	}

}

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

using namespace std;



int main(void) {

	int n, m, r;

	cin >> n >> m;

	vector<int> tree(n);

	vector<vector<int> > parent(n, vector<int>(0)), child(n, vector<int>(0));

	

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

		int a, b;

		cin >> a >> b;

		a--; b--;

		parent[b].push_back(a);

		child[a].push_back(b);

	}

	

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

		if (parent[i].size() == 0) r = i;

	}

	

	queue<int> q;

	vector<int> v(n, 0);

	q.push(r);

	

	tree[r] = -1;

	

	while (!q.empty()) {

		int now = q.front(); q.pop();

		

		for (int i = 0; i < child[now].size(); i++) {

			bool flag = true;

			int next = child[now][i];

			

			v[next]++;

			

			if (v[next] != parent[next].size()) continue;

			

			tree[next] = now;

			q.push(next);

		}

	}

	

	for (int i = 0; i < n; i++) cout << tree[i] + 1 << endl;

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

#include<vector>

#include<queue>

using namespace std; // 575



const int MAX = 100000;

struct Node {

	vector<int> edge, rev;

	int parent;

};



int main() {

	int N, M, A, B;

	cin >> N >> M;

	static Node node[MAX];

	for (int i = 0;i < N;++ i) node[i].parent = -1;

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

		cin >> A >> B;

		node[A - 1].edge.push_back(B - 1);

		node[B - 1].rev.push_back(A - 1);

	}

	int search;

	for (int i = 0;i < N;++ i) if (node[i].rev.size() == 0) search = i;

	queue<pair<int, int> > que;

	que.push(make_pair(search, 0));

	while(!que.empty()) {

		search = que.front().first;

		node[search].parent = que.front().second;

		que.pop();

		if (node[search].edge.empty()) continue;

		for (int j = 0;j < node[search].edge.size();++ j) {

			for (int k = 0;k < node[node[search].edge[j]].rev.size();++ k) {

				if (node[node[node[search].edge[j]].rev[k]].parent < 0) goto cont;

			}

			que.push(make_pair(node[search].edge[j], search + 1));

			cont:;

		}

	}

	for (int i = 0;i < N;++ i) cout << node[i].parent << endl;

	return 0;

}

/*

31536000のコメント解説欄

ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー



まず、必ず増えた辺は子孫に向かってる→ショートカットである

よって、とりあえず根はO(N)で確定、どれからも辺が来てないはず

すると次の辺はその根からのみ矢印が来てるのでやっぱ確定

以下同様



各頂点について

1. 繋がってる全ての辺を調べる O(N+M)

2. その辺は、確定親以外から辺が来てないか調べる O(N+M)

はい

*/

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

#include<vector>

#include<queue>

using namespace std; // 575

const int MAX = 100000;



int main() {

	int N, M, A, B;

	cin >> N >> M;

	static pair<int, vector<int>> node[MAX]; // 向かってくる辺の数、向かう辺の行き先

	for (int i = 0;i < N;++ i) node[i].first = 0;

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

		cin >> A >> B;

		node[A - 1].second.push_back(B - 1);

		++ node[B - 1].first;

	}

    static int search, ans[MAX];

	for (int i = 0;i < N;++ i) if (node[i].first == 0) search = i;

	queue<pair<int, int> > que; // 確定頂点とその親

	que.push(make_pair(search, 0));

	while(!que.empty()) {

		search = que.front().first;

		ans[search] = que.front().second;

		que.pop();

		for (int i = 0;i < node[search].second.size();++ i) if (-- node[node[search].second[i]].first <= 0) que.push(make_pair(node[search].second[i], search + 1));

	}

	for (int i = 0;i < N;++ i) cout << ans[i] << endl;

	return 0;

}

/*

31536000のコメント解説欄

ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー



まず、必ず増えた辺は子孫に向かってる→ショートカットである

よって、とりあえず根はO(N)で確定、どれからも辺が来てないはず

すると次の辺はその根からのみ矢印が来てるのでやっぱ確定

以下同様



各頂点について

1. 繋がってる全ての辺を調べる O(N+M)

2. その辺は、確定親以外から辺が来てないか調べる O(N+M)

はい

*/
// Slower C++ solution:
/***********************

*  Author: xuziyuan    * 

***********************/



#include <bits/stdc++.h>



#define rt0 return 0

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

#define repn(i,n) for(int i=1;i<=n;i++)

#define replet(c) for(char c='a';c<='z';c++)

#define LL long long

#define pii pair <int,int>

#define pb push_back

#define fi first

#define se second

#define mpr make_pair

#define sqr(a) ((a)*(a))



using namespace std;



const LL MOD=1e9+7;



int n,m,x,y,in[100010],num[100010],ans[100010];

vector <int> g[100010],dg[100010],topo;

bool vis[100010];



void dfs(int pos)

{

	vis[pos]=true;

	rep(i,g[pos].size())

	{

		if(vis[g[pos][i]]) continue;

		dfs(g[pos][i]);

	}

	topo.pb(pos);

}



int main()

{

	cin>>n>>m;

	rep(i,m+n-1)

	{

		scanf("%d%d",&x,&y);

		g[x].pb(y);

		dg[y].pb(x);

		in[y]++;

	}

	repn(i,n)

	{

		if(in[i]==0)

		{

			dfs(i);

			break;

		}

	}

	reverse(topo.begin(),topo.end());

	rep(i,n) num[topo[i]]=i;

	rep(i,n)

	{

		if(in[topo[i]]==0) continue;

		int opt=-1,par;

		rep(j,dg[topo[i]].size()) 

		{

			if(num[dg[topo[i]][j]]>opt)

			{

				opt=num[dg[topo[i]][j]];

				par=dg[topo[i]][j];

			}

		}

		ans[topo[i]]=par;

	}

	repn(i,n) cout<<ans[i]<<endl;

	rt0;

}

/*

6 3

2 1

2 3

4 1

4 2

6 1

2 6

4 6

6 5

*/

// Faster C++ solution for the same problem (measured speedup: 1.459986557328747x):
/***********************

*  Author: xuziyuan    * 

***********************/



#include <bits/stdc++.h>



#define rt0 return 0

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

#define repn(i,n) for(int i=1;i<=n;i++)

#define replet(c) for(char c='a';c<='z';c++)

#define LL long long

#define pii pair <int,int>

#define pb push_back

#define fi first

#define se second

#define mpr make_pair

#define sqr(a) ((a)*(a))



using namespace std;



const LL MOD=1e9+7;



int n,m,x,y,in[100010],dist[100010],ans[100010];

vector <int> g[100010];



int dfs_init(int pos)

{

	//cout<<pos<<endl;

	if(dist[pos]!=-1) return dist[pos];//作为vis数组 

	rep(i,g[pos].size()) dist[pos]=max(dist[pos],dfs_init(g[pos][i])+1);

	if(dist[pos]==-1) dist[pos]=0;

	return dist[pos];

}



bool cmp(pii a,pii b)

{

	return a.fi>b.fi;

}



void dfs(int pos,int lst)

{

	if(ans[pos]!=-1) return;

	ans[pos]=lst;

	vector <pii> v;

	rep(i,g[pos].size()) v.pb({dist[g[pos][i]],g[pos][i]});

	sort(v.begin(),v.end(),cmp);

	rep(i,v.size()) dfs(v[i].se,pos);

}



int main()

{

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

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

	cin>>n>>m;

	rep(i,n+m-1)

	{

		scanf("%d%d",&x,&y);

		g[x].pb(y);

		in[y]++;

	}

	repn(i,n)

	{

		if(in[i]==0)

		{

			dfs_init(i);

			dfs(i,0);

			repn(j,n) cout<<ans[j]<<endl;

			rt0;

		}

	}

	rt0;

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

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

	int a,b;

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

	int maxx=max(a+b,a-b);

	maxx=max(maxx,a*b);

	printf("%d\n",maxx);

	return 0;

}

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



int main (){

	//belum selesai masalah kalau input angka 0

	int A,B,x,y,z;

	scanf("%d %d",&A,&B);

	x=A+B;

	y=A-B;

	z=A*B;

	if(x>y && x>z){

		printf("%d\n",x);

	}

	else if(y>x && y>z){

		printf("%d\n",y);

	}

	else if(z>y && z>x){

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

	}

	else if(A==0 & B==0){

		printf("0\n");

	}

	else if(A==0||B==0){

		printf("%d\n",x);

	}

	return 0;

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

using namespace std;

int main() {

    int a,b;

    cin>>a>>b;

    int x=a+b;

    int y=a-b;

    int z=a*b;

    if(x>=y&&x>=z)cout<<x;

    else if(x<=y&&y>=z) cout<<y;

    else if(z>=x&&z>=y) cout<<z;



    }


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



int main (){

	//belum selesai masalah kalau input angka 0

	int A,B,x,y,z;

	scanf("%d %d",&A,&B);

	x=A+B;

	y=A-B;

	z=A*B;

	if(x>y && x>z){

		printf("%d\n",x);

	}

	else if(y>x && y>z){

		printf("%d\n",y);

	}

	else if(z>y && z>x){

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

	}

	else if(A==0 & B==0){

		printf("0\n");

	}

	else if(A==0||B==0){

		printf("%d\n",x);

	}

	return 0;

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

#include <cstring>

#include <cstdio>

#include <algorithm>

#include <cmath>

using namespace std;

const int N = 1000 + 5;

int a[N];

int main()

{

  int a,b;

  while(cin >> a >> b)

  {

      int maxx = a + b;

      maxx = max(maxx,a-b);

      maxx = max(maxx,a*b);

      printf("%d\n",maxx);

  }

}


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



int main (){

	//belum selesai masalah kalau input angka 0

	int A,B,x,y,z;

	scanf("%d %d",&A,&B);

	x=A+B;

	y=A-B;

	z=A*B;

	if(x>y && x>z){

		printf("%d\n",x);

	}

	else if(y>x && y>z){

		printf("%d\n",y);

	}

	else if(z>y && z>x){

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

	}

	else if(A==0 & B==0){

		printf("0\n");

	}

	else if(A==0||B==0){

		printf("%d\n",x);

	}

	return 0;

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

#include<cstdio>

#include<string.h>

#include<algorithm>

#include<cmath>

using namespace std;



int main()

{

    int a,b;

    cin>>a>>b;

    cout<<max(a+b,max(a-b,a*b));

    return 0;

}


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



int main (){

	//belum selesai masalah kalau input angka 0

	int A,B,x,y,z;

	scanf("%d %d",&A,&B);

	x=A+B;

	y=A-B;

	z=A*B;

	if(x>y && x>z){

		printf("%d\n",x);

	}

	else if(y>x && y>z){

		printf("%d\n",y);

	}

	else if(z>y && z>x){

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

	}

	else if(A==0 & B==0){

		printf("0\n");

	}

	else if(A==0||B==0){

		printf("%d\n",x);

	}

	return 0;

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

#include<iostream>

#include<algorithm>

using namespace std;

int main()

{

	int a,b;

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

	int maxx=max(a+b,a-b);

	maxx=max(maxx,a*b);

	printf("%d\n",maxx);

	return 0;

}

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

#include<string.h>





int main(){

	int a,b;

	

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

	

	int tambah=a+b;

	int kurang=a-b;

	int kali=a*b;

	

	printf("%d\n", tambah>=kurang&&tambah>=kali?tambah:(kurang>=kali&&kurang>=tambah?kurang:kali));

	

	return 0;

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

using namespace std;

int main() {

    int a,b;

    cin>>a>>b;

    int x=a+b;

    int y=a-b;

    int z=a*b;

    if(x>=y&&x>=z)cout<<x;

    else if(x<=y&&y>=z) cout<<y;

    else if(z>=x&&z>=y) cout<<z;



    }


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

#include<string.h>





int main(){

	int a,b;

	

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

	

	int tambah=a+b;

	int kurang=a-b;

	int kali=a*b;

	

	printf("%d\n", tambah>=kurang&&tambah>=kali?tambah:(kurang>=kali&&kurang>=tambah?kurang:kali));

	

	return 0;

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

#include <cstring>

#include <cstdio>

#include <algorithm>

#include <cmath>

using namespace std;

const int N = 1000 + 5;

int a[N];

int main()

{

  int a,b;

  while(cin >> a >> b)

  {

      int maxx = a + b;

      maxx = max(maxx,a-b);

      maxx = max(maxx,a*b);

      printf("%d\n",maxx);

  }

}


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

#include<string.h>





int main(){

	int a,b;

	

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

	

	int tambah=a+b;

	int kurang=a-b;

	int kali=a*b;

	

	printf("%d\n", tambah>=kurang&&tambah>=kali?tambah:(kurang>=kali&&kurang>=tambah?kurang:kali));

	

	return 0;

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

#include<cstdio>

#include<string.h>

#include<algorithm>

#include<cmath>

using namespace std;



int main()

{

    int a,b;

    cin>>a>>b;

    cout<<max(a+b,max(a-b,a*b));

    return 0;

}


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

#include<string.h>





int main(){

	int a,b;

	

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

	

	int tambah=a+b;

	int kurang=a-b;

	int kali=a*b;

	

	printf("%d\n", tambah>=kurang&&tambah>=kali?tambah:(kurang>=kali&&kurang>=tambah?kurang:kali));

	

	return 0;

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



using namespace std;



int main(){

    long int a,b;

    cin>>a>>b;

    long int c=a*b;

    long int d=a+b;

    long int e=a-b;

    long int f=max(c,d);

    cout<<max(f,e)<<endl;

    return 0;

}


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







int main()

{

	

	int A,B,sum,mult,sub;

	

	scanf("%d %d", &A, &B);

	

	sum = A + B;

	mult = A * B;

	sub = A - B;

	

	if (sum > mult && sum > sub){

		printf("%d", sum);

	}

	else if(mult > sum && mult > sub){

		printf("%d", mult);

	}

	else if(sub > sum && sub > mult){

		printf("%d", sub);

	}

	else{

		printf("%d", sum);

	}



	

	return 0;

}
// Slower C++ solution:


#include <iostream>

using namespace std;



int main() {

    int a,b,sum,taf,time;

    cin >> a >> b;

    sum = a + b;

    taf = a - b;

    time = a*b;

   

    if (sum > taf && sum > time  ) {

        cout << sum;

    }

    else if (taf > sum && taf > time) {

        cout << taf;

    }

    else if (time > taf && time > sum) {

        cout << time;

    }

    else{

        cout << sum;

    }



    

    

    return 0;

}


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







int main()

{

	

	int A,B,sum,mult,sub;

	

	scanf("%d %d", &A, &B);

	

	sum = A + B;

	mult = A * B;

	sub = A - B;

	

	if (sum > mult && sum > sub){

		printf("%d", sum);

	}

	else if(mult > sum && mult > sub){

		printf("%d", mult);

	}

	else if(sub > sum && sub > mult){

		printf("%d", sub);

	}

	else{

		printf("%d", sum);

	}



	

	return 0;

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

using namespace std;



int a,b;



int main(){

cin >> a >> b;

int x = a+b;

int y = a-b;

int z = a*b;

if(x >= y && x >= z){

cout << x ;

}else

if(y >= x && y >= z){

cout << y ;

}else

if(z >= y && z >= x){

cout << z;

}

cout << endl;

}

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







int main()

{

	

	int A,B,sum,mult,sub;

	

	scanf("%d %d", &A, &B);

	

	sum = A + B;

	mult = A * B;

	sub = A - B;

	

	if (sum > mult && sum > sub){

		printf("%d", sum);

	}

	else if(mult > sum && mult > sub){

		printf("%d", mult);

	}

	else if(sub > sum && sub > mult){

		printf("%d", sub);

	}

	else{

		printf("%d", sum);

	}



	

	return 0;

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



int main(){

    int A,B, Max = 0;

    scanf("%d %d", &A, &B);

    Max = A + B;

    if((A - B) > Max){

        Max = A - B;

    }

    if((A * B) > Max){

        Max = A * B;

    }

    printf("%d", Max);



    return 0;

}

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







int main()

{

	

	int A,B,sum,mult,sub;

	

	scanf("%d %d", &A, &B);

	

	sum = A + B;

	mult = A * B;

	sub = A - B;

	

	if (sum > mult && sum > sub){

		printf("%d", sum);

	}

	else if(mult > sum && mult > sub){

		printf("%d", mult);

	}

	else if(sub > sum && sub > mult){

		printf("%d", sub);

	}

	else{

		printf("%d", sum);

	}



	

	return 0;

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



using namespace std;



int main(void)

{

    int a, b; cin >> a >> b;



    int mais, menos, multiplicacao;



    mais = a + b;

    menos = a - b;

    multiplicacao = a * b;



    if(mais > menos and mais > multiplicacao)

        cout << mais << endl;

    else if (menos > mais and menos > multiplicacao)

        cout << menos << endl;

    else if (multiplicacao > mais and multiplicacao > menos)

        cout << multiplicacao << endl;



    else

        cout << mais << endl;

    

    return 0;

}

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







int main()

{

	

	int A,B,sum,mult,sub;

	

	scanf("%d %d", &A, &B);

	

	sum = A + B;

	mult = A * B;

	sub = A - B;

	

	if (sum > mult && sum > sub){

		printf("%d", sum);

	}

	else if(mult > sum && mult > sub){

		printf("%d", mult);

	}

	else if(sub > sum && sub > mult){

		printf("%d", sub);

	}

	else{

		printf("%d", sum);

	}



	

	return 0;

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

#include <algorithm>

 

int A, B, X ;





int main()

{

	int A;

	std::cin >> A;

	int B;

	std::cin >> B;

	X = A * B;

	X = std::max(X, A - B);

	X = std::max(X, A + B);

	std::cout << X;

}

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

#include <stdlib.h>

int main()

{

    int a,b;

    while(~scanf("%d %d",&a,&b))

    {

        if(a*b>(a+b)&&a*b>(a-b))

            printf("%d\n",a*b);

        else if((a+b)>(a-b)&&(a+b)>a*b)

            printf("%d\n",a+b);

        else

            printf("%d\n",a-b);

    }

    return 0;

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

using namespace std;

int a,b,x;

int main(){

	cin>>a>>b;

	x=a*b;

	x=max(x,a+b);

	x=max(x,a-b);

	cout<<x<<"\n";

	

}

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

#include <stdlib.h>

int main()

{

    int a,b;

    while(~scanf("%d %d",&a,&b))

    {

        if(a*b>(a+b)&&a*b>(a-b))

            printf("%d\n",a*b);

        else if((a+b)>(a-b)&&(a+b)>a*b)

            printf("%d\n",a+b);

        else

            printf("%d\n",a-b);

    }

    return 0;

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

#include <algorithm>

 

int A, B, X ;





int main()

{

	int A;

	std::cin >> A;

	int B;

	std::cin >> B;

	X = A * B;

	X = std::max(X, A - B);

	X = std::max(X, A + B);

	std::cout << X;

}

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

int main()

{

    int a,b,s,m,p;

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

    s=a+b,p=a*b,m=a-b;

    a=(s>p?(s>m?s:m):(p>m?p:m));

    printf("%d\n",a);



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

using namespace std;

int a,b,x;

int main(){

	cin>>a>>b;

	x=a*b;

	x=max(x,a+b);

	x=max(x,a-b);

	cout<<x<<"\n";

	

}

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

int main()

{

    int a,b,s,m,p;

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

    s=a+b,p=a*b,m=a-b;

    a=(s>p?(s>m?s:m):(p>m?p:m));

    printf("%d\n",a);



}
// Slower C++ solution:


#include<bits/stdc++.h>

using namespace std;

main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);



    long long i,j,k,l,m,n,o,p,q;

    while(cin>>m>>n)



    {

        i=m+n;

        j=m-n;

        k=m*n;

        cout<<max(i,max(j,k))<<endl;



    }

    return 0;

}


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

int main()

{

    int a,b,s,m,p;

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

    s=a+b,p=a*b,m=a-b;

    a=(s>p?(s>m?s:m):(p>m?p:m));

    printf("%d\n",a);



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

using namespace std;

void display()

{

    int a, b, ar[3];

    cin>>a>>b;

    ar[0] = a+ b, ar[1] = a - b , ar[2] = a * b;

    sort(ar, ar + 3);

    cout<<ar[2]<<endl;

}

int main(void)

{

    display();

}


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

int main()

{

    int a,b,s,m,p;

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

    s=a+b,p=a*b,m=a-b;

    a=(s>p?(s>m?s:m):(p>m?p:m));

    printf("%d\n",a);



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

#include <iostream>

#include <cmath>

using namespace std;

int a,b,c,d;

int main(){

	while(~scanf("%d%d",&a,&b)){

		int ans = max(a+b,a-b);

		ans = max(ans,a*b);

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

	}

	return 0;

}

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



int main()

{

	int a,b,d,e,f;

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

	d=a+b;e=a-b;f=a*b;

	

	if(d>=e&&d>=f)

	{

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

	}

	

	else if(e>=d&&e>=f)

	{

		printf("%d\n",e);

	}

	

	else if(f>=d&&f>=e)

	{

		printf("%d\n",f);

	}

	return 0;

}