stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<iostream>

#include<string>

#include<cstdio>

#include<cstring>

#include<queue>

using namespace std;

int dx[]={-1,0,1,0};

int dy[]={0,1,0,-1};

char ma[888][888];

int n,m,k,dist[888][888],pis[888][888],mn;

queue<pair<int,int> > q;

bool In(int x,int y)

{

	return (x>=0 && x<n && y>=0 && y<m);

}

int main()

{

	mn=1e9;

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

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

	scanf("%s",ma[i]);

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

	{

		for (int j=0;j<m;j++)

		{

			pis[i][j]=min(min(i,j),min(n-i-1,m-j-1));

			pis[i][j]=(pis[i][j]+k-1)/k;

		}

	}

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

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

	{

		for (int j=0;j<m;j++)

		{

			if (ma[i][j]=='S') 

			{

				q.push(make_pair(i,j));

				dist[i][j]=0;

				mn=min(mn,pis[i][j]+1);

			}

		}

	}

	while(!q.empty())

	{

		int x=q.front().first,y=q.front().second;

		q.pop();

		if (dist[x][y]==k) break;

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

		{

			int xx=x+dx[i],yy=y+dy[i];

			if (In(xx,yy) && ma[xx][yy]=='.' && dist[xx][yy]==-1)

			{

				mn=min(mn,pis[xx][yy]+1);

				dist[xx][yy]=dist[x][y]+1;

				q.push(make_pair(xx,yy));

			}

		}

	}

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

	return 0;

}

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

#include <fstream>

#include <cstdio>

#include <algorithm>

#include <string>

#include <vector>

#include <queue>

#include <deque>

#include <utility>

#include <map>

#include <set>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <functional>

#include <sstream>

#include <cstring>

#include <bitset>

#include <stack>

using namespace std;

#define MP make_pair

#define PB push_back

const int INF=1e9;



int n,m,k,sx,sy,ans;

char c[805][805];

int dist[805][805];

int mx[]={0,0,1,0,-1};

int my[]={0,1,0,-1,0};



inline void bfs(int X,int Y)

{

	queue <int> q;

	q.push(X);q.push(Y);

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

	dist[X][Y]=0;

	while (!q.empty())

	{

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

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

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

		{

			int tx=x+mx[i];

			int ty=y+my[i];

			if (tx<1 || tx>n || ty<1 || ty>m || dist[tx][ty]!=-1 || c[tx][ty]!='.') continue;

			dist[tx][ty]=dist[x][y]+1;

			q.push(tx);

			q.push(ty);

		}

	} 

}



int main()

{

	cin>>n>>m>>k;

	for (int i=1;i<=n;i++) scanf("%s",c[i]+1);

	for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) if (c[i][j]=='S') {sx=i;sy=j;break;}

	bfs(sx,sy);

	ans=INF;

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

		for (int j=1;j<=m;j++)

			if (dist[i][j]<=k && dist[i][j]!=-1)

			{

		//		cout<<i<<" "<<j<<endl;

				int res=min(i-1,n-i);

				res=min(res,min(j-1,m-j));

				ans=min(ans,res);

			}

	cout<<1+(ans+k-1)/k;

	return 0;

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

#include<string>

#include<cstdio>

#include<cstring>

#include<queue>

using namespace std;

int dx[]={-1,0,1,0};

int dy[]={0,1,0,-1};

char ma[888][888];

int n,m,k,dist[888][888],pis[888][888],mn;

queue<pair<int,int> > q;

bool In(int x,int y)

{

	return (x>=0 && x<n && y>=0 && y<m);

}

int main()

{

	mn=1e9;

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

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

	scanf("%s",ma[i]);

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

	{

		for (int j=0;j<m;j++)

		{

			pis[i][j]=min(min(i,j),min(n-i-1,m-j-1));

			pis[i][j]=(pis[i][j]+k-1)/k;

		}

	}

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

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

	{

		for (int j=0;j<m;j++)

		{

			if (ma[i][j]=='S') 

			{

				q.push(make_pair(i,j));

				dist[i][j]=0;

				mn=min(mn,pis[i][j]+1);

			}

		}

	}

	while(!q.empty())

	{

		int x=q.front().first,y=q.front().second;

		q.pop();

		if (dist[x][y]==k) break;

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

		{

			int xx=x+dx[i],yy=y+dy[i];

			if (In(xx,yy) && ma[xx][yy]=='.' && dist[xx][yy]==-1)

			{

				mn=min(mn,pis[xx][yy]+1);

				dist[xx][yy]=dist[x][y]+1;

				q.push(make_pair(xx,yy));

			}

		}

	}

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

	return 0;

}

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

#include <cstring>

#include <cstdio>

#include <queue>

#include <cmath>

 

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

#define CLOSEALL() fclose(stdin), fclose(stdout)

 

using namespace std;

 

const int MAXN = 800 + 5;

const int DIRX[] =

{ 1, -1, 0, 0 };

const int DIRY[] =

{ 0, 0, 1, -1 };

 

int H, W, K;

int stX, stY;

char mz[MAXN][MAXN];

bool vist[MAXN][MAXN];

 

int answer = 0x7F7F7F7F;

 

void BFS()

{

	queue<pair<pair<int, int>, int> > Q;

	Q.push(make_pair(make_pair(stX, stY), 0));

 

	while (!Q.empty())

	{

		pair<pair<int, int>, int> cur = Q.front();

		Q.pop();

 

		if(vist[cur.first.first][cur.first.second])

			continue;

		vist[cur.first.first][cur.first.second] = true;

 

		int curAns = min(min(cur.first.first - 1, H - cur.first.first),

				min(cur.first.second - 1, W - cur.first.second));

		curAns = (curAns + K - 1) / K;

		answer = min(answer, curAns + 1);

 

		if (cur.second >= K)

			continue;

 

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

		{

			pair<int, int> newPos = make_pair(cur.first.first + DIRX[i],

					cur.first.second + DIRY[i]);

			if(newPos.first <= 0 || newPos.first > H)

				continue;

			if(newPos.second <= 0 || newPos.second > W)

				continue;

			if(mz[newPos.first][newPos.second] != '#' && !vist[newPos.first][newPos.second])

				Q.push(make_pair(newPos, cur.second + 1));

		}

	}

}

 

int main()

{

 

	//REDIRECT("room");

 

	scanf("%d%d%d", &H, &W, &K);

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

	{

		scanf("%s", mz[i] + 1);

		for (int j = 1; j <= W; j++)

			if (mz[i][j] == 'S')

				stX = i, stY = j;

	}

 

	BFS();

 

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

 

	CLOSEALL();

	return 0;

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

using namespace std;

#define pb push_back

#define pf push_front

#define eb emplace_back

#define PF pop_front

#define PB pop_back

#define mp make_pair

#define s second

#define f first

#define mt make_tuple

#define foreach(it, a) for(__typeof(a.begin()) it=a.begin(); it!=a.end(); it++)

#define forn(i, a) for(int i=0; i<a; i++)

#define INF 1e9

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

#define MOD 1e9+7 

 

typedef long long ll;

typedef pair<int,int> pi;

typedef pair<pi,int> pii;

typedef unsigned long long ull;

typedef vector<int> vi;

typedef unsigned int uint;

 

const int dx[4]={0, 0, 1, -1};

const int dy[4]={1, -1, 0, 0};

 

int n, m, stx, sty, step[805][805], mx, res=2e9;

char grid[805][805];

queue<int> q;

 

inline bool out(int x, int y)

{

	return x<0||x==n||y<0||y==m;

}

 

void Init()

{

	cin>>n>>m>>mx;

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

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

		for(int j=0; j<m; j++)

		{

			cin>>grid[i][j];

			if(grid[i][j]=='S')

				stx=i, sty=j;

		}

		

	q.push(stx), q.push(sty);

	

	step[stx][sty]=0;

	while(!q.empty())

	{

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

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

		if(step[x][y]==mx+1)

			break;

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

		{

			int xx=x+dx[i], yy=y+dy[i];

			if(!out(xx, yy)&&step[xx][yy]==-1&&grid[xx][yy]!='#')

			{

				step[xx][yy]=step[x][y]+1;

				q.push(xx);

				q.push(yy);

			}

		}

	}

	while(!q.empty())

		q.pop();

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

		for(int j=0; j<m; j++)

			if(step[i][j]<=mx&&step[i][j]!=-1)

				q.push(i), q.push(j);

}

 

int main() 

{

	Init();

	while(!q.empty())

	{

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

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

		res=min(res, (min(min(n-x-1, x), min(y, m-y-1))+mx-1)/mx);

	}

	printf("%d", res+1);

	return 0;

}


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

#define pii pair<int,int>

using namespace std;

const int dx[4]={1,0,-1,0};

const int dy[4]={0,1,0,-1};

int n,m,k,sx,sy,step[888][888],ans=1e9;

string s[888];

bool ch(int x,int y)

{

	return x>=0 && x<n && y>=0 && y<m && step[x][y]==0 && s[x][y]=='.';

}

int main()

{

	cin>>n>>m>>k;

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

	{

		cin>>s[i];

		for(int j=0;j<m;j++)

		{

			if(s[i][j]=='S')

			{

				sx=i;

				sy=j;

			}

		}

	}

	queue<pii>q;

	q.push(pii(sx,sy));

	step[sx][sy]=1;

	while(!q.empty())

	{

		pii p=q.front();

		int x=p.first,y=p.second;

		q.pop();

		ans=min(ans,min(min(x,n-x-1),min(y,m-y-1)));

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

		{

			int nx=x+dx[i],ny=y+dy[i];

			if(ch(nx,ny) && step[x][y]<=k)

			{

				step[nx][ny]=step[x][y]+1;

				q.push(pii(nx,ny));

			}

		}

	}

	cout<<(ans+k-1)/k+1<<endl;

	return 0;

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

using namespace std;

#define pb push_back

#define pf push_front

#define eb emplace_back

#define PF pop_front

#define PB pop_back

#define mp make_pair

#define s second

#define f first

#define mt make_tuple

#define foreach(it, a) for(__typeof(a.begin()) it=a.begin(); it!=a.end(); it++)

#define forn(i, a) for(int i=0; i<a; i++)

#define INF 1e9

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

#define MOD 1e9+7 

 

typedef long long ll;

typedef pair<int,int> pi;

typedef pair<pi,int> pii;

typedef unsigned long long ull;

typedef vector<int> vi;

typedef unsigned int uint;

 

const int dx[4]={0, 0, 1, -1};

const int dy[4]={1, -1, 0, 0};

 

int n, m, stx, sty, step[805][805], mx, res=2e9;

char grid[805][805];

queue<int> q;

 

inline bool out(int x, int y)

{

	return x<0||x==n||y<0||y==m;

}

 

void Init()

{

	cin>>n>>m>>mx;

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

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

		for(int j=0; j<m; j++)

		{

			cin>>grid[i][j];

			if(grid[i][j]=='S')

				stx=i, sty=j;

		}

		

	q.push(stx), q.push(sty);

	

	step[stx][sty]=0;

	while(!q.empty())

	{

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

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

		if(step[x][y]==mx+1)

			break;

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

		{

			int xx=x+dx[i], yy=y+dy[i];

			if(!out(xx, yy)&&step[xx][yy]==-1&&grid[xx][yy]!='#')

			{

				step[xx][yy]=step[x][y]+1;

				q.push(xx);

				q.push(yy);

			}

		}

	}

	while(!q.empty())

		q.pop();

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

		for(int j=0; j<m; j++)

			if(step[i][j]<=mx&&step[i][j]!=-1)

				q.push(i), q.push(j);

}

 

int main() 

{

	Init();

	while(!q.empty())

	{

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

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

		res=min(res, (min(min(n-x-1, x), min(y, m-y-1))+mx-1)/mx);

	}

	printf("%d", res+1);

	return 0;

}

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

#define pii pair<int,int>

using namespace std;

const int dx[4]={1,0,-1,0};

const int dy[4]={0,1,0,-1};

int n,m,k,sx,sy,step[888][888],ans=1e9;

string s[888];

bool ch(int x,int y)

{

	return x>=0 && x<n && y>=0 && y<m && step[x][y]==0 && s[x][y]=='.';

}

int main()

{

	cin>>n>>m>>k;

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

	{

		cin>>s[i];

		for(int j=0;j<m;j++)

		{

			if(s[i][j]=='S')

			{

				sx=i;

				sy=j;

			}

		}

	}

	queue<pii>q;

	q.push(pii(sx,sy));

	step[sx][sy]=1;

	while(!q.empty())

	{

		pii p=q.front();

		int x=p.first,y=p.second;

		q.pop();

		ans=min(ans,min(min(x,n-x-1),min(y,m-y-1)));

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

		{

			int nx=x+dx[i],ny=y+dy[i];

			if(ch(nx,ny) && step[x][y]<=k)

			{

				step[nx][ny]=step[x][y]+1;

				q.push(pii(nx,ny));

			}

		}

	}

	cout<<(ans+k-1)/k+1<<endl;

	return 0;

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

#include<stdio.h>

#include<fstream>

#include<algorithm>

#include<ctime>

#include<cstdlib>

#include<cstring>

#include<vector>

#include<set>

#include<string>

#include<queue>

#include<map>

#include<iomanip>

#include<cassert>

#include<complex>

#include<functional>

#include<list>

#include<cmath>

#include<stack>

#define ll long long

#define pb push_back

#define mp make_pair

using namespace std;

const int dx[]={1,0,-1,0};

const int dy[]={0,1,0,-1};

int n,m,k,d[1024][1024],xs,ys,x,y,xx,yy;

char a[1024][1024];

queue<pair<int,int> > q;

bool valid(int i,int j)

{

	return i>=0 && i<n && j>=0 && j<m && a[i][j]!='#';

}

int asd(int i,int j)

{

	int r=i;

	r=min(r,j);

	r=min(r,n-1-i);

	r=min(r,m-1-j);

	return r;

}

int main()

{

	cin>>n>>m>>k;

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

		for (int j=0;j<m;j++)

		{

			cin>>a[i][j];

			if (a[i][j]=='S') xs=i,ys=j;

		}

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

	d[xs][ys]=0;

	q.push(mp(xs,ys));

	while (!q.empty())

	{

		x=q.front().first; y=q.front().second;

		q.pop();

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

		{

			xx=x+dx[i]; yy=y+dy[i];

			if (valid(xx,yy) && d[xx][yy]<0)

			{

				d[xx][yy]=d[x][y]+1;

				q.push(mp(xx,yy));

			}

		}

	}

	int r=1<<20;

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

		for (int j=0;j<m;j++)

			if (d[i][j]>=0 && d[i][j]<=k)

				r=min(r,1+(asd(i,j)+k-1)/k);

	cout<<r;

    return 0;

}

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

#define INF 0x3f3f3f3f

using namespace std;

const int dx[4]={1,-1,0,0};

const int dy[4]={0,0,1,-1};

int n,m,k,d[801][801],xs,ys,ans=INF;

char s[801][801];

int asd(int i,int j)

{

	int r=i;

	r=min(r,j);

	r=min(r,n-1-i);

	r=min(r,m-1-j);

	return r;

}

queue<pair<int,int> > q;

int main()

{

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);

	cin>>n>>m>>k;

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

		for (int j=0;j<m;++j)

		{

			cin>>s[i][j];

			if (s[i][j]=='S') xs=i,ys=j;

		}

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

	d[xs][ys]=0;

	q.push(make_pair(xs,ys));

	while (!q.empty())

	{

		int x=q.front().first;

		int y=q.front().second;

		q.pop();

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

		{

			int xx=x+dx[i];

			int yy=y+dy[i];

			if (xx>=0 && xx<n && yy>=0 && yy<m && s[xx][yy]=='.' && d[xx][yy]<0)

			{

				d[xx][yy]=d[x][y]+1;

				q.push(make_pair(xx,yy));

			}

		}

	}

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

		for (int j=0;j<m;++j)

			if (d[i][j]>=0 && d[i][j]<=k)

				ans=min(ans,1+(asd(i,j)+k-1)/k);

	cout<<ans;

	return 0;

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

using namespace std;

int main()

{

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);

	long long int a,ans;

    double b;

	cin>>a>>b;

	ans=a*b;

	cout<<ans;

}


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

int main(){

int a,b;

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

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

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

using namespace std;

int main()

{

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);

	long long int ans;

    long double a,b,s;

	cin>>a>>b;

	s=a*b;

	ans=(long long int) s;

	cout<<ans;

}

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

int main(){

int a,b;

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

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

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

using namespace std;



signed main()

{

	int a,b;

	cin>>a>>b;

	cout<<a*b<<endl;

	

	return 0;

}

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

int main()

{

    int a, b;

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

    int sum = a*b;

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

    return 0;

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

using namespace std;



int main()

{

	int a,b;

	cin>>a>>b;

	cout<<a*b<<endl;

	

	return 0;

}


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

int main()

{

    int a, b;

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

    int sum = a*b;

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

    return 0;

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

#include<algorithm>

#include<cstring>

using namespace std;

typedef long long  ll;

int main()

{

	ll a,b;

	cin>>a>>b;

	cout<<a*b;

}

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

int main()

{

    int a, b;

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

    int sum = a*b;

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

    return 0;

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

using namespace std;

int main()

{

	int a,b;

	cin>>a>>b;

	cout<<a*b;

	return 0;

} 

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

int main()

{

    int a, b;

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

    int sum = a*b;

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

    return 0;

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

using namespace std;

int main()

{

	int a,b;

	cin>>a>>b;

	cout<<a*b;//

 } 

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

int main()

{

    int a, b;

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

    int sum = a*b;

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

    return 0;

}
// Slower C++ solution:
 

#include<bits/stdc++.h>

#include<iostream>

#include<algorithm>

#include<cstring>

#include<cstdio>

#include<cmath>

#define ll  long long

#define ull unsigned long long

#define IO ios::sync_with_stdio(false), cin.tie(0)

#define endl '\n'

#define main() int main()

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

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

#define pi acos(-1.0)

#define ms(a, x) memset(a, x, sizeof(a))

#define lowbit(x) ((x)&(-(x)))

#define pb push_back

#define binarycount __builtin_popcount(x)

#define tr t[root]

#define lson t[root << 1]

#define rson t[root << 1 | 1]

#define fir first

#define sec second

#define debug(x) cout<<x<<'\n'

#define sa(a) scanf("%d", &a)

#define sab(a, b) scanf("%d%d", &a, &b)

#define pa(a) printf("%d",a)

#define pab(a,b) printf("%d%d",a,b)

#define pii pair<int,int>

using namespace std;



#define maxn 1000005

const int inf = 0x3f3f3f3f;

const int mod = 1e9+7;

const double eps = 1e-8;

ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}

ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}

ll powmod(ll a,ll b){

    ll ans = 1, pow = a%mod;

    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }

    return ans%mod;

}

main()

{  

    ll a,b;

    cin>>a>>b;

    cout<<a*b<<endl;

}

 

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

int main()

{

    int a, b;

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

    int sum = a*b;

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

    return 0;

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

using namespace std;

int main()

{

    int a,b,c;

    cin>>a>>b;

    c=a*b;

    cout<<c<<endl;

    return 0;

}


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

int main()

{

    int a, b;

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

    int sum = a*b;

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

    return 0;

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

using namespace std;

int main()

{

    long long int a,b;

    cin>>a>>b;

    cout<<a*b<<endl;

    return 0;

}


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

int main()

{

    int a, b;

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

    int sum = a*b;

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

    return 0;

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

using namespace std;

int main()

{

    int A,B;

    cin >> A >> B;

    cout << A*B << endl;

}


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

using namespace std;

int main()

{

    int a,b;

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

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

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

#define ll long long

#define endl '\n'

using namespace std;

#define N 100007

#define mod 1000000000000000000

#define pb push_back

vector<ll> v[N];

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()

{

    ll a,b;

    cin>>a>>b;

    cout<<a*b;

    

}

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

#define ll long long

#define endl '\n'

using namespace std;

//#define N 100007

//#define mod 1000000000000000000

//#define pb push_back

// vector<ll> v[N];

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);

int main()

{

    ll a,b;

    cin>>a>>b;

    cout<<a*b;

    

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

#define int long long

using namespace std;

int a, b, c, x, y, ans = 1e18 + 13;

int32_t main () {

    cin >> a >> b >> c >> x >> y;

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

	int resx = max(0ll, x - i / 2), resy = max(0ll, y - i / 2);

	ans = min(ans, i * c + resx * a + resy * b);

    }

    cout << ans << endl;

}


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



using namespace std;



typedef long long ll;

typedef unsigned long long ull;

typedef vector<int> vi;

typedef pair<int,int> ii;

typedef pair<int,pair<int,int>> iii;

typedef vector<pair<int,int>> vii;

typedef vector<vector<int>> vvi;



#define pb push_back

#define mp make_pair

#define fi first

#define se second



int main (void) {

    ios_base::sync_with_stdio(false);



    int a,b,c,x,y;

    int ans = 1e9;



    cin >> a >> b >> c >> x >> y;



    ans = min(ans, a*x+b*y);

    if (x < y) {

        ans = min(ans, 2*c*x+(y-x)*b);

        ans = min(ans, 2*c*y);

    } else {

        ans = min(ans, 2*c*y+(x-y)*a);

        ans = min(ans, 2*c*x);

    }



    cout << ans << endl;



    return 0;

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

#define int long long

using namespace std;

int a, b, c, x, y, ans = 1e18 + 13;

int32_t main () {

    cin >> a >> b >> c >> x >> y;

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

	int resx = max(0ll, x - i / 2), resy = max(0ll, y - i / 2);

	ans = min(ans, i * c + resx * a + resy * b);

    }

    cout << ans << endl;

}


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

#include <algorithm>

#include <stdio.h>

#include <iostream>

#include <queue>

#include <string>

#include <set>

#include <map>

#include <unordered_set>

#include <unordered_map>

using namespace std;

int main(){

    int a,b,c,x,y;

    scanf("%d %d %d %d %d\n",&a,&b,&c,&x,&y);

    int sum=a*x+b*y;

    int d=min(x,y);

    //cout<<sum<<endl;

    sum=min(sum,d*2*c+(x-d)*a+(y-d)*b);

    //cout<<sum<<endl;

    d=max(x,y);

    sum=min(sum,d*2*c);

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

	return 0;

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

#define int long long

using namespace std;

int a, b, c, x, y, ans = 1e18 + 13;

int32_t main () {

    cin >> a >> b >> c >> x >> y;

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

	int resx = max(0ll, x - i / 2), resy = max(0ll, y - i / 2);

	ans = min(ans, i * c + resx * a + resy * b);

    }

    cout << ans << endl;

}


// Faster C++ solution for the same problem (measured speedup: 2.4130913575842214x):
////////////////////////// Author

////////////////////////// Nasim Hossain Rabbi

////////////////////////// JU-CSE28

////////////////////////// CF - imnasim3.1415

////////////////////////// UVA - imnasim3.1415

////////////////////////// Mail - imnasim3.1415@gmail.com

#include<bits/stdc++.h>

using namespace std;

#define sz size()

#define mk make_pair

#define clr clear()

#define B begin()

#define E end()

#define EM empty()

#define mem(a,b) memset(a,b,sizeof(a))

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

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

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

#define pb push_back

string en="\n";

string t="hello";

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

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)

#define pi 3.1415926535897932384626433832795

#define vi vector<int>

#define vl vector<long long>

#define vs vector<string>

#define vp(vi,x) cin>>x; vi.pb(x);

#define LB(a,x) (lower_bound(aov(a),x)-a.begin())

#define UB(a,x) (upper_bound(aov(a),x)-a.begin())

typedef long long LL;

typedef unsigned long long ULL;

bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}

int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}

template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}

template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

int main()

{

//    fast;

    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;

    while(cin>>i>>j>>k>>x>>y)

    {

        s=0;

        c=INT_MAX;

        l=min(x,y);

        s=l*2*k;

        s+=(x-l)*i;

        s+=(y-l)*j;

        if(s<c) c=s;

        s=i*x+j*y;

        if(s<c) c=s;

        l=max(x,y);

        s=k*l*2;

        if(s<c) c=s;

        cout<<c<<en;

    }

}