Problem:
Score : 100 points

Problem Statement

A Hitachi string is a concatenation of one or more copies of the string hi.

For example, hi and hihi are Hitachi strings, while ha and hii are not.

Given a string S, determine whether S is a Hitachi string.

Constraints

The length of S is between 1 and 10 (inclusive).

S is a string consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If S is a Hitachi string, print Yes; otherwise, print No.

Sample Input 1

hihi

Sample Output 1

Yes

hihi is the concatenation of two copies of hi, so it is a Hitachi string.

Sample Input 2

hi

Sample Output 2

Yes

Sample Input 3

ha

Sample Output 3

No

Solution in C (GCC 5.4.1) (judge verdict: Runtime Error)

#include <stdio.h>
#include <stdlib.h>

typedef struct {
    int x;
    int y;
    int c;
} Coupon;

int *A,*B;
Coupon *M;

int an,bn,mn;

int *x_asc;
int *y_asc;

void createDataStrc(void);
void createSortSeq(void);
void Qsort(int *p,int l,int r,int (*partition)(int*,int,int));
int x_partition(int *p,int l,int r);
int y_partition(int *p,int l,int r);
int search_coupon(int ai,int bi);

void main(void){
    int i,j;
    int min_price = 200000000;
    createDataStrc();
    createSortSeq();
    int t;
    for(i = 0;i < an ;i++){
        for(j = 0;j < bn;j++){
            t = A[i] + B[i] - search_coupon(i+1,j+1);
            if(t < min_price) min_price = t;
        }
    }
    return;
}

void createDataStrc(void){
    int i;
    scanf("%d%d%d",&an,&bn,&mn);
    
    if((A = (int*)malloc(sizeof(int)*an)) == NULL){
        exit(1);
    }
    if((B = (int*)malloc(sizeof(int)*bn)) == NULL){
        exit(1);
    }
    if((M = (Coupon*)malloc(sizeof(Coupon)*mn)) == NULL){
        exit(1);
    }

    for(i = 0;i < an;i++){
        scanf("%d",&(A[i]));
    }
    for(i = 0;i < bn;i++){
        scanf("%d",&(B[i]));
    }
    for(i = 0;i < mn;i++){
        int x,y,c;
        scanf("%d%d%d",&x,&y,&c);
        M[i].x = x;
        M[i].y = y;
        M[i].c = c;
    }
}

void createSortSeq(void){
    int i,x_piv,y_piv;
    if((x_asc = (int*)malloc(sizeof(int)*mn)) == NULL){
        exit(1);
    }
    if((y_asc = (int*)malloc(sizeof(int)*mn)) == NULL){
        exit(1);
    }
    for(i = 0;i < mn;i++){
        x_asc[i] = i;
        y_asc[i] = i;
    }
    Qsort(x_asc,0,mn-1,x_partition);
    Qsort(y_asc,0,mn-1,y_partition);
    
    return;
}

void Qsort(int *p,int l,int r,int (*partition)(int*,int,int)){

    if(l > r){
        int pivot = partition(p,l,r);
        Qsort(x_asc,l,pivot,partition);
        Qsort(x_asc,pivot+1,r,partition);
    }
    return;
}


int x_partition(int *p,int l,int r){
    int i,j,temp = 0;
    int p_value = M[p[0]].x;
    i = 1;
    j = mn-1;
    do{
        while(M[p[i]].x <= p_value) i++;
        while(M[p[j]].x >  p_value) j--;
        temp = p[i];
        p[i] = p[j];
        p[j] = temp;
    }while(i >= j);
    temp = p[i];
    p[i] = p[j];
    p[j] = temp;

    temp = p[l];
    p[l] = p[j];
    p[j] = temp;
    
    return j;
}

int y_partition(int *p,int l,int r){
    int i,j,temp = 0;
    int p_value = M[p[0]].y;
    i = 1;
    j = mn-1;
    do{
        while(M[p[i]].y <= p_value) i++;
        while(M[p[j]].y >  p_value) j--;
        temp = p[i];
        p[i] = p[j];
        p[j] = temp;
    }while(i >= j);
    temp = p[i];
    p[i] = p[j];
    p[j] = temp;

    temp = p[l];
    p[l] = p[j];
    p[j] = temp;
    
    return j;
}

int search_coupon(int ai,int bi){
    int i;

    if(ai < bi){
        for(i = 0;i < mn;i++){
            int x = M[y_asc[i]].x;
            int y = M[y_asc[i]].y;
            int c = M[y_asc[i]].c;
            if(y == bi){
                if(x == ai){
                    return c;
                }
            }else if(y > bi){
                return 0;
            }
        }
    }else {
        for(i = 0;i < mn;i++){
            int x = M[x_asc[i]].x;
            int y = M[x_asc[i]].y;
            int c = M[x_asc[i]].c;
            if(x == ai){
                if(y == bi){
                    return c;
                }
            }else if(x > ai){
                return 0;
            }
        }
    }

    return 0;
}