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



Sample input:
hihi


Sample output:
Yes

Submission status: Runtime Error

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M = inpl()
H = 2**N-1
W = 2**M-1

ans = [[0] * W for _ in range(H)]
# for i in range(W):
    # for j in range(H):
        # ans[j][i] =

ans[0][0] = 1
ans[0][W-1] = 1
ans[H-1][0] = 1
ans[H-1][W-1] = 1
# ans[H//2][W//2] = 1
# ans[0][W//2] = 1
# ans[H-1][W//2] = 1
# ans[H//2][0] = 1
# ans[H//2][W-1] = 1

for a in ans:
    print("".join(map(str,a)))

Submission status: Runtime Error

Solution code:
a, b, m = map(int, input().split())
a1 = list(map(int, input().split()))
b1 = list(map(int, input().split()))

disc = [list(map(int, input().split())) for i in range(m)]
import numpy as np



from collections import deque
ans = []
ans = deque(ans)

for i in range(m):
    ans.append( a1[disc[i][0]-1] + b1[disc[i][1]-1] - disc[i][2] )
b2 = np.array(b1)
a2 = np.array(a1)
a2 = a2.reshape(a,1)
ans = list(ans)
print(min( min(ans), np.min(a2+b2) ))

Submission status: Runtime Error

Solution code:
import mojimoji

S = input().strip()
s = mojimoji.zen_to_han(S)
target = 'hi'
index = s.find(target)
if 10 >index > -1:
    print('Yes')
else:
    print('No')
index = -1

Submission status: Runtime Error

Solution code:
import math
import itertools
N = int(input())
array=[]
for i in range(0, N-1):
    array.append(input().split())
dist3=[]
for row in array:
    a,b=row
    c = []
    d=[]
    for tmpc1,tmpc2 in array:
        if tmpc1 == a and tmpc2 != a and tmpc2!=b:
            c.append(int(tmpc2)-1)
        if tmpc1 != a and tmpc2 == a and tmpc1 != b:
            c.append(int(tmpc1)-1)
    for tmpd1,tmpd2 in array:
        if tmpd1 == b and tmpd2!=a and tmpd2 != b and tmpd2!=c:
            d.append(int(tmpd2)-1)
        if tmpd1 != b and tmpd1!=a and tmpd2 == b and tmpd1!=c:
            d.append(int(tmpd1)-1)
    if c != [] and d != []:
        #print("{} {} {} {}".format(a, b, c, d))
        dist3.append([c, d])
        
for kouho in itertools.permutations(list(range(1,N+1)),N):
    breakflag=False
    for c, d in dist3:
        for tmpc in c:
            for tmpd in d:
                if (kouho[tmpc] + kouho[tmpd]) % 3 != 0 and (kouho[tmpc] * kouho[tmpd]) % 3 != 0:
                    breakflag = True
                    break
                #else:
                    #print("{} {} {} {}".format( tmpc, tmpd,kouho[tmpc],kouho[tmpd]))
            if breakflag==True:
                break
        if breakflag!=True:
            print(' '.join(map(str,kouho)))
            exit()

print('-1')

Submission status: Runtime Error

Solution code:
def mi():return map(int,input().split())
n,m=mi()
n=pow(2,n)-1
m=pow(2,m)-1

for i in range(n):
    if i==0 or i==n-1:
        print("1"*m)
    else:
        if i%2==1:
            print("1"*m)
        else:
            print("1"+"0"*(m-2)+"1")

Submission status: Runtime Error

Solution code:
import sys
s = input()

l = len(s)

if l % 2 == 1:
    print("No")
    return
    sys.exit(0)
else:
    for i in range(0, l, 2):
        if s[i:i+2] == "hi":
            continue
        else:
            print("No")
            sys.exit(0)
    print("Yes")

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
ans = [[1 for j in range(2**m-1)] for i in range(2**n-1)]
for i in range(2**n-1):
  for j in range(2**m-1):
    if i%2 != j%2:
      ans[i][j] = 0
    if (abs(i%8) == 3) ^ (abs(j%8) == 3):
      ans[i][j] = 1
for arr in ans:
  print(*arr,sep="")

Submission status: Runtime Error

Solution code:
N,T=map(int,input().split())
l=[]
t=0
c=0
for _ in range(N):
  L=list(map(int,input().split()))
  l.append(L)
l.sort()
def f(x):
  ls=[]
  for i in range(len(l)):
    v=l[i][0]*x+l[i][1]
    ls.append([v,i])
  return min(ls)
if f(1)[0]+1>T:
  print(0)
  exit()
for i in range(N):
  t+=1
  t+=f(t)[0]
  if f(t)[0]<=T:
    c+=1
    del l[f(t)[1]]
  else:
    print(c+1)
    exit()
print(N)

Submission status: Runtime Error

Solution code:
s = input()

l = len(s)

if l % 2 == 1:
    print("No")
else:
    for i in range(0, l, 2):
        if s[i:i+2] == "hi":
            continue
        else:
            print("No")
            return
    print("Yes")

Submission status: Runtime Error

Solution code:
import re
if re.match ('(hi)'+, input()):
    print ('Yes')
else:
    print ('No')

Submission status: Runtime Error

Solution code:
import re
 
if re.match(r'^(hi)+$',S):
  print('Yes')

else:
  print('No')

Submission status: Runtime Error

Solution code:
data = input().split(" ")
A = input().split(" ")
B = input().split(" ")
total = 0
a = 0
b = 0
j = 0
for i in data:
    data[j] = int(i)
    j += 1
j = 0
for i in A:
    A[j] = int(i)
    j += 1
j = 0
for i in B:
    B[j] = int(i)
    j += 1


for i in range(data[2]):
    data1 = input().split()
    j = 0
    for i in data1:
        data1[j] = int(i)
        j += 1
    data2 = A[data1[0]-1] + B[data1[1]-1] - data1[2]
    if total > data2:
        total = data2

for i in A:
    if a > i:
        a = i
for i in B:
    if b > i:
        b = i

if total > a+b:
    total = a+b

print(total)

Submission status: Runtime Error

Solution code:
import re
if re.match ("(hi)"+, input()):
    print ("Yes")
else:
    print ("No")

Submission status: Runtime Error

Solution code:
data = input().split(" ")
A = input().split(" ")
B = input().split(" ")
total = 100000
a = 100000
b = 100000
j = 0
for i in data:
    data[j] = int(i)
    j += 1
j = 0
for i in A:
    A[j] = int(i)
    j += 1
j = 0
for i in B:
    B[j] = int(i)
    j += 1


for i in range(data[2]):
    data1 = input().split()
    j = 0
    for i in data1:
        data1[j] = int(i)
        j += 1
    data2 = A[data1[0]-1] + B[data1[1]-1] - data1[2]
    if total > data2:
        total = data2

for i in A:
    if a > i:
        a = i
for i in B:
    if b > i:
        b = i

if total > a+b:
    total = a+b

print(total)

Submission status: Runtime Error

Solution code:
import re

if re.match(r'^(hi)+$'):
  print('Yes')

else:
  print('No')

Submission status: Runtime Error

Solution code:
def lin(t,i):
    return As[i]*t+Bs[i]
f=input().split(" ")
n,t=int(f[0]),int(f[1])
As=[]
Bs=[]
for i in range(n):
    f=input().split(" ")
    As.append(int(f[0]))
    Bs.append(int(f[1]))
time=0
count=0
shop_list=list(range(n))
while len(shop_list)>0:
    test=min(enumerate([lin(time+1,i) for i in shop_list]), key = lambda x:x[1])
    next_time,shop=test[1],shop_list[test[0]]
    if time+1+next_time>t:
        break
    else:
        time=time+1+next_time
        shop_list.remove(shop)
        count+=1
print(count)

Submission status: Runtime Error

Solution code:
data = input().split(" ")
A = input().split(" ")
B = input().split(" ")
total = 100000
a = 100000
b = 100000
j = 0
for i in data:
    data[j] = int(i)
    j += 1
j = 0
for i in A:
    A[j] = int(i)
    j += 1
j = 0
for i in B:
    B[j] = int(i)
    j += 1


for i in range(data[2]):
    data1 = input().split()
    j = 0
    for i in data1:
        data1[j] = int(i)
        j += 1
    data2 = A[data1[0]-1] + B[data1[1]-1] - data1[2]
    print(data2)
    if total > data2:
        total = data2

for i in A:
    if a > i:
        a = i
for i in B:
    if b > i:
        b = i

if total > a+b:
    total = a+b

print(total)

Submission status: Runtime Error

Solution code:
f=0
s=list(input())
for i in range(len(s)):
    if i%2==1:
        if s[i]!=i:
            f=1
            print('No')
            break
    else:
        if s[i]!=h:
            f=1
            print('No')
            break
if f==0:
    print('Yes')

Submission status: Runtime Error

Solution code:
import re
if re.match ((hi)+, input()):
    print ("Yes")
else:
    print ("No")

Submission status: Runtime Error

Solution code:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

x = [0] * M
y = [0] * M
c = [0] * M

min = 99999999

for i in range(M):
    x[i], y[i], c[i] = map(int, input().split())
    cost = a[x[i] - 1] + b[y[i] - 1] - c[i]
    if cost < min:
        min = cost

for i in range(A):
    if a[i] > cost:
        continue
    for j in range(B):
        if b[j] > cost:
            break
        cost = a[i] + b[j]
        if cost < min:
            min = cost

print(min)

Submission status: Runtime Error

Solution code:
s = input()

l = len(s)
# print(l)
# print(s[0:1])
if l % 2 != 0:
    print("No")
else:
    for i in range(0, l, 2):
        if s[i:i+2] == "hi":
            # print(s[i:i+1])
        else:
            print("No")
            break
    print("Yes")

Submission status: Runtime Error

Solution code:
import numpy as np
a,b,m = [int(i) for i in input().split()]
aa = [int(i) for i in input().split()]
bb = [int(i) for i in input().split()]
x = np.zeros(m,dtype=int)
y = np.zeros(m,dtype=int)
c = np.zeros(m,dtype=int)
for i in range(m):
    x[i],y[i],c[i] = [int(j) for j in input().split()]
r = np.zeros((a,b),dtype=int)
for i in range(a):
    for j in range(b):
        r[i][j] = aa[i] + bb[j]
v = np.min(r)
for i,j,l in zip(x,y,c):
    if v > r[i-1][j-1] - l:
        v = r[i-1][j-1] - l
print(v)

Submission status: Runtime Error

Solution code:
A,B,M = map(int, input().split())

la = list(map(int, input().split()))
lb = list(map(int, input().split()))

d = []
for i in range(M):
  d.append(list(map(int, input().split())))
           
for i in range(M):
  d[i] = la[(d[i][0]-1)] + lb[(d[i][1]-1)] - d[i][2]
  
o = min(la) + min(lb)
d.append(o)

print(min(d))

Submission status: Runtime Error

Solution code:
S = input()
result = ["Yes" if (S[-2] == "h") and (S[-1] == "i") else "No"]
p = list(map(print, result))

Submission status: Runtime Error

Solution code:
S = input()
 
j_S = 'hi'
j_b = ['a','i','o','u','e']
#j_b2 =  ['a','o','u','e']

if len(S) > 1:
    if not j_S in S:
        print('No')    
    else:
        i = 0
        S_1 = S.replace(j_S,'X')
        for in_b in j_b:
            j_S_b = 'X' + in_b
            if j_S_b in S:
                S_1 = S_1.replace(j_S_b, 'Y')
        
        
        
        if 'X' in S_1:
            if S_1.startswith('X')
                print('Yes')
        else:
            print('No')
else:
    print('No')

Submission status: Runtime Error

Solution code:
A,B,M = map(int, input().split())

la = list(map(int, input().split()))
lb = list(map(int, input().split()))

d = []
for i in range(M):
  d.append(list(map(int, input().split())))
           
for i in range(M):
  d[i] = la[(d[i][0]-1)] + lb[(d[i][1]-1)] - d[i][2]

print(min(d))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
graph = {i:[] for i in range(n)}
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  graph[a].append(b)
  graph[b].append(a)
  
one = n//3 + bool(n%3)
two = n//3 + bool(n%3>1)
three = n//3
nums = [three+1,one,two]
perms = [0 for i in range(n)]



def dfs(i,n):
  global nums
  perms[i] = (nums[n]-1)*3 + n
  nums[n] -= 1 
  for node in graph[i]:
    if perms[node] == 0:
      next_n = (3-n)%3
      if nums[next_n] == 0:
        dfs(node,0)
      else:
        dfs(node,next_n)


for i in range(n):
  dfs(i,1)
  if sum(perms) == n*(n+1)//2:
    break
  perms = [0 for _ in range(n)]
  nums = [three+1,one,two]
print(*perms)

Submission status: Runtime Error

Solution code:
hitachi = input()
#type(hitachi)
flag = 0
if(len(hitachi) == 1):
    hitachi += " "
elif(len(hitachi) >= 11):
    hitachi = " "
for x in range(len(hitachi)):
    if(hitachi[x] == " "):
        break
    if(x %2 == 0):
        if(hitachi[x] + hitachi[x+1] == "hi"):
            #print(hitachi[x] + hitachi[x+1])
            flag += 1
        else:
            #print(hitachi[x] + hitachi[x+1])
            print("No")
            break
if(not len(hitachi) == 0):
    if(flag == len(hitachi)//2):
        print("Yes")

Submission status: Runtime Error

Solution code:
hitachi = input()
#type(hitachi)
flag = 0
if(len(hitachi) == 1):
    hitachi += " "
for x in range(len(hitachi)):
    if(hitachi[x] == " "):
        break
    if(x %2 == 0):
        if(hitachi[x] + hitachi[x+1] == "hi"):
            #print(hitachi[x] + hitachi[x+1])
            flag += 1
        else:
            #print(hitachi[x] + hitachi[x+1])
            print("No")
            break
if(not len(hitachi) == 0):
    if(flag == len(hitachi)//2):
        print("Yes")

Submission status: Runtime Error

Solution code:
h=input()

id=[i for i,k in enumerate(h) if k=="h"] 

a=0

for l in id:
  if "i"==h[l+1]:
    if "i"!=h[l+2]:
      a+=1
    elif "ii" == h[l+2]:
      a+=0
  elif "i" != h[l+1]:
    a+=0
        
if "h" not in h:
  a+=0
  
if a>0:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import sys

lines = sys.stdin.readlines()

num_a ,num_b, num_m = [int(v) for v in lines[0].split()]
# ----

a_list = [int(v) for v in lines[1].split()[:num_a+1]]
b_list = [int(v) for v in lines[2].split()[:num_b+1]]

# print(a_list)
# print(b_list)

result = max(a_list) + max(b_list)
# ignores = set()
for c in lines[3:num_m+3]:
    a_i, b_i, discount = map(int, c.split())
    try:
#         ignores.add((int(a_i), int(b_i)))    
        price = a_list[a_i-1] + b_list[b_i-1] - discount
        
        if price < result:
            result = price
    except IndexError:
        print('------')
        print(c)
        pass

res1 = [
    a_list[a_i-1]+b_list[b_i-1]-discount for a_i, b_i, discount in [map(int, l.split())  for l in lines[3:num_m+3]]]


res2 = [a+b for b in b_list
        for a in a_list]

print(min(min(res1), min(res2)))

Submission status: Runtime Error

Solution code:
# coding:utf8
S = input()

if S == hi or S ==hihi or S=hihih or S=hihihihi or S=hihihihihi:
    print("Yes")
else :
    print("No")

Submission status: Runtime Error

Solution code:
A=input
if A='hi' or A='hihi' or A='hihihi' or A='hihihihi' or A='hihihihihi' or A='hih' or A='hihih' or A='hihihih' or A='hihihihih':
    print('Yes')
else:
    print('No')