Problem:
Score : 200 points

Problem Statement

La Confiserie d'ABC sells cakes at 4 dollars each and doughnuts at 7 dollars each.
Determine if there is a way to buy some of them for exactly N dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.

Constraints

N is an integer between 1 and 100, inclusive.

Input

Input is given from Standard Input in the following format:

N

Output

If there is a way to buy some cakes and some doughnuts for exactly N dollars, print Yes; otherwise, print No.

Sample Input 1

11

Sample Output 1

Yes

If you buy one cake and one doughnut, the total will be 4 + 7 = 11 dollars.

Sample Input 2

40

Sample Output 2

Yes

If you buy ten cakes, the total will be 4 \times 10 = 40 dollars.

Sample Input 3

3

Sample Output 3

No

The prices of cakes (4 dollars) and doughnuts (7 dollars) are both higher than 3 dollars, so there is no such way.

Solution in Kotlin (1.0.0) (judge verdict: Accepted)

import java.io.IOException
import java.io.InputStream
import java.util.NoSuchElementException

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    for (i in 0..(n / 4)) {
        var cost = i * 4
        while (cost <= n) {
            if (cost == n) {
                println("Yes")
                return
            }
            cost += 7
        }
    }
    println("No")
}

class Scanner(private val `in`: InputStream) {
    private val buffer: ByteArray = ByteArray(1024)
    private var ptr = 0
    private var buflen = 0

    private fun hasNextByte(): Boolean {
        if (ptr < buflen) return true
        else {
            ptr = 0
            try {
                buflen = `in`.read(buffer)
            } catch (e: IOException) {
                e.printStackTrace()
            }
            if (buflen <= 0) return false
        }
        return true
    }

    private fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else -1
    }

    private fun isPrintableChar(c: Char): Boolean {
        return c in '!'..'~'
    }

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr].toChar())) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (isPrintableChar(b.toChar())) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var minus = false
        var b = readByte()
        if (b.toChar() == '-') {
            minus = true
            b = readByte()
        }
        if (b.toChar() !in '0'..'9') throw NumberFormatException()
        while (true) {
            if (b.toChar() in '0'..'9') {
                n *= 10
                n += b - '0'.toByte()
            } else return if (b.toInt() == -1 || !isPrintableChar(b.toChar())) {
                if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextIntArray(n: Int): IntArray {
        return IntArray(n) { nextInt() }
    }

    fun nextIntArrayPair(n: Int): Pair<IntArray, IntArray> {
        val (a, b) = Pair(IntArray(n), IntArray(n))
        for (i in 0 until n) {
            a[i] = nextInt()
            b[i] = nextInt()
        }
        return Pair(a, b)
    }

    fun nextIntArrayTriple(n: Int): Triple<IntArray, IntArray, IntArray> {
        val (a, b, c) = Triple(IntArray(n), IntArray(n), IntArray(n))
        for (i in 0 until n) {
            a[i] = nextInt()
            b[i] = nextInt()
            c[i] = nextInt()
        }
        return Triple(a, b, c)
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n: Long = 0
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b.toChar() !in '0'..'9') throw NumberFormatException()
        while (true) {
            if (b.toChar() in '0'..'9') {
                n *= 10
                n += (b - '0'.toByte()).toLong()
            } else return if (b.toInt() == -1 || !isPrintableChar(b.toChar())) {
                if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextLongArray(n: Int): LongArray {
        return LongArray(n) { nextLong() }
    }

    fun nextLongArrayPair(n: Int): Pair<LongArray, LongArray> {
        val (a, b) = Pair(LongArray(n), LongArray(n))
        for (i in 0 until n) {
            a[i] = nextLong()
            b[i] = nextLong()
        }
        return Pair(a, b)
    }

    fun nextLongArrayTriple(n: Int): Triple<LongArray, LongArray, LongArray> {
        val (a, b, c) = Triple(LongArray(n), LongArray(n), LongArray(n))
        for (i in 0 until n) {
            a[i] = nextLong()
            b[i] = nextLong()
            c[i] = nextLong()
        }
        return Triple(a, b, c)
    }
}