program yukicoder_2534 use, intrinsic :: iso_fortran_env implicit none integer(int32), parameter :: max_iter = 50 integer(int32) :: n integer(int32) :: i read(input_unit, *) n call operation_1(n) contains subroutine operation_1(n) integer(int32), intent(in) :: n call operation_2(n, 2) end subroutine operation_1 recursive subroutine operation_2(n, i) integer(int32), intent(in) :: n, i if (i > max_iter) then write(output_unit, '(a)') "No" stop else if (n == 1) then write(output_unit, '(a)') "Yes" write(output_unit, '(i0)') i stop end if call operation_3(n, i + 1) end subroutine operation_2 recursive subroutine operation_3(n, i) integer(int32), intent(in) :: n, i if (i > max_iter) then write(output_unit, '(a)') "No" stop end if if (iand(n, b'1') == 0) then call operation_2(n / 2, i + 1) else call operation_2(3 * n + 1, i + 1) end if end subroutine operation_3 end program yukicoder_2534