program yukicoder_2647 use, intrinsic :: iso_fortran_env implicit none integer(int32) :: t integer(int32) :: i read(input_unit, *) t do i = 1, t call calc_query() end do contains impure subroutine calc_query() integer(int32) :: d integer(int64) :: a integer(int64), allocatable :: xs(:) read(input_unit, *) d, a allocate(xs(d)) read(input_unit, *) xs(:) write(output_unit, '(*(i0, 1x))') round_div(xs, a) end subroutine calc_query pure elemental integer(int64) function round_div(x, y) result(res) integer(int64), intent(in) :: x, y integer(int64) :: rest res = x / y rest = x - res * y if (2 * rest >= y) & & res = res + 1_int64 end function round_div end program yukicoder_2647