Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where   <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive.  <hostname> — is a sequence of word separated by periods (characters «.»), where each word should contain only characters allowed for <username>, the length of each word is between 1 and 16, inclusive. The length of <hostname> is between 1 and 32, inclusive.  <resource> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <resource> is between 1 and 16, inclusive. The content of square brackets is optional — it can be present or can be absent.There are the samples of correct Jabber IDs: mike@codeforces.com, 007@en.codeforces.com/contest.Your task is to write program which checks if given string is a correct Jabber ID.

The input contains of a single line. The line has the length between 1 and 100 characters, inclusive. Each characters has ASCII-code between 33 and 127, inclusive.

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()

  def isGood(str: String) = {
    str.length >= 1 && str.length <= 16 && str.forall(ch => (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_')
  }

  if (line.split("@", -1) match {
    case Array(first, second) if isGood(first) =>
      second.split("/", -1) match {
        case Array(hostname, resource) =>
          hostname.split("\\.", -1).forall(isGood) && isGood(resource) && hostname.length <= 32
        case Array(hostname) =>
          hostname.split("\\.", -1).forall(isGood)
        case _ => false
      }
    case _ => false
  })
    println("YES")
  else
    println("NO")
}

import java.util._
import java.io._

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

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

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

  def solve: Int = {
    val user = next
    if (user.split("@").length != 2 ||  user.endsWith("@")) {
      out.println("NO")
      return 1
    }
    val name = user.split("@")(0)
    if (name.length <= 0 || name.length > 16) {
      out.println("NO")
      return 1
    }
    val part2 = user.split("@")(1)
    val allow = "QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_".toCharArray
    if (name.filter(x => !allow.contains(x)).length > 0) {
      out.println("NO")
      return 1
    }
    if (part2.split("/")(0).length <= 0 || part2.split("/")(0).length > 32) {
      out.println("NO")
      return 1
    }

    val hosts = part2.split("/")(0).split("\\.")
    if (part2.split("/")(0).startsWith(".") || part2.split("/")(0).endsWith(".")) {
      out.println("NO")
      return 1
    }
    if (part2.split("/")(0).contains(".") && hosts.length == 0) {
      out.println("NO")
      return 1
    }
    for (i <- 0 until hosts.length) {
      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
      if (hosts(i).length <= 0 || hosts(i).length > 16) {
        out.println("NO")
        return 1
      }
    }

    if (part2.split("/").length > 1) {
      val res = part2.split("/")(1)
      if (res.filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
    }
    if (user.endsWith("/")) {
      out.println("NO")
      return 1
    }
    out.println("YES")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()

  def isGood(str: String) = {
    str.length >= 1 && str.length <= 16 && str.forall(ch => (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_')
  }

  if (line.split('@') match {
    case Array(first, second) if isGood(first) =>
      second.split("/", -1) match {
        case Array(hostname, resource) =>
          hostname.split("\\.", -1).forall(isGood) && isGood(resource) && hostname.length <= 32
        case Array(hostname) =>
          hostname.split("\\.", -1).forall(isGood)
        case _ => false
      }
    case _ => false
  })
    println("YES")
  else
    println("NO")
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()

  def isGood(str: String) = {
    str.length >= 1 && str.length <= 16 && str.forall(ch => (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_')
  }

  if (line.split('@') match {
    case Array(first, second) if isGood(first) =>
      second.split('/') match {
        case Array(hostname, resource) =>
          hostname.split('.').forall(isGood) && isGood(resource) && hostname.length <= 32
        case Array(hostname) =>
          hostname.split('.').forall(isGood)
        case _ => false
      }
    case _ => false
  })
    println("YES")
  else
    println("NO")
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()

  def isGood(str: String) = {
    str.length >= 1 && str.length <= 16 && str.forall(ch => (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_')
  }

  if (line.split('@') match {
    case Array(first, second) if isGood(first) =>
      second.split('/') match {
        case Array(hostname, resource) =>
          hostname.split("\\.", -1).forall(isGood) && isGood(resource) && hostname.length <= 32
        case Array(hostname) =>
          hostname.split("\\.", -1).forall(isGood)
        case _ => false
      }
    case _ => false
  })
    println("YES")
  else
    println("NO")
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()

  def isGood(str: String) = {
    str.length >= 1 && str.length <= 16 && str.forall(ch => (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_')
  }

  if (line.split('@') match {
    case Array(first, second) =>
      second.split('/') match {
        case Array(hostname, resource) =>
          hostname.split('.').forall(isGood) && isGood(resource) && hostname.length <= 32
        case Array(hostname) =>
          hostname.split('.').forall(isGood)
        case _ => false
      }
    case _ => false
  })
    println("YES")
  else
    println("NO")
}

object Solution extends App {
  val in = io.Source.stdin.getLines()
  val line = in.next()

  def isGood(str: String) = {
    str.length >= 1 && str.length <= 16 && str.forall(ch => (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_')
  }

  if (line.split('@') match {
    case Array(first, second) =>
      second.split('/') match {
        case Array(hostname, resource) =>
          hostname.split('.').forall(isGood) && isGood(resource) && hostname.length <= 32
        case Array(hostname) =>
          println("HERE")
          hostname.split('.').forall(isGood)
        case _ => false
      }
    case _ => false
  })
    println("YES")
  else
    println("NO")
}

import java.util._
import java.io._

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

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

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

  def solve: Int = {
    val user = next
    if (user.split("@").length != 2) {
      out.println("NO")
      return 1
    }

    val name = user.split("@")(0)
    if (name.length <= 0 || name.length > 16) {
      out.println("NO")
      return 1
    }
    val part2 = user.split("@")(1)
    val allow = "abcdefghijklmnopqrstuvwxyz1234567890_".toCharArray
    if (name.filter(x => !allow.contains(x)).length > 0) {
      out.println("NO")
      return 1
    }
    if (part2.split("\\\\")(0).length <= 0 || part2.split("\\\\")(0).length > 32) {
      out.println("NO")
      return 1
    }

    val hosts = part2.split("\\\\")(0).split(".")
    for (i <- 0 until hosts.length) {
      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
      if (hosts(i).length <= 0 || hosts(i).length > 16) {
        out.println("NO")
        return 1
      }
    }

    if (part2.split("\\\\").length > 1) {
      val res = part2.split("\\\\")(1)
      if (res.filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
    }
    out.println("YES")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

import java.util._
import java.io._

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

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

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

  def solve: Int = {
    val user = next
    if (user.split("@").length != 2) {
      out.println("NO")
      return 1
    }
    val name = user.split("@")(0)
    if (name.length <= 0 || name.length > 16) {
      out.println("NO")
      return 1
    }
    val part2 = user.split("@")(1)
    val allow = "QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_".toCharArray
    if (name.filter(x => !allow.contains(x)).length > 0) {
      out.println("NO")
      return 1
    }
    if (part2.split("/")(0).length <= 0 || part2.split("/")(0).length > 32) {
      out.println("NO")
      return 1
    }

    val hosts = part2.split("/")(0).split("\\.")
    if (part2.startsWith(".") || (part2.endsWith("."))) {
      out.println("NO")
      return 1
    }
    if (part2.split("/")(0).contains(".") && hosts.length == 0) {
      out.println("NO")
      return 1
    }
    for (i <- 0 until hosts.length) {
      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
      if (hosts(i).length <= 0 || hosts(i).length > 16) {
        out.println("NO")
        return 1
      }
    }

    if (part2.split("/").length > 1) {
      val res = part2.split("/")(1)
      if (res.filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
    }
    if (user.endsWith("/")) {
      out.println("NO")
      return 1
    }
    out.println("YES")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

import java.util._
import java.io._

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

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

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

  def solve: Int = {
    val user = next
    if (user.split("@").length != 2) {
      out.println("NO")
      return 1
    }
    val name = user.split("@")(0)
    if (name.length <= 0 || name.length > 16) {
      out.println("NO")
      return 1
    }
    val part2 = user.split("@")(1)
    val allow = "QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_".toCharArray
    if (name.filter(x => !allow.contains(x)).length > 0) {
      out.println("NO")
      return 1
    }
    if (part2.split("/")(0).length <= 0 || part2.split("/")(0).length > 32) {
      out.println("NO")
      return 1
    }

    val hosts = part2.split("/")(0).split("\\.")
    if (part2.split("/")(0).startsWith(".") || part2.split("/")(0).endsWith(".")) {
      out.println("NO")
      return 1
    }
    if (part2.split("/")(0).contains(".") && hosts.length == 0) {
      out.println("NO")
      return 1
    }
    for (i <- 0 until hosts.length) {
      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
      if (hosts(i).length <= 0 || hosts(i).length > 16) {
        out.println("NO")
        return 1
      }
    }

    if (part2.split("/").length > 1) {
      val res = part2.split("/")(1)
      if (res.filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
    }
    if (user.endsWith("/")) {
      out.println("NO")
      return 1
    }
    out.println("YES")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

import java.util._
import java.io._

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

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

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

  def solve: Int = {
    val user = next
    if (user.split("@").length != 2) {
      out.println("NO")
      return 1
    }
    val name = user.split("@")(0)
    if (name.length <= 0 || name.length > 16) {
      out.println("NO")
      return 1
    }
    val part2 = user.split("@")(1)
    val allow = "QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_".toCharArray
    if (name.filter(x => !allow.contains(x)).length > 0) {
      out.println("NO")
      return 1
    }
    if (part2.split("/")(0).length <= 0 || part2.split("/")(0).length > 32) {
      out.println("NO")
      return 1
    }

    val hosts = part2.split("/")(0).split(".")
    for (i <- 0 until hosts.length) {
      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
      if (hosts(i).length <= 0 || hosts(i).length > 16) {
        out.println("NO")
        return 1
      }
    }

    if (part2.split("/").length > 1) {
      val res = part2.split("/")(1)
      if (res.filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
    }
    if (user.endsWith("/")) {
      out.println("NO")
      return 1
    }
    out.println("YES")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

import java.util._
import java.io._

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

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

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

  def solve: Int = {
    val user = next
    if (user.split("@").length != 2) {
      out.println("NO")
      return 1
    }
    val name = user.split("@")(0)
    if (name.length <= 0 || name.length > 16) {
      out.println("NO")
      return 1
    }
    val part2 = user.split("@")(1)
    val allow = "QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_".toCharArray
    if (name.filter(x => !allow.contains(x)).length > 0) {
      out.println("NO")
      return 1
    }
    if (part2.split("/")(0).length <= 0 || part2.split("/")(0).length > 32) {
      out.println("NO")
      return 1
    }

    val hosts = part2.split("/")(0).split(".")
    if (part2.startsWith(".") || (part2.endsWith("."))) {
      out.println("NO")
      return 1
    }
    if (part2.split("/")(0).contains(".") && hosts.length == 0) {
      out.println("NO")
      return 1
    }
    for (i <- 0 until hosts.length) {
      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
      if (hosts(i).length <= 0 || hosts(i).length > 16) {
        out.println("NO")
        return 1
      }
    }

    if (part2.split("/").length > 1) {
      val res = part2.split("/")(1)
      if (res.filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
    }
    if (user.endsWith("/")) {
      out.println("NO")
      return 1
    }
    out.println("YES")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

import java.util._
import java.io._

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

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

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

  def solve: Int = {
    val user = next
    if (user.split("@").length != 2) {
      out.println("NO")
      return 1
    }
    val name = user.split("@")(0)
    if (name.length <= 0 || name.length > 16) {
      out.println("NO")
      return 1
    }
    val part2 = user.split("@")(1)
    val allow = "QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_".toCharArray
    if (name.filter(x => !allow.contains(x)).length > 0) {
      out.println("NO")
      return 1
    }
    if (part2.split("/")(0).length <= 0 || part2.split("/")(0).length > 32) {
      out.println("NO")
      return 1
    }

    val hosts = part2.split("/")(0).split(".")
    if (part2.startsWith(".") || (part2.endsWith("."))) {
      out.println("NO")
      return 1
    }
    for (i <- 0 until hosts.length) {
      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
      if (hosts(i).length <= 0 || hosts(i).length > 16) {
        out.println("NO")
        return 1
      }
    }

    if (part2.split("/").length > 1) {
      val res = part2.split("/")(1)
      if (res.filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
    }
    if (user.endsWith("/")) {
      out.println("NO")
      return 1
    }
    out.println("YES")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

import java.util._
import java.io._

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

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

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

  def solve: Int = {
    val user = next
    if (user.split("@").length != 2) {
      out.println("NO")
      return 1
    }
    val name = user.split("@")(0)
    if (name.length <= 0 || name.length > 16) {
      out.println("NO")
      return 1
    }
    val part2 = user.split("@")(1)
    val allow = "QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_".toCharArray
    if (name.filter(x => !allow.contains(x)).length > 0) {
      out.println("NO")
      return 1
    }
    if (part2.split("/")(0).length <= 0 || part2.split("/")(0).length > 32) {
      out.println("NO")
      return 1
    }

    val hosts = part2.split("/")(0).split(".")
    if (part2.startsWith(".")) {
      out.println("NO")
      return 1
    }
    for (i <- 0 until hosts.length) {
      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
      if (hosts(i).length <= 0 || hosts(i).length > 16) {
        out.println("NO")
        return 1
      }
    }

    if (part2.split("/").length > 1) {
      val res = part2.split("/")(1)
      if (res.filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
    }
    if (user.endsWith("/")) {
      out.println("NO")
      return 1
    }
    out.println("YES")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

import java.util._
import java.io._

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

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

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

  def solve: Int = {
    val user = next
    if (user.split("@").length != 2) {
      out.println("NO")
      return 1
    }
    val name = user.split("@")(0)
    if (name.length <= 0 || name.length > 16) {
      out.println("NO")
      return 1
    }
    val part2 = user.split("@")(1)
    val allow = "abcdefghijklmnopqrstuvwxyz1234567890_".toCharArray
    if (name.filter(x => !allow.contains(x)).length > 0) {
      out.println("NO")
      return 1
    }
    if (part2.split("/")(0).length <= 0 || part2.split("/")(0).length > 32) {
      out.println("NO")
      return 1
    }

    val hosts = part2.split("/")(0).split(".")
    for (i <- 0 until hosts.length) {
      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
      if (hosts(i).length <= 0 || hosts(i).length > 16) {
        out.println("NO")
        return 1
      }
    }

    if (part2.split("/").length > 1) {
      val res = part2.split("/")(1)
      if (res.filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
    }
    if (user.endsWith("/")) {
      out.println("NO")
      return 1
    }
    out.println("YES")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

import java.util._
import java.io._

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

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

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

  def solve: Int = {
    val user = next
    if (user.split("@").length != 2) {
      out.println("NO")
      return 1
    }

    val name = user.split("@")(0)
    if (name.length <= 0 || name.length > 16) {
      out.println("NO")
      return 1
    }
    val part2 = user.split("@")(1)
    val allow = "QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_".toCharArray
    val filter: String = name.filter(x => allow.contains(x))
    if (filter.length != name.length) {
      out.println("NO")
      return 1
    }
    if (part2.split("\\\\")(0).length <= 0 || part2.split("\\\\")(0).length > 32) {
      out.println("NO")
      return 1
    }

    val hosts = part2.split("\\\\")(0).split(".")
    for (i <- 0 until hosts.length) {
      val filter1: String = hosts(i).filter(x => allow.contains(x))
      if (filter1.length != hosts(i).length) {
        out.println("NO")
        return 1
      }
      if (hosts(i).length <= 0 || hosts(i).length > 16) {
        out.println("NO")
        return 1
      }
    }

    if (part2.split("\\\\").length > 1) {
      val res = part2.split("\\\\")(1)
      val filter1: String = res.filter(x => allow.contains(x))
      if (filter1.length != res.length) {
        out.println("NO")
        return 1
      }
    }
    out.println("YES")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

import java.util._
import java.io._

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

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

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

  def solve: Int = {
    val user = next
    if (user.split("@").length != 2) {
      out.println("NO")
      return 1
    }

    val name = user.split("@")(0)
    if (name.length <= 0 || name.length > 16) {
      out.println("NO")
      return 1
    }
    val part2 = user.split("@")(1)
    val allow = "QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_".toCharArray
    if (name.filter(x => !allow.contains(x)).length > 0) {
      out.println("NO")
      return 1
    }
    if (part2.split("\\\\")(0).length <= 0 || part2.split("\\\\")(0).length > 32) {
      out.println("NO")
      return 1
    }

    val hosts = part2.split("\\\\")(0).split(".")
    for (i <- 0 until hosts.length) {
      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
      if (hosts(i).length <= 0 || hosts(i).length > 16) {
        out.println("NO")
        return 1
      }
    }

    if (part2.split("\\\\").length > 1) {
      val res = part2.split("\\\\")(1)
      if (res.filter(x => !allow.contains(x)).length > 0) {
        out.println("NO")
        return 1
      }
    }
    out.println("YES")
    return 1
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}


Karen is getting ready for a new school day!  It is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome.What is the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome?Remember that a palindrome is a string that reads the same forwards and backwards. For instance, 05:39 is not a palindrome, because 05:39 backwards is 93:50. On the other hand, 05:50 is a palindrome, because 05:50 backwards is 05:50.

The first and only line of input contains a single string in the format hh:mm (00 ≤  hh  ≤ 23, 00 ≤  mm  ≤ 59).

Output a single integer on a line by itself, the minimum number of minutes she should sleep, such that, when she wakes up, the time is a palindrome.

NoteIn the first test case, the minimum number of minutes Karen should sleep for is 11. She can wake up at 05:50, when the time is a palindrome.In the second test case, Karen can wake up immediately, as the current time, 13:31, is already a palindrome.In the third test case, the minimum number of minutes Karen should sleep for is 1 minute. She can wake up at 00:00, when the time is a palindrome.

object _816A extends CodeForcesApp {
  import Utils._, annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._

  override def apply(io: IO) = {import io.{read, readAll, write, writeAll, writeLine}
    var Array(hh, mm) = read[String].split(':').map(_.toInt)
    var ans = 0
    while(!isPalindrome(hh, mm)) {
      val (nh, nm) = next(hh, mm)
      hh = nh
      mm = nm
      ans += 1
    }
    write(ans)
  }

  def pad(x: Int) = if (x < 10) s"0$x" else x.toString

  def isPalindrome(hh: Int, mm: Int) = {
    val t = s"${pad(hh)}:${pad(mm)}"
    t == t.reverse
  }

  def next(hh: Int, mm: Int) = {
    if (mm == 59) {
      ((hh + 1)%24, 0)
    } else {
      (hh, mm + 1)
    }
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def in(set: collection.Set[A]): Boolean = set(a)
    def some: Option[A] = Some(a)
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {
    def onlyElement: A = assuming(t.size == 1)(t.head)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates(implicit b: C of A): C[A] = {
      val elems = mutable.Set.empty[A]
      (t collect {case i if !elems.add(i) => i}).to[C]
    }
    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}
    def maxWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.max)
    def minWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.min)
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]
    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0
    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {
    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t
  }
  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {
    def key = p._1
    def value = p._2
  }
  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])
    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]
  }
  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {
    def lastKeyOption: Option[K] = m.lastOption.map(_.key)
    def firstKeyOption: Option[K] = m.headOption.map(_.key)
    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m
    def mapValuesSafely[V2](f: V => V2): Map[K, V2] = m.mapValues(f).view.force //Hack to get around https://issues.scala-lang.org/browse/SI-4776
  }
  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {
    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)
    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)
    private def removeNode(kv: (K, V)): (K, V) = {
      m -= kv.key
      kv
    }
  }
  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }
  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {
    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}
    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)
    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)
  }
  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
    def toEnglish = if(x) "YES" else "NO"
  }
  implicit class IntExtensions(val x: Int) extends AnyVal {
    import java.lang.{Integer => JInt}
    def withHighestOneBit: Int = JInt.highestOneBit(x)
    def withLowestOneBit: Int = JInt.lowestOneBit(x)
    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)
    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)
    def bitCount: Int = JInt.bitCount(x)
    def setLowestBits(n: Int): Int = x | (left(n) - 1)
    def clearLowestBits(n: Int): Int = x & left(n, ~0)
    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)
    def setBit(i: Int): Int = x | left(i)
    def clearBit(i: Int): Int = x & ~left(i)
    def toggleBit(i: Int): Int = x ^ left(i)
    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1
    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)
    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    import java.lang.{Long => JLong}
    def withHighestOneBitSet: Long = JLong.highestOneBit(x)
    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)
    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)
    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)
    def bitCount: Int = JLong.bitCount(x)
    def setLowestBits(n: Int): Long = x | (left(n) - 1)
    def clearLowestBits(n: Int): Long = x & left(n, ~0L)
    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)
    def setBit(i: Int): Long = x | left(i)
    def clearBit(i: Int): Long = x & ~left(i)
    def toggleBit(i: Int): Long = x ^ left(i)
    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1
    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def **(i: Int): A = if (i == 0) n.one else {
      val h = x ** (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def distance(y: A) = (x - y).abs()
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf "Greg" whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)
    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)
  }
  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new java.awt.geom.Point2D.Double(n.toDouble(p._1), n.toDouble(p._2))
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: => V): Dict[K, V] = using(_ => default)
    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {
      override def apply(key: K) = getOrElseUpdate(key, f(key))
    }
  }
  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]
  def memoize[A, B](f: A => B): A ==> B = map[A] using f
  implicit class FuzzyDouble(val x: Double) extends AnyVal {
    def  >~(y: Double) = x > y + eps
    def >=~(y: Double) = x >= y + eps
    def  ~<(y: Double) = y >=~ x
    def ~=<(y: Double) = y >~ x
    def  ~=(y: Double) = (x distance y) <= eps
  }
  def toPolygon(points: Traversable[(Int, Int)]): java.awt.Polygon = {
    val (xs, ys) = points.unzip
    new java.awt.Polygon(xs.toArray, ys.toArray, points.size)
  }
  def toShape(points: Traversable[(Double, Double)]): java.awt.geom.GeneralPath = {
    val shape = new java.awt.geom.GeneralPath()
    points.headOption foreach {case (x, y) => shape.moveTo(x, y)}
    points.tail foreach {case (x, y) => shape.lineTo(x, y)}
    shape.closePath()
    shape
  }
  def until(until: Int): Range = 0 until until
  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}
  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None
  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  type ==>[A, B] = collection.Map[A, B]
  val mod: Int = (1e9 + 7).toInt
  val eps: Double = 1e-9
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer

class IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered
  val printer = new PrintWriter(out, true)

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    when(tokenizers.nonEmpty)(tokenizers.head)
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]

  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

  def readAll[A: IO.Read]: (Int, Vector[A]) = {
    val data = read[Vector[A]]
    (data.length, data)
  }

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  def write(obj: Any): this.type = {
    printer.print(obj)
    this
  }
  def writeLine(): this.type = {
    printer.println()
    this
  }
  def writeLine(obj: Any): this.type = {
    printer.println(obj)
    this
  }
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = write(obj mkString separator)
  def query[A: IO.Read](question: Any): A = writeLine(question).read

  override def flush() = printer.flush()
  def close() = {
    flush()
    in.close()
    printer.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }
  object Read {
    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val int                                          : Read[Int]          = string.map(_.toInt)
    implicit val long                                         : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                       : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r.read[A], r.read[B], r.read[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r.read[A], r.read[B], r.read[C], r.read[D]))
    implicit val boolean                                      : Read[Boolean]      = string map {s =>
      s.toLowerCase match {
        case "yes" | "true" | "1" => true
        case "no" | "false" | "0" => false
        case _ => s.toBoolean
      }
    }
  }
}

import java.util.Scanner

/**
  * Created by pinguinson on 6/17/2017.
  */
object A extends App {
 val sc = new Scanner(System.in)
  val palindromes = Seq((0,0),(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (10, 1), (11, 11), (12,21),(13,31), (14,41),(15,51),(20,2), (21,12), (22,22),(23,32))
  val s = sc.next()
  val h = s.substring(0, 2).toInt
  val m = s.substring(3, 5).toInt
  val togo = palindromes.find {
    case (hour, minute) => hour >= h && minute >= m
  } match {
    case Some((hr, min)) => (hr - h) * 60 + (min - m)
    case None => (23 - h) + (60 - m)
  }
  println(togo)
}


A string $$$s$$$ of length $$$n$$$ can be encrypted by the following algorithm:  iterate over all divisors of $$$n$$$ in decreasing order (i.e. from $$$n$$$ to $$$1$$$),  for each divisor $$$d$$$, reverse the substring $$$s[1 \dots d]$$$ (i.e. the substring which starts at position $$$1$$$ and ends at position $$$d$$$). For example, the above algorithm applied to the string $$$s$$$="codeforces" leads to the following changes: "codeforces" $$$\to$$$ "secrofedoc" $$$\to$$$ "orcesfedoc" $$$\to$$$ "rocesfedoc" $$$\to$$$ "rocesfedoc" (obviously, the last reverse operation doesn't change the string because $$$d=1$$$).You are given the encrypted string $$$t$$$. Your task is to decrypt this string, i.e., to find a string $$$s$$$ such that the above algorithm results in string $$$t$$$. It can be proven that this string $$$s$$$ always exists and is unique.

The first line of input consists of a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of the string $$$t$$$. The second line of input consists of the string $$$t$$$. The length of $$$t$$$ is $$$n$$$, and it consists only of lowercase Latin letters.

Print a string $$$s$$$ such that the above algorithm results in $$$t$$$.

NoteThe first example is described in the problem statement.

object CF_490_3_B {

  type In  = (Int, String)
  type Out = String

  def solve(in: In): Out = {
    val (n, s) = in

    var ms = s
    for {
      i <- 1 to n
      if n % i == 0
    } {
      val (a, b) = ms.splitAt(i)
      ms = a.reverse + b
    }

    ms
  }

//   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//   Specify Input and Output formats on RHS here:

  def formatIn(i: Input): In       = (i.int, {i.nextLine; i.nextLine})
  def formatOut(out: Out): String  = out.toString

//   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//   Boilerplate & utility methods that don't change (so ignore):

  import java.util.Scanner
  import java.io.InputStream
  import language.implicitConversions

  def main(args: Array[String]): Unit = {
    val out = new java.io.PrintWriter(System.out)
    val resultStr = new Input(System.in).solveStr
    out.println(resultStr)
    out.close()
  }

  class Input(val sc: Scanner) {
    // This class is useful for convenience, and for mock stdin in test scripts
    // Remember to call nextLine to advance past the newline character (if required) before taking a whole line
    def this(i: InputStream)       = this(new Scanner(i))
    def this(s: String)            = this(new Scanner(s.stripMargin))
    def int                        = sc.nextInt()
    def long                       = sc.nextLong()
    def double                     = sc.nextDouble()
    def nextLine                   = sc.nextLine()
    def collect[T](f: String => T) = sc.nextLine().split(" ").toVector.map(f)
    def intSeq                     = collect(_.toInt)
    def doubleSeq                  = collect(_.toDouble)
    def getLines: Vector[String]   = if (!sc.hasNextLine) Vector.empty
                                     else sc.nextLine +: getLines
    def getLines(lineCount: Int)   = {nextLine; (1 to lineCount).map(_ => sc.nextLine)}
    def solveVal: Out              = (solve _).tupled(formatIn(this))
    def solveStr: String           = formatOut(solveVal)
  }

  // Ceiling division for Int & Long
  // `a` MUST be > 0. Incorrect otherwise.
  def divideCeil(a: Int, b: Int)   = (a - 1)/b + 1
  def divideCeil(a: Long, b: Long) = (a - 1)/b + 1

  // A frequently used number in these comps
  val modulo = 1000000007

  // For convenience in test scripts, treat a String as an Input
  implicit def stringToInput(s: String): Input = new Input(s)
  // Required to make `solveVal` work when input has just 1 value (i.e. not a Tuple)
  implicit class makeTupledWorkOnFunction1[-T,+R](f: T => R) {
    def tupled: T => R = x => f(x)
  }
}

object B999 {

  import IO._
  import collection.{mutable => cu}

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    var str = read
    for(fact <- 1 to n) {
      if(n % fact == 0) {
        str = (str.take(fact).reverse) ++ str.drop(fact)
      }
    }
    out.println(str)

    out.close()
  }

  object IO {
    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream("src/input")))
    val out = new java.io.PrintWriter(System.out)

    @inline def read: String = input.readLine()

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInt: Int = tokenizeLine.nextToken.toInt

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}

import scala.io.StdIn

object ReversingEncryption {
  def decrypt(length: Int, line: String): String = {
    var newString = line
    for (i <- 1 to length) {
      if (length % i == 0) {
        newString = newString.replaceFirst(newString.substring(0, i), newString.substring(0, i).reverse)
      }
    }
    newString
  }

  def main(args: Array[String]): Unit = {
    val length = StdIn.readInt()
    var line = StdIn.readLine()
    println(decrypt(length, line))
  }
}

import scala.io.StdIn._
import scala.annotation.tailrec

object ProblemB {
  def readLineToList = readLine.split(" ").map(_.toInt).toList

  def main(args: Array[String]): Unit = {
      val max = readLine.toInt
      val encryptedStr = readLine
      val divisors = (1 to max).filter(max % _ == 0)

      val result = divisors.foldLeft(encryptedStr)((a,b) => {
        a.substring(0, b).reverse + a.splitAt(b)._2
      })
      println(result)
  }
}

object Main2 extends App {

  import java.io._
  import java.util.{StringTokenizer}

  val in = new Reader()
  val out: PrintWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)))

  val n = in.nextInt
  var s = in.next
  (2 to n) filter(n % _ == 0) foreach { d =>
    s = s.substring(0, d).reverse + s.substring(d, n)
  }
  out.print(s)
  out.flush()
  out.close()

  class Reader @throws[IOException]
  () {
    var br: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    var tok: StringTokenizer = null

    def this(file: String) {
      this()
      br = new BufferedReader(new FileReader(file))
    }

    def next: String = {
      while (tok == null || !tok.hasMoreElements) tok = new StringTokenizer(br.readLine)
      tok.nextToken
    }

    def nextInt: Int = next.toInt

    def nextLong: Long = next.toLong

    def nextDouble: Double = next.toDouble

    def nextLine: String = br.readLine
  }

}

import scala.io.StdIn

object ReverseEncryption {
  def main(args: Array[String]): Unit = {
    StdIn.readLine()
    val string = StdIn.readLine()
    println(solve(string))
  }

  def solve(input: String) = {
    var result = input
    divisor(input.length).foreach(n => result = flip(result, n))
    result
  }

  private def divisor(n: Int): Seq[Int] = {
    for {
       i <- 2 to n
       if n % i == 0
    }
    yield i
  }

  private def flip(input: String, n: Int): String = {
    input.substring(0, n).reverse + input.substring(n)
  }
}

import math._
object Main extends App {
  val n = readInt
  val s = readLine
  val d = (1 to sqrt(n).toInt).filter(n % _ == 0)
  val all_d = (d ++ d.map(n / _).reverse).distinct
  val b = StringBuilder.newBuilder
  b.append(s)
  all_d.foreach(i => b.replace(0, i, b.substring(0, i).reverse))
  println(b)
}

import math._
object Main extends App {
  val n = readInt
  val s = readLine
  val d = (1 to sqrt(n).toInt).filter(n % _ == 0)
  val all_d = d ++ d.map(n / _).reverse
  val b = StringBuilder.newBuilder
  b.append(s)
  all_d.foreach(i => b.replace(0, i, b.substring(0, i).reverse))
  println(b)
}


Tattah is asleep if and only if Tattah is attending a lecture. This is a well-known formula among Tattah's colleagues.On a Wednesday afternoon, Tattah was attending Professor HH's lecture. At 12:21, right before falling asleep, he was staring at the digital watch around Saher's wrist. He noticed that the digits on the clock were the same when read from both directions i.e. a palindrome.In his sleep, he started dreaming about such rare moments of the day when the time displayed on a digital clock is a palindrome. As soon as he woke up, he felt destined to write a program that finds the next such moment.However, he still hasn't mastered the skill of programming while sleeping, so your task is to help him.

The first and only line of the input starts with a string with the format "HH:MM" where "HH" is from "00" to "23" and "MM" is from "00" to "59". Both "HH" and "MM" have exactly two digits.

Print the palindromic time of day that comes soonest after the time given in the input. If the input time is palindromic, output the soonest palindromic time after the input time.

object P108A extends App {

  val Array(hh,mm) = readLine.split(":").map(_.toInt)

  def inc(t:(Int,Int)) = ((t._1 + (if (t._2==59) 1 else 0)) % 24,(t._2+1) % 60)
  def f(s:Int) = "%02d".format(s)
  def isPal(t:Int,s:Int) = (f(t) == f(s).reverse)

  var time = (hh,mm)
  do time = inc(time) while(!isPal(time._1,time._2))
  print(f(time._1) + ":" + f(time._2))

}

object P108A extends App {
  val Array(h,m)=readLine.split(":").map(_.toInt)
  def i(t:(Int,Int))=((t._1+(if(t._2==59)1 else 0))%24,(t._2+1)%60)
  def f(s:Int)="%02d".format(s)
  var t = (h,m)
  do t = i(t) while(f(t._1) != f(t._2).reverse)
  print(f(t._1) + ":" + f(t._2))
}

import scala.io.Source

object Solution extends App {
  def pol(time: Int) = {
    val minutes = time % 60
    val hours = time / 60 % 24
    minutes % 10 == hours / 10 && minutes / 10 == hours % 10
  }

  val in = Source.stdin.getLines()
  val Array(hh, mm) = in.next().split(":").map(_.toInt)
  var time = hh * 60 + mm + 1
  while (!pol(time)) time += 1
  val minutes = time % 60
  val hours = time / 60 % 24
  println(f"$hours%02d:$minutes%02d")
}

object A108 {

  import IO._
  import collection.{mutable => cu}

  def main(args: Array[String]): Unit = {
    val in = {
      val str = read
      Array(str.take(2).toInt, str.takeRight(2).toInt)
    }
    var break = false
    while(!break) {
      if(in(0) == 23 && in(1) == 59) {
        in(0) = 0
        in(1) = 0
      } else if(in(1) == 59){
        in(0) += 1
        in(1) = 0
      } else {
        in(1) += 1
      }
      val str = "%02d".format(in(0)) + ":" + "%02d".format(in(1))
      if(str == str.reverse) {
        println(str)
        break = true
      }
    }
  }

  object IO {
    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))

    @inline def read: String = input.readLine()

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInt: Int = tokenizeLine.nextToken.toInt

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}

import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
import scala.util.control.Breaks._

object P108A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val List(hh, mm): List[String] = sc.nextLine.split(":").toList

  def nextPalindromicTime(n: Int): String = {
    val h = (n + 1) % 24
    val m = f"$h%02d".reverse.toInt
    if (m < 60) f"$h%02d:$m%02d"
    else nextPalindromicTime(h)
  }

  val res = {
    val rh = hh.reverse.toInt
    if (rh < 60 && rh > mm.toInt) hh + ":" + hh.reverse
    else nextPalindromicTime(hh.toInt)
  }

  out.println(res)
  out.close
}

object Main {
  def main(args: Array[String]) {
    val Array(hh, mm) = readLine().split(":")
    val h1 =
      if (hh.reverse.toInt <= mm.toInt) hh.toInt + 1
      else hh.toInt
    val h2 = h1 match {
      case 24 => "00"
      case i if i < 6 => "0" + i
      case i if i >= 6 && i <= 9 => "10"
      case i if i >= 16 && i <= 19 => "20"
      case i => i.toString
    }
    println(h2 + ":" + h2.reverse)
  }
}

object P108A extends App {

  val Array(hh,mm) = readLine.split(":").map(_.toInt)

  def inc(t:(Int,Int)) = ((t._1 + (if (t._2==59) 1 else 0)) % 24,(t._2+1) % 60)
  def isPal(t:(Int,Int)) = (t._1 == t._2.toString.reverse.toInt)

  var time = (hh,mm)
  do time = inc(time) while(!isPal(time))
  printf("%02d:%02d", time._1, time._2)

}

object P108A extends App {
  val Array(h,m)=readLine.split(":").map(_.toInt)
  def i(t:(Int,Int))=((t._1+(if(t._2==59)1 else 0))%24,(t._2+1)%60)
  def f(s:Int)="%02d".format(s)
  var t = (h,m)
  do t = i(t) while(f(t._1) != f(t._2))
  print(f(t._1) + ":" + f(t._2))
}

import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
import scala.util.control.Breaks._

object P108A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val List(h, m) = sc.nextLine.split(":").toList

  val res = if (h.reverse.toInt > m.toInt) out.println(h + ":" + h.reverse)
            else nextPalindromicTIme(h.toInt)

  def nextPalindromicTIme(x: Int): String = {
    val y = (x + 1) % 24
    val z = f"$y%02d".reverse.toInt
    if (z < 60) f"$y%02d:$z%02d"
    else (nextPalindromicTIme(x + 1))
  }

  out.println(res)
  out.close
}

import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
import scala.util.control.Breaks._

object P108A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val List(h, m) = sc.nextLine.split(":").toList

  if (h.reverse.toInt >= m.toInt) out.println(h + ":" + h.reverse)
  else nextPalindromicTIme(h.toInt)

  def nextPalindromicTIme(x: Int): String = {
    val y = (x + 1) % 24
    val z = f"$y%02d".reverse.toInt
    if (z < 60) f"$y%02d:$z%02d"
    else (nextPalindromicTIme(x + 1))
  }

 out.close
}

import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
import scala.util.control.Breaks._

object P108A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val List(h, m) = sc.nextLine.split(":").toList

  if (h.reverse.toInt > m.toInt) out.println(h + ":" + h.reverse)
  else nextPalindromicTIme(h.toInt)

  def nextPalindromicTIme(x: Int): String = {
    val y = (x + 1) % 24
    val z = f"$y%02d".reverse.toInt
    if (z < 60) f"$y%02d:$z%02d"
    else (nextPalindromicTIme(x + 1))
  }

 out.close
}

import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
import scala.util.control.Breaks._

object P108A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val List(h, m) = sc.nextLine.split(":").toList

  val res = if (h.reverse.toInt > m.toInt) h + ":" + h.reverse
            else nextPalindromicTIme(h.toInt)

  def nextPalindromicTIme(x: Int): String = {
    val y = (x + 1) % 24
    val z = f"$y%02d".reverse.toInt
    if (z < 60) f"$y%02d:$z%02d"
    else nextPalindromicTIme(x + 1)
  }

  out.println(res)
  out.close
}

import java.util.Scanner
import java.io.PrintWriter
import java.util.Arrays.binarySearch
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ArrayBuffer
import scala.util.Random
import scala.util.control.Breaks._

object P108A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val n = sc.nextLine.split(":")(0).toInt

  def nextPalindromicTIme(x: Int): String = {
    val y = (x + 1) % 24
    val z = f"$y%02d".reverse.toInt
    if (z < 60) f"$y%02d:$z%02d"
    else (nextPalindromicTIme(x + 1))
  }

  out.println(nextPalindromicTIme(n))
  out.close
}


Recently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe. She thinks that each Fibonacci number can be represented as sum of three not necessary different Fibonacci numbers.Let's remember how Fibonacci numbers can be calculated. F0 = 0, F1 = 1, and all the next numbers are Fi = Fi - 2 + Fi - 1.So, Fibonacci numbers make a sequence of numbers: 0, 1, 1, 2, 3, 5, 8, 13, ...If you haven't run away from the PC in fear, you have to help the virus. Your task is to divide given Fibonacci number n by three not necessary different Fibonacci numbers or say that it is impossible.

The input contains of a single integer n (0 ≤ n < 109) — the number that should be represented by the rules described above. It is guaranteed that n is a Fibonacci number.

Output three required numbers: a, b and c. If there is no answer for the test you have to print "I'm too stupid to solve this problem" without the quotes. If there are multiple answers, print any of them.

import java.util.Scanner

object Main {

	def main(args: Array[String]): Unit = {
		val scanner = new Scanner (System.in)
		val n = scanner nextInt ()
		print ("0 0 ")
		println (n)
	}

}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val n = in.next().toInt
  println(s"$n 0 0")
}

object A199 {

  import IO._
  import collection.{mutable => cu}
  def main(args: Array[String]): Unit = {
    val Array(n) = readLongs(1)
    println(s"0 0 $n")
  }

  object IO {
    @inline def read: String = scala.io.StdIn.readLine

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine;
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}

import java.util.Scanner
import java.io.PrintWriter
import scala.annotation.tailrec
import scala.collection.mutable
import scala.util.Random

object P199A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val N = sc.nextInt

  def solve(): List[Int] = {

    @tailrec
    def loop(a: Int, b: Int, c: Int, d: Int, x: Int): List[Int] = {
      if (x == N) List(a, b, d)
      else loop(b, c, d, x, d + x)
    }

    N match {
      case 0 => List(0, 0, 0)
      case 1 => List(0, 0, 1)
      case 2 => List(0, 1, 1)
      case _ => loop(0, 1, 1, 2, 3)
    }
  }

  out.println(solve.mkString(" "))
  out.close
}

import java.util

import scala.annotation.tailrec

/**
 * @author pvasilyev
 * @since 16 Jun 2016
 */
object A199 extends App {

  @tailrec
  // fibs[from] <= f
  def binarySearch(fibs: util.ArrayList[Int], f: Int, from: Int, to: Int): Int = {
    if (to - from < 2) {
      from
    } else {
      val mid: Int = (from + to) / 2
      if (fibs.get(mid) <= f) {
        binarySearch(fibs, f, mid, to)
      } else {
        binarySearch(fibs, f, from, mid)
      }
    }
  }

  def solve() = {
    val f: Int = scala.io.StdIn.readInt()
    if (f == 0) {
      println("0 0 0")
    } else if (f == 1) {
      println("0 0 1")
    } else {
      val fibs = new util.ArrayList[Int]()
      fibs.add(0)
      fibs.add(1)
      var k = 2
      while (fibs.get(k - 1) + fibs.get(k - 2) < 1000000000) {
        fibs.add(fibs.get(k - 1) + fibs.get(k - 2))
        k += 1
      }
      val i: Int = binarySearch(fibs, f, 0, fibs.size())
      println("0 " + fibs.get(i-2) + " " + fibs.get(i-1))
    }
  }

  solve()

}

import java.io._
import java.util.Locale
import scala.annotation.tailrec

object Easy {
  val reader = new BufferedReader(new InputStreamReader(System.in))
  def readInt = reader.readLine().toInt
  def readInts = reader.readLine().split(" ").map(_.toInt)
  def readLongs = reader.readLine().split(" ").map(_.toLong)
  def readLine = reader.readLine

  def ans = Array(0, 0, readInt).mkString(" ")

  def main(a: Array[String]) {
    println(ans)
  }
}

object Main {
  val fib: Stream[Int] = {
    def fibf(a: Int, b: Int): Stream[Int] = {
      a #:: fibf(b, a + b)
    }
    fibf(0, 1)
  }

  def main(args: Array[String]) = {
    val n = readLine()
    val i = fib.takeWhile(_ < 1000000000).indexOf(n)
    if (i <= 3) println("0 0 " + n)
    else println(fib(i - 4) + " " + fib(i - 3) + " " + fib(i - 1))
  }
}

object Solution extends App{

    val in = scala.io.Source.stdin.getLines()
    val n = in.next().toInt
    println(s"$n 0 0")
}

object A199 {

  import IO._
  import collection.{mutable => cu}
  def generateFib(till: Long): Array[Long] = {
    var num1 = 1L
    var num2 = 2L
    var res = Array(1L, 2L)
    while(num2 <= till) {
      val temp = num1 + num2
      num1 = num2
      num2 = temp
      res ++= Array(num2)
    }
    res
  }
  def main(args: Array[String]): Unit = {
    val Array(n) = readLongs(1)
    val fibs = generateFib(1000000000L)
    var break = false
    for(i <- fibs; j <- fibs; k <- fibs if !break) {
      if(i+j+k == n) {
        println(s"$i $j $k")
        break = true
      }
    }
    if(!break)
      println("I'm too stupid to solve this problem")
  }

  object IO {
    @inline def read: String = scala.io.StdIn.readLine

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine;
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine;
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}


Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than $$$a$$$ and screen height not greater than $$$b$$$. Monocarp is also used to TV sets with a certain aspect ratio: formally, if the width of the screen is $$$w$$$, and the height of the screen is $$$h$$$, then the following condition should be met: $$$\frac{w}{h} = \frac{x}{y}$$$.There are many different TV sets in the shop. Monocarp is sure that for any pair of positive integers $$$w$$$ and $$$h$$$ there is a TV set with screen width $$$w$$$ and height $$$h$$$ in the shop.Monocarp isn't ready to choose the exact TV set he is going to buy. Firstly he wants to determine the optimal screen resolution. He has decided to try all possible variants of screen size. But he must count the number of pairs of positive integers $$$w$$$ and $$$h$$$, beforehand, such that $$$(w \le a)$$$, $$$(h \le b)$$$ and $$$(\frac{w}{h} = \frac{x}{y})$$$.In other words, Monocarp wants to determine the number of TV sets having aspect ratio $$$\frac{x}{y}$$$, screen width not exceeding $$$a$$$, and screen height not exceeding $$$b$$$. Two TV sets are considered different if they have different screen width or different screen height.

The first line contains four integers $$$a$$$, $$$b$$$, $$$x$$$, $$$y$$$ ($$$1 \le a, b, x, y \le 10^{18}$$$) — the constraints on the screen width and height, and on the aspect ratio.

Print one integer — the number of different variants to choose TV screen width and screen height so that they meet the aforementioned constraints.

NoteIn the first example, there are $$$3$$$ possible variants: $$$(5, 3)$$$, $$$(10, 6)$$$, $$$(15, 9)$$$.In the second example, there is no TV set meeting the constraints.In the third example, there is only one variant: $$$(3, 2)$$$.

object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val a, b = nl()
    var x, y = nl()
    val d = gcd(x, y)
    x /= d
    y /= d

    val ans = min(a / x, b / y)

    out.println(ans)
  }

  def gcd(a: Long, b: Long): Long = {
    if (b == 0) a
    else gcd(b, a % b)
  }

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

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }
}


A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami beach. Unfortunately, the company that made the banner mixed up two orders and delivered somebody else's banner that contains someone else's word. The word on the banner consists only of upper-case English letters.There is very little time to correct the mistake. All that we can manage to do is to cut out some substring from the banner, i.e. several consecutive letters. After that all the resulting parts of the banner will be glued into a single piece (if the beginning or the end of the original banner was cut out, only one part remains); it is not allowed change the relative order of parts of the banner (i.e. after a substring is cut, several first and last letters are left, it is allowed only to glue the last letters to the right of the first letters). Thus, for example, for example, you can cut a substring out from string 'TEMPLATE' and get string 'TEMPLE' (if you cut out string AT), 'PLATE' (if you cut out TEM), 'T' (if you cut out EMPLATE), etc.Help the organizers of the round determine whether it is possible to cut out of the banner some substring in such a way that the remaining parts formed word CODEFORCES.

The single line of the input contains the word written on the banner. The word only consists of upper-case English letters. The word is non-empty and its length doesn't exceed 100 characters. It is guaranteed that the word isn't word CODEFORCES.

Print 'YES', if there exists a way to cut out the substring, and 'NO' otherwise (without the quotes).

CODEWAITFORITFORCES BOTTOMCODER DECODEFORCES DOGEFORCES

object Main extends App with fastIO{
  val s = readLine
  val st = "CODEFORCES"
  var bo = false
  //if(s.contains(st)) bo = true
  for(a <- 0 until s.length; b <- a to s.length){
    if(s.substring(0,a)++s.substring(b,s.length)==st) bo = true
  }
  println(if(bo)"YES" else "NO")
  flush
}

trait fastIO {
  import java.io._
  val isFile = false
  val input = "file.in"
  val output = "file.out"
  val bf = new BufferedReader(if(isFile) new FileReader(input) else new InputStreamReader(System.in))
  val in = new StreamTokenizer(bf)
  val out = new PrintWriter(if(isFile)new FileWriter(output) else new OutputStreamWriter(System.out))

  def next: String = {
    in.ordinaryChars('0', '9')
    in.wordChars('0', '9')
    in.nextToken()
    in.sval
  }
  def nextInt: Int = {
    in.nextToken()
    in.nval.toInt
  }
  def nextLong:Long ={
    in.nextToken()
    in.nval.toLong
  }
  def nextDouble: Double = {
    in.nextToken()
    in.nval
  }
  def readLine: String = bf.readLine()
  def println(o:Any) = out.println(o)
  def print(o:Any) = out.print(o)
  def printf(s:String,o:Any*) = out.printf(s,o)
  def flush() = out.flush()
}

import scala.io.Source

object A extends App {
  val str = Source.stdin.getLines().next()
  val a = (0 until str.length).exists(s => (s to str.length).exists(e => str.substring(0, s) + str.substring(e) == "CODEFORCES"))
  println(if (a) "YES" else "NO")
}

import scala.collection._

object A extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }
  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }

  val a = readLine
  val b = "CODEFORCES"
  var canCut = true
  var hasCut = false
  var ok = true

  var i = 0
  while (i < a.length && i < b.length && a(i) == b(i)) {
    i += 1
  }

  var j = 0
  while (j < a.length && j < b.length && a(a.length - j - 1) == b(b.length - j - 1)) {
    j += 1
  }
//println(i, j)
  println(if (i == b.length || j == b.length || i + j >= b.length) "YES" else "NO")
}

import java.io._
import java.util._

import scala.collection.mutable

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = return Integer.parseInt(next)

  def nextLong: Long = return java.lang.Long.parseLong(next)

  def nextDouble: Double = return java.lang.Double.parseDouble(next)

  class MultiHashSet[T <% Comparable[T]] {
    val map = new mutable.HashMap[T, Int]()

    def count(x: T): Int = {
      return map.getOrElse(x, 0)
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  class MultiTreeSet[T <% Comparable[T]] {
    val map = new TreeMap[T, Int]()

    def count(x: T): Int = {
      val res = map.get(x)
      if (res == null)
        return 0
      return res
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def first(): T = return map.firstKey()

    def last(): T = return map.lastKey()

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  def solve: Int = {
    val banner = next
    val n = banner.length
    for (i <- 0 until n) {
      for (j <- i - 1 until n) {
        if ((banner.substring(0, i) + banner.substring(j + 1)).equalsIgnoreCase("codeforces")) {
          out.println("YES")
          return 0
        }
      }
    }
    out.println("NO")
    return 0
  }
}

import scala.io.StdIn._

object A_CuttingBanner extends App {
  val banner = readLine()
  val Code = "CODEFORCES"

  private def isPossible: Boolean = {
    if (banner.length > Code.length) {
      val sizeToCut = banner.length - Code.length
      for {
        left <- 0 to banner.length
      } {
        val L = banner.take(left)
        val R = banner.drop(left + sizeToCut)
//        println(L + "|" + R)
        if (L + R == Code) return true
      }
    }

    false
  }

  println(if (isPossible) "YES" else "NO")
}

object Main extends App with fastIO{
  val s = readLine
  val st = "CODEFORCES"
  var bo = false
  if(s.contains(st)) bo = true
  else for(a <- 0 until s.length; b <- a until s.length){
    if(s.substring(0,a)++s.substring(b,s.length)==st) bo = true
  }
  println(if(bo)"YES" else "NO")
  flush
}

trait fastIO {
  import java.io._
  val isFile = false
  val input = "file.in"
  val output = "file.out"
  val bf = new BufferedReader(if(isFile) new FileReader(input) else new InputStreamReader(System.in))
  val in = new StreamTokenizer(bf)
  val out = new PrintWriter(if(isFile)new FileWriter(output) else new OutputStreamWriter(System.out))

  def next: String = {
    in.ordinaryChars('0', '9')
    in.wordChars('0', '9')
    in.nextToken()
    in.sval
  }
  def nextInt: Int = {
    in.nextToken()
    in.nval.toInt
  }
  def nextLong:Long ={
    in.nextToken()
    in.nval.toLong
  }
  def nextDouble: Double = {
    in.nextToken()
    in.nval
  }
  def readLine: String = bf.readLine()
  def println(o:Any) = out.println(o)
  def print(o:Any) = out.print(o)
  def printf(s:String,o:Any*) = out.printf(s,o)
  def flush() = out.flush()
}

object Main extends App with fastIO{
  val s = readLine
  val st = "CODEFORCES"
  var bo = false
  //if(s.contains(st)) bo = true
  for(a <- 0 until s.length; b <- a until s.length){
    if(s.substring(0,a)++s.substring(b,s.length)==st) bo = true
  }
  println(if(bo)"YES" else "NO")
  flush
}

trait fastIO {
  import java.io._
  val isFile = false
  val input = "file.in"
  val output = "file.out"
  val bf = new BufferedReader(if(isFile) new FileReader(input) else new InputStreamReader(System.in))
  val in = new StreamTokenizer(bf)
  val out = new PrintWriter(if(isFile)new FileWriter(output) else new OutputStreamWriter(System.out))

  def next: String = {
    in.ordinaryChars('0', '9')
    in.wordChars('0', '9')
    in.nextToken()
    in.sval
  }
  def nextInt: Int = {
    in.nextToken()
    in.nval.toInt
  }
  def nextLong:Long ={
    in.nextToken()
    in.nval.toLong
  }
  def nextDouble: Double = {
    in.nextToken()
    in.nval
  }
  def readLine: String = bf.readLine()
  def println(o:Any) = out.println(o)
  def print(o:Any) = out.print(o)
  def printf(s:String,o:Any*) = out.printf(s,o)
  def flush() = out.flush()
}

import scala.collection._

object A extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }
  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }

  val a = readLine
  val b = "CODEFORCES"
  var canCut = true
  var hasCut = false
  var ok = true

  var i = 0
  while (i < a.length && i < b.length && a(i) == b(i)) {
    i += 1
  }

  var j = 0
  while (j < a.length && j < b.length && a(a.length - j - 1) == b(b.length - j - 1)) {
    j += 1
  }
//println(i, j)
  println(if (i == b.length || j == b.length || i + j == b.length) "YES" else "NO")
}

import scala.collection._

object A extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }
  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }

  val a = readLine
  val b = "CODEFORCES"
  var canCut = true
  var hasCut = false
  var ok = true

  var i = 0
  while (i < a.length && i < b.length && a(i) == b(i)) {
    i += 1
  }

  var j = 0
  while (j < a.length && j < b.length && a(a.length - j - 1) == b(b.length - j - 1)) {
    j += 1
  }
//println(i, j)
  println(if (a == b || (i + j == b.length && (i > 0 || j > 0))) "YES" else "NO")
}

import java.io._
import java.util._

import scala.collection.mutable

object A {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = return Integer.parseInt(next)

  def nextLong: Long = return java.lang.Long.parseLong(next)

  def nextDouble: Double = return java.lang.Double.parseDouble(next)

  class MultiHashSet[T <% Comparable[T]] {
    val map = new mutable.HashMap[T, Int]()

    def count(x: T): Int = {
      return map.getOrElse(x, 0)
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  class MultiTreeSet[T <% Comparable[T]] {
    val map = new TreeMap[T, Int]()

    def count(x: T): Int = {
      val res = map.get(x)
      if (res == null)
        return 0
      return res
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def first(): T = return map.firstKey()

    def last(): T = return map.lastKey()

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  def solve: Int = {
    val banner = next
    val n = banner.length
    for (i <- 0 until n) {
      for (j <- i + 1 until n) {
        if ((banner.substring(0, i) + banner.substring(j)).equalsIgnoreCase("codeforces")) {
          out.println("YES")
          return 0
        }
      }
    }
    out.println("NO")
    return 0
  }
}

import scala.io.StdIn._

object A_CuttingBanner extends App {
  val banner = readLine()
  val Code = "CODEFORCES"

  private def isPossible: Boolean = {
    if (banner.length > Code.length) {
      val sizeToCut = banner.length - Code.length
      for {
        left <- 0 to (banner.length - Code.length)
      } {
        val L = banner.take(left)
        val R = banner.drop(left + banner.length - Code.length)
        if (L + R == Code) return true
      }
    }

    false
  }

  println(if (isPossible) "YES" else "NO")
}