Skip to content

Instantly share code, notes, and snippets.

View qwert2603's full-sized avatar

Alexander Zhdanov qwert2603

View GitHub Profile
import com.google.gson.Gson
import com.google.gson.annotations.SerializedName
data class Q @JvmOverloads constructor(
val i: Int,
@SerializedName("list") val list: List<String> = emptyList()
)
fun main(args: Array<String>) {
val gson = Gson()
import java.io.BufferedReader
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.InputStreamReader
const val HEADER_SIZE = 54L
const val BITS_PER_CHAR = 8
fun <T> List<T>.divide(i: Int) = (0..(size - 1) / i).map { drop(it * i).take(i) }
fun Int.charsRepeat(c: Char): String = if (this == 0) "" else (1..this).map { c.toString() }.reduce { s1, s2 -> "$s1$s2" }
fun <T> List<T>.reduceToString() = if (isEmpty()) "" else this.map { it.toString() }.reduce { c1, c2 -> "$c1$c2" }
fun powMod(n: Long, p: Long, mod: Long): Long {
var p = p
var res: Long = 1
var pow = n
while (p > 0) {
if (p and 1 == 1L) res = res * pow % mod