execute store result score @s maxhp run attribute @s max_health get
execute store result score @s hunger run data get entity @s Health
scoreboard players set @s itemcount 2
scoreboard players operation @s maxhp /= @s itemcount
execute if score @s hunger <= @s maxhp run effect give @s instant_damage
scoreboard players reset @s maxhp
scoreboard players reset @s itemcount
scoreboard players reset @s hunger