(i) You have to take input of length of each procession and not a single time because the length is varying . Take the input of l in the for loop of R.
(ii) As the length of maximum procession is given to be 500 , you can declare a char array of length slightly greater than 500 say 505 .
(iii) You are checking for the number of heads and no. of tails should be equal . Instead you should check that each occurence of head is followed by an occurence of tail . If it satisfies this criteria then the answer would be valid .
(iv) Try to use c++ style of coding and take input using cin because scanf sometimes cause array .
If you have any other query , feel free to comment it .