Please help me on this

#include <iostream>
using namespace std;

int main() {
// your code goes here'
int r,c,testcase,min,cost;
cost = 0;
cin >> testcase;
char start_r,start_c;


for (int i = 0; i <testcase; i++)
{		
	cin >> r >> c;
	
	char orginal[r][c],fake[r][c];
	for ( int i =0 ; i<r ; i++){
		cin>>fake[i];
	}

	

	min = 0;
	start_r = 'R';
	for (int i=0;i<r;i++){
	start_c = start_r;
	for(int j=0;j<c;j++){
		orginal[i][j] = start_c;
		if (start_c == 'G'){
			start_c = 'R';
		}
		else
		{
			start_c = 'G';
		}
	
		if (fake[i][j] != orginal[i][j]){
			if (fake[i][j] == 'R'){
				cost = cost + 3;
			}
			else{
				cost = cost + 5;
			}
		}

		
	}
	if (start_r=='R'){
		start_r = 'G';
	}
	else
	{
		start_r='R';
	}
}






min = cost;
cost = 0;

	start_r = 'G';
for (int i=0;i<r;i++){
	start_c = start_r;
	for(int j=0;j<c;j++){
		orginal[i][j] = start_c;
		if (start_c == 'G'){
			start_c = 'R';
		}
		else
		{
			start_c = 'G';
		}
			
		if (fake[i][j] != orginal[i][j]){
			if (fake[i][j] == 'R'){
				cost = cost + 3;
			}
			else{
				cost = cost + 5;
			}
		}

		
	}
	if (start_r=='R'){
		start_r = 'G';
	}
	else
	{
		start_r='R';
	}
}








if (min < cost){
	cout<<min<<"\n";
}
else{
	cout<<cost<<"\n";
}



}




return 0;
}

**Above is my code which runs fine on my desktop but on codechef compiler it gives this error “sigsegv” … Please help **

You declared fake as 2d char array and taking input as 1d char array which is not correct because 0,1,2 index does not exist for fake.
This causes runtime error.

i changed that to this:
for ( int i =0 ; i<r ; i++){
for(int j=0;j<c;j++){
cin>>fake[i][j];
}
}

then also it is not working, but its working fine with custom input.

here is the link to my solution.