Overlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.Arkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dimensional canvas split into n consecutive segments, each segment needs to be painted in one of the colours.Arkady has already painted some (possibly none or all) segments and passes the paintbrush to you. You are to determine whether there are at least two ways of colouring all the unpainted segments so that no two adjacent segments are of the same colour. Two ways are considered different if and only if a segment is painted in different colours in them.

The first line contains a single positive integer n (1 ≤ n ≤ 100) — the length of the canvas. The second line contains a string s of n characters, the i-th of which is either 'C' (denoting a segment painted in cyan), 'M' (denoting one painted in magenta), 'Y' (one painted in yellow), or '?' (an unpainted one).

If there are at least two different ways of painting, output "Yes"; otherwise output "No" (both without quotes). You can print each character in any case (upper or lower).

NoteFor the first example, there are exactly two different ways of colouring: CYCMY and CYMCY.For the second example, there are also exactly two different ways of colouring: CMCMY and CYCMY.For the third example, there are four ways of colouring: MCYCM, MCYCY, YCYCM, and YCYCY.For the fourth example, no matter how the unpainted segments are coloured, the existing magenta segments will prevent the painting from satisfying the requirements. The similar is true for the fifth example.

import java.io.*
import java.util.*

fun main(args: Array<String>) {
    solve(System.`in`, System.out)
}

val MAX_N = (1e6 + 10).toInt()
val INF = (1e9 + 7).toInt()
val MOD = (1e9 + 7).toInt()

fun solve(input: InputStream, output: OutputStream) {
    val reader = InputReader(BufferedInputStream(input))
    val writer = PrintWriter(BufferedOutputStream(output))

    solve(reader, writer)
    writer.close()
}

fun solve(reader: InputReader, writer: PrintWriter) {
    val n = reader.nextInt()
    val s = reader.next()

    var ans = false
    for (i in 1 until n - 1) {
        val c1 = s[i - 1]
        val c2 = s[i]
        val c3 = s[i + 1]

        if (c2 == '?' && c3 == '?') {
            ans = true
            break
        }

        if (c2 == '?' && c1 == c3) {
            ans = true
            break
        }
    }

    if (s.first() == '?' || s.last() == '?') {
        ans = true
    }

    for (i in 0 until n - 1) {
        val c1 = s[i]
        val c2 = s[i + 1]
        if (c1 == c2 && c1 != '?') {
            ans = false
            break
        }
    }

    writer.println(if (ans) "YES" else "NO")
}

class InputReader(stream: InputStream) {
    val reader: BufferedReader
    var tokenizer: StringTokenizer? = null

    init {
        reader = BufferedReader(InputStreamReader(stream), 32768)
        tokenizer = null
    }

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextArrayInt(count: Int): IntArray {
        return nextArrayInt(0, count)
    }

    fun nextArrayInt(start: Int, count: Int): IntArray {
        val a = IntArray(start + count)
        for (i in start until start + count) {
            a[i] = nextInt()
        }
        return a
    }

    fun nextArrayLong(count: Int): LongArray {
        val a = LongArray(count)
        for (i in 0 until count) {
            a[i] = nextLong()
        }
        return a
    }
}

fun main(args : Array<String>) {
    var input = System.`in`.bufferedReader()
    try {
        var n = input.readLine().toInt()
        var s = input.readLine()

        var i = 0
        var ok = false
        mainloop@ while (i < s.length) {
            when (s[i]) {
                '?' -> {
                    var j = i
                    while (j < s.length && s[i] == s[j])
                        ++j

                    if (j - i >= 2)
                        ok = true
                    else {
                        var lch = if (i > 0) s[i - 1] else '\u0000'
                        var rch = if (j < s.length) s[j] else '\u0000'
                        if (lch == rch || lch == '\u0000' || rch == '\u0000')
                            ok = true
                    }
                    i = j
                }
                else -> {
                    if (i < s.length - 1 && s[i] == s[i + 1]) {
                        ok = false
                        break@mainloop
                    } else
                        ++i
                }
            }
        }

        println(if (ok) "Yes" else "No")
    } finally {
        input.close()
    }
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    var painting = readLine()!!

    painting =
            painting.replace("C?Y", "CMY")
                    .replace("C?M", "CYM")
                    .replace("Y?C", "YMC")
                    .replace("Y?M", "YCM")
                    .replace("M?C", "MYC")
                    .replace("M?Y", "MCY")

    with (painting) {
        if (contains("CC") || contains("MM") || contains("YY")) {
            println("No")
            return
        }
        if (painting.count { it == '?' } == 0) {
            println("No")
            return
        }
    }

    println("Yes")
}

import java.io.*
import java.util.*

fun main(args: Array<String>) {
    solve(System.`in`, System.out)
}

val MAX_N = (1e6 + 10).toInt()
val INF = (1e9 + 7).toInt()
val MOD = (1e9 + 7).toInt()

fun solve(input: InputStream, output: OutputStream) {
    val reader = InputReader(BufferedInputStream(input))
    val writer = PrintWriter(BufferedOutputStream(output))

    solve(reader, writer)
    writer.close()
}

fun solve(reader: InputReader, writer: PrintWriter) {
    val n = reader.nextInt()
    val s = reader.next()

    var ans = false
    for (i in 1 until n - 1) {
        val c1 = s[i - 1]
        val c2 = s[i]
        val c3 = s[i + 1]

        if (c2 == '?' && c3 == '?') {
            ans = true
            break
        }

        if (c2 == '?' && c1 == c3) {
            ans = true
            break
        }
    }

    if (s.last() == '?') {
        ans = true
    }

    for (i in 0 until n - 1) {
        val c1 = s[i]
        val c2 = s[i + 1]
        if (c1 == c2) {
            ans = false
            break
        }
    }

    writer.println(if (ans) "YES" else "NO")
}

class InputReader(stream: InputStream) {
    val reader: BufferedReader
    var tokenizer: StringTokenizer? = null

    init {
        reader = BufferedReader(InputStreamReader(stream), 32768)
        tokenizer = null
    }

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextArrayInt(count: Int): IntArray {
        return nextArrayInt(0, count)
    }

    fun nextArrayInt(start: Int, count: Int): IntArray {
        val a = IntArray(start + count)
        for (i in start until start + count) {
            a[i] = nextInt()
        }
        return a
    }

    fun nextArrayLong(count: Int): LongArray {
        val a = LongArray(count)
        for (i in 0 until count) {
            a[i] = nextLong()
        }
        return a
    }
}

import java.io.*
import java.util.*

fun main(args: Array<String>) {
    solve(System.`in`, System.out)
}

val MAX_N = (1e6 + 10).toInt()
val INF = (1e9 + 7).toInt()
val MOD = (1e9 + 7).toInt()

fun solve(input: InputStream, output: OutputStream) {
    val reader = InputReader(BufferedInputStream(input))
    val writer = PrintWriter(BufferedOutputStream(output))

    solve(reader, writer)
    writer.close()
}

fun solve(reader: InputReader, writer: PrintWriter) {
    val n = reader.nextInt()
    val s = reader.next()

    var ans = false
    for (i in 1 until n - 1) {
        val c1 = s[i - 1]
        val c2 = s[i]
        val c3 = s[i + 1]

        if (c2 == '?' && c3 == '?') {
            ans = true
            break
        }

        if (c2 == '?' && c1 == c3) {
            ans = true
            break
        }
    }

    if (s.last() == '?') {
        ans = true
    }

    for (i in 0 until n - 1) {
        val c1 = s[i]
        val c2 = s[i + 1]
        if (c1 == c2 && c1 != '?') {
            ans = false
            break
        }
    }

    writer.println(if (ans) "YES" else "NO")
}

class InputReader(stream: InputStream) {
    val reader: BufferedReader
    var tokenizer: StringTokenizer? = null

    init {
        reader = BufferedReader(InputStreamReader(stream), 32768)
        tokenizer = null
    }

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextArrayInt(count: Int): IntArray {
        return nextArrayInt(0, count)
    }

    fun nextArrayInt(start: Int, count: Int): IntArray {
        val a = IntArray(start + count)
        for (i in start until start + count) {
            a[i] = nextInt()
        }
        return a
    }

    fun nextArrayLong(count: Int): LongArray {
        val a = LongArray(count)
        for (i in 0 until count) {
            a[i] = nextLong()
        }
        return a
    }
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val painting = readLine()!!

    with (painting) {
        if (contains("CC") || contains("MM") || contains("YY")) {
            println("No")
            return
        }
        if (painting.count { it == '?' } == 1) {
            if (contains("C?M") || contains("M?Y") || contains("Y?C")
                    || contains("M?C") || contains("Y?M") || contains("C?Y")) {
                println("No")
                return
            }
        }
        if (painting.count { it == '?' } == 0) {
            println("No")
            return
        }
    }

    println("Yes")
}


Katie, Kuro and Shiro are best friends. They have known each other since kindergarten. That's why they often share everything with each other and work together on some very hard problems.Today is Shiro's birthday. She really loves pizza so she wants to invite her friends to the pizza restaurant near her house to celebrate her birthday, including her best friends Katie and Kuro.She has ordered a very big round pizza, in order to serve her many friends. Exactly $$$n$$$ of Shiro's friends are here. That's why she has to divide the pizza into $$$n + 1$$$ slices (Shiro also needs to eat). She wants the slices to be exactly the same size and shape. If not, some of her friends will get mad and go home early, and the party will be over.Shiro is now hungry. She wants to cut the pizza with minimum of straight cuts. A cut is a straight segment, it might have ends inside or outside the pizza. But she is too lazy to pick up the calculator.As usual, she will ask Katie and Kuro for help. But they haven't come yet. Could you help Shiro with this problem?

A single line contains one non-negative integer $$$n$$$ ($$$0 \le n \leq 10^{18}$$$) — the number of Shiro's friends. The circular pizza has to be sliced into $$$n + 1$$$ pieces.

A single integer — the number of straight cuts Shiro needs.

NoteTo cut the round pizza into quarters one has to make two cuts through the center with angle $$$90^{\circ}$$$ between them.To cut the round pizza into five equal parts one has to make five cuts.

import java.io.BufferedReader
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.lang.Math.pow
import java.util.*
import kotlin.collections.ArrayList
import kotlin.math.log
import kotlin.math.log2
import kotlin.math.min

fun main(args: Array<String>)
        = Thread { run() }.start()

fun run() {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextLong()
    if (n == 0L)
        println(0)
    else if (n % 2 == 1L)
        println((n + 1) / 2)
    else
        println(n + 1)
}

class Scanner(s: InputStream) {
    var st: StringTokenizer? = null
    var br: BufferedReader = BufferedReader(InputStreamReader(s))
    @Throws(IOException::class)
    operator fun next(): String {
        while (st == null || !st!!.hasMoreTokens())
            st = StringTokenizer(br.readLine())
        return st!!.nextToken()
    }
    @Throws(IOException::class)
    fun nextInt(): Int {
        return Integer.parseInt(next())
    }
    @Throws(IOException::class)
    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }
    @Throws(IOException::class)
    fun nextLine(): String {
        return br.readLine()
    }
    @Throws(IOException::class)
    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }
    @Throws(IOException::class)
    fun ready(): Boolean {
        return br.ready()
    }
}
//class Pair(val a: Int, val b: Int)
//class Triple(val a: Int, val b: Int, val c: Int)

import java.util.*
import java.math.*

fun main(args: Array<String>)
{
    var sc=Scanner(System.`in`)
    var n=sc.nextLong()
    if(n==0L)
    {
        println("0");
        return ;
    }
    n++;
    if(n%2==0L)n/=2
    println(n);
}

fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    val k = n + 1
    val r = when {
        k == 1L -> 0L
        k % 2 == 0L -> k / 2
        else -> k
    }
    println(r)
}

import java.io.*
import java.util.*

const val INPUT_FILE_NAME = "input"
const val OUTPUT_FILE_NAME = "output"

fun main(args: Array<String>) {
    solve(System.`in`, System.out)
//    solve(FileInputStream("$INPUT_FILE_NAME.txt"), FileOutputStream("$OUTPUT_FILE_NAME.txt"))
}

val MAX_N = (1e6 + 10).toInt()
val INF = (1e9 + 7).toInt()
val MOD = (1e9 + 7).toInt()

fun solve(input: InputStream, output: OutputStream) {
    val reader = InputReader(BufferedInputStream(input))
    val writer = PrintWriter(BufferedOutputStream(output))

    solve(reader, writer)
    writer.close()
}

fun solve(reader: InputReader, writer: PrintWriter) {
    val n = reader.nextLong()
    if (n == 0L) {
        writer.println("0")
        return
    }
    if (n % 2 == 0L) {
        writer.println(n + 1)
    } else {
        writer.println((n + 1) / 2)
    }
}

fun gcd(a: Int, b: Int): Int {
    return if (b == 0) a else gcd(b, a % b)
}

class InputReader(stream: InputStream) {
    private val reader = BufferedReader(InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer? = null

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextArrayInt(count: Int): IntArray {
        return nextArrayInt(0, count)
    }

    fun nextArrayInt(start: Int, count: Int): IntArray {
        val a = IntArray(start + count)
        for (i in start until start + count) {
            a[i] = nextInt()
        }
        return a
    }

    fun nextArrayLong(count: Int): LongArray {
        val a = LongArray(count)
        for (i in 0 until count) {
            a[i] = nextLong()
        }
        return a
    }
}

fun main(args: Array<String>){
    val n: Long = readLine()?.toLong() ?: 0
    val pieces = n+1
    if (pieces%2 == 0L)
        println(pieces/2)
    else if (pieces == 1L)
        println(0)
    else
        println(pieces)
}

fun main(){
    var n = readLine()!!.toLong()+1

    if (n==1L){
        println(0)
    }else{
        if (n%2L==0L){
            println(n/2)
        }else{
            println(n)
        }
    }
}

fun main(args: Array<String>) {
    var lo = readLine()!!.toLong()
    if(lo < 2) print(lo) else {
        if(++lo % 2L == 0L) print(lo/2)
        else print(lo)
    }
}

fun main() {
    val numPeople = readLine()!!.toLong() + 1
    if (numPeople == 1L) return print(0)
    print(if (numPeople  and 1 == 0L) numPeople / 2 else numPeople)
}

fun main(args: Array<String>){
	val cats = readLine()!!.toLong() + 1L
	if(cats==1L){
		println(0)
		return
	}
	val res = if(cats.rem(2L)==0L) cats/2L else cats
	println(res)
}

fun main(args: Array<String>) {
  val n  = readLine()!!.toLong()

  if (n == 0L) {
    println(0)
    return
  }

  val ans = if ((n + 1) % 2 == 0L) (n + 1) / 2 else n + 1
  println(ans)
}

/**
 * Created by aursaty on 5/14/2018.
 */

fun main(args : Array<String>) {
    var n : Long = 0
    n = readLine()!!.toLong() + 1
    when {
        n % 2 == 0.toLong() -> print(n/2)
        n == 1.toLong() -> print(0)
        else -> print(n)
    }
}

import java.io.BufferedReader
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.lang.Math.pow
import java.util.*
import kotlin.collections.ArrayList
import kotlin.math.log
import kotlin.math.log2
import kotlin.math.min

fun main(args: Array<String>)
        = Thread { run() }.start()

fun run() {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextLong()
    if (n % 2 == 1L)
        println((n + 1) / 2)
    else
        println(n + 1)
}

class Scanner(s: InputStream) {
    var st: StringTokenizer? = null
    var br: BufferedReader = BufferedReader(InputStreamReader(s))
    @Throws(IOException::class)
    operator fun next(): String {
        while (st == null || !st!!.hasMoreTokens())
            st = StringTokenizer(br.readLine())
        return st!!.nextToken()
    }
    @Throws(IOException::class)
    fun nextInt(): Int {
        return Integer.parseInt(next())
    }
    @Throws(IOException::class)
    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }
    @Throws(IOException::class)
    fun nextLine(): String {
        return br.readLine()
    }
    @Throws(IOException::class)
    fun nextDouble(): Double {
        return java.lang.Double.parseDouble(next())
    }
    @Throws(IOException::class)
    fun ready(): Boolean {
        return br.ready()
    }
}
//class Pair(val a: Int, val b: Int)
//class Triple(val a: Int, val b: Int, val c: Int)

import java.util.*
import java.math.*

fun main(args: Array<String>)
{
    var sc=Scanner(System.`in`)
    var n=sc.nextLong()
    if(n==0L)
    {
        println("0");
    }
    n++;
    if(n%2==0L)n/=2
    println(n);
}

import java.io.*
import java.util.*

const val INPUT_FILE_NAME = "input"
const val OUTPUT_FILE_NAME = "output"

fun main(args: Array<String>) {
    solve(System.`in`, System.out)
//    solve(FileInputStream("$INPUT_FILE_NAME.txt"), FileOutputStream("$OUTPUT_FILE_NAME.txt"))
}

val MAX_N = (1e6 + 10).toInt()
val INF = (1e9 + 7).toInt()
val MOD = (1e9 + 7).toInt()

fun solve(input: InputStream, output: OutputStream) {
    val reader = InputReader(BufferedInputStream(input))
    val writer = PrintWriter(BufferedOutputStream(output))

    solve(reader, writer)
    writer.close()
}

fun solve(reader: InputReader, writer: PrintWriter) {
    val n = reader.nextLong()
    if (n % 2 == 0L) {
        writer.println(n + 1)
    } else {
        writer.println((n + 1) / 2)
    }
}

fun gcd(a: Int, b: Int): Int {
    return if (b == 0) a else gcd(b, a % b)
}

class InputReader(stream: InputStream) {
    private val reader = BufferedReader(InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer? = null

    operator fun next(): String {
        while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
            try {
                tokenizer = StringTokenizer(reader.readLine())
            } catch (e: IOException) {
                throw RuntimeException(e)
            }

        }
        return tokenizer!!.nextToken()
    }

    fun nextInt(): Int {
        return Integer.parseInt(next())
    }

    fun nextLong(): Long {
        return java.lang.Long.parseLong(next())
    }

    fun nextArrayInt(count: Int): IntArray {
        return nextArrayInt(0, count)
    }

    fun nextArrayInt(start: Int, count: Int): IntArray {
        val a = IntArray(start + count)
        for (i in start until start + count) {
            a[i] = nextInt()
        }
        return a
    }

    fun nextArrayLong(count: Int): LongArray {
        val a = LongArray(count)
        for (i in 0 until count) {
            a[i] = nextLong()
        }
        return a
    }
}

fun main(args: Array<String>){
    val n: Long = readLine()?.toLong() ?: 0
    val pieces = n+1
    if (pieces%2 == 0L)
        println(pieces/2)
    else
        println(pieces)
}

fun main() {
    val numPeople = readLine()!!.toLong() + 1
    print(if (numPeople  and 1 == 0L) numPeople / 2 else numPeople)
}

fun main() {
    val numPeople = readLine()!!.toLong() + 1
    if (numPeople == 0L) return print(0)
    print(if (numPeople  and 1 == 0L) numPeople / 2 else numPeople)
}

fun main(args : Array<String>) {
    var n = 0
    n = readLine()!!.toInt() + 1
    if (n % 2 == 0)
        print(n/2)
    else
        if (n == 1)
            print(0)
        print(n)
}


Calendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified the Julian calendar's scheme of leap years as follows: Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100; the centurial years that are exactly divisible by 400 are still leap years. For example, the year 1900 is not a leap year; the year 2000 is a leap year.   In this problem, you have been given two dates and your task is to calculate how many days are between them. Note, that leap years have unusual number of days in February.Look at the sample to understand what borders are included in the aswer.

The first two lines contain two dates, each date is in the format yyyy:mm:dd (1900 ≤ yyyy ≤ 2038 and yyyy:mm:dd is a legal date).

Print a single integer — the answer to the problem.

import java.io.*
import java.text.SimpleDateFormat
import java.util.*
import kotlin.Comparator
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
import kotlin.math.round
import kotlin.random.Random
import kotlin.system.measureTimeMillis

/**
 * 23.02.2020
 * Main
 *
 * @author Havlong
 * @version v1.0
 */
class LineReader(tempReader: Reader) {
    private val reader = BufferedReader(tempReader)
    fun hasNext() = peek() != -1
    private fun peek(): Int {
        reader.mark(1)
        return reader.read().also { reader.reset() }
    }

    fun skipSpaces() {
        while (Character.isWhitespace(peek()))
            reader.read()
    }

    fun readLine(): String = reader.readLine()
    fun longList() = readLine().split(' ').map(String::toLong)
    fun intList() = readLine().split(' ').map(String::toInt)
}

typealias ML = MutableList<Long>
typealias MI = MutableList<Int>
typealias LL = List<Long>
typealias LLL = List<LL>
typealias PLL = Pair<Long, Long>
typealias PPLL = Pair<Long, PLL>

const val M7 = 1000000007L
const val M9 = 1000000009L
const val MFFT = 998244353L
const val INF = 2000000000000000000L

fun lowerBound(from: Long, to: Long, comparison: (Long) -> Long): Long {
    var left = from
    var right = to + 1
    while (left < right) {
        val mid = (left + right) / 2
        val result = comparison(mid)
        if (result >= 0) {
            right = mid
        } else {
            left = mid + 1
        }
    }
    return left
}

fun upperBound(from: Long, to: Long, comparison: (Long) -> Long): Long {
    var left = from
    var right = to + 1
    while (left < right) {
        val mid = (left + right) / 2
        val result = comparison(mid)
        if (result > 0) {
            right = mid
        } else {
            left = mid + 1
        }
    }
    return left
}

fun <T : Comparable<T>> List<T>.upperBound(key: T, from: Int = 0, to: Int = size - 1): Int {
    return upperBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()
}

fun <T : Comparable<T>> List<T>.lowerBound(key: T, from: Int = 0, to: Int = size - 1): Int {
    return lowerBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()
}

fun <T : Comparable<T>> Array<T>.upperBound(key: T, from: Int = 0, to: Int = size - 1): Int {
    return upperBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()
}

fun <T : Comparable<T>> Array<T>.lowerBound(key: T, from: Int = 0, to: Int = size - 1): Int {
    return lowerBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()
}

operator fun <A : Comparable<A>, B : Comparable<B>> Pair<A, B>.compareTo(other: Pair<A, B>): Int {
    return first.compareTo(other.first).let { if (it == 0) second.compareTo(other.second) else it }
}

fun binPow(number: Long, power: Long, mod: Long): Long {
    var result = 1L
    var a = number % mod
    var n = power
    while (n > 0) {
        if (n % 2 != 0L)
            result = (result * a) % mod
        a = (a * a) % mod
        n /= 2
    }
    return result
}

tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

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

fun main(args: Array<String>) {
    if (args.isNotEmpty() && args[0] == "local") {
        val reader = LineReader(FileReader("input.txt"))
        PrintWriter(File("output.txt")).use {
            while (reader.hasNext()) {
                it.println("\n${measureTimeMillis {
                    solve(reader, it)
                }} ms\n")
                reader.skipSpaces()
            }
        }
    } else {
        val reader = LineReader(InputStreamReader(System.`in`))
        PrintWriter(System.out).use { solve(reader, it) }
    }
}

fun solve(reader: LineReader, writer: PrintWriter) {
    val format = SimpleDateFormat("yyyy:MM:dd")
    val start = format.parse(reader.readLine().trim())
    val end = format.parse(reader.readLine().trim())
    writer.println(abs(round((end.time - start.time) / 1000.0 / 3600 / 24)).toLong())
}

import java.io.*
import java.util.*
import kotlin.Comparator
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
import kotlin.random.Random
import kotlin.system.measureTimeMillis

/**
 * 23.02.2020
 * Main
 *
 * @author Havlong
 * @version v1.0
 */
class LineReader(tempReader: Reader) {
    private val reader = BufferedReader(tempReader)
    fun hasNext() = peek() != -1
    private fun peek(): Int {
        reader.mark(1)
        return reader.read().also { reader.reset() }
    }

    fun skipSpaces() {
        while (Character.isWhitespace(peek()))
            reader.read()
    }

    fun readLine(): String = reader.readLine()
    fun longList() = readLine().split(' ').map(String::toLong)
    fun intList() = readLine().split(' ').map(String::toInt)
}

typealias ML = MutableList<Long>
typealias MI = MutableList<Int>
typealias LL = List<Long>
typealias LLL = List<LL>
typealias PLL = Pair<Long, Long>
typealias PPLL = Pair<Long, PLL>

const val M7 = 1000000007L
const val M9 = 1000000009L
const val MFFT = 998244353L
const val INF = 2000000000000000000L

fun lowerBound(from: Long, to: Long, comparison: (Long) -> Long): Long {
    var left = from
    var right = to + 1
    while (left < right) {
        val mid = (left + right) / 2
        val result = comparison(mid)
        if (result >= 0) {
            right = mid
        } else {
            left = mid + 1
        }
    }
    return left
}

fun upperBound(from: Long, to: Long, comparison: (Long) -> Long): Long {
    var left = from
    var right = to + 1
    while (left < right) {
        val mid = (left + right) / 2
        val result = comparison(mid)
        if (result > 0) {
            right = mid
        } else {
            left = mid + 1
        }
    }
    return left
}

fun <T : Comparable<T>> List<T>.upperBound(key: T, from: Int = 0, to: Int = size - 1): Int {
    return upperBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()
}

fun <T : Comparable<T>> List<T>.lowerBound(key: T, from: Int = 0, to: Int = size - 1): Int {
    return lowerBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()
}

fun <T : Comparable<T>> Array<T>.upperBound(key: T, from: Int = 0, to: Int = size - 1): Int {
    return upperBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()
}

fun <T : Comparable<T>> Array<T>.lowerBound(key: T, from: Int = 0, to: Int = size - 1): Int {
    return lowerBound(from.toLong(), to.toLong()) { this[it.toInt()].compareTo(key).toLong() }.toInt()
}

operator fun <A : Comparable<A>, B : Comparable<B>> Pair<A, B>.compareTo(other: Pair<A, B>): Int {
    return first.compareTo(other.first).let { if (it == 0) second.compareTo(other.second) else it }
}

fun binPow(number: Long, power: Long, mod: Long): Long {
    var result = 1L
    var a = number % mod
    var n = power
    while (n > 0) {
        if (n % 2 != 0L)
            result = (result * a) % mod
        a = (a * a) % mod
        n /= 2
    }
    return result
}

tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

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

fun main(args: Array<String>) {
    if (args.isNotEmpty() && args[0] == "local") {
        val reader = LineReader(FileReader("input.txt"))
        PrintWriter(File("output.txt")).use {
            while (reader.hasNext()) {
                it.println("\n${measureTimeMillis {
                    solve(reader, it)
                }} ms\n")
                reader.skipSpaces()
            }
        }
    } else {
        val reader = LineReader(InputStreamReader(System.`in`))
        PrintWriter(System.out).use { solve(reader, it) }
    }
}

fun solve(reader: LineReader, writer: PrintWriter) {
    val (year, month, day) = reader.readLine().split(':').map(String::toInt)
    val (year2, month2, day2) = reader.readLine().split(':').map(String::toInt)
    val start = Calendar.getInstance().apply { set(year + 400, month, day) }
    val end = Calendar.getInstance().apply { set(year2 + 400, month2, day2) }
    val result = abs(end.timeInMillis - start.timeInMillis + 1) / 1000
    writer.println(result / 3600 / 24)
}


Greatest common divisor GCD(a, b) of two positive integers a and b is equal to the biggest integer d such that both integers a and b are divisible by d. There are many efficient algorithms to find greatest common divisor GCD(a, b), for example, Euclid algorithm. Formally, find the biggest integer d, such that all integers a, a + 1, a + 2, ..., b are divisible by d. To make the problem even more complicated we allow a and b to be up to googol, 10100 — such number do not fit even in 64-bit integer type!

The only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 10100).

Output one integer — greatest common divisor of all integers from a to b inclusive.

import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val (a, b) = readLine()!!.split(" ")
    println(if (a == b) a else "1")
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

fun main() {
    val (a, b) = readLine()!!.split(" ")
    print(if (a == b) a else 1)
}

    fun main(args: Array<String>) {
        val (a, b) = readLine()!!.split(" ")
        println( if (a == b) a else "1" )
    }

fun main() {
    val (a, b) = readLine()!!.split(" ")
    println(if (a==b) a else "1")
}


There are well-known formulas: , , . Also mathematicians found similar formulas for higher degrees.Find the value of the sum  modulo 109 + 7 (so you should find the remainder after dividing the answer by the value 109 + 7).

The only line contains two integers n, k (1 ≤ n ≤ 109, 0 ≤ k ≤ 106).

Print the only integer a — the remainder after dividing the value of the sum by the value 109 + 7.

fun POW(N:Int ,P: Int ,mod : Int):Int{
    var x=1
    var n=N
    var p=P
    while (p > 0) {
        if (p%2 == 0) {
            n = (n.toLong()*n %mod).toInt()
            p /= 2
        } else {
            x = (x.toLong()*n %mod).toInt()
            p -= 1
        }
    }

    return x
}

fun main(){
    var (n,K) = readLine()!!.split(' ').map { it.toInt() }
    val mod=1000000007

    var FACT=mutableListOf<Int>()
    var F=mutableListOf<Int>()
    var FACT_INV=mutableListOf<Int>()

    FACT.add(1)
    F.add(0)

    for (i in 1..1000010){
        FACT.add((FACT[i-1].toLong()*i%mod).toInt())
        F.add((F[i-1]+POW(i,K,mod))%mod)
    }

    //println(FACT[1000010])

    FACT_INV.add(POW(FACT[1000010],mod-2,mod))

    for (i in 1000010 downTo 1){
        FACT_INV.add((FACT_INV[1000010-i].toLong()*i%mod).toInt())
    }

    //println(FACT_INV[0])
    //println(FACT_INV[1000010])
    FACT_INV = FACT_INV.asReversed()

    //println(FACT_INV[0])
    //println(FACT_INV[1000010])

    var ANS=0L
    var PI=1L

    if (n<=K+2){
        println(F[n])
        return
    }

    for (i in 1..K+2){
        PI=PI*(n-i)%mod
        if ((K+2-i)%2==0){
            ANS=ANS+F[i.toInt()].toLong()*FACT_INV[(K+2-i).toInt()]%mod*FACT_INV[(i-1).toInt()]%mod*POW(n-i,mod-2,mod)
            ANS=(ANS+mod)%mod
        }
        else{
            ANS=ANS-F[i.toInt()].toLong()*FACT_INV[(K+2-i).toInt()]%mod*FACT_INV[(i-1).toInt()]%mod*POW(n-i,mod-2,mod)
            ANS=(ANS+mod)%mod
        }
    }
    println((ANS*PI+mod)%mod)
}

fun POW(N:Long ,P: Long ,mod : Long):Long{
    var x=1L
    var n=N
    var p=P
    while (p > 0) {
        if (p%2 == 0L) {
            n = n*n %mod
            p /= 2
        } else {
            x = x*n %mod
            p -= 1
        }
    }

    return x
}

fun main(){
    var (n,K) = readLine()!!.split(' ').map { it.toLong() }
    val mod=1000000007L

    var FACT=mutableListOf<Long>()
    var F=mutableListOf<Long>()
    var FACT_INV=mutableListOf<Long>()

    FACT.add(1)
    F.add(0)

    for (i in 1..1000010){
        FACT.add(FACT[i-1]*i%mod)
        F.add((F[i-1]+POW(i.toLong(),K,mod))%mod)
    }
    //println(FACT[1000010])

    FACT_INV.add(POW(FACT[1000010],mod-2,mod))

    for (i in 1000010 downTo 1){
        FACT_INV.add(FACT_INV[1000010-i]*i%mod)
    }

    //println(FACT_INV[0])
    //println(FACT_INV[1000010])
    FACT_INV = FACT_INV.asReversed()

    //println(FACT_INV[0])
    //println(FACT_INV[1000010])

    var ANS=0L
    var PI=1L

    if (n<=K+2){
        println(F[n.toInt()])
        return
    }

    for (i in 1..K+2){
        PI=PI*(n-i)%mod
        if ((K+2-i)%2==0L){
            ANS=ANS+F[i.toInt()]*FACT_INV[(K+2-i).toInt()]%mod*FACT_INV[(i-1).toInt()]%mod*POW(n-i,mod-2,mod)
            ANS%=mod
        }
        else{
            ANS=ANS-F[i.toInt()]*FACT_INV[(K+2-i).toInt()]%mod*FACT_INV[(i-1).toInt()]%mod*POW(n-i,mod-2,mod)
            ANS%=mod
        }
    }
    println(ANS*PI%mod)
}

fun POW(N:Int ,P: Int ,mod : Int):Int{
    var x=1
    var n=N
    var p=P
    while (p > 0) {
        if (p%2 == 0) {
            n = n*n %mod
            p /= 2
        } else {
            x = x*n %mod
            p -= 1
        }
    }

    return x
}

fun main(){
    var (n,K) = readLine()!!.split(' ').map { it.toInt() }
    val mod=1000000007

    var FACT=mutableListOf<Int>()
    var F=mutableListOf<Int>()
    var FACT_INV=mutableListOf<Int>()

    FACT.add(1)
    F.add(0)

    for (i in 1..1000010){
        FACT.add(FACT[i-1]*i%mod)
        F.add((F[i-1]+POW(i,K,mod))%mod)
    }

    //println(FACT[1000010])

    FACT_INV.add(POW(FACT[1000010],mod-2,mod))

    for (i in 1000010 downTo 1){
        FACT_INV.add(FACT_INV[1000010-i]*i%mod)
    }

    //println(FACT_INV[0])
    //println(FACT_INV[1000010])
    FACT_INV = FACT_INV.asReversed()

    //println(FACT_INV[0])
    //println(FACT_INV[1000010])

    var ANS=0L
    var PI=1L

    if (n<=K+2){
        println(F[n.toInt()])
        return
    }

    for (i in 1..K+2){
        PI=PI*(n-i)%mod
        if ((K+2-i)%2==0){
            ANS=ANS+F[i.toInt()]*FACT_INV[(K+2-i).toInt()]%mod*FACT_INV[(i-1).toInt()]%mod*POW(n-i,mod-2,mod)
            ANS=(ANS+mod)%mod
        }
        else{
            ANS=ANS-F[i.toInt()]*FACT_INV[(K+2-i).toInt()]%mod*FACT_INV[(i-1).toInt()]%mod*POW(n-i,mod-2,mod)
            ANS=(ANS+mod)%mod
        }
    }
    println((ANS*PI+mod)%mod)
}