Language: C++

import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (n, m, l) = readListOfInt()

	val minCostMap = Array(n) { Array(n) { Long.MAX_VALUE / 2 } }
	(0 until n).forEach {
		minCostMap[it][it] = 0L
	}

    for(i in 0 until m) {
        var (a, b, c) = readListOfInt()
		a--; b--
		val cl = c.toLong()
		minCostMap[a][b] = cl
		minCostMap[b][a] = cl
    }

	for(i in 0 until n) {
		for(j in 0 until n) {
			for(k in 0 until n) {
				minCostMap[i][j] = Math.min(minCostMap[i][j], minCostMap[i][k] + minCostMap[k][j])
			}
		}
	}

	val minSupplyMap = Array(n) { Array(n) { Long.MAX_VALUE / 2 } }
	(0 until n).forEach {
		minSupplyMap[it][it] = 0L
	}

	for(i in 0 until n) {
		for(j in 0 until n) {
			if(minCostMap[i][j] <= l) {
				minSupplyMap[i][j] = 1L
				minSupplyMap[j][i] = 1L
			}
		}
	}

	for(i in 0 until n) {
		for(j in 0 until n) {
			for(k in 0 until n) {
				minSupplyMap[i][j] = Math.min(minSupplyMap[i][j], minSupplyMap[i][k] + minSupplyMap[k][j])
			}
		}
	}

    val q = readInt()
    (0 until q).map {
        val (s, t) = readListOfInt().map { it-1 }
		val supply = minSupplyMap[s][t] - 1L
		println(if(supply > Long.MAX_VALUE / 10) -1L else supply)
    }

	pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

// Extensions
fun<T> List<T>.toBuckets(): Map<T, Int>
	= this.groupBy { it }.mapValues { it.value.size }

fun<T: Comparable<T>> List<T>.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {
	var l = fromIndex
	var r = toIndex
	while(l < r) {
		val mid = (l+r) / 2
		if(element >= this[mid]) { 
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

fun<T: Comparable<T>> List<T>.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {
	var l = fromIndex
	var r = toIndex
	while(l < r) {
		val mid = (l+r) / 2
		if(element <= this[mid]) { 
			r = mid
		} else {
			l = mid + 1
		}
	}
	return r 
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

// Util Functions
fun Long.makeDivisors(): List<Long> {
	val divisors = mutableListOf<Long>()
	for(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) {
		if(this % i == 0L) {
			divisors.add(i)
			if(i != this/i) {
				divisors.add(this/i)
			}
		}
	}
	return divisors.distinct().sorted()
}

fun Long.isPrime(): Boolean {
	if(this==1L) return false
	for(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) {
		if(this % i == 0L && this != i) {
			return false
		}
	}
	return true
}


fun<T> permutations(src: List<T>): List<List<T>> {
	if(src.size == 1) return listOf(src)
	val perms = mutableListOf<List<T>>()
	val insertElement = src[0]
	permutations(src.drop(1)).forEach { perm ->
		for(i in 0..perm.size) {
			val newPerm = perm.toMutableList()
			newPerm.add(i, insertElement)
			perms.add(newPerm.toList())
		}
	}
	return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
	val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
	for(i in 0 until v.size) {
		v[i][0] = 1L
		v[i][i] = 1L
	}
	for(i in 0 until v.size) {
		for(j in 1 until i) {
			v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
		}
	}
	return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
	if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
	a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
	var num = num_
	var rtn: Long = 0
	while(num != 0.toLong()) {
		val tmp = num % 10
		rtn += tmp
		num /= 10
	}
	return rtn
}

fun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
	fun isEmpty() = st.isEmpty()
	fun top(): T = st.last()
	fun push(e: T) { st.add(e) }
	fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
	fun isEmpty() = que.isEmpty()
	fun top(): T = que.first()
	fun push(e: T) { que.add(e) }
	fun pop() { que = que.drop(1).toMutableList() }
    override fun toString(): String = que.toString()
    
    
}


Compiler output:
a.cc:147:26: error: too many decimal points in number
  147 |                 for(i in 0..perm.size) {
      |                          ^~~~~~~~~~~~
a.cc:158:18: error: too many decimal points in number
  158 |         val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
      |                  ^~~~
a.cc:158:31: error: too many decimal points in number
  158 |         val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
      |                               ^~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.PrintWriter
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:68:1: error: 'fun' does not name a type
   68 | fun read() = readLine()!!
      | ^~~
a.cc:74:1: error: 'fun' does not name a type
   74 | fun readListOfLong() = readListOfString().map { it.toLong() }
      | ^~~
a.cc:75:1: error: 'fun' does not name a type
   75 | fun readListOfDouble() = readListOfString().map { it.toDouble() }
      | ^~~
a.cc:77:1: error: 'fun' does not name a type
   77 | fun Double.format(digits: Int) = String.format("%.${digits}f", this)
      | ^~~
a.cc:81:1: error: 'fun' does not name a type
   81 | fun println(value : Any) { pw.println(value) }
      | ^~~
a.cc:84:1: error: 'fun' does not name a type
   84 | fun<T> List<T>.toBuckets(): Map<T, Int>
      | ^~~
a.cc:85:30: error: expected unqualified-id before '.' token
   85 |         = this.groupBy { it }.mapValues { it.value.size }
      |                              ^
a.cc:87:1: error: 'fun' does not name a type
   87 | fun<T: Comparable<T>> List<T>.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {
      | ^~~
a.cc:101:1: error: 'fun' does not name a type
  101 | fun<T: Comparable<T>> List<T>.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int {
      | ^~~
a.cc:115:1: error: 'fun' does not name a type
  115 | fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)
      | ^~~
a.cc:131:1: error: 'fun' does not name a type
  131 | fun Long.isPrime(): Boolean {
      | ^~~
a.cc:142:1: error: 'fun' does not name a type
  142 | fun<T> permutations(src: List<T>): List<List<T>> {
      | ^~~
a.cc:157:1: error: 'fun' does not name a type
  157 | fun combinations(n: Long): List<List<Long>> {
      | ^~~
a.cc:172:1: error: 'fun' does not name a type
  172 | fun gcd(a: Long, b: Long): Long =
      | ^~~
a.cc:190:1: error: 'fun' does not name a type
  190 | fun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)
      | ^~~
a.cc:200:7: error: 'Queue' is not a class template
  200 | class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
      |       ^~~~~
a.cc:200:13: error: 'T' was not declared in this scope
  200 | class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
      |             ^
a.cc:200:16: error: expected unqualified-id before 'private'
  200 | class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
      |                ^~~~~~~
a.cc:200:16: error: expected ')' before 'private'
  200 | class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
      |               ~^~~~~~~
      |                )