Help me in solving GROUPS problem

My issue

this code is running successfully , but while submitting it gives Runtime Error
pls verify my code

My code

#include <stdio.h>

int main(void) {
	int T,i,j,ctr=0,arr[50];
	char str[50];
	scanf("%d",&T);
	for(i=0;i<T;i++){
	        scanf("%s", str); 
	        j=0;
	        ctr=0;
	        while(str[j]!='\0'){
	            if((str[j]=='1') && str[j+1]!='1'){
	                ctr++;
	            }
	            
	            j++;
	        }
	        arr[i]=ctr;
	}
	
    for(i=0;i<T;i++) {
        printf("%d",arr[i]);
        printf("\n");
    }
}


Problem Link: Chef and Groups Practice Coding Problem - CodeChef

@saicharan237
have corrected your code , Hope u will get the mistake

#include <stdio.h>

int main(void) {
	int T,i,j,ctr=0,arr[100001];
	char str[100001];
	scanf("%d",&T);
	for(i=0;i<T;i++){
	        scanf("%s", str); 
	        j=0;
	        ctr=0;
	        while(str[j]!='\0'){
	            if((str[j]=='1') && str[j+1]!='1'){
	                ctr++;
	            }
	            
	            j++;
	        }
	        arr[i]=ctr;
	}
	
    for(i=0;i<T;i++) {
        printf("%d",arr[i]);
        printf("\n");
    }
}

you got run time error because you declared str with utmost 50 characters. But if input has more characters than 50 you will get run time error. In question they given N<100000. so declare str with 100000 characters.