{"source_code": "// codeforces 224A\nobject Parallelipiped extends App {\n  val ss = (Console.readLine.split(\" \")) map (_.toInt)\n  val sxy = ss(0)\n  val syz = ss(1)\n  val sxz = ss(2)\n  \n  def lxyz():Int = {\n    val vars = for {\n      x <- 1 to 10000\n      if sxy % x == 0\n      val y = sxy / x\n      if syz % y == 0\n      val z = syz / y\n      if x*z == sxz      \n    } yield (x + y + z)\n    vars(0) * 4\n  }\n  \n  println(lxyz())\n}", "positive_code": [{"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P224A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val X, Y, Z = sc.nextLong\n\n  val xyz = math.sqrt(X * Y * Z).round\n\n  val a = xyz / X\n  val b = xyz / Y\n  val c = xyz / Z\n\n  val answer = 4 * (a + b + c)\n\n  out.println(answer)\n  out.close\n}\n"}, {"source_code": "import java.io._\nimport java.util.Locale\nimport scala.annotation.tailrec\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInt = reader.readLine().toInt\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readLongs = reader.readLine().split(\" \").map(_.toLong)\n\n  val Array(ab, bc, ac) = readInts\n  def intStream(i: Int): Stream[Int] = i #:: intStream(i + 1)\n  def a = intStream(1).filter(ab % _ == 0).filter(ac % _ == 0)\n  def ans = a.filter(a => ab / a  * ac / a == bc).head\n\n  def main(a: Array[String]) {\n    println(4 * (ans + ab / ans + ac / ans))\n  }\n}\n"}, {"source_code": "object test5 extends App {\n    val Array(x,y,z)=readLine.split(\" \").map(_.toInt)\n    for(a<-1 to x if x%a==0)\n    {\n\t\tval b=x/a\n\t\tif(y%a==0)\n\t\t{\n\t\t\tval c=y/a\n\t\t\tif(b*c==z)\n\t\t\t{\n\t\t\t\tprintln((a+b+c)*4)\n\t\t\t\texit\n\t\t\t}\n\t\t}\n    }\n}   \n\n/*\na*b=x\n\na*c=y && b*c=z ||\nb*c=y && a*c=z\n*/"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val ss = readLine().split(\" \").map(_.toInt).sorted\n    val s1 = ss(0)\n    val s2 = ss(1)\n    val s3 = ss(2)\n    \n    val ls0 = for {\n      i <- 1 to s1\n      j = (s1 / i).toInt\n      if i * j == s1\n    } yield(i, j)\n    val ls = for {\n      (i, j) <- ls0\n      k = (ss(1) / i).toInt\n      if i * k == s2\n      if j * k == s3\n    } yield(i, j, k)\n    println((ls(0)._1 + ls(0)._2 + ls(0)._3) * 4)\n  }\n}"}, {"source_code": "import collection.mutable.ArrayBuffer\nimport java.io.InputStreamReader\nimport java.io.BufferedReader\nimport scala.collection.JavaConversions._\n\n\nobject CodeForces138_1 {\n\n  val in = System.in\n  val out = System.out\n\n  def grabData {\n    val reader = new BufferedReader(new InputStreamReader(in))\n    //val array = new ArrayBuffer[]()\n    var line = reader.readLine()\n    while(line != null) {\n\n      line = reader.readLine()\n    }\n    //array\n  }\n\n  def grabData2 = {\n    val reader = new BufferedReader(new InputStreamReader(in))\n    val line = reader.readLine()\n    line.split(' ').toSeq.map(_.toInt)\n  }\n\n\n\n  def main(args: Array[String]) {\n    val sses = grabData2\n    val s1:Double = sses(0)\n    val s2:Double = sses(1)\n    val s3:Double = sses(2)\n    val c = Math.sqrt(s2*s3/s1)\n    val a = s3/c\n    val b = s2/c\n    out.print(((c+a+b)*4).toInt)\n  }\n\n}\n"}, {"source_code": "object A {\n    def main(args : Array[String]) : Unit = {\n        val Array(x, y, z) = readLine.split(\" \").map(s => s toInt);\n\n        def side(x : Int, y : Int, z : Int) : Double = {\n            scala.math.sqrt(x * y / z)\n        }\n\n        val sm = side(x, y, z) + side(y, z, x) + side(z, x, y)\n\n        println((4 * sm) toInt)\n    }\n}\n"}, {"source_code": "import java.util.StringTokenizer\n\nobject _224A extends App {\n  var token = new StringTokenizer(\"\")\n\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n\n  val a = next.toInt\n  val b = next.toInt\n  val c = next.toInt\n  val cb = a.toLong * b * c\n  val wb = Math.sqrt(cb).round\n  val zb = (for {\n    i <- (wb - 10) to (wb + 10)\n    if (i > 0)\n    if (i * i == cb)\n  } yield i).head\n\n  val t = zb / a\n  val tt = zb / b\n  val ttt = zb / c\n  println(4 * (t + tt + ttt))\n}\n"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val Array(x1, x2, x3) = in.next().split(' ').map(_.toInt)\n\n  def findSolution(x1: Int, x2: Int, x3: Int) = {\n    (1 to x1).collectFirst {\n      case a if x3 == x2 / a * x1 / a =>\n        (a, x2 / a, x1 / a)\n      case a if x2 == x3 / a * x1 / a =>\n        (a, x3 / a, x1 / a)\n    }\n  }\n\n  println(findSolution(x1, x2, x3).map(i => 4 * (i._1 + i._2 + i._3)).get)\n\n}\n"}, {"source_code": "object A224 {\n\n  import IO._\n  import collection.{mutable => cu}\n  def gcd(a: Long, b: Long): Long = {\n    if(b == 0) a else gcd(b, a%b)\n  }\n  def main(args: Array[String]): Unit = {\n    val in = readLongs(3).sorted\n    var break = false\n    for(i <- 1 to in.min.toInt if !break) {\n      val a = i\n      val b = in(0)/a\n      val c = in(2)/a\n      if(b*c == in(1)) {\n        println(4 * (a + b + c))\n        break = true\n      }\n    }\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}], "negative_code": [{"source_code": "object A224 {\n\n  import IO._\n  import collection.{mutable => cu}\n  def gcd(a: Long, b: Long): Long = {\n    if(b == 0) a else gcd(b, a%b)\n  }\n  def main(args: Array[String]): Unit = {\n    val in = readLongs(3)\n    var break = false\n    for(i <- 1 to in.min.toInt if !break) {\n      val a = i\n      val b = in(0)/a\n      val c = in(2)/a\n      if(b*c == in(1)) {\n        println(4 * (a + b + c))\n        break = true\n      }\n    }\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}], "src_uid": "c0a3290be3b87f3a232ec19d4639fefc"}
{"source_code": "import scala.collection.mutable._\nimport scala.math._\nimport scala.util.control.Breaks.break\nimport scala.util.control.Breaks.breakable\nimport java.util._\nobject Main extends App {\n  val sc = new Scanner(System.in)\n  def gcd(a: Int, b: Int): Int = if(b == 0) a else gcd(b, a%b)\n  var t = Array[Int](sc.nextInt,sc.nextInt)\n  var n = sc.nextInt\n  def sim(s: Int): Int = {\n    val g = gcd(n,t(s))\n    val ns = (s+1)%2\n    if(n < g) ns\n    else { n-=g; sim(ns) }\n  }\n  println(sim(0))\n}\n", "positive_code": [{"source_code": "import scala.util.Sorting\nimport scala.io.StdIn\n\nobject App {\n\n\n  def main(args: Array[String]) {\n\n    val Array(a, b, n) = StdIn.readLine().split(\" \").map(_.toInt)\n\n    val A:Array[Int] = Array(a,b)\n    var cur = 0\n    var curn = n\n    while(gcd(curn,A(cur)) <= curn) {\n      curn-=gcd(curn,A(cur));\n      if(cur == 0) {\n        cur = 1\n      } else {\n        cur = 0\n      }\n    }\n    if(cur == 0) {\n      cur = 1\n    } else {\n      cur = 0\n    }\n    print(cur)\n\n\n    def gcd(x:Int, y:Int):Int = {\n      if(x % y == 0)\n        y\n      else\n        gcd( y % x, x)\n    }\n\n  }\n\n\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject TEST extends App {\n  val a : Array[Int] = readLine.split(\" \").map(_.toInt)\n\n  def gcd(x: Int, y: Int): Int = if(y==0) x else gcd(y,x%y)\n\n  def play(state :Int,n: Int):Int =if(n==0)  state^1 else  play(state^1,n-gcd(n,a(state)))\n\n  print(play(0,a(2)))\n}"}, {"source_code": "import scala.annotation.tailrec\nobject Main {\n\n  def main(args: Array[String]): Unit = {\n    @tailrec\n    def gcd(x:Int,y:Int):Int= y match{\n      case 0 => return x;\n      case _ => return gcd(y,x%y);\n    }\n    var fix = readLine().split(\" \").map(_.toInt)\n    @tailrec\n    def rec(t:Int,n:Int):Int= n match{\n      case _ if gcd(fix(t),n)>n => return 1-t;\n      case _ => return rec(1-t,n-gcd(fix(t),n))\n    }\n    println(rec(0,fix(2)))\n  }\n\n}"}, {"source_code": "import scala.annotation.tailrec\nobject Main {\n\n  def main(args: Array[String]): Unit = {\n    @tailrec\n    def gcd(x:Int,y:Int):Int={\n      if(y==0)return x;\n      return gcd(y,x%y);\n    }\n    var fix = readLine().split(\" \").map(_.toInt)\n    @tailrec\n    def rec(t:Int,n:Int):Int={\n      val req = gcd(fix(t),n)\n      if(req>n)return 1-t;\n      return rec(1-t,n-req)\n    }\n    println(rec(0,fix(2)))\n  }\n\n}"}, {"source_code": "import scala.collection.immutable.Nil\n\nobject A00119 extends App {\n  def parseInt(str: String, count: Int): Seq[Int] = {\n    val scanner = new java.util.Scanner(str)\n    val res = (1 to count) map (_ => scanner.nextInt())\n    scanner.close()\n    res\n  }\n  def scanInts(count: Int): Seq[Int] = parseInt(Console.readLine, count)\n  def readMatrix(row: Int, col: Int) = (1 to row) map (x => scanInts(col))\n\n  def oneIntLine = {\n    val Seq(count) = parseInt(Console.readLine(), 1);\n    count\n  }\n  \n  def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)\n  \n  def nextVals(x: (Int, Int, Int)): (Int, Int, Int) =\n    if (x._3 == 0) null\n    else (x._2, x._1, x._3 - gcd(x._1, x._3))\n  \n  def valStream(x: (Int, Int, Int)): Stream[(Int, Int, Int)] = {\n    val n = nextVals(x)\n    if (n == null) Stream.Empty\n    else x #:: valStream(n)\n  }\n\n  val Seq(a, b, n) = readMatrix(1, 3).head\n\n  println((valStream((a, b, n)).length - 1) % 2)\n  \n  \n  \n}"}, {"source_code": "object Main {\n\n    def gcd(x: Int, y: Int): Int = {\n        var a = x; var b = y\n        while (b > 0) {\n            a %= b\n            val k = a\n            a = b\n            b = k\n        }\n        return a\n    }   \n\n    def main(args: Array[String]): Unit = {\n        var Array(a, b, n) = readLine split \" \" map(_.toInt)\n        var cur = 1\n        while (n > 0) {\n            val k = if (cur == 1) a else b\n            n -= gcd(k, n)\n            cur += 1;\n            cur %= 2 \n        }\n\n        println (cur)\n    }\n}"}, {"source_code": "\nobject One19A extends App {\n\n\tval Array(a, b, n) = readLine.split(' ').map(_.toInt)\n\n\tdef recursive(tog: Boolean, left: Int): Boolean = if (tog) {\n\t\tval cal = left - gcd(a, left)\n\t\tif (cal >= 0) recursive(!tog, cal) else tog\n\t} else {\n\t\tval cal = left - gcd(b, left)\n\t\tif (cal >= 0) recursive(!tog, cal) else tog\n\t}\n\n\tdef gcd(a: Int, b: Int): Int = if (a == 0) b else gcd(b % a, a)\n\n\tif (recursive(true, n)) {\n\t\tprintln(1)\n\t} else {\n\t\tprintln(0)\n\t}\n}"}, {"source_code": "import scala.io.StdIn\n\nobject Main extends App {\n  val str = StdIn.readLine().split(\" \").map(_.toInt)\n  val a = str(0)\n  val b = str(1)\n  var n = str(2)\n  var moveCount = 0\n\n  def gcd(a: Int, b: Int): Int =\n    if (b == 0) a else gcd(b, a % b)\n\n  while(n >= 0) {\n    if (moveCount == 0) {\n      val move = gcd(a, n)\n      n = n - move\n      moveCount = 1\n    } else {\n      val move = gcd(b, n)\n      n = n - move\n      moveCount = 0\n    }\n  }\n\n  if (moveCount == 1) println(1)\n  else println(0)\n}"}, {"source_code": "object Solutuin119A extends App {\n\n\n  def norm(a: Int, b: Int): (Int, Int) = (scala.math.min(a,b), scala.math.max(a, b))\n\n  def gcd(a: Int, b: Int): Int = {\n    val n = norm(a, b)\n    n._2 % n._1 match {\n      case 0 => n._1\n      case m => gcd(m, n._1)\n    }\n  }\n\n  def solution() {\n    val a = _int\n    val b = _int\n    val n = _int\n    val qqq = Map(0 -> a, 1 -> b)\n\n    def wins(n: Int, turn: Int): Int = n match {\n      case 0 => (turn + 1) % 2\n      case _ => wins(n - gcd(n, qqq(turn)), (turn + 1) % 2)\n    }\n\n    println(wins(n, 0))\n  }\n\n  //////////////////////////////////////////////////\n  import java.util.Scanner\n  val SC: Scanner = new Scanner(System.in)\n  def _line: String = SC.nextLine\n  def _int: Int = SC.nextInt\n  def _long: Long = SC.nextLong\n  def _string: String = SC.next\n  solution()\n}"}, {"source_code": "object Solution extends App{\n  def gcd(a: Int, b: Int): Int = {\n    if(b == 0) a else gcd(b, a % b)\n  }\n\n  val in = scala.io.Source.stdin.getLines()\n  var Array(a, b, n) = in.next().split(\" \").map(_.toInt)\n  var count = 0\n  var take = gcd(a, n)\n  while (n > take) {\n    n -= take\n    count += 1\n    if (count % 2 == 1)\n      take = gcd(b, n)\n    else\n      take = gcd(a, n)\n  }\n  println(count % 2)\n}"}, {"source_code": "import scala.collection.JavaConversions._\nimport scala.collection.mutable.ArraySeq\n\nobject Codeforces119A {\n    def gcd(a: Int,b: Int): Int = {\n       if(b ==0) a else gcd(b, a%b)\n    }\n\n    def main(args: Array[String]) {\n        val arr: ArraySeq[Int] = scala.io.StdIn.readLine().split(\" \").map(Integer.parseInt)\n        var currentPlayer = 0       // Simon\n        var g: Int = 0\n        while (arr(2) >= 0) {\n            g = gcd(arr(currentPlayer), arr(2))\n            if (arr(2) < g) {\n                println(1-currentPlayer)\n                return\n            }\n            else {\n                arr(2) -= g\n                currentPlayer = 1 - currentPlayer\n            }\n        }\n    }\n}"}, {"source_code": "object A119 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def gcd(a: Int, b: Int): Int = if(b==0) a else gcd(b, a%b)\n  def main(args: Array[String]): Unit = {\n    var Array(a, b, n) = readInts(3)\n    val arr = Array(a, b)\n    var player = 0\n    while(n > 0) {\n      val gc = gcd(arr(player), n)\n      n -= gc\n      player = 1-player\n    }\n    println(1-player)\n  }\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P119A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val A, B, N = sc.nextInt\n\n  @tailrec\n  def euclid(a: Int, b: Int): Int =\n    if (b == 0) a\n    else euclid(b, a % b)\n\n  def gcd(a: Int, b: Int): Int =\n    if (a > b) euclid(a, b)\n    else euclid(b, a)\n\n  def antisimon(x: Int): Int = {\n    val r = gcd(x, B)\n    if (x < r) 0\n    else simon(x - r)\n  }\n\n  def simon(x: Int): Int = {\n    val r = gcd(x, A)\n    if (x < r) 1\n    else antisimon(x - r)\n  }\n\n  val solve: Int = simon(N)\n\n  out.println(solve)\n  out.close\n}\n"}, {"source_code": "\n\nobject EpicGame {\n\tdef main (args: Array[String]) {\n\t\tval scanner = new java.util.Scanner(System.in);\n\t\tval a = scanner.nextInt();\n\t\tval b = scanner.nextInt();\n\t\tvar n = scanner.nextInt();\n\t\tvar turn = 0 // 0 for Simon's turn\n\t\twhile (n > 0) {\n\t\t  n -= gcd(n, if (turn == 0) a else b)\n\t\t  turn = 1 - turn\n\t\t}\n\t\tprint(1 - turn)\n\t}\n\t\n\tdef gcd (x: Int, y: Int) : Int = {\n\t  if (x > y) {\n\t    gcd(x - y, y)\n\t  }\n\t  else {\n\t    if (x == y) {\n\t      x\n\t    }\n\t    else {\n\t      gcd (x, y - x)\n\t    }\n\t  }\n\t      \n\t}\n}"}, {"source_code": "object Codeforces119A extends App{\n\n  def GCDFind(first:Int,second:Int):Int={\n    var a:Int=first\n    var b:Int=second\n    var temp:Int=0\n    if (b>a){\n      temp=a\n      a=b\n      b=temp\n    }\n    temp=b\n    while((a%temp!=0)||(b%temp!=0)){\n      temp=a-(a/b)*b\n      a=b\n      b=temp\n    }\n    return temp\n  }\n\n  def EpicGame(simon:Int,antisimon:Int,totalstone:Int):Int={\n    var currentstone:Int=totalstone\n    var temp:Int=0\n    while(currentstone!=0){\n      temp=GCDFind(simon,currentstone)\n      currentstone = currentstone-temp\n      if (currentstone==0){\n        return 0\n      }\n      temp=GCDFind(antisimon,currentstone)\n      currentstone = currentstone-temp\n      if (currentstone==0){\n        return 1\n      }\n    }\n    return 1\n  }\n  val oldgroup=scala.io.StdIn.readLine.split(\" \")\n  var ingroup=oldgroup.map(_.toInt)\n  println(EpicGame(ingroup(0),ingroup(1),ingroup(2)))\n\n}\n"}, {"source_code": "import java.io._\nimport scala.annotation.tailrec\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInt = reader.readLine().toInt\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n\n  @tailrec\n  def gcd(a: Int, b: Int): Int = if(b == 0) a else gcd(b, a % b)\n\n  @tailrec\n  def ans(a: Array[Int], i: Int, n: Int): Int = if(n == 0) 1 - i else ans(a, (i + 1) % 2, n - gcd(n, a(i)))\n\n  def main(a: Array[String]) {\n    val a = readInts\n    println(ans(a, 0, a(2)))\n  }\n}\n"}, {"source_code": "object Main {\n  def gcd(a: Int, b: Int): Int = \n    if (a % b == 0) b\n    else gcd(b, a % b)\n\n  def main(args: Array[String]) {\n    val arr = readLine().split(\" \").map(_.toInt)\n    val a = arr(0)\n    val b = arr(1)\n    var n = arr(2)\n    var turn = 1\n    while (n != 0) { \n      if (turn == 1) {\n        n -= gcd(n, a)\n        turn = 0\n      } else {\n        n -= gcd(n, b)\n        turn = 1\n      }\n    }\n    println(turn)\n  }\n}"}, {"source_code": "import java.util.Scanner\n\nobject CF119A {\n  def gcd(a:Int,b:Int):Int = b match{\n    case 0=> a\n    case b=> gcd(b,a%b)\n  }\n  \n  def main(args: Array[String]){\n    val sc:Scanner = new Scanner(System.in)\n    val a = sc.nextInt; val b = sc.nextInt; var s = sc.nextInt\n    var turn = 0\n    while(gcd(if (turn==0) a else b,s) <= s){\n      s -= gcd(if (turn==0) a else b,s)\n      turn = (turn+1)%2\n    }\n    turn = (turn+1)%2\n    println(turn);\n  }\n}"}, {"source_code": "import scala.io.StdIn.readLine\n\n/**\n * @author slie742\n */\nobject EpicGame {\n  \n  def gcd(a: Int,b:Int) : Int = {\n    b match {\n      case 0 => a\n      case _ => gcd(b,a%b)\n    }\n  }\n  \n  def solve(a: Int, b: Int, n:Int) : Int = {\n    def go(rem: Int, turn: Int) : Int = turn match {\n        case 0 => if (rem < gcd(a,rem)) 1\n                  else go(rem - gcd(a,rem),1)\n        case _ => if (rem < gcd(b,rem)) 0\n                  else go(rem - gcd(b,rem),0)                 \n      }                  \n    go(n,0)\n  }\n  \n  def main(args: Array[String]) {\n    val line = readLine.split(' ').map(_.toInt)\n    println(solve(line(0),line(1),line(2)))\n  }\n  \n}"}], "negative_code": [{"source_code": "import scala.collection.mutable._\nimport scala.math._\nimport scala.util.control.Breaks.break\nimport scala.util.control.Breaks.breakable\nimport java.util._\nobject Main extends App {\n  val sc = new Scanner(System.in)\n  def gcd(a: Int, b: Int): Int = if(b == 0) a else gcd(b, a%b)\n  var t = Array[Int](sc.nextInt,sc.nextInt)\n  var n = sc.nextInt\n  def sim(s: Int): Int = {\n    val g = gcd(n,t(s))\n    if(n > g) return (s+1)%2\n    else { n-=g; sim((s+1)%2) }\n  }\n  println(sim(0))\n}\n"}], "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2"}
{"source_code": "object A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  val as = readInts(3)\n  val bs = readInts(3)\n \n  val have = (0 to 2).map(i => ((as(i) - bs(i)) / 2) max 0).sum\n  val need = (0 to 2).map(i => (bs(i) - as(i)) max 0).sum\n\n  println(if (have >= need) \"Yes\" else \"No\")\n}", "positive_code": [{"source_code": "object A{\n  //import scala.collection.mutable.PriorityQueue\n  //import scala.collection.mutable.ArrayBuffer\n  import util.control.Breaks._\n  import java.io.{PrintWriter,InputStream,BufferedReader,InputStreamReader}\n  import java.util.{Locale, Scanner,StringTokenizer}\n  class InputReader(val stream:InputStream ) {\n    var st:StringTokenizer=new StringTokenizer(\"\")\n    val reader=new BufferedReader(new InputStreamReader(stream), 32768);\n\n    def next():String = {\n        while (!st.hasMoreTokens()){\n          val currentLine = reader.readLine\n          st=new StringTokenizer(currentLine)\n        }\n        return st.nextToken\n    }\n\n    def nextInt():Int = {\n        return next.toInt\n    }\n\n    def nextLong():Long = {\n    \treturn next.toLong\n    }\n    def nextDouble:Double = {\n      return next.toDouble\n    }\n  }\n\n  def main(args: Array[String]){\n\n\n    val in = new InputReader(System.in)\n    val out = new PrintWriter(System.out)\n\n    def nextInt = in.nextInt\n    def nextLong = in.nextLong\n    def nextDouble = in.nextDouble\n    def nextString = in.next\n    //code starts here\n    val has=for(i<-0 until 3) yield nextInt\n    val want=for(i<-0 until 3) yield nextInt\n    var sum=0\n    for(i<-0 until 3){\n      if(has(i)>want(i)){\n        sum+=(has(i)-want(i))/2\n      }else{\n        sum+=has(i)-want(i)\n      }\n\n    }\n    if(sum>=0){\n      out.print(\"Yes\")\n    }else{\n      out.print(\"No\")\n    }\n\n    //code ends here\n    out.flush\n    out.close\n  }\n}\n\n"}, {"source_code": "import io.StdIn._\n\nobject Main{\n  def main (args: Array[String]){\n    val yes = \"Yes\"\n    val no = \"No\"\n\n    val Array(a, b, c) = readLine.split(' ').map(_.toInt)\n    val Array(x, y, z) = readLine.split(' ').map(_.toInt)\n\n    var dif = new Array[Int](3)\n    dif(0) = a - x\n    dif(1) = b - y\n    dif(2) = c - z\n\n    var over = 0\n    var husoku = 0\n    for(i <- 0 to 2){\n      if (dif(i) >= 0) over += dif(i) / 2\n      else husoku += Math.abs(dif(i))\n    }\n\n    if(over >= husoku) println(yes)\n    else println(no)\n  }\n}\n"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val r = in.next().split(' ').map(_.toInt).zip(in.next().split(' ').map(_.toInt)).foldLeft(0, 0) {\n    case((minus, plus), (have, need)) if need <= have => (minus, plus + (have - need) / 2)\n    case((minus, plus), (have, need)) => (minus + need - have, plus)\n  }\n  if (r._1 > r._2)\n    println(\"No\")\n  else\n    println(\"Yes\")\n}\n"}, {"source_code": "object A606 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def main(args: Array[String]): Unit = {\n    val Array(a,b,c) = readInts(3)\n    val Array(x,y,z) = readInts(3)\n    if(solve(a,b,c,x,y,z)) {\n      println(\"Yes\")\n    } else {\n      println(\"No\")\n    }\n  }\n\n  def solve(a: Int, b: Int, c: Int, x: Int, y: Int, z: Int): Boolean = {\n    if(x == 0 && y == 0 && z == 0)\n      true\n    else {\n      if (a >= x) {\n        solve(b, c, a - x, y, z, 0)\n      } else {\n        val short = x-a\n        if((c-z)/2 > 0) {\n          val extra = math.min(short, (c-z)/2)\n          solve(a+extra, b, c - extra*2, x, y, z)\n        } else if((b-y)/2 > 0) {\n          val extra = math.min(short, (b-y)/2)\n          solve(a+extra, b - extra*2, c, x, y, z)\n        } else {\n          false\n        }\n      }\n    }\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}], "negative_code": [{"source_code": "object A606 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def main(args: Array[String]): Unit = {\n    val Array(a,b,c) = readInts(3)\n    val Array(x,y,z) = readInts(3)\n    if(solve(a,b,c,x,y,z)) {\n      println(\"Yes\")\n    } else {\n      println(\"No\")\n    }\n  }\n\n  def solve(a: Int, b: Int, c: Int, x: Int, y: Int, z: Int): Boolean = {\n    if(x == 0 && y == 0 && z == 0)\n      true\n    else {\n      if (a >= x) {\n        solve(b, c, a - x, y, z, 0)\n      } else {\n        val short = x-a\n        if((b-y)/2 > 0) {\n          val extra = (b-y)/2\n          solve(a+extra, b - extra*2, c, x, y, z)\n        } else if((c-z)/2 > 0) {\n          val extra = (c-z)/2\n          solve(a+extra, b, c - extra*2, x, y, z)\n        } else {\n          false\n        }\n      }\n    }\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "import scala.collection._\n\nobject A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  \n  case class X(a: Int, b: Int, c: Int)\n\n  val Array(a, b, c) = readInts(3)\n  val start = X(a, b, c)\n\n  val Array(x, y, z) = readInts(3)\n  val goal = X(x, y, z)\n\n  val end = System.currentTimeMillis() + 1500\n  val visited = mutable.Set.empty[X]\n\n  def check(q: X): Unit = {\n    //println(q)\n    if (!visited(q) && System.currentTimeMillis < end) {\n      visited += q\n      if (q == goal) {\n        println(\"Yes\")\n        System.exit(0)\n      } else {\n        if (q.a > goal.a) {\n          check(X(q.a - 2, q.b + 1, q.c))\n          check(X(q.a - 2, q.b, q.c + 1))\n        }\n        if (q.b > goal.b) {\n          check(X(q.a + 1, q.b - 2, q.c))\n          check(X(q.a, q.b - 2, q.c + 1))\n        }\n        if (q.c > goal.c) {\n          check(X(q.a + 1, q.b, q.c - 2))\n          check(X(q.a, q.b + 1, q.c - 2))\n        }\n      }\n    }\n  }\n\n  check(start)\n  \n  println(\"No\")\n}\n"}, {"source_code": "import scala.collection._\n\nobject A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  \n  case class X(a: Int, b: Int, c: Int)\n\n  val Array(a, b, c) = readInts(3)\n  val start = X(a, b, c)\n\n  val Array(x, y, z) = readInts(3)\n  val goal = X(x, y, z)\n\n  val end = System.currentTimeMillis() + 1500\n  val visited = mutable.Set.empty[X]\n\n  def check(q: X): Unit = {\n    //println(q)\n    if (!visited(q) && System.currentTimeMillis < end) {\n      visited += q\n      if (q.a >= goal.a && q.b >= goal.b && q.c >= goal.c) {\n        println(\"Yes\")\n        System.exit(0)\n      } else {\n        if (q.a > goal.a + 2000) {\n          check(X(q.a - 1000, q.b + 500, q.c))\n          check(X(q.a - 1000, q.b, q.c + 500))\n        }\n        if (q.b > goal.b + 2000) {\n          check(X(q.a + 500, q.b - 1000, q.c))\n          check(X(q.a, q.b - 1000, q.c + 500))\n        }\n        if (q.c > goal.c + 2000) {\n          check(X(q.a + 500, q.b, q.c - 1000))\n          check(X(q.a, q.b + 500, q.c - 1000))\n        }\n        if (q.a > goal.a) {\n          check(X(q.a - 2, q.b + 1, q.c))\n          check(X(q.a - 2, q.b, q.c + 1))\n        }\n        if (q.b > goal.b) {\n          check(X(q.a + 1, q.b - 2, q.c))\n          check(X(q.a, q.b - 2, q.c + 1))\n        }\n        if (q.c > goal.c) {\n          check(X(q.a + 1, q.b, q.c - 2))\n          check(X(q.a, q.b + 1, q.c - 2))\n        }\n      }\n    }\n  }\n\n  check(start)\n  \n  println(\"No\")\n}\n"}, {"source_code": "import scala.collection._\n\nobject A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  \n  case class X(a: Int, b: Int, c: Int)\n\n  val Array(a, b, c) = readInts(3)\n  val start = X(a, b, c)\n\n  val Array(x, y, z) = readInts(3)\n  val goal = X(x, y, z)\n\n  val end = System.currentTimeMillis() + 1500\n  val visited = mutable.Set.empty[X]\n\n  def check(q: X): Unit = {\n    //println(q)\n    if (!visited(q) && System.currentTimeMillis < end) {\n      visited += q\n      if (q.a >= goal.a && q.b >= goal.b && q.c >= goal.c) {\n        println(\"Yes\")\n        System.exit(0)\n      } else {\n        if (q.a > goal.a + 4000) {\n          check(X(q.a - 1000, q.b + 500, q.c))\n          check(X(q.a - 1000, q.b, q.c + 500))\n        }\n        if (q.b > goal.b + 4000) {\n          check(X(q.a + 500, q.b - 1000, q.c))\n          check(X(q.a, q.b - 1000, q.c + 500))\n        }\n        if (q.c > goal.c + 4000) {\n          check(X(q.a + 500, q.b, q.c - 1000))\n          check(X(q.a, q.b + 500, q.c - 1000))\n        }\n        if (q.a > goal.a) {\n          check(X(q.a - 2, q.b + 1, q.c))\n          check(X(q.a - 2, q.b, q.c + 1))\n        }\n        if (q.b > goal.b) {\n          check(X(q.a + 1, q.b - 2, q.c))\n          check(X(q.a, q.b - 2, q.c + 1))\n        }\n        if (q.c > goal.c) {\n          check(X(q.a + 1, q.b, q.c - 2))\n          check(X(q.a, q.b + 1, q.c - 2))\n        }\n      }\n    }\n  }\n\n  check(start)\n  \n  println(\"No\")\n}\n"}], "src_uid": "1db4ba9dc1000e26532bb73336cf12c3"}
{"source_code": "object E extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n\n  val Array(n, k) = readInts(2)\n  val MOD = 998244353L\n  val MODB = BigInt(MOD)\n  val TWO = BigInt(2)\n\n  val counts = Array.fill(n + 1)(0L)\n  var prev = 0L\n  for (kh <- 1 to (k min n)) {\n    val dp = Array.fill(n + 1, 2)(0L)\n    for (i <- 1 to n) {\n      if (i <= kh) {\n        val pp = TWO.modPow((i min kh) - 1, MODB).toLong\n        dp(i)(0) = pp\n        dp(i)(1) = pp\n      } else {\n        var p = 1L\n        for (j <- 1 to (i min kh)) {\n          dp(i)(0) = (dp(i)(0) + dp(i - j)(1)) % MOD\n          dp(i)(1) = (dp(i)(1) + dp(i - j)(0)) % MOD\n          p = 2 * p % MOD\n        }\n      }\n    }\n    val total = (dp(n)(0) + dp(n)(1)) % MOD\n    counts(kh) = (total - prev + MOD) % MOD\n    prev = total\n  }\n\n  var res = 0L\n  for (kh <- 1 to n) {\n    for (kv <- 1 to n) {\n      if (kh * kv < k) res = (res + counts(kh) * counts(kv)) % MOD\n    }\n  }\n\n  println(res * TWO.modInverse(MODB) % MOD)\n}\n", "positive_code": [{"source_code": "object Main {\n  import java.io._\n  import java.util.StringTokenizer\n\n  import scala.collection.mutable\n  import scala.util.Sorting\n  import math.{abs, max, min}\n  import mutable.{ArrayBuffer, ListBuffer}\n  import scala.reflect.ClassTag\n\n  val MOD = 998244353\n  val out = new PrintWriter(System.out)\n\n  def solve(): Unit = {\n    val sc = new InputReader(System.in)\n    val N, K = sc.nextInt()\n    val s = System.nanoTime()\n    var dp, ndp = Array.ofDim[Int](N + 2, N + 2)\n    dp(0)(0) = 1\n    rep(N) { i =>\n      import java.util\n      rep(ndp.length)(i => util.Arrays.fill(ndp(i), 0))\n      rep(i + 1) { j =>\n        rep(i + 1) { k =>\n          ndp(j + 1)(max(k, j + 1)) = (ndp(j + 1)(max(k, j + 1)) + dp(j)(k)) % MOD\n          ndp(1)(max(k, 1)) = (ndp(1)(max(k, 1)) + dp(j)(k)) % MOD\n        }\n      }\n      val tmp = dp\n      dp = ndp\n      ndp = tmp\n    }\n\n    val cnt = Array.ofDim[Long](N + 1)\n    rep(N + 1) { j =>\n      rep(N + 1) { k =>\n        cnt(k) = (cnt(k) + dp(j)(k)) % MOD\n      }\n    }\n    val cum = Array.ofDim[Long](N + 1)\n    cum(0) = cnt(0)\n    rep(N){ k =>\n      cum(k + 1) = (cum(k + 1) + cum(k) + cnt(k + 1)) % MOD\n    }\n\n    var ans = 0L\n    rep(N, 1) { i =>\n      val j = min(N, (K - 1) / i)\n      ans = (ans + cnt(i) * cum(j)) % MOD\n    }\n\n    ans = ans * (MOD + 1) / 2 % MOD\n\n    out.println(ans)\n\n    val e = System.nanoTime()\n    System.err.println(s\"${(e-s)/1000000}\")\n  }\n\n  def main(args: Array[String]): Unit = {\n    solve()\n    out.flush()\n  }\n\n\n  class InputReader(val stream: InputStream) {\n    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n    private var tokenizer: StringTokenizer = _\n\n    def next(): String = {\n      while (tokenizer == null || !tokenizer.hasMoreTokens)\n        tokenizer = new StringTokenizer(reader.readLine)\n      tokenizer.nextToken\n    }\n\n    def nextInt(): Int = next().toInt\n    def nextLong(): Long = next().toLong\n    def nextChar(): Char = next().charAt(0)\n  }\n  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = offset\n    val N = n + offset\n    while(i < N) { f(i); i += 1 }\n  }\n  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = n - 1 + offset\n    while(i >= offset) { f(i); i -= 1 }\n  }\n\n  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n    val res = Array.ofDim[A](n)\n    rep(n)(i => res(i) = f(i))\n    res\n  }\n\n  implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n    // todo Orderingだとboxing発生するので自作Orderを用意したい\n    def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n      if (as.nonEmpty) Some(as.maxBy(f)) else None\n    }\n\n    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n      val map = mutable.Map.empty[K, ArrayBuffer[A]]\n      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))\n      map\n    }\n\n    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n      var sum = num.zero\n      rep(as.length)(i => sum = num.plus(sum, f(as(i))))\n      sum\n    }\n\n    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n      limit(f, ixRange)(cmp.lt)\n    }\n\n    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n      limit(f, ixRange)(cmp.gt)\n    }\n\n    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {\n      var limA = as(ixRange.head)\n      var limB = f(limA)\n\n      for (i <- ixRange.tail) {\n        val a = as(i)\n        val b = f(a)\n        if (cmp(b, limB)) {\n          limA = a\n          limB = b\n        }\n      }\n      (limA, limB)\n    }\n  }\n\n  implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n    }\n  }\n}"}], "negative_code": [{"source_code": "object E extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(n, k) = readInts(2)\n  val MOD = 998244353L\n  val MODB = BigInt(MOD)\n  val TWO = BigInt(2)\n\n  val counts = Array.fill(n + 1)(0L)\n  for (kh <- 1 to (k min n)) {\n    val dp = Array.fill(n + 1, 2)(0L)\n    for (i <- 1 to n) {\n      if (i <= kh) {\n        val pp = TWO.modPow((i min kh) - 1, MODB).toLong\n        dp(i)(0) = pp\n        dp(i)(1) = pp\n      } else {\n        var p = 1L\n        for (j <- 1 to (i min kh)) {\n          dp(i)(0) = (dp(i)(0) + dp(i - j)(1)) % MOD\n          dp(i)(1) = (dp(i)(1) + dp(i - j)(0)) % MOD\n          p = 2 * p % MOD\n        }\n      }\n//      val p = TWO.modPow((i min kh) - 1, MODB).toLong\n//      if (i <= kh) {\n//        dp(i)(0) = p\n//        dp(i)(1) = p\n//      } else {\n//        dp(i)(0) = p * dp(i - kh)(1) % MOD\n//        dp(i)(1) = p * dp(i - kh)(0) % MOD\n//      }\n    }\n    //println(kh, dp.map(_.sum).mkString(\" \"))\n    counts(kh) = (dp(n)(0) + dp(n)(1) + MOD - counts(kh - 1)) % MOD\n  }\n//println(counts.mkString(\" \"))\n  var res = 0L\n  for (kh <- 1 to n) {\n    for (kv <- 1 to n) {\n      //println(res, counts(kh), counts(kv))\n      if (kh * kv < k) res = (res + counts(kh) * counts(kv)) % MOD\n    }\n  }\n\n  println(res * TWO.modInverse(MODB) % MOD)\n}\n"}], "src_uid": "77177b1a2faf0ba4ca1f4d77632b635b"}
{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val Array(az, kz) = in.next().split(' ')\n  val k = kz.toInt\n  val a = az.toCharArray\n\n  def solve(data: Array[Char], index: Int, k: Int, ch: Char): Array[Char] =\n    if (k == 0 || index == data.length - 1)\n      a\n    else if (ch <= data(index))\n      solve(data, index + 1, k, '9')\n    else {\n      ((index + 1) to Math.min(data.length - 1, index + k)).find(i => data(i) == ch) match {\n        case None => solve(data, index, k, (ch - 1).toChar)\n        case Some(i) =>\n          val tmp = data(i)\n          (i until index by - 1).foreach {\n            j => data(j) = data(j - 1)\n          }\n          data(index) = tmp\n          solve(data, index + 1, k + index - i, '9')\n      }\n    }\n\n  def sol(data: Array[Char], k: Int) = {\n    solve(data, 0, k, '9')\n  }\n\n  println(sol(a, k).mkString)\n\n}", "positive_code": [{"source_code": "import scala.collection.JavaConversions._\nimport scala.collection.mutable.ArraySeq\n\nobject Codeforces435B {\n    def main(args: Array[String]) {\n        var Array(num, swaps) = scala.io.StdIn.readLine().split(\" \").map(_.toLong)\n        val numSeq = ArraySeq(num.toString.toList: _*)\n        var i = 0\n        while (i < numSeq.length-1 && swaps > 0) {\n            var temp = 1\n            var maxIndex = 0\n            while (temp <= swaps && (i+temp) <= (numSeq.length-1)) {\n                if (Integer.parseInt(numSeq(i+maxIndex).toString) < Integer.parseInt(numSeq(i+temp).toString))\n                    maxIndex = temp\n                temp += 1\n            }\n            swaps -= maxIndex\n            while (maxIndex > 0) {\n                val t = numSeq(i+maxIndex)\n                numSeq(i+maxIndex) = numSeq(i+maxIndex-1)\n                numSeq(i+maxIndex-1) = t\n                maxIndex -= 1\n            }\n            i += 1\n        }\n        println(numSeq.mkString(\"\"))\n    }\n}"}, {"source_code": "/**\n * Created by ashione on 14-6-19.\n */\nimport java.util.Scanner\nobject swapNum {\n  def main(Arg:Array[String]): Unit= {\n    val s = new Scanner(System.in)\n    val sl:String = s.next\n    val dist = s.nextInt\n    val (ans,_,_)=findNum(sl.toList,1,dist)\n    ans foreach print\n  }\n  def findNum(sl:List[Char],start:Int,dist:Int):(List[Char],Int,Int) = {\n    if(dist<=0 || start>=sl.length) return (sl,0,0)\n    var localtion = start-1\n    for(i <- start to start + dist-1 if i<sl.length)\n      if(sl(i)>sl(localtion)) localtion = i\n    if(localtion!=start-1) {\n      val (sl1, sl2) = sl.splitAt(localtion)\n      val (d, e) = sl2.splitAt(1)\n      val (a, sl1t) = sl1.splitAt(start - 1)\n      val (b, c) = sl1t.splitAt(1)\n      findNum(a ::: d ::: b ::: c ::: e, start + 1, dist-(localtion - start+1))\n    }\n    else findNum(sl,start+1,dist)\n\n  }\n\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject Main {\n  def main(args: Array[String]) {\n    val in = new Scanner(System.in)\n    val s = in.next\n    var k = in.nextInt\n\n    val arr = s.toCharArray()\n\n    for (i <- 0 to arr.length - 2) {\n      var maxPos = -1\n      for (j <- i to Math.min(i + k, arr.length - 1))\n        if (maxPos == -1 || arr(j) > arr(maxPos))\n          maxPos = j\n      if (maxPos != 0) {\n        while (maxPos > i) {\n          var t = arr(maxPos)\n          arr(maxPos) = arr(maxPos - 1)\n          arr(maxPos - 1) = t\n          k = k - 1\n          maxPos = maxPos - 1\n        }\n      }\n    }\n\n    println(arr.mkString)\n  }\n}"}], "negative_code": [{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val Array(as, ks) = in.next().split(' ')\n  val k = ks.toInt\n  val a = as.toCharArray\n  val r = (1 to k).foreach { _ =>\n    val i = (1 until a.length).find(i => a(i) > a(i - 1))\n    if (i.nonEmpty) {\n      val tmp = a(i.get)\n      a(i.get) = a(i.get - 1)\n      a(i.get - 1) = tmp\n    }\n\n  }\n  println(a.mkString)\n}\n"}, {"source_code": "/**\n * Created by ashione on 14-6-19.\n */\nimport java.util.Scanner\nobject swapNum {\n  def main(Arg:Array[String]): Unit= {\n    val s = new Scanner(System.in)\n    val sl:String = s.next\n    val dist = s.nextInt\n    val (ans,_,_)=findNum(sl.toList,1,dist)\n    ans foreach print\n  }\n  def findNum(sl:List[Char],start:Int,dist:Int):(List[Char],Int,Int) = {\n    if(dist<=0 || start>=sl.length) return (sl,0,0)\n    var localtion = start-1\n    for(i <- start to start + dist-1 if i<sl.length)\n      if(sl(i)>sl(localtion)) localtion = i\n    if(localtion!=start-1) {\n      val (sl1, sl2) = sl.splitAt(localtion)\n      val (d, e) = sl2.splitAt(1)\n      val (a, sl1t) = sl1.splitAt(start - 1)\n      val (b, c) = sl1t.splitAt(1)\n      findNum(a ::: d ::: c ::: b ::: e, start + 1, localtion - start)\n    }\n    else findNum(sl,start+1,dist)\n\n  }\n\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject Main {\n  def main(args: Array[String]) {\n    val in = new Scanner(System.in)\n    val s = in.next\n    var k = in.nextInt\n\n    val arr = s.toCharArray()\n\n    while (k > 0) {\n      k = k - 1\n      def loop(i: Int): Unit =\n        if (i < arr.length - 1) {\n          if (arr(i) < arr(i + 1)) {\n            val t = arr(i)\n            arr(i) = arr(i + 1)\n            arr(i + 1) = t\n          } else loop(i + 1)\n        }\n      loop(0)\n    }\n\n    println(arr.mkString)\n  }\n}"}, {"source_code": "import java.util.Scanner\n\nobject Main {\n  def main(args: Array[String]) {\n    val in = new Scanner(System.in)\n    val s = in.next\n    var k = in.nextInt\n\n    val arr = s.toCharArray()\n\n    for (i <- 0 to arr.length - 2) {\n      var maxPos = 0\n      for (j <- i to Math.min(i + k, arr.length - 1))\n        if (arr(j) > arr(maxPos) || maxPos == 0)\n          maxPos = j\n      if (maxPos != 0) {\n        while (maxPos > i) {\n          var t = arr(maxPos)\n          arr(maxPos) = arr(maxPos - 1)\n          arr(maxPos - 1) = t\n          k = k - 1\n          maxPos = maxPos - 1\n        }\n      }\n    }\n\n    println(arr.mkString)\n  }\n}"}], "src_uid": "e56f6c343167745821f0b18dcf0d0cde"}
{"source_code": "object TwoButtons {\n  case class Pair(e:Int,stp:Int)\n  def main(args: Array[String]): Unit = {\n    val in =scala.io.StdIn\n    var line=in.readLine()\n    var n=line.split(\" \")(0).toInt\n    var m=line.split(\" \")(1).toInt\n    //val n=4 ; val m=6\n    //val n=10 ; val m=1\n    //Applying BSF and in level order search the first occurrence of m is the minimum step\n    var click=0\n\twhile (m!=n){\n\t  click+=1\n\t  if(m>n) {\n\t\tif (m % 2 == 0) {\n\t\t  m /= 2\n\t\t} else {\n\t\t  m = (m + 1) / 2\n\t\t  click+=1\n\t\t}\n\t  }else{\n\t\tm+=1\n\t  }\n\t}\n\tprintln(click)\n  }\n}", "positive_code": [{"source_code": "import java.io._\nimport java.util.StringTokenizer\n\nobject TwoButtons {\n  def main(args: Array[String]): Unit = {\n    val in = new InputReader(System.in)\n    val out = new PrintWriter(new BufferedOutputStream(System.out))\n    val solver = new Task()\n    solver.solve(in, out)\n    out.close()\n  }\n\n  class Task {\n    private val INF = 1e6.asInstanceOf[Int]\n\n    def solve(in: InputReader, out: PrintWriter): Unit = {\n      val n = in.nextInt()\n      val m = in.nextInt()\n      val ans = dfs(n, m, Array.ofDim[Int](math.max(n, m) + 1))\n      out.println(ans)\n    }\n\n    private def dfs(n: Int, m: Int, memo: Array[Int]): Int = {\n      if (n >= m) n - m\n      else if (n <= 0) INF\n      else if (memo(n) > 0) memo(n)\n      else {\n        memo(n) = INF\n        memo(n) = math.min(dfs(n * 2, m, memo), dfs(n - 1, m, memo)) + 1\n        memo(n)\n      }\n    }\n  }\n\n  class InputReader(val stream: InputStream) {\n    private val reader = new BufferedReader(new InputStreamReader(stream))\n    private var tokenizer: StringTokenizer = _\n\n    def next(): String = {\n      while (tokenizer == null || !tokenizer.hasMoreTokens) {\n        try {\n          tokenizer = new StringTokenizer(reader.readLine())\n        } catch {\n          case _: IOException => throw new RuntimeException\n        }\n      }\n      tokenizer.nextToken()\n    }\n\n    def nextInt(): Int = {\n      Integer.parseInt(next())\n    }\n  }\n\n}\n"}, {"source_code": "import java.io._\nimport java.util.StringTokenizer\n\nobject TwoButtons {\n  def main(args: Array[String]): Unit = {\n    val inputStream = System.in\n    val outputStream = System.out\n    val in = new InputReader(inputStream)\n    val out = new PrintWriter(outputStream)\n    val solver = new Task()\n    solver.solve(in, out)\n    out.close()\n  }\n\n  class Task {\n    private val INF = 1e6.asInstanceOf[Int]\n\n    def solve(in: InputReader, out: PrintWriter): Unit = {\n      val n = in.nextInt()\n      val m = in.nextInt()\n      val ans = dfs(n, m, Array.ofDim[Int](math.max(n, m) + 1))\n      out.println(ans)\n    }\n\n    private def dfs(n: Int, m: Int, memo: Array[Int]): Int = {\n      if (n >= m) n - m\n      else if (n <= 0) INF\n      else if (memo(n) > 0) memo(n)\n      else {\n        memo(n) = INF\n        memo(n) = math.min(dfs(n * 2, m, memo), dfs(n - 1, m, memo)) + 1\n        memo(n)\n      }\n    }\n  }\n\n  class InputReader(val stream: InputStream) {\n    private val reader = new BufferedReader(new InputStreamReader(stream))\n    private var tokenizer: StringTokenizer = _\n\n    def next(): String = {\n      while (tokenizer == null || !tokenizer.hasMoreTokens) {\n        try {\n          tokenizer = new StringTokenizer(reader.readLine())\n        } catch {\n          case _: IOException => throw new RuntimeException\n        }\n      }\n      tokenizer.nextToken()\n    }\n\n    def nextInt(): Int = {\n      Integer.parseInt(next())\n    }\n  }\n\n}\n"}, {"source_code": "import scala.collection.mutable\n\nobject B520 {\n  @inline def read = scala.io.StdIn.readLine\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  val MAX = 2*10000\n  val graph = Array.fill(MAX+1)(List.empty[Int])\n  graph(1) = List(2)\n  for(i <- 2 to MAX) {\n    graph(i) = List(2*i, i-1)\n  }\n  def bfs(src: Int, des: Int): Int = {\n    val vis = Array.fill(MAX+1)(false)\n    val q = mutable.Queue.empty[(Int, Int)]\n    q.enqueue((0, src))\n    vis(src) = true\n    while(q.nonEmpty) {\n      val (dist, ele) = q.dequeue()\n      if(des == ele) {\n        return dist\n      }\n      if(ele <= MAX) {\n        for (i <- graph(ele) if i <= MAX && !vis(i)) {\n          q.enqueue((dist + 1, i))\n          vis(i) = true\n        }\n      }\n    }\n    -1\n  }\n  def main(args: Array[String]): Unit = {\n    var Array(n, m) = readInts(2)\n    println(bfs(n, m))\n  }\n\n}"}, {"source_code": "\n/**\n * Created by yangchaozhong on 3/16/15.\n */\nobject CF520B extends App {\n  import scala.collection.mutable.HashSet\n  import java.util.{Scanner}\n  import java.io.{PrintWriter}\n\n  val in = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  def nextInt = in.nextInt\n  def nextLong = in.nextLong\n  def nextDouble = in.nextDouble\n  def nextString = in.next\n  def nextLine = in.nextLine\n\n  def solve = {\n    val n = nextInt\n    val m = nextInt\n\n    if (n >= m) {\n      out.println(n - m)\n    } else {\n\n      def dfs(x: Int): Int = {\n        if (x == n) 0\n        else if (x < n) {\n          n - x\n        } else {\n          if (x % 2 == 0) {\n            dfs(x / 2) + 1\n          } else {\n            dfs(x + 1) + 1\n          }\n        }\n      }\n\n      out.println(dfs(m))\n    }\n  }\n\n  try {\n    solve\n  } catch {\n    case _: Exception => sys.exit(9999)\n  } finally {\n    out.flush\n    out.close\n  }\n}\n"}, {"source_code": "import java.io._\nimport java.util.StringTokenizer\n\nimport scala.collection.mutable\n\nobject B {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def f(n: Int, m: Int, dp: Array[Int]): Int = {\n    if (n >= m) {\n      return n - m\n    }\n    if (n <= 0) {\n      return 1e6.toInt\n    }\n    if (dp(n) > 0) {\n      return dp(n)\n    }\n    dp(n) = 1e6.toInt\n    dp(n) = Math.min(f(2 * n, m, dp), f(n - 1, m, dp)) + 1\n    return dp(n)\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val m = nextInt\n    val sz = Math.max(n, m)\n    val dp = new Array[Int](sz + 1)\n    out.println(f(n, m, dp))\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}"}, {"source_code": "import scala.collection.mutable\nimport scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn._\n\nobject Main2 extends App {\n  val Array(initialNumber, desiredNumber) = readLine().split(\" \").map(_.toInt)\n  val queue = mutable.Queue((initialNumber, 0))\n  var answers = ArrayBuffer.fill(20001)(-1)\n  while (queue.nonEmpty) {\n    val (value, actionCount) = queue.dequeue()\n    if (value - 1 > 0 && answers(value - 1) == -1) {\n      answers(value - 1) = actionCount + 1\n      queue.enqueue((value - 1, actionCount + 1))\n    }\n    if (value * 2 < 20001 && answers(value * 2) == -1) {\n      answers(value * 2) = actionCount + 1\n      queue.enqueue((value * 2, actionCount + 1))\n    }\n  }\n  println(answers(desiredNumber))\n}\n"}], "negative_code": [{"source_code": "object TwoButtons {\n  case class Pair(e:Int,stp:Int)\n  def main(args: Array[String]): Unit = {\n    val in =scala.io.StdIn\n    var line=in.readLine()\n    var n=line.split(\" \")(0).toInt\n    var m=line.split(\" \")(1).toInt\n    //val n=4 ; val m=6\n    //val n=10 ; val m=1\n    //Applying BSF and in level order search the first occurrence of m is the minimum step\n    var click=0\n\twhile (m!=n){\n\t  click+=1\n\t  if(m>n) {\n\t\tif (m % 2 == 0) {\n\t\t  m /= 2\n\t\t} else {\n\t\t  m = (m + 1) / 2\n\t\t}\n\t  }else{\n\t\tm+=1\n\t  }\n\t}\n\tprintln(click)\n  }\n}"}, {"source_code": "object B520 {\n  @inline def read = scala.io.StdIn.readLine\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    var Array(n, m) = readInts(2)\n    if(n > m) {\n      println(n-m)\n    } else {\n      if (m % 2 == 0) {\n        var res = 0\n        while(m % 2 == 0 && n < m) {\n          m /= 2\n          res += 1\n        }\n        println(res + (n-m))\n      } else {\n        var res = 0\n        while(n < m) {\n          n *= 2\n          res += 1\n        }\n        println(res + n-m)\n      }\n    }\n  }\n\n}"}, {"source_code": "/**\n * Created by yangchaozhong on 3/16/15.\n */\nobject CF520B extends App {\n  import java.util.{Scanner}\n  import java.io.{PrintWriter}\n\n  val in = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  def nextInt = in.nextInt\n  def nextLong = in.nextLong\n  def nextDouble = in.nextDouble\n  def nextString = in.next\n  def nextLine = in.nextLine\n\n  def solve = {\n    val n = nextInt\n    val m = nextInt\n\n    if (n >= m) {\n      out.println(n - m)\n    } else {\n      def dfs(x: Int): Int = {\n        if (x == m) 0\n        else if (x > m) {\n          x - m\n        } else {\n          if (x > m / 2 && x > 2)\n            Math.min(dfs(x * 2) + 1, dfs(x - 1) + 1)\n          else\n            dfs(x * 2) + 1\n        }\n      }\n\n      out.println(dfs(n))\n    }\n  }\n\n  try {\n    solve\n  } catch {\n    case _: Exception => sys.exit(9999)\n  } finally {\n    out.flush\n    out.close\n  }\n}\n"}, {"source_code": "import java.io._\nimport java.util\nimport java.util._\n\nobject B {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val m = nextInt\n    if (m < n) {\n      out.println(n - m)\n      return 1\n    }\n    if (m == n) {\n      out.println(0)\n      return 1\n    }\n    var y = m\n    var ans = 0\n    while (y % 2 == 0) {\n      y /= 2\n      ans += 1\n    }\n    val sz = Math.max(n, y)\n    val dp = new Array[Array[Int]](sz + 1)\n    for (i <- 0 until sz + 1) {\n      dp(i) = new Array[Int](sz + 1)\n    }\n\n    for (i <- 0 to sz) {\n      for (j <- i + 1 until sz) {\n        dp(i)(j) = j - i\n      }\n    }\n    for (i <- 1 to sz) {\n      for (j <- 1 to sz) {\n        if (i * 2 <= sz) {\n          dp(i)(j) = Math.min(dp(i - 1)(j), dp(i * 2)(j)) + 1\n        }\n        else {\n          dp(i)(j) = dp(i - 1)(j) + 1\n        }\n      }\n    }\n    out.println(dp(y - 1)(y - 1) + ans)\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n"}, {"source_code": "import java.io._\nimport java.util\nimport java.util._\n\nobject B {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val m = nextInt\n    if (m < n) {\n      out.println(n - m)\n      return 1\n    }\n    if (m == n) {\n      out.println(0)\n      return 1\n    }\n    var x = n\n    var y = m\n    var ans = 0\n    while (y > n && y % 2 == 0) {\n      y /= 2\n      ans += 1\n    }\n    while (x < y) {\n      x *= 2\n      ans += 1\n    }\n    if (y < x) {\n      out.println(ans + x - y)\n      return 1\n    }\n    if (y == x) {\n      out.println(ans)\n      return 1\n    }\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n"}, {"source_code": "import java.io._\nimport java.util\nimport java.util._\n\nobject B {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val m = nextInt\n    if (m < n) {\n      out.println(n - m)\n      return 1\n    }\n    if (m == n) {\n      out.println(0)\n      return 1\n    }\n    var x = n\n    var ans = 0\n    while (x < m) {\n      x *= 2\n      ans += 1\n    }\n    if (m % 2 == 0 && n > m / 2) {\n      out.println(Math.min(n - m / 2 + 1, ans + x - m))\n    } else {\n      out.println(ans + x - m)\n    }\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n"}], "src_uid": "861f8edd2813d6d3a5ff7193a804486f"}
{"source_code": "object _964A extends CodeForcesApp {\n  import annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._, Math._\n\n  override def apply(io: IO): io.type = {\n    val n = io.read[Long]\n    io.write(n/2 + 1)\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\n/***********************************[Scala I/O]*********************************************/\nimport java.io._, java.util.StringTokenizer\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  import IO._\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    tokenizers.headOption\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  def readAll[A: IO.Read]: (Int, Vector[A]) = {\n    val data = read[Vector[A]]\n    (data.length, data)\n  }\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any): this.type = {\n    printer.print(obj)\n    this\n  }\n  def writeLine(): this.type = {\n    printer.println()\n    this\n  }\n  def writeLine(obj: Any): this.type = {\n    printer.println(obj)\n    this\n  }\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n  def query[A: IO.Read](question: Any): A = writeLine(question).read\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  private[IO] type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]\n\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                       : Read[String]       = new Read(_.next())\n    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.head)\n    implicit val int                                          : Read[Int]          = string.map(_.toInt)\n    implicit val long                                         : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                       : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                      : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n", "positive_code": [{"source_code": "\n\nobject CF964A extends App {\n  import scala.io.Source\n\n  //val src = Source.fromFile(\"data.txt\")\n  val src = Source.stdin\n  val lines = src.getLines\n  \n  def readInts(): Array[Int] =  {\n    val line = if (lines.hasNext) lines.next else null\n    if (line == null) throw new RuntimeException(\"Premature end of source encountered\")\n    line.split(\" \").map(x => x.toInt)\n  }\n  val ints = readInts()\n  println(ints(0)/2 + 1)\n \n}"}], "negative_code": [], "src_uid": "5551742f6ab39fdac3930d866f439e3e"}
{"source_code": "import scala.collection.mutable\n\nobject A extends App {\n  def readLongs = scala.io.StdIn.readLine().split(\" \").map(_.toLong)\n\n  val Array(n) = readLongs\n\n  case class E(prev: Long, cur: Long, games : Int) {\n    def next = E(cur, prev+cur, games+1)\n  }\n\n  var e = E(1, 1, 0)\n  while (e.cur <= n) {\n    e = e.next\n   // println(e)\n  }\n\n  println(e.games-1)\n}\n", "positive_code": [{"source_code": "object A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(n) = readLongs(1)\n\n  var res = 1\n  val memo = Array.fill(100000){ -1L }\n\n  memo(1) = 2\n  memo(2) = 3\n\n  def minPlayers(moves: Int): Long = {\n    if (memo(moves) < 0) memo(moves) = minPlayers(moves - 1) + minPlayers(moves - 2)\n    memo(moves)\n  }\n\n  while (minPlayers(res) <= n) res += 1\n\n  println(res - 1)\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val n = in.next().toLong\n  var i = 0\n  var a = 1l\n  var b = 1l\n  while (b <= n) {\n    val tmp = a + b\n    a = b\n    b = tmp\n    i += 1\n  }\n  println(i - 1)\n}\n"}, {"source_code": "import java.io._\nimport scala.io.Source\n\nimport scala.annotation.tailrec\n\nobject ProblemCFib {\n  def main(args: Array[String]): Unit = processStdInOut()\n\n  def processStdInOut(): Unit = {\n    val src = Source.fromInputStream(System.in)\n    processFromSource(src)\n  }\n\n  def processFromSource(src: Source): Unit = {\n    try {\n      val bw = new BufferedWriter(new OutputStreamWriter(System.out));\n      try {\n        val lines = src.getLines()\n        processLines(lines, bw)\n      } finally {\n        bw.flush()\n      }\n    } finally {\n      src.close();\n    }\n  }\n\n  // Standard code above, custom code below\n  def processLines(lines: Iterator[String], bw: BufferedWriter): Unit = {\n    val n = lines.next().toLong\n    val soln = solve(n)\n    bw.write(soln.toString)\n    bw.newLine()\n  }\n\n  // Cache the Fibonacci lookup for good performance:\n  var minPlayersByChampionsWinsLookup = Map[Long, Long](\n    0L -> 1L,  // A single player is champion without playing a single match\n    1L -> 2L   // With 2 players the champion wins after a single match\n  )\n\n  // The following function is equivalent to fib(wins + 2) where fib is the Fibonacci sequence\n  def minPlayersForChampionWithWins(wins: Long): Long = {\n    if (minPlayersByChampionsWinsLookup.contains(wins)) {\n      minPlayersByChampionsWinsLookup(wins)\n    } else {\n      val result = minPlayersForChampionWithWins(wins - 1) + minPlayersForChampionWithWins(wins - 2)\n      minPlayersByChampionsWinsLookup += wins -> result\n      result\n    }\n  }\n\n  def solve(n: Long): Long = {\n    @tailrec\n    def search(candidateWins: Long): Long = {\n      val minTournamentSize = minPlayersForChampionWithWins(candidateWins)\n\n      if (minTournamentSize == n) candidateWins\n      else if (minTournamentSize > n) (candidateWins - 1)  // overshot the target, so use previous value\n      else search(candidateWins + 1)\n    }\n\n    search(0)\n  }\n}\n"}], "negative_code": [{"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val n = in.next().toLong\n  var i = 0\n  var a = 1l\n  var b = 1l\n  while (b < n) {\n    val tmp = a + b\n    a = b\n    b = tmp\n    i += 1\n  }\n  println(i - 1)\n}\n"}, {"source_code": "import java.io._\nimport scala.io.Source\n\nimport scala.annotation.tailrec\n\nobject ProblemC {\n  def main(args: Array[String]): Unit = processStdInOut()\n\n  def processStdInOut(): Unit = {\n    val src = Source.fromInputStream(System.in)\n    processFromSource(src)\n  }\n\n  def processFromSource(src: Source): Unit = {\n    try {\n      val bw = new BufferedWriter(new OutputStreamWriter(System.out));\n      try {\n        val lines = src.getLines()\n        processLines(lines, bw)\n      } finally {\n        bw.flush()\n      }\n    } finally {\n      src.close();\n    }\n  }\n\n  // Standard code above, custom code below\n  def processLines(lines: Iterator[String], bw: BufferedWriter): Unit = {\n    val n = lines.next().toLong\n    val log2 = math.log(2)\n    val rounds = math.ceil(math.log(n) / log2) + 0.1\n      // note: bump it slightly in case of round errors like a ?.999999 \"integer\"\n    bw.write(rounds.toLong.toString)\n    bw.newLine()\n  }\n}\n"}, {"source_code": "import java.io._\nimport scala.io.Source\n\nimport scala.annotation.tailrec\n\nobject ProblemC {\n  def main(args: Array[String]): Unit = processStdInOut()\n\n  def processStdInOut(): Unit = {\n    val src = Source.fromInputStream(System.in)\n    processFromSource(src)\n  }\n\n  def processFromSource(src: Source): Unit = {\n    try {\n      val bw = new BufferedWriter(new OutputStreamWriter(System.out));\n      try {\n        val lines = src.getLines()\n        processLines(lines, bw)\n      } finally {\n        bw.flush()\n      }\n    } finally {\n      src.close();\n    }\n  }\n\n  // Standard code above, custom code below\n  def processLines(lines: Iterator[String], bw: BufferedWriter): Unit = {\n    val n = lines.next().toLong\n    val soln = solve(n)\n    bw.write(soln.toString)\n    bw.newLine()\n  }\n\n  def solve(n: Long): Long = {\n    @tailrec\n    def loop(minGames: Long, counts: List[Long]): Long = counts match {\n      case 0 :: tl           => loop(minGames + 1, tl)\n      case 1 :: Nil          => minGames\n      case a :: Nil          => loop(minGames, List(a - 2, 1))\n      case 1 :: 1 :: Nil     => minGames + 2\n      case 1 :: 1 :: c :: tl => loop(minGames + 2, (c + 1) :: tl)\n      case 2 :: 1 :: tl      => loop(minGames + 1, 2 :: tl)  // Don't leave an \"orphaned\" player\n      case a :: 0 :: tl      => loop(minGames, (a - 2) :: 1l :: tl)\n      case a :: b :: Nil     => loop(minGames, List(a - 1, b - 1, 1))\n      case a :: b :: c :: tl => loop(minGames, (a - 1) :: (b - 1) :: (c + 1) :: tl)\n      case Nil => 0\n    }\n\n    val maxGamesPlayed = loop(0, List(n))\n    maxGamesPlayed\n  }\n}\n"}, {"source_code": "import java.io._\nimport scala.io.Source\n\nimport scala.annotation.tailrec\n\nobject ProblemC {\n  def main(args: Array[String]): Unit = processStdInOut()\n\n  def processStdInOut(): Unit = {\n    val src = Source.fromInputStream(System.in)\n    processFromSource(src)\n  }\n\n  def processFromSource(src: Source): Unit = {\n    try {\n      val bw = new BufferedWriter(new OutputStreamWriter(System.out));\n      try {\n        val lines = src.getLines()\n        processLines(lines, bw)\n      } finally {\n        bw.flush()\n      }\n    } finally {\n      src.close();\n    }\n  }\n\n  // Standard code above, custom code below\n  def processLines(lines: Iterator[String], bw: BufferedWriter): Unit = {\n    val n = lines.next().toDouble\n    val log2 = math.log(2)\n    val rounds = math.ceil(math.log(n) / log2).toLong\n    val adjRounds = if (math.pow(2, rounds) < n) rounds + 1\n      else if (math.pow(2, rounds - 1) >= n) rounds - 1\n      else rounds\n    bw.write(adjRounds.toString)\n    bw.newLine()\n  }\n}\n"}], "src_uid": "3d3432b4f7c6a3b901161fa24b415b14"}
{"source_code": "object Hitagi extends App {\n\n  def replaceZeros(seq: List[Int], replacement: List[Int]): List[Int] = seq match {\n    case Nil => List[Int]()\n    case 0 :: xs => replacement.head :: replaceZeros(xs, replacement.tail)\n    case x :: xs => x :: replaceZeros(xs, replacement)\n  }\n\n  val Array(n: Int, k: Int) = readLine.split(' ').map(_.toInt)\n  val a: List[Int] = readLine.split(' ').map(_.toInt).toList\n  val b: List[Int] = readLine.split(' ').map(_.toInt).toList\n\n  val initialSequence = replaceZeros(a, b.sortBy(x => -x))\n  val result: Boolean = initialSequence.zip(initialSequence.tail).map {\n    case (a, b) => b <= a\n  }.exists(x => x)\n\n  if (result) println(\"Yes\") else println(\"No\")\n\n}\n", "positive_code": [{"source_code": "import scala.io.Source\n\n/** A. An abandoned sentiment from past\n  * time limit per test1 second\n  * memory limit per test256 megabytes\n  *\n  * A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight.\n  * Ever since, she tried to avoid contact with others, for fear that this secret might be noticed.\n  *\n  * To get rid of the oddity and recover her weight, a special integer sequence is needed.\n  * Hitagi's sequence has been broken for a long time, but now Kaiki provides an opportunity.\n  *\n  * Hitagi's sequence a has a length of n. Lost elements in it are denoted by zeros. Kaiki provides another sequence b,\n  * whose length k equals the number of lost elements in a (i.e. the number of zeros).\n  *\n  * Hitagi is to replace each zero in a with an element from b so that each element in b should be used exactly once.\n  * Hitagi knows, however, that, apart from 0, no integer occurs in a and b more than once in total.\n  * If the resulting sequence is not an increasing sequence, then it has the power to recover Hitagi from the oddity.\n  * You are to determine whether this is possible, or Kaiki's sequence is just another fake. In other words,\n  * you should detect whether it is possible to replace each zero in a with an integer from b so that each integer\n  * from b is used exactly once, and the resulting sequence is not increasing.\n  */\nobject P814A {\n  /** get integer seqence `a`. the length of sequence is n\n    *\n    * @param args\n    */\n  def main(args: Array[String]): Unit = {\n    val lines = Source.stdin.getLines()\n\n    val Array(n, k) = lines.next().split(\" \")\n\n    /** n-length arr with k zero values */\n    val a = lines.next().split(\" \").map(_.toInt).toList\n\n    /** k-length arr */\n    val b = lines.next().split(\" \").map(_.toInt)\n\n    /** Input guarantees that apart from 0, no integer occurs in a and b more than once in total.\n      *\n      * Detect whether it is possible to replace each zero in a with an integer from b so that each integer\n      * from b is used exactly once, and the resulting sequence is not increasing */\n\n    def test(a: List[Int], b: Int): Boolean = {\n      a match {\n        case a0 :: a1 :: tail =>\n          if (a1 == 0) test(a0 :: b :: tail, b)\n          else {\n            if (a0 > a1) true\n            else test(a1 :: tail, b)\n          }\n        case _ => false\n      }\n    }\n\n    val result =\n      if (b.length > 1) true\n      else if (a.head == 0) test(b.head :: a.tail, b.head)\n      else test(a, b.head)\n\n    if (result) println(\"Yes\")\n    else println(\"No\")\n  }\n}\n\n"}, {"source_code": "\nimport java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextBoolean: Boolean = next.equalsIgnoreCase(\"1\")\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n\n    override def toString = s\"MultiHashSet($map)\"\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  /**\n    * Segment tree for any commutative function\n    *\n    * @param values      Array of Int\n    * @param commutative function like min, max, sum\n    * @param zero        zero value - e.g. 0 for sum, Inf for min, max\n    */\n  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {\n    private val SIZE = 1e5.toInt\n    private val n = values.length\n    val t = new Array[Int](2 * n)\n    Array.copy(values, 0, t, n, n)\n\n    // build segment tree\n    def build = {\n      for (i <- n - 1 until 0 by -1) {\n        t(i) = commutative(t(2 * i), t(2 * i + 1))\n      }\n    }\n\n    // change value at position p to x\n    // TODO beatify\n    def modify(p: Int, x: Int) = {\n      var pos = p + n\n      t(pos) = x\n      while (pos > 1) {\n        t(pos / 2) = commutative(t(pos), t(pos ^ 1))\n        pos /= 2\n      }\n    }\n\n    // TODO implement me!\n    def modify(p: Int, left: Int, right: Int) = ???\n\n    def query(p: Int) = ???\n\n    // sum [l, r)\n    // min l = 0\n    // max r = n\n    // TODO beatify\n    def query(left: Int, right: Int): Int = {\n      var res = zero\n      var r = right + n\n      var l = left + n\n      while (l < r) {\n        if (l % 2 == 1) {\n          res = commutative(res, t(l))\n          l += 1\n        }\n        if (r % 2 == 1) {\n          r -= 1\n          res = commutative(res, t(r))\n        }\n        l /= 2\n        r /= 2\n      }\n      res\n    }\n  }\n\n  def sorted(a: Array[Int]): Boolean = {\n    for (i <- 1 until a.length) {\n      if (a(i) < a(i - 1)) {\n        return false\n      }\n    }\n    true\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val k = nextInt\n    val a = new Array[Int](n)\n    val b = new Array[Int](k)\n    for (i <- 0 until n) {\n      a(i) = nextInt\n    }\n    for (i <- 0 until k) {\n      b(i) = nextInt\n    }\n    if (k > 1) {\n      out.println(\"Yes\")\n      return 0\n    }\n    val pos = a.indexOf(0)\n    a(pos) = b(0)\n    if (sorted(a)) {\n      out.println(\"No\")\n    } else {\n      out.println(\"Yes\")\n    }\n    return 0\n  }\n}\n"}, {"source_code": "object EightOneFourA {\n  def checkIfSeqAsc(seq: Seq[Int]): Boolean = {\n    val startValue = Int.MinValue\n    seq.foldLeft((true, startValue)) {\n      case ((isSorted, previousValue), currentValue) => {\n        (isSorted && (currentValue >= previousValue), currentValue)\n      }\n    }._1\n  }\n\n  def main(args: Array[String]): Unit = {\n    val input = readLine().toString.split(\" \")\n    val stringA = readLine().toString.split(\" \")\n    val stringB = readLine().toString.split(\" \")\n\n    if (input(1).toInt > 1) {\n      println(\"YES\")\n    } else {\n      val finalArray = stringA.map(_.toInt).map(p => {\n        if (p == 0) {\n          stringB(0).toInt\n        } else {\n          p\n        }\n      })\n\n      if (checkIfSeqAsc(finalArray)) {\n        println(\"NO\")\n      } else {\n        println(\"YES\")\n      }\n    }\n  }\n}\n"}, {"source_code": "/**\n  * Created by Hyper on 22.06.2017.\n  */\nimport scala.io.StdIn\nobject cf extends App{\n  def checkNonAscending(l: List[Int]):String ={\n    l match {\n      case head::tail::Nil => if(head > tail) \"Yes\" else \"No\"\n      case head::tail => if(head > tail.head) \"Yes\" else checkNonAscending(tail)\n    }\n  }\n  def replace(a: List[Int], b: Int): List[Int] ={\n    a match{\n      case Nil =>  Nil\n      case 0 :: tail => b :: tail\n      case u :: tail => u :: replace(tail,b)\n    }\n  }\n  val v = StdIn.readLine().split(\" \").toList\n  val n = v.head.toInt\n  val k = v.tail.head.toInt\n  val A = StdIn.readLine().split(\" \").toList.map(s => s.toInt)\n  val B = StdIn.readLine().split(\" \").toList.map(s => s.toInt)\n  if (k > 2) println(\"Yes\")\n  else println(checkNonAscending(replace(A,B.head)))\n}\n\n"}], "negative_code": [{"source_code": "import scala.io.Source\n\n/** A. An abandoned sentiment from past\n  * time limit per test1 second\n  * memory limit per test256 megabytes\n  *\n  * A few years ago, Hitagi encountered a giant crab, who stole the whole of her body weight.\n  * Ever since, she tried to avoid contact with others, for fear that this secret might be noticed.\n  *\n  * To get rid of the oddity and recover her weight, a special integer sequence is needed.\n  * Hitagi's sequence has been broken for a long time, but now Kaiki provides an opportunity.\n  *\n  * Hitagi's sequence a has a length of n. Lost elements in it are denoted by zeros. Kaiki provides another sequence b,\n  * whose length k equals the number of lost elements in a (i.e. the number of zeros).\n  *\n  * Hitagi is to replace each zero in a with an element from b so that each element in b should be used exactly once.\n  * Hitagi knows, however, that, apart from 0, no integer occurs in a and b more than once in total.\n  * If the resulting sequence is not an increasing sequence, then it has the power to recover Hitagi from the oddity.\n  * You are to determine whether this is possible, or Kaiki's sequence is just another fake. In other words,\n  * you should detect whether it is possible to replace each zero in a with an integer from b so that each integer\n  * from b is used exactly once, and the resulting sequence is not increasing.\n  */\nobject P814A {\n  /** get integer seqence `a`. the length of sequence is n\n    *\n    * @param args\n    */\n  def main(args: Array[String]): Unit = {\n    val lines = Source.stdin.getLines()\n\n    val Array(n, k) = lines.next().split(\" \")\n\n    /** n-length arr with k zero values */\n    val a = lines.next().split(\" \").map(_.toInt).toList\n\n    /** k-length arr */\n    val b = lines.next().split(\" \").map(_.toInt)\n\n    /** Input guarantees that apart from 0, no integer occurs in a and b more than once in total.\n      *\n      * Detect whether it is possible to replace each zero in a with an integer from b so that each integer\n      * from b is used exactly once, and the resulting sequence is not increasing */\n\n    def test(a: List[Int], b: Int): Boolean = {\n      a match {\n        case a0 :: a1 :: tail =>\n          if (a1 == 0) test(a0 :: b :: tail, b)\n          else {\n            if (a0 > a1) true\n            else test(a1 :: tail, b)\n          }\n        case _ => false\n      }\n    }\n\n    val result =\n      if (b.length > 1) true\n      else test(a, b.head)\n\n    if (result) println(\"Yes\")\n    else println(\"No\")\n  }\n}\n\n"}, {"source_code": "\nimport java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextBoolean: Boolean = next.equalsIgnoreCase(\"1\")\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n\n    override def toString = s\"MultiHashSet($map)\"\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  /**\n    * Segment tree for any commutative function\n    *\n    * @param values      Array of Int\n    * @param commutative function like min, max, sum\n    * @param zero        zero value - e.g. 0 for sum, Inf for min, max\n    */\n  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {\n    private val SIZE = 1e5.toInt\n    private val n = values.length\n    val t = new Array[Int](2 * n)\n    Array.copy(values, 0, t, n, n)\n\n    // build segment tree\n    def build = {\n      for (i <- n - 1 until 0 by -1) {\n        t(i) = commutative(t(2 * i), t(2 * i + 1))\n      }\n    }\n\n    // change value at position p to x\n    // TODO beatify\n    def modify(p: Int, x: Int) = {\n      var pos = p + n\n      t(pos) = x\n      while (pos > 1) {\n        t(pos / 2) = commutative(t(pos), t(pos ^ 1))\n        pos /= 2\n      }\n    }\n\n    // TODO implement me!\n    def modify(p: Int, left: Int, right: Int) = ???\n\n    def query(p: Int) = ???\n\n    // sum [l, r)\n    // min l = 0\n    // max r = n\n    // TODO beatify\n    def query(left: Int, right: Int): Int = {\n      var res = zero\n      var r = right + n\n      var l = left + n\n      while (l < r) {\n        if (l % 2 == 1) {\n          res = commutative(res, t(l))\n          l += 1\n        }\n        if (r % 2 == 1) {\n          r -= 1\n          res = commutative(res, t(r))\n        }\n        l /= 2\n        r /= 2\n      }\n      res\n    }\n  }\n\n  def sorted(l: Array[Int]): Boolean = l == l.sorted\n\n  def solve: Int = {\n    val n = nextInt\n    val k = nextInt\n    val a = new Array[Int](n)\n    val b = new Array[Int](k)\n    for (i <- 0 until n) {\n      a(i) = nextInt\n    }\n    for (i <- 0 until k) {\n      b(i) = nextInt\n    }\n    if (k > 1) {\n      out.println(\"Yes\")\n      return 0\n    }\n    val pos = a.indexOf(0)\n    a(pos) = b(0)\n    if (sorted(a)) {\n      out.println(\"No\")\n    } else {\n      out.println(\"Yes\")\n    }\n    return 0\n  }\n}\n"}, {"source_code": "\nimport java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextBoolean: Boolean = next.equalsIgnoreCase(\"1\")\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n\n    override def toString = s\"MultiHashSet($map)\"\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  /**\n    * Segment tree for any commutative function\n    *\n    * @param values      Array of Int\n    * @param commutative function like min, max, sum\n    * @param zero        zero value - e.g. 0 for sum, Inf for min, max\n    */\n  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {\n    private val SIZE = 1e5.toInt\n    private val n = values.length\n    val t = new Array[Int](2 * n)\n    Array.copy(values, 0, t, n, n)\n\n    // build segment tree\n    def build = {\n      for (i <- n - 1 until 0 by -1) {\n        t(i) = commutative(t(2 * i), t(2 * i + 1))\n      }\n    }\n\n    // change value at position p to x\n    // TODO beatify\n    def modify(p: Int, x: Int) = {\n      var pos = p + n\n      t(pos) = x\n      while (pos > 1) {\n        t(pos / 2) = commutative(t(pos), t(pos ^ 1))\n        pos /= 2\n      }\n    }\n\n    // TODO implement me!\n    def modify(p: Int, left: Int, right: Int) = ???\n\n    def query(p: Int) = ???\n\n    // sum [l, r)\n    // min l = 0\n    // max r = n\n    // TODO beatify\n    def query(left: Int, right: Int): Int = {\n      var res = zero\n      var r = right + n\n      var l = left + n\n      while (l < r) {\n        if (l % 2 == 1) {\n          res = commutative(res, t(l))\n          l += 1\n        }\n        if (r % 2 == 1) {\n          r -= 1\n          res = commutative(res, t(r))\n        }\n        l /= 2\n        r /= 2\n      }\n      res\n    }\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val k = nextInt\n    val a = new Array[Int](n)\n    val b = new Array[Int](k)\n    for (i <- 0 until n) {\n      a(i) = nextInt\n    }\n    for (i <- 0 until k) {\n      b(i) = nextInt\n    }\n    if (n == k) {\n      out.println(\"Yes\")\n      return 0\n    }\n    for (i <- 1 until n) {\n      if (a(i) == 0 && a(i - 1) == 0) {\n        out.println(\"Yes\")\n        return 0\n      }\n    }\n    for (i <- 0 until n) {\n      if (a(i) == 0) {\n        if (i - 1 >= 0 && a(i - 1) != 0) {\n          for (j <- 0 until k) {\n            if (b(j) < a(i - 1)) {\n              out.println(\"Yes\")\n              return 0\n            }\n          }\n        } else if (i + 1 < n && a(i + 1) != 0) {\n          for (j <- 0 until k) {\n            if (a(i + 1) != 0 && b(j) > a(i + 1)) {\n              out.println(\"Yes\")\n              return 0\n            }\n          }\n        }\n      }\n    }\n    out.println(\"No\")\n    return 0\n  }\n}\n"}, {"source_code": "\nimport java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextBoolean: Boolean = next.equalsIgnoreCase(\"1\")\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n\n    override def toString = s\"MultiHashSet($map)\"\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  /**\n    * Segment tree for any commutative function\n    *\n    * @param values      Array of Int\n    * @param commutative function like min, max, sum\n    * @param zero        zero value - e.g. 0 for sum, Inf for min, max\n    */\n  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {\n    private val SIZE = 1e5.toInt\n    private val n = values.length\n    val t = new Array[Int](2 * n)\n    Array.copy(values, 0, t, n, n)\n\n    // build segment tree\n    def build = {\n      for (i <- n - 1 until 0 by -1) {\n        t(i) = commutative(t(2 * i), t(2 * i + 1))\n      }\n    }\n\n    // change value at position p to x\n    // TODO beatify\n    def modify(p: Int, x: Int) = {\n      var pos = p + n\n      t(pos) = x\n      while (pos > 1) {\n        t(pos / 2) = commutative(t(pos), t(pos ^ 1))\n        pos /= 2\n      }\n    }\n\n    // TODO implement me!\n    def modify(p: Int, left: Int, right: Int) = ???\n\n    def query(p: Int) = ???\n\n    // sum [l, r)\n    // min l = 0\n    // max r = n\n    // TODO beatify\n    def query(left: Int, right: Int): Int = {\n      var res = zero\n      var r = right + n\n      var l = left + n\n      while (l < r) {\n        if (l % 2 == 1) {\n          res = commutative(res, t(l))\n          l += 1\n        }\n        if (r % 2 == 1) {\n          r -= 1\n          res = commutative(res, t(r))\n        }\n        l /= 2\n        r /= 2\n      }\n      res\n    }\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val k = nextInt\n    val a = new Array[Int](n)\n    val b = new Array[Int](k)\n    for (i <- 0 until n) {\n      a(i) = nextInt\n    }\n    for (i <- 0 until k) {\n      b(i) = nextInt\n    }\n    for (i <- 1 until n) {\n      if (a(i) == 0 && a(i - 1) == 0) {\n        out.println(\"Yes\")\n        return 0\n      }\n    }\n    for (i <- 0 until n) {\n      if (a(i) == 0) {\n        if (i - 1 >= 0 && a(i - 1) != 0) {\n          for (j <- 0 until k) {\n            if (b(j) < a(i - 1)) {\n              out.println(\"Yes\")\n              return 0\n            }\n          }\n        }\n        if (i + 1 < n && a(i + 1) != 0) {\n          for (j <- 0 until k) {\n            if (a(i + 1) != 0 && b(j) > a(i + 1)) {\n              out.println(\"Yes\")\n              return 0\n            }\n          }\n        }\n      }\n    }\n    out.println(\"No\")\n    return 0\n  }\n}\n"}, {"source_code": "import java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextBoolean: Boolean = next.equalsIgnoreCase(\"1\")\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n\n    override def toString = s\"MultiHashSet($map)\"\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  /**\n    * Segment tree for any commutative function\n    *\n    * @param values      Array of Int\n    * @param commutative function like min, max, sum\n    * @param zero        zero value - e.g. 0 for sum, Inf for min, max\n    */\n  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {\n    private val SIZE = 1e5.toInt\n    private val n = values.length\n    val t = new Array[Int](2 * n)\n    Array.copy(values, 0, t, n, n)\n\n    // build segment tree\n    def build = {\n      for (i <- n - 1 until 0 by -1) {\n        t(i) = commutative(t(2 * i), t(2 * i + 1))\n      }\n    }\n\n    // change value at position p to x\n    // TODO beatify\n    def modify(p: Int, x: Int) = {\n      var pos = p + n\n      t(pos) = x\n      while (pos > 1) {\n        t(pos / 2) = commutative(t(pos), t(pos ^ 1))\n        pos /= 2\n      }\n    }\n\n    // TODO implement me!\n    def modify(p: Int, left: Int, right: Int) = ???\n\n    def query(p: Int) = ???\n\n    // sum [l, r)\n    // min l = 0\n    // max r = n\n    // TODO beatify\n    def query(left: Int, right: Int): Int = {\n      var res = zero\n      var r = right + n\n      var l = left + n\n      while (l < r) {\n        if (l % 2 == 1) {\n          res = commutative(res, t(l))\n          l += 1\n        }\n        if (r % 2 == 1) {\n          r -= 1\n          res = commutative(res, t(r))\n        }\n        l /= 2\n        r /= 2\n      }\n      res\n    }\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val k = nextInt\n    val a = new Array[Int](n)\n    val b = new Array[Int](k)\n    for (i <- 0 until n) {\n      a(i) = nextInt\n    }\n    for (i <- 0 until k) {\n      b(i) = nextInt\n    }\n    if (n == k) {\n      out.println(\"Yes\")\n      return 0\n    }\n    for (i <- 0 until n) {\n      if (a(i) == 0) {\n        if (i > 0) {\n          for (j <- 0 until k) {\n            if (a(i - 1) != 0 && b(j) < a(i - 1)) {\n              out.println(\"Yes\")\n              return 0\n            }\n          }\n        } else {\n          for (j <- 0 until k) {\n            if (a(i + 1) != 0 && b(j) > a(i + 1)) {\n              out.println(\"Yes\")\n              return 0\n            }\n          }\n        }\n      }\n    }\n    out.println(\"No\")\n    return 0\n  }\n}\n"}, {"source_code": "\nimport java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextBoolean: Boolean = next.equalsIgnoreCase(\"1\")\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n\n    override def toString = s\"MultiHashSet($map)\"\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  /**\n    * Segment tree for any commutative function\n    *\n    * @param values      Array of Int\n    * @param commutative function like min, max, sum\n    * @param zero        zero value - e.g. 0 for sum, Inf for min, max\n    */\n  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {\n    private val SIZE = 1e5.toInt\n    private val n = values.length\n    val t = new Array[Int](2 * n)\n    Array.copy(values, 0, t, n, n)\n\n    // build segment tree\n    def build = {\n      for (i <- n - 1 until 0 by -1) {\n        t(i) = commutative(t(2 * i), t(2 * i + 1))\n      }\n    }\n\n    // change value at position p to x\n    // TODO beatify\n    def modify(p: Int, x: Int) = {\n      var pos = p + n\n      t(pos) = x\n      while (pos > 1) {\n        t(pos / 2) = commutative(t(pos), t(pos ^ 1))\n        pos /= 2\n      }\n    }\n\n    // TODO implement me!\n    def modify(p: Int, left: Int, right: Int) = ???\n\n    def query(p: Int) = ???\n\n    // sum [l, r)\n    // min l = 0\n    // max r = n\n    // TODO beatify\n    def query(left: Int, right: Int): Int = {\n      var res = zero\n      var r = right + n\n      var l = left + n\n      while (l < r) {\n        if (l % 2 == 1) {\n          res = commutative(res, t(l))\n          l += 1\n        }\n        if (r % 2 == 1) {\n          r -= 1\n          res = commutative(res, t(r))\n        }\n        l /= 2\n        r /= 2\n      }\n      res\n    }\n  }\n\n  def sorted(l: Array[Int]): Boolean = l == l.sorted\n\n  def solve: Int = {\n    val n = nextInt\n    val k = nextInt\n    val a = new Array[Int](n)\n    val b = new Array[Int](k)\n    for (i <- 0 until n) {\n      a(i) = nextInt\n    }\n    for (i <- 0 until k) {\n      b(i) = nextInt\n    }\n    if (k > 1) {\n      out.println(\"Yes\")\n      return 0\n    }\n    val pos = a.indexOf(0)\n    a(pos) = b(0)\n    if (!sorted(a)) {\n      out.println(\"Yes\")\n    } else {\n      out.println(\"No\")\n    }\n    return 0\n  }\n}\n"}, {"source_code": "\nimport java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextBoolean: Boolean = next.equalsIgnoreCase(\"1\")\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n\n    override def toString = s\"MultiHashSet($map)\"\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  /**\n    * Segment tree for any commutative function\n    *\n    * @param values      Array of Int\n    * @param commutative function like min, max, sum\n    * @param zero        zero value - e.g. 0 for sum, Inf for min, max\n    */\n  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {\n    private val SIZE = 1e5.toInt\n    private val n = values.length\n    val t = new Array[Int](2 * n)\n    Array.copy(values, 0, t, n, n)\n\n    // build segment tree\n    def build = {\n      for (i <- n - 1 until 0 by -1) {\n        t(i) = commutative(t(2 * i), t(2 * i + 1))\n      }\n    }\n\n    // change value at position p to x\n    // TODO beatify\n    def modify(p: Int, x: Int) = {\n      var pos = p + n\n      t(pos) = x\n      while (pos > 1) {\n        t(pos / 2) = commutative(t(pos), t(pos ^ 1))\n        pos /= 2\n      }\n    }\n\n    // TODO implement me!\n    def modify(p: Int, left: Int, right: Int) = ???\n\n    def query(p: Int) = ???\n\n    // sum [l, r)\n    // min l = 0\n    // max r = n\n    // TODO beatify\n    def query(left: Int, right: Int): Int = {\n      var res = zero\n      var r = right + n\n      var l = left + n\n      while (l < r) {\n        if (l % 2 == 1) {\n          res = commutative(res, t(l))\n          l += 1\n        }\n        if (r % 2 == 1) {\n          r -= 1\n          res = commutative(res, t(r))\n        }\n        l /= 2\n        r /= 2\n      }\n      res\n    }\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val k = nextInt\n    val a = new Array[Int](n)\n    val b = new Array[Int](k)\n    for (i <- 0 until n) {\n      a(i) = nextInt\n    }\n    val set = new mutable.HashSet[Int]()\n    for (i <- 0 until k) {\n      b(i) = nextInt\n      set += b(i)\n    }\n    for (i <- 1 until n) {\n      if (a(i) == 0 && a(i - 1) == 0) {\n        out.println(\"Yes\")\n        return 0\n      }\n    }\n    for (i <- 0 until n) {\n      if (a(i) == 0) {\n        if (i - 1 >= 0 && i + 1 < n) {\n          for (j <- 0 until k) {\n            if (b(j) < a(i - 1) && b(j) > a(i + 1)) {\n              out.println(\"Yes\")\n              return 0\n            }\n          }\n        } else if (i - 1 >= 0) {\n          for (j <- 0 until k) {\n            if (b(j) < a(i - 1)) {\n              out.println(\"Yes\")\n              return 0\n            }\n          }\n        } else if (i + 1 < n) {\n          for (j <- 0 until k) {\n            if (b(j) > a(i + 1)) {\n              out.println(\"Yes\")\n              return 0\n            }\n          }\n        }\n      }\n    }\n    out.println(\"No\")\n    return 0\n  }\n}\n"}, {"source_code": "\nimport java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextBoolean: Boolean = next.equalsIgnoreCase(\"1\")\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n\n    override def toString = s\"MultiHashSet($map)\"\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  /**\n    * Segment tree for any commutative function\n    *\n    * @param values      Array of Int\n    * @param commutative function like min, max, sum\n    * @param zero        zero value - e.g. 0 for sum, Inf for min, max\n    */\n  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {\n    private val SIZE = 1e5.toInt\n    private val n = values.length\n    val t = new Array[Int](2 * n)\n    Array.copy(values, 0, t, n, n)\n\n    // build segment tree\n    def build = {\n      for (i <- n - 1 until 0 by -1) {\n        t(i) = commutative(t(2 * i), t(2 * i + 1))\n      }\n    }\n\n    // change value at position p to x\n    // TODO beatify\n    def modify(p: Int, x: Int) = {\n      var pos = p + n\n      t(pos) = x\n      while (pos > 1) {\n        t(pos / 2) = commutative(t(pos), t(pos ^ 1))\n        pos /= 2\n      }\n    }\n\n    // TODO implement me!\n    def modify(p: Int, left: Int, right: Int) = ???\n\n    def query(p: Int) = ???\n\n    // sum [l, r)\n    // min l = 0\n    // max r = n\n    // TODO beatify\n    def query(left: Int, right: Int): Int = {\n      var res = zero\n      var r = right + n\n      var l = left + n\n      while (l < r) {\n        if (l % 2 == 1) {\n          res = commutative(res, t(l))\n          l += 1\n        }\n        if (r % 2 == 1) {\n          r -= 1\n          res = commutative(res, t(r))\n        }\n        l /= 2\n        r /= 2\n      }\n      res\n    }\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val k = nextInt\n    val a = new Array[Int](n)\n    val b = new Array[Int](k)\n    for (i <- 0 until n) {\n      a(i) = nextInt\n    }\n    for (i <- 0 until k) {\n      b(i) = nextInt\n    }\n    for (i <- 1 until n) {\n      if (a(i) == 0 && a(i - 1) == 0) {\n        out.println(\"Yes\")\n        return 0\n      }\n    }\n    for (i <- 0 until n) {\n      if (a(i) == 0) {\n        if (i - 1 >= 0) {\n          for (j <- 0 until k) {\n            if (b(j) < a(i - 1)) {\n              out.println(\"Yes\")\n              return 0\n            }\n          }\n        }\n        if (i + 1 < n) {\n          for (j <- 0 until k) {\n            if (b(j) > a(i + 1)) {\n              out.println(\"Yes\")\n              return 0\n            }\n          }\n        }\n      }\n    }\n    out.println(\"No\")\n    return 0\n  }\n}\n"}, {"source_code": "\nimport java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextBoolean: Boolean = next.equalsIgnoreCase(\"1\")\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n\n    override def toString = s\"MultiHashSet($map)\"\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  /**\n    * Segment tree for any commutative function\n    *\n    * @param values      Array of Int\n    * @param commutative function like min, max, sum\n    * @param zero        zero value - e.g. 0 for sum, Inf for min, max\n    */\n  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {\n    private val SIZE = 1e5.toInt\n    private val n = values.length\n    val t = new Array[Int](2 * n)\n    Array.copy(values, 0, t, n, n)\n\n    // build segment tree\n    def build = {\n      for (i <- n - 1 until 0 by -1) {\n        t(i) = commutative(t(2 * i), t(2 * i + 1))\n      }\n    }\n\n    // change value at position p to x\n    // TODO beatify\n    def modify(p: Int, x: Int) = {\n      var pos = p + n\n      t(pos) = x\n      while (pos > 1) {\n        t(pos / 2) = commutative(t(pos), t(pos ^ 1))\n        pos /= 2\n      }\n    }\n\n    // TODO implement me!\n    def modify(p: Int, left: Int, right: Int) = ???\n\n    def query(p: Int) = ???\n\n    // sum [l, r)\n    // min l = 0\n    // max r = n\n    // TODO beatify\n    def query(left: Int, right: Int): Int = {\n      var res = zero\n      var r = right + n\n      var l = left + n\n      while (l < r) {\n        if (l % 2 == 1) {\n          res = commutative(res, t(l))\n          l += 1\n        }\n        if (r % 2 == 1) {\n          r -= 1\n          res = commutative(res, t(r))\n        }\n        l /= 2\n        r /= 2\n      }\n      res\n    }\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val k = nextInt\n    val a = new Array[Int](n)\n    val b = new Array[Int](k)\n    for (i <- 0 until n) {\n      a(i) = nextInt\n    }\n    val set = new mutable.HashSet[Int]()\n    for (i <- 0 until k) {\n      b(i) = nextInt\n      set += b(i)\n    }\n    for (i <- 1 until n) {\n      if (a(i) == 0 && a(i - 1) == 0) {\n        out.println(\"Yes\")\n        return 0\n      }\n    }\n    for (i <- 0 until n) {\n      if (a(i) == 0) {\n        if (i - 1 >= 0 && i + 1 < n) {\n          for (j <- 0 until k) {\n            if (b(j) < a(i - 1) && b(j) > a(i + 1)) {\n              out.println(\"Yes\")\n              return 0\n            }\n          }\n        }\n      }\n    }\n    out.println(\"No\")\n    return 0\n  }\n}\n"}], "src_uid": "40264e84c041fcfb4f8c0af784df102a"}
{"source_code": "import java.util.Scanner\n\nobject BarkUnlock {\n\tdef main(args: Array[String]) = {\n\t\tval sc: Scanner = new Scanner(System.in)\n\t\tval password: String = sc.next()\n\t\tval n: Int = sc.nextInt()\n\t\tval words: List[String] = (1 to n).map(_ => sc.next()).toList\n\n\t\tif(words.exists(_.equals(password))) println(\"YES\")\n\t\telse if(words.exists(_.charAt(1) == password.charAt(0)) && \n\t\t\twords.exists(_.charAt(0) == password.charAt(1))) println(\"YES\")\n\t\telse println(\"NO\")\n\t}\n}", "positive_code": [{"source_code": "import scala.io.StdIn\n\nobject Atdroch {\n  def main(args: Array[String]) {\n    val actualPwd = StdIn.readLine()\n\n    val numSubstrings = StdIn.readInt()\n    val substrings = (0 until numSubstrings).map(i => StdIn.readLine())\n\n    println(if (bruteforcePossible(actualPwd, substrings)) \"YES\" else \"NO\")\n  }\n\n  def bruteforcePossible(actualPwd: String, substrings: Seq[String]): Boolean = {\n    if(substrings.contains(actualPwd)) {\n      true\n    }\n    else {\n      (for (x <- substrings; y <- substrings) yield (x, y)).foldLeft(false)((possible, xy) => {\n        if(possible) true\n        else {\n          val (x, y) = xy\n\n          x(1) == actualPwd(0) && y(0) == actualPwd(1)\n        }\n      })\n    }\n  }\n\n}\n"}], "negative_code": [], "src_uid": "cad8283914da16bc41680857bd20fe9f"}
{"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val Array(n, t) = in.next().split(' ').map(_.toInt)\n  val data = (1 to n).map(i => Array.fill[(Int, Int)](i){(0, 1)}).toArray\n\n  def norm(a: (Int, Int)): (Int, Int) = {\n    (2 to Math.min(a._1, a._2)).find(j => a._1 % j == 0 && a._2 % j == 0) match {\n      case None => a\n      case Some(i) => norm((a._1 / i, a._2 / i))\n    }\n  }\n\n  def sum(a: (Int, Int), b: (Int, Int)): (Int, Int) = {\n    if (a._2 == b._2)\n      norm((a._1 + b._1, b._2))\n    else\n      norm((a._1 * b._2 + b._1 * a._2, a._2 * b._2))\n  }\n\n  data(0)(0) = sum(data(0)(0), (t, 1))\n  data.indices.foreach(i =>\n      data(i).indices.foreach { j =>\n        val el = data(i)(j)\n        if (el._1 >= el._2 && el != (1, 1)) {\n          val temp = (data(i)(j)._1 - data(i)(j)._2, data(i)(j)._2)\n          data(i)(j) = (1, 1)\n          if (i != data.length - 1) {\n            data(i + 1)(j) = sum(data(i + 1)(j), (temp._1, temp._2 * 2))\n            data(i + 1)(j + 1) = sum(data(i + 1)(j + 1), (temp._1, temp._2 * 2))\n          }\n        }\n    })\n  println(data.map(_.count(_ == (1, 1))).sum)\n}\n", "positive_code": [{"source_code": "import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._\n\nobject _676B extends CodeForcesApp {\n  override def apply(io: IO) = {\n    val n, t = io[Int]\n    val tower = Array.ofDim[Double]((n * (n + 1))/2)\n\n    def pour(glass: Int, amount: Double): Unit = if (glass < tower.length) {\n      val capacity = 1 - tower(glass)\n      val fill = amount min capacity\n      tower(glass) += fill\n      val next = amount - fill\n      if(next >~ 0) {\n        val level = ((Math.sqrt(1 + 8.0*glass) - 1)/2).toInt\n        pour(glass + level + 1, next/2)\n        pour(glass + level + 2, next/2)\n      } else {\n        //debug(glass, amount, fill, tower.toList)\n      }\n    }\n\n    repeat(t) {\n      pour(glass = 0, amount = 1)\n    }\n\n    val ans = tower.count(_ ~= 1)\n    io += ans\n  }\n}\n\n// ((sqrt(1+8*n)-1)/2)\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\nobject Utils {\n  import scala.collection.mutable, mutable.{Map => Dict}\n  implicit class GenericExtensions[A](val a: A) extends AnyVal {\n    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a\n  }\n  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {\n    def onlyElement: A = t.head.ensuring(t.size == 1)\n    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)\n    def duplicates(implicit b: C of A): C[A] = {\n      val elems = mutable.Set.empty[A]\n      (t collect {case i if !elems.add(i) => i}).to[C]\n    }\n    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}\n    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]\n    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap\n    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)\n    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}\n    def toMutableMultiSet: Dict[A, Int] = {\n      val c = map[A] to 0\n      t.foreach(i => c(i) += 1)\n      c\n    }\n    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0\n    def prefixSum(implicit n: Numeric[A]) = t.scanLeft(n.zero) {case (acc, i) => n.plus(acc, i)}\n    def suffixSum(implicit n: Numeric[A]) = t.scanRight(n.zero) {case (i, acc) => n.plus(acc, i)}\n  }\n  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)\n  }\n  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)\n  }\n  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {\n    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t\n  }\n  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {\n    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_._1).mapValues(_._2)\n    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_._1).mapValues(_.map(_._2).to[C])\n    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]\n  }\n  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {\n    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap\n    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}\n    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m\n  }\n  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {\n    def notContains(x: A): Boolean = !(s contains x)\n    def toMutable = mutable.Set.empty[A] ++ s\n  }\n  implicit class SortedExtensions[A, C[A] <: collection.SortedSet[A]](val s: C[A]) extends AnyVal {\n    def greaterThanOrEqualTo(a: A): Option[A] = s.from(a).headOption\n    def lessThan(a: A): Option[A] = s.until(a).lastOption\n  }\n  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {\n    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}\n    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f) findWithIndex c\n  }\n  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {\n    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero\n  }\n  implicit class LongExtensions(val x: Long) extends AnyVal {\n    def bitCount: Int = java.lang.Long.bitCount(x)\n  }\n  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {\n    import Numeric.Implicits._\n    def **(i: Int): A = if (i == 0) n.one else {\n      val h = x ** (i/2)\n      if (i%2 == 0) h * h else h * h * x\n    }\n    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)\n    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf \"Greg\" whenNegative Int.MaxValue\n  }\n  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {\n    import scala.collection.immutable.NumericRange, Integral.Implicits._\n    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x\n    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(n.min(x, y), n.max(x, y), n.one)\n  }\n  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))\n  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)\n  def asc[A](implicit order: Ordering[A]): Ordering[A] = order\n  def map[K] = new {\n    def to[V](default: V): Dict[K, V] = Dict.empty[K, V] withDefaultValue default // also to(Dict.empty[K2, V])\n  }\n  def memoize[A, B](f: A => B): collection.Map[A, B] = new mutable.HashMap[A, B]() {\n    override def apply(key: A) = getOrElseUpdate(key, f(key))\n  }\n  implicit class FuzzyDouble(x: Double)(implicit eps: Double = 1e-9) {\n    def >~(y: Double) = x > y+eps\n    def >=~(y: Double) = x >= y-eps\n    def ~<(y: Double) = x < y-eps\n    def ~=<(y: Double) = x <= y+eps\n    def ~=(y: Double) = ~=<(y) && >=~(y)\n  }\n  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None\n  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)\n  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]\n  val mod: Int = (1e9 + 7).toInt\n}\n/***********************************[Scala I/O]*********************************************/\nimport Utils._, java.io._, java.util.StringTokenizer\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends PrintWriter(out, true) with Iterator[String] {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    if (tokenizers.nonEmpty) Some(tokenizers.head) else None\n  }\n\n  def apply[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def apply[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(apply).to[C]\n\n  def till(delim: String): String = tokenizer().get.nextToken(delim)\n  def tillEndOfLine(): String = till(\"\\n\\r\")\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  var separator = \" \"\n  private[this] var isNewLine = true\n\n  def +=[A](x: A)(implicit write: IO.Write[A]): this.type = {\n    write(this)(x)\n    this\n  }\n  def ++=[A: IO.Write](xs: Traversable[A]): this.type = (this += xs.size) appendNewLine xs\n\n  def appendNewLine[A: IO.Write](x: A): this.type = {\n    println()\n    this += x\n  }\n\n  override def print(obj: String) = {\n    if (isNewLine) isNewLine = false else super.print(separator)\n    super.print(obj)\n  }\n  override def println() = if (!isNewLine) {\n    super.println()\n    isNewLine = true\n  }\n  override def close() = {\n    flush()\n    in.close()\n    super.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r[C, A](r[Int]))\n    implicit val string                                       : Read[String]       = new Read(_.next())\n    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)\n    implicit val boolean                                      : Read[Boolean]      = string.map(_.toBoolean)\n    implicit val int                                          : Read[Int]          = string.map(_.toInt)\n    implicit val long                                         : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                       : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r[A], r[B]))\n    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r[A], r[B], r[C]))\n    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r[A], r[B], r[C], r[D]))\n  }\n  trait Write[-A] {\n    def apply(out: PrintWriter)(x: A): Unit\n  }\n  trait DefaultWrite {\n    implicit def any[A]: Write[A] = Write(_.toString)\n  }\n  object Write extends DefaultWrite {\n    def apply[A](f: A => String) = new Write[A] {\n      override def apply(out: PrintWriter)(x: A) = out.print(f(x))\n    }\n    implicit val boolean: Write[Boolean] = Write(b => if (b) \"YES\" else \"NO\")\n    implicit def tuple2[A, B]: Write[(A, B)] = Write {case (a, b) => s\"$a $b\"}\n    implicit def array[A]: Write[Array[A]] = Write(_ mkString \" \")\n    implicit def iterable[A](implicit write: Write[A]): Write[Traversable[A]] = new Write[Traversable[A]] {\n      override def apply(out: PrintWriter)(xs: Traversable[A]) = {\n        xs foreach write(out)\n        out.println()\n      }\n    }\n  }\n}\n\n"}], "negative_code": [{"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val Array(n, t) = in.next().split(' ').map(_.toInt)\n  val data = (1 to n).map(i => Array.fill[(Int, Int)](i){(0, 1)}).toArray\n\n  def norm(a: (Int, Int)): (Int, Int) = {\n    (2 to Math.min(a._1, a._2)).find(j => a._1 % j == 0 && a._2 % j == 0) match {\n      case None => a\n      case Some(i) => norm((a._1 / i, a._2 / i))\n    }\n  }\n\n  def sum(a: (Int, Int), b: (Int, Int)): (Int, Int) = {\n    if (a._2 == b._2)\n      norm((a._1 + b._1, b._2))\n    else\n      norm((a._1 * b._2 + b._1 * a._2, a._2 * b._2))\n  }\n\n  data.indices.foreach(i =>\n      data(i).indices.foreach { j =>\n        val el = data(i)(j)\n        if (el._1 >= el._2 && el != (1, 1)) {\n          val temp = (data(i)(j)._1 - data(i)(j)._2, data(i)(j)._2)\n          data(i)(j) = (1, 1)\n          if (i != data.length - 1) {\n            data(i + 1)(j) = sum(data(i + 1)(j), (temp._1, temp._2 * 2))\n            data(i + 1)(j + 1) = sum(data(i + 1)(j + 1), (temp._1, temp._2 * 2))\n          }\n        }\n    })\n  println(data.map(_.count(_ == (1, 1))).sum)\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val Array(n, t) = in.next().split(' ').map(_.toInt)\n  val data = (1 to n).map(i => Array.fill[(Int, Int)](i){(0, 1)}).toArray\n\n  def norm(a: (Int, Int)): (Int, Int) = {\n    (2 to Math.min(a._1, a._2)).find(j => a._1 % j == 0 && a._2 % j == 0) match {\n      case None => a\n      case Some(i) => norm((a._1 / i, a._2 / i))\n    }\n  }\n\n  def sum(a: (Int, Int), b: (Int, Int)): (Int, Int) = {\n    if (a._2 == b._2)\n      norm((a._1 + b._1, b._2))\n    else\n      norm((a._1 * b._2 + b._1 * a._2, a._2 * b._2))\n  }\n\n  (1 to t).foreach { _ =>\n    data(0)(0) = sum(data(0)(0), (1, 1))\n    data.indices.foreach(i =>\n        data(i).indices.foreach { j =>\n          val el = data(i)(j)\n          if (el._1 >= el._2 && el != (1, 1)) {\n            val temp = (data(i)(j)._1 - data(i)(j)._2, data(i)(j)._2)\n            data(i)(j) = (1, 1)\n            if (i != data.length - 1) {\n              data(i + 1)(j) = sum(data(i + 1)(j), (temp._1, temp._2 * 2))\n              data(i + 1)(j + 1) = sum(data(i + 1)(j + 1), (temp._1, temp._2 * 2))\n            }\n          }\n      })\n    println(data.map(_.toList).toList)\n\n  }\n  println(data.map(_.toList).toList)\n  println(data.map(_.count(_ == (1, 1))).sum)\n}\n"}], "src_uid": "b2b49b7f6e3279d435766085958fb69d"}
{"source_code": "object _977B extends CodeForcesApp {\n  import annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._, Math._\n\n  override def apply(io: IO): io.type = {\n    val _, s = io.read[String]\n    val (ans, _) = s.sliding(2).toSeq.groupBy(identity).mapValues(_.size).maxBy(_._2)\n    io.write(ans)\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\n/***********************************[Scala I/O]*********************************************/\nimport java.io._, java.util.StringTokenizer\nimport scala.collection.generic.CanBuild\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    tokenizers.headOption\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: CanBuild[A, C[A]]): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  def readAll[A: IO.Read]: (Int, Vector[A]) = {\n    val data = read[Vector[A]]\n    (data.length, data)\n  }\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any): this.type = {\n    printer.print(obj)\n    this\n  }\n  def writeLine(): this.type = {\n    printer.println()\n    this\n  }\n  def writeLine(obj: Any): this.type = {\n    printer.println(obj)\n    this\n  }\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n  def query[A: IO.Read](question: Any): A = writeLine(question).read\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: CanBuild[A, C[A]]) : Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                                   : Read[String]       = new Read(_.next())\n    implicit val int                                                      : Read[Int]          = string.map(_.toInt)\n    implicit val long                                                     : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                                   : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                                   : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                               : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                                 : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                                  : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n", "positive_code": [{"source_code": "object Main {\n  import java.io._\n  import java.util.StringTokenizer\n\n  import scala.collection.mutable\n  import scala.util.Sorting\n  import math.{abs, max, min}\n  import mutable.{ArrayBuffer, ListBuffer}\n  import scala.reflect.ClassTag\n\n  val MOD = 1000000007\n  val out = new PrintWriter(System.out)\n\n  def solve(): Unit = {\n    val N = ni()\n    val s = ns(N)\n    val cnt = Array.ofDim[Int](26, 26)\n    rep(N - 1) { i =>\n      val a = s(i) - 'A'\n      val b = s(i + 1) - 'A'\n      cnt(a)(b) += 1\n    }\n\n    val ms = cnt.map(_.max).max\n    var a, b = 0\n    rep(26) { i =>\n      rep(26) { j =>\n        if (cnt(i)(j) == ms) {\n          a = i\n          b = j\n        }\n      }\n    }\n\n    out.println(s\"${('A'+a).toChar}${('A'+b).toChar}\")\n  }\n\n  def main(args: Array[String]): Unit = {\n    solve()\n    out.flush()\n  }\n\n\n  class InputReader(val stream: InputStream) {\n    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n    private var tokenizer: StringTokenizer = _\n\n    def next(): String = {\n      while (tokenizer == null || !tokenizer.hasMoreTokens)\n        tokenizer = new StringTokenizer(reader.readLine)\n      tokenizer.nextToken\n    }\n\n    def nextInt(): Int = next().toInt\n    def nextLong(): Long = next().toLong\n    def nextChar(): Char = next().charAt(0)\n  }\n  val sc = new InputReader(System.in)\n  def ni(): Int = sc.nextInt()\n  def nl(): Long = sc.nextLong()\n  def nc(): Char = sc.nextChar()\n  def ns(): String = sc.next()\n  def ns(n: Int): Array[Char] = ns().toCharArray\n  def na(n: Int): Array[Int] = map(n)(_ => ni())\n  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = offset\n    val N = n + offset\n    while(i < N) { f(i); i += 1 }\n  }\n  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = n - 1 + offset\n    while(i >= offset) { f(i); i -= 1 }\n  }\n\n  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n    val res = Array.ofDim[A](n)\n    rep(n)(i => res(i) = f(i))\n    res\n  }\n\n  implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {\n    // todo Orderingだとboxing発生するので自作Orderを用意したい\n    def maxByOpt[B: Ordering](f: A => B): Option[A] = {\n      if (as.nonEmpty) Some(as.maxBy(f)) else None\n    }\n\n    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {\n      val map = mutable.Map.empty[K, ArrayBuffer[A]]\n      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))\n      map\n    }\n\n    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n      var sum = num.zero\n      rep(as.length)(i => sum = num.plus(sum, f(as(i))))\n      sum\n    }\n\n    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n      limit(f, ixRange)(cmp.lt)\n    }\n\n    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {\n      limit(f, ixRange)(cmp.gt)\n    }\n\n    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {\n      var limA = as(ixRange.head)\n      var limB = f(limA)\n\n      for (i <- ixRange.tail) {\n        val a = as(i)\n        val b = f(a)\n        if (cmp(b, limB)) {\n          limA = a\n          limB = b\n        }\n      }\n      (limA, limB)\n    }\n  }\n\n  implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {\n    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {\n      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))\n    }\n  }\n}"}, {"source_code": "import scala.collection.mutable\n\nobject CE976B extends App {\n  readInt();\n  val string = readLine();\n  val charArray = string.toCharArray();\n  val map = mutable.Map[String, Int]()\n  for (i <- 0 to string.length - 2) {\n    val subString = string.substring(i, i + 2);\n    if (map.contains(subString)) {\n      val currentTime = map(subString) + 1\n      map += (subString -> currentTime)\n    }\n    else\n      map += (subString -> 1)\n  }\n  val maxTime = map.reduceLeft((a, b) => if (a._2 > b._2) a else b)\n  println(maxTime._1)\n\n  def sub(n: Int) = if (n % 10 == 0) n / 10 else n - 1;\n}\n"}, {"source_code": "\nimport scala.io.StdIn\n\nobject TwoGram extends App {\n\n  val l1 = StdIn.readLine()\n  val l2 = StdIn.readLine()\n  print(impl(l2))\n\n  def impl(st: String): String = {\n    val m = collection.mutable.Map[String, Int]().withDefaultValue(0)\n\n    for (i <- Range(0, st.length - 1)) {\n      m(st.charAt(i).toString + st.charAt(i + 1)) += 1\n    }\n\n    m.maxBy(_._2)._1\n  }\n}"}, {"source_code": "object B977 extends App {\n  type Base = String\n  type Pair = (Char, Char)\n  type Splitted = List[Pair]\n\n  val s: String = { readLine(); readLine() }\n\n  def answer0 = (s head, (s tail) head)\n  def splitted: Splitted = ((s tail) tail).foldLeft(List[(Char, Char)](answer0)) { (answer: List[(Char, Char)], i: Char) => \n    val (_, previous) = (answer).head\n    (previous, i) :: (answer)\n  }\n\n  def iterate(result: Map[Pair, Int], over: Splitted): Pair = {\n    over match {\n      case Nil =>\n        result\n          .toList\n          .maxBy{ p => p._2 }\n          ._1\n        \n      case h :: t =>\n        if (result.contains(h)) iterate(result + (h -> (result(h) + 1)), over tail)\n        else iterate(result + (h -> 1), over tail)\n    }\n  }\n\n  val r = iterate(Map.empty, splitted)\n  print(r._1 + \"\" + r._2)\n}"}, {"source_code": "object CF_379_Two_Gram extends App {\n\n  def createListGroup[T](\n      list: List[T],\n      accumList: List[(T, T)] = List[(T, T)]()): List[(T, T)] = {\n    list match {\n      case head :: tail if tail != Nil =>\n        createListGroup(tail, accumList :+ (head, tail.head))\n      case _ :: tail if tail == Nil => accumList\n      case Nil                      => accumList\n    }\n  }\n\n  val numOfChar = scala.io.StdIn.readLine\n  val string = createListGroup(scala.io.StdIn.readLine.toList)\n  println(\n    string\n      .map(x => x._1.toString + x._2.toString)\n      .groupBy(identity)\n      .mapValues(_.size)\n      .toSeq\n      .sortWith(_._2 > _._2)\n      .head\n      ._1)\n}"}, {"source_code": "object B extends App {\n  val n = scala.io.StdIn.readInt()\n  val s = scala.io.StdIn.readLine()\n\n  val a = Array.fill(65535)(0)\n  var m = -1\n  var j = -1\n\n  var p = s.head\n  for (c <- s.tail) {\n    val i = ((p.toByte - 65) << 8) + c.toByte - 65\n    a(i) += 1\n    if (a(i) > m) {\n      j = i\n      m = a(i)\n    }\n    p = c\n  }\n\n  println(s\"${((j >> 8) + 65).toChar}${((j & 0xFF) + 65).toChar}\")\n}\n"}, {"source_code": "\nobject problemA {\n    import java.io.{BufferedReader, FileInputStream, InputStreamReader}\n    import scala.collection.mutable.ArrayBuffer\n    import scala.collection.mutable\n    import scala.util.control.Breaks._\n    import scala.collection.JavaConverters._\n\n    val source = System.in\n    implicit val reader = new BufferedReader(new InputStreamReader(source))\n\n    def read()(implicit reader: BufferedReader): String = reader.readLine().split(\" \")(0)\n    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(\" \")\n    def readString()(implicit reader: BufferedReader): String = reader.readLine()\n\n    def main(args: Array[String]): Unit = {\n        val n = read().toInt\n        val s = readString()\n\n        val f = new mutable.HashMap[String, Int]()\n\n        for (i <- 0 until s.length - 1) {\n            val key = s.substring(i, i + 2)\n            val value = f.getOrElse(key, 0)\n            f.put(key, value + 1)\n        }\n\n        var rs = \"\"\n        var max = 0\n        f.foreach{case (k, v) => {\n            if (max < v) {\n                max = v\n                rs = k\n            }\n        }}\n        println(rs)\n    }\n}\n"}, {"source_code": "\nobject CF977A extends App {\n\n  import java.io.{PrintWriter}\n  import java.util.{Locale, Scanner}\n\n  val in  = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  def nextInt    = in.nextInt\n  def nextDouble = in.nextDouble\n  def nextString = in.next\n\n  def substract(n: Int, k: Int): Int = {\n    if (k == 0) n\n    else {\n      val updatedN = if (n % 10 == 0) n / 10 else n - 1\n      substract(updatedN, k - 1)\n    }\n  }\n\n  def sub(text: String, s: Int): Unit = {\n    text.substring(s, s + 1)\n  }\n\n  def solve: Unit = {\n    val n     = nextInt\n    val input = nextString\n\n    val res = for (i <- (0 until n - 1)) yield input.substring(i, i + 2)\n    val m   = res.groupBy(x => x).mapValues(_.size).maxBy(_._2)._1\n    out.println(m)\n  }\n\n  try {\n    solve\n  } catch {\n    case _: Exception => sys.exit(9999)\n  } finally {\n    out.flush\n    out.close\n  }\n}\n"}, {"source_code": "object Problem_977B {\n  //  Two-gram\n\n  def main(args: Array[String]) {\n    val scan = scala.io.StdIn\n    val len: Int = scan.readLine.toInt\n    val targetStr: String = scan.readLine()\n\n    val occurenceMap = targetStr.foldLeft(Map.empty[String, Int], ' ') {\n      case ((map: Map[String, Int], prevChar: Char), elem: Char) =>\n        if (prevChar != ' ') {\n          (map + (f\"$prevChar$elem\" -> (map.getOrElse(s\"$prevChar$elem\", 0) + 1)), elem)\n        }\n        else {\n          (map, elem)\n        }\n    }._1\n\n    println(occurenceMap.maxBy(_._2)._1)\n  }\n\n}\n"}], "negative_code": [], "src_uid": "e78005d4be93dbaa518f3b40cca84ab1"}
{"source_code": "object Main extends App {\n\tdef findMinMonth(array: Array[Int], poitner: Int, neededLength: Int, currentLength: Int): Int = {\n\t\tif (neededLength == 0) 0\n\t\telse if (poitner == array.size) -1\n\t\telse if (currentLength + array(poitner) >= neededLength) poitner + 1\n\t\telse findMinMonth(array, poitner + 1, neededLength, currentLength + array(poitner))\n\t}\n\n\tval neededLength = readLine.toInt\n\tval growPerMonthList = readLine.split(\" \").map(_.toInt).sortWith((a: Int, b: Int) => a > b)\n\tprintln(findMinMonth(growPerMonthList, 0, neededLength, 0))\n}", "positive_code": [{"source_code": "/*input\n45\n0 0 0 0 0 0 0 1 1 2 3 0\n*/\n\nimport java.util.Scanner\nimport scala.io.StdIn\n\nobject Solution {\n\tdef main(args: Array[String]): Unit = {\n\n\t\tval k = StdIn.readInt();\n\t\tval arr = StdIn.readLine().split(\" \").map( _.toInt ).sortWith( _ > _);\n\t\tif(arr.sum < k) println(-1)\n\t\telse{\n\t\t\tval out = arr.foldLeft(List(0,0)){(x: List[Int], y: Int) => {\n\n\t\t\t\t\tif(x(0) >= k) x else List(x(0)+y, x(1)+1)\n\t\t\t\t}\n\t\t\t}(1);\n\t\t\tprintln(out);\n\t\t}\n\n\t}\n\n}"}, {"source_code": "import java.io.BufferedReader\nimport java.io.IOException\nimport java.io.InputStreamReader\nimport java.io.PrintWriter\nimport java.util.StringTokenizer;\nimport java.util.Arrays\n\nobject Solver {\n\n    var st : StringTokenizer = null;\n    var in : BufferedReader = null;\n    var out : PrintWriter = null;\n\n    def main(args: Array[String]){\n        open();\n        solve();\n        close();\n    }\n\n    def open() {\n        in = new BufferedReader(new InputStreamReader(System.in));\n        out = new PrintWriter(System.out);\n    }\n\n    def nextToken() : String = {\n        while (st == null || !st.hasMoreTokens()) {\n            st = new StringTokenizer(in.readLine());\n        }\n        st.nextToken();\n    }\n\n    def nextInt() : Int = {\n        Integer.parseInt(nextToken());\n    }\n\n//    def nextLong() {\n//        return Long.parseLong(nextToken());\n//    }\n//\n//    def nextDouble() : Double = {\n//        Double.parseDouble(nextToken());\n//    }\n\n    def solve(){\n        var k:Int = nextInt;\n        var ar: Array[Int] = new Array[Int](12);\n        var sum: Int = 0;\n        for (i <- 0 to 11){\n            ar(i) = nextInt;\n            sum += ar(i);\n        }\n        \n        if (sum<k){\n            out.println(-1);\n            return;\n        }\n        \n        Arrays.sort(ar);        \n        var i:Int = 12;\n        while (k>0){\n            i-=1;\n            k -= ar(i);\n        }\n        \n        out.println(12-i);\n        return\n    }\n\n    def close() {\n        out.flush();\n        out.close();\n    }\n\n}"}, {"source_code": "object P149A extends App {\n  var k = readLine.toInt\n  val months = readLine.split(\" \").map(_.toInt).toList.sortWith(_ > _)\n  print(if (months.sum < k) -1\n  else months.takeWhile({(e) => if (k>0) {k -= e; true} else false }).length)\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val k = in.next().toInt\n  val data = in.next().split(\" \").map(_.toInt).sorted.reverse\n  var i = 0\n  var soFar = 0\n  if (data.sum < k)\n    println(-1)\n  else {\n    while (soFar < k) {\n      soFar += data(i)\n      i += 1\n    }\n    println(i)\n  }\n\n}\n"}, {"source_code": "object A149 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val Array(k) = readInts(1)\n    val months = readInts(12).sortBy(x => -x)\n    var size = 0\n    var i = 0\n    while(size < k && i < 12) {\n      size += months(i)\n      i += 1\n    }\n    if(size < k) {\n      println(\"-1\")\n    } else {\n      println(i)\n    }\n  }\n}"}, {"source_code": "\nobject tmp extends App {\n\n  import java.io._\n  import java.util.StringTokenizer\n\n  class MyScanner(br: BufferedReader) {\n    var st = new StringTokenizer(\"\")\n\n    def this(is: InputStream) = this(new BufferedReader(new InputStreamReader(is)))\n\n    private def next() = {\n\n      while (!st.hasMoreElements) {\n        st = new StringTokenizer(br.readLine())\n      }\n      st.nextToken()\n    }\n\n    def nextInt() = java.lang.Integer.parseInt(next())\n\n    def nextLong() = java.lang.Long.parseLong(next())\n\n    def nextLine() = br.readLine()\n  }\n\n  val sc = new MyScanner(System.in)\n  val n = sc.nextInt()\n  val a = (for (_ <- 0 until 12) yield sc.nextInt()).sorted.reverse\n  if (n == 0) {\n    println(0)\n    System.exit(0)\n  }\n  if (a.sum < n) {\n    println(-1)\n    System.exit(0)\n  }\n  var count = 0\n  val part = a.takeWhile(v => {val cond = count < n; count += v; cond})\n  println(part.length)\n\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P149A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val K = sc.nextInt\n  val g = List.fill(12)(sc.nextInt).sorted.reverse\n\n  def solve: Int = {\n    @tailrec\n    def loop(acc: Int, m: Int, gs: List[Int]): Int =\n      if (acc >= K) m\n      else gs match {\n        case Nil => -1\n        case x :: xs => loop(acc + x, m + 1, xs)\n      }\n    loop(0, 0, g)\n  }\n\n  out.println(solve)\n  out.close\n}\n"}, {"source_code": "import annotation.tailrec\nimport java.io._\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readInt = reader.readLine().toInt\n\n  val k = readInt\n  def ans = readInts.sortWith(_ > _).foldLeft(List(0)) {\n    case (l @ head :: _, x) => head + x :: l\n  }.filter(_ < k).size\n\n  def main(args: Array[String]) {\n    println((ans + 1) % 14 - 1)\n  }\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val k = readInt()\n    val a = readLine().split(\" \").map(_.toInt)\n    val r = a.sortWith(_ > _).foldLeft((0, 0)) { (t, a) => \n      if (t._1 >= k) t\n      else (t._1 + a, t._2 + 1)\n    }\n    if (r._1 < k) println(\"-1\")\n    else println(r._2)\n  }\n}"}, {"source_code": "import java.util.Scanner\n\nobject Amain {\n  def main(args: Array[String]) {\n    val sc = new Scanner(System.in)\n    val N = sc.nextInt\n    val cal = (for(i <- 1 to 12) yield sc.nextInt).sortWith(_ > _)\n    \n    // println(cal)\n    \n    val ret = for(i <- 0 to 12) yield {\n      (cal.take(i).sum, i)\n    }\n    \n    if(cal.sum < N) println(-1)\n    else println(ret.filter(_._1 >= N).head._2)\n  }\n}\n"}, {"source_code": "import scala.io.StdIn\n\nobject Main {\n  def main(args: Array[String]): Unit = {\n    val k = StdIn.readInt()\n    val a = StdIn.readLine().split(\" \").toList.map(_.toInt).sorted.reverse\n    println(a.inits.toList.reverse.find(_.sum >= k).map(_.length).getOrElse(-1))\n  }\n}\n"}], "negative_code": [{"source_code": "object Main extends App {\n\tdef findMinMonth(array: Array[Int], poitner: Int, neededLength: Int, currentLength: Int): Int = {\n\t\tval newLength = currentLength + array(poitner)\n\t\tif (newLength >= neededLength) poitner + 1\n\t\telse if (poitner == array.size) 0\n\t\telse findMinMonth(array, poitner + 1, neededLength, newLength)\n\t}\n\n\tval neededLength = readLine.toInt\n\tval growPerMonthList = readLine.split(\" \").map(_.toInt).sortWith((a: Int, b: Int) => a > b)\n\tprintln(findMinMonth(growPerMonthList, 0, neededLength, 0))\n}"}, {"source_code": "object Main extends App {\n\tdef findMinMonth(array: Array[Int], poitner: Int, neededLength: Int, currentLength: Int): Int = {\n\t\tif (neededLength == 0) 0\n\t\telse if (poitner == array.size) currentLength\n\t\telse if (currentLength + array(poitner) >= neededLength) poitner + 1\n\t\telse findMinMonth(array, poitner + 1, neededLength, currentLength + array(poitner))\n\t}\n\n\tval neededLength = readLine.toInt\n\tval growPerMonthList = readLine.split(\" \").map(_.toInt).sortWith((a: Int, b: Int) => a > b)\n\tprintln(findMinMonth(growPerMonthList, 0, neededLength, 0))\n}"}, {"source_code": "object P149A extends App {\n  var k = readLine.toInt\n  val months = readLine.split(\" \").map(_.toInt).toList.sortWith(_ > _)\n  print(months.takeWhile({(e) => if (k>=0) {k -= e; true} else false }).length)\n}"}, {"source_code": "object P149A extends App {\n  var k = readLine.toInt\n  val months = readLine.split(\" \").map(_.toInt).toList.sortWith(_ > _)\n  print(months.takeWhile({(e) => if (k>0) {k -= e; true} else false }).length)\n}"}, {"source_code": "object P149A extends App {\n  var k = readLine.toInt\n  val months = readLine.split(\" \").map(_.toInt).toList.sortWith(_ > _)\n  print(if (months.sum > k) -1\n  else months.takeWhile({(e) => if (k>0) {k -= e; true} else false }).length)\n}"}, {"source_code": "\nobject tmp extends App {\n\n  import java.io._\n  import java.util.StringTokenizer\n\n  class MyScanner(br: BufferedReader) {\n    var st = new StringTokenizer(\"\")\n\n    def this(is: InputStream) = this(new BufferedReader(new InputStreamReader(is)))\n\n    private def next() = {\n\n      while (!st.hasMoreElements) {\n        st = new StringTokenizer(br.readLine())\n      }\n      st.nextToken()\n    }\n\n    def nextInt() = java.lang.Integer.parseInt(next())\n\n    def nextLong() = java.lang.Long.parseLong(next())\n\n    def nextLine() = br.readLine()\n  }\n\n  val sc = new MyScanner(System.in)\n  val n = sc.nextInt()\n  val a = (for (_ <- 0 until 12) yield sc.nextInt()).sorted.reverse\n  if (n == 0) {\n    println(0)\n    System.exit(0)\n  }\n  if (a.sum < n) {\n    println(-1)\n    System.exit(0)\n  }\n  var count = 0\n  val part = a.takeWhile(v => {val cond = count < n; count += v; cond})\n  println(part)\n  println(part.length)\n\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val k = readInt()\n    val a = readLine().split(\" \").map(_.toInt)\n    val r = a.sortWith(_ > _).foldLeft((0, 0)) { (t, a) => \n      if (t._1 >= k) t\n      else (t._1 + a, t._2 + 1)\n    }\n    println(r._2)\n  }\n}"}, {"source_code": "import scala.io.StdIn\n\nobject Main {\n  def main(args: Array[String]): Unit = {\n    val k = StdIn.readInt()\n    val a = StdIn.readLine().split(\" \").toList.map(_.toInt).sorted.reverse\n    println(a.inits.toList.reverse.find(_.sum >= k).getOrElse(List.empty).length)\n  }\n}\n"}], "src_uid": "59dfa7a4988375febc5dccc27aca90a8"}
{"source_code": "import scala.io.StdIn._\n\nobject F extends App {\n    val n = readInt()\n    val xs = readLine().split(\" \").map(_.toInt)\n    if (n % 7 == 0) {\n        var mi = -1\n        xs.zipWithIndex.foreach({ case (x, i) =>\n            if ((i + 1) % 7 != 0 && (mi == -1 || xs(mi) > x)) mi = i else ()\n        })\n        println(mi + 1)\n    } else {\n        val mx = (xs.min - 1) / 6 * 6\n        var ys = xs.map(_ - mx)\n        var (i, d) = (0, 1)\n        while (d != 8) {\n            if (d == 7) d = 0 else {\n                ys(i) = ys(i) - 1\n                if (ys(i) == 0) d = 7 else ()\n            }\n            d += 1\n            i = (i + 1) % n\n        }\n        println(if (i == 0) n else i)\n    }\n}\n", "positive_code": [{"source_code": "import scala.io.StdIn._\n\nobject F extends App {\n    val n = readInt()\n    val xs = readLine().split(\" \").map(_.toInt)\n    if (n % 7 == 0) {\n        var mi = -1\n        xs.zipWithIndex.foreach({ case (x, i) =>\n            if ((i + 1) % 7 != 0 && (mi == -1 || xs(mi) > x)) mi = i else ()\n        })\n        println(mi + 1)\n    } else {\n        val mx = (xs.min - 1) / 6 * 6\n        var ys = xs.map(_ - mx)\n        var (i, d) = (0, 1)\n        while (d != 8) {\n            if (d == 7) d = 0 else {\n                ys(i) = ys(i) - 1\n                if (ys(i) == 0) d = 7 else ()\n            }\n            d += 1\n            i = (i + 1) % n\n        }\n        println(if (i == 0) n else i)\n    }\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject F extends App {\n    val n = readInt()\n    val xs = readLine().split(\" \").map(_.toInt)\n    if (n % 7 == 0) {\n        var mi = -1\n        xs.zipWithIndex.foreach({ case (x, i) =>\n            if ((i + 1) % 7 != 0 && (mi == -1 || xs(mi) > x)) mi = i else ()\n        })\n        println(mi + 1)\n    } else {\n        val mx = (xs.min - 1) / 6 * 6\n        var ys = xs.map(_ - mx)\n        var (i, d) = (0, 1)\n        while (d != 8) {\n            if (d == 7) d = 0 else {\n                ys(i) = ys(i) - 1\n                if (ys(i) == 0) d = 7 else ()\n            }\n            d += 1\n            i = (i + 1) % n\n        }\n        println(if (i == 0) n else i)\n    }\n}"}], "negative_code": [{"source_code": "import scala.io.StdIn._\n\nobject F extends App {\n    val n = readInt()\n    val a = readLine().split(\" \").map(_.toInt)\nvar mn = 0;\n                var i = 0;\n\t\twhile(i<n) {\n\t\t\tif (a(i) < a(mn)) {\n                                if (n%7!=0 || i%7!=6) {\n\t\t\t\t     mn = i;\n                                }\n\t\t\t}\n                        i+=1;\n\t\t}\n\n\t        var del = (a(mn) - 1) / 7 * 7;\n                i = 0;\n\t        while(i<n) {\n\t\t\ta(i) -= del;\n\n                        i+=1;\n\t\t}\n\t        var day = 0;\n\t\twhile (i<=n) {\n                        i = 0;\n\t\t\twhile(i<n) {\n\t\t\t        day+=1;\n\t\t\t\tif (day % 7 != 0) {\n\t\t\t\t\ta(i)-=1;\n\t\t\t\t}\n\t\t\t\tif (a(i) == 0) {\n                         \n                                    if (n%7!=0 || i%7!=6) {\n\t\t\t\t\tprintln(i + 1);\n\t\t\t\t\ti = n+5;\n                                    }\n\t\t\t\t}\n                                i += 1;\n\t\t\t}\n\t\t}\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject F extends App {\n    val n = readInt()\n    val a = readLine().split(\" \").map(_.toInt)\nvar mn = 0;\n                var i = 0;\n\t\twhile(i<n) {\n\t\t\tif (a(i) < a(mn) && (n%7!=0 || i%7!=6)) {\n\t\t\t\tmn = i;\n\t\t\t}\n                        i+=1;\n\t\t}\n\n\t        var del = (a(mn) - 1) / 7 * 7;\n                i = 0;\n\t        while(i<n) {\n\t\t\ta(i) -= del;\n\n                        i+=1;\n\t\t}\n\t        var day = 0;\n\t\twhile (i<=n) {\n                        i = 0;\n\t\t\twhile(i<n) {\n\t\t\t        day+=1;\n\t\t\t\tif (day % 7 != 0) {\n\t\t\t\t\ta(i)-=1;\n\t\t\t\t}\n\t\t\t\tif (a(i) == 0 && (i%7!=6 || n%7!=0)) {\n\t\t\t\t\tprintln(i + 1);\n\t\t\t\t\ti = n+5;\n\t\t\t\t}\n                                i += 1;\n\t\t\t}\n\t\t}\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject F extends App {\n    val n = readInt()\n    val a = readLine().split(\" \").map(_.toInt)\n  \tif (n % 7 == 0) {\n\t\tvar mn = 0;\n                var i = 0;\n\t\twhile(i<n) {\n\t\t\tif (i % 7 != 6 && a(i) < a(mn)) {\n\t\t\t\tmn = i;\n                        }\n                        i+=1;\n\t\t}\n\t\tprintln(mn+1);\n\t}\n\telse {\n\t\tvar mn = 0;\n                var i = 0;\n\t\twhile(i<n) {\n\t\t\tif (a(i) < a(mn)) {\n\t\t\t\tmn = i;\n\t\t\t}\n                        i+=1;\n\t\t}\n\t        var del = (a(mn) - 1) / 7 * 7;\n                i = 0;\n\t        while(i<n) {\n\t\t\ta(i) -= del;\n                        i+=1;\n\t\t}\n\t        var day = 0;\n\t\twhile (i<=n) {\n                        i = 0;\n\t\t\twhile(i<n) {\n\t\t\t        day+=1;\n\t\t\t\tif (day % 7 != 0) {\n\t\t\t\t\ta(i)-=1;\n\t\t\t\t}\n\t\t\t\tif (a(i) == 0) {\n\t\t\t\t\tprintln(i + 1);\n\t\t\t\t\ti = n+5;\n\t\t\t\t}\n                                i += 1;\n\t\t\t}\n\t\t}\n\t}\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject F extends App {\n    val n = readInt()\n    val a = readLine().split(\" \").map(_.toInt)\n    var mx = 2e9;\n    var d = 1;\n    var i = 0;\n    while(i<n) {\n        var x = a(i);\n\tvar l = 1.toLong;\n        var r = 2e9.toLong;\n\tvar pv = 0;\n        var nxt = 0;\n\tvar j = 1;\n        while (j<=21) {\n\t    if ((i + 1 + n*(j-1)) % 7 == 0) {\n\t\tif (pv > 0) {\n           \t\tnxt = j;\n                        j = 25;\n\t\t} else {\n\t\t        pv = j;\n                }\n\t    }\n            j += 1;\n\t}\n\twhile (l != r) {\n\t    var m = ((l + r) / 2).toInt;\n\t    var emptyC = 0;\n\t    if (m >= pv && pv > 0) {\n\t\temptyC = (m - pv) / (nxt - pv);\n\t\temptyC += 1;\n       \t    }\n\t    if (m - emptyC > x) {\n\t\tr = m.toLong;\n     \t    }\n            else {\n\t\tl = (m + 1).toLong;\n\t    }\n\t}\n\tif (l - 1 < mx) {\n \t    mx = (l - 1).toInt;\n\t    d = i + 1;\n\t}\n        i+=1;\n    }\n    println(d)\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject F extends App {\n    val n = readInt()\n    val a = readLine().split(\" \").map(_.toInt)\n    var mx = 4e9.toLong;\n    var d = 1;\n    var i = 0;\n    while(i<n) {\n        var x = a(i);\n\tvar l = 1.toLong;\n        var r = 4e9.toLong;\n\tvar pv = 0;\n        var nxt = 0;\n\tvar j = 1;\n        while (j<=21) {\n\t    if ((i + 1 + n*(j-1)) % 7 == 0) {\n\t\tif (pv > 0) {\n           \t\tnxt = j;\n                        j = 25;\n\t\t} else {\n\t\t        pv = j;\n                }\n\t    }\n            j += 1;\n\t}\n\twhile (l != r) {\n\t    var m = ((l + r) / 2+1e-5).toLong;\n\t    var emptyC = 0.toLong;\n\t    if (m >= pv && pv > 0) {\n\t\temptyC = ((m - pv) / (nxt - pv) + 1e-5).toLong;\n\t\temptyC += 1;\n       \t    }\n\t    if (m - emptyC > x) {\n\t\tr = m.toLong;\n     \t    }\n            else {\n\t\tl = (m + 1).toLong;\n\t    }\n\t}\n\tif (l - 1 < mx) {\n \t    mx = (l - 1).toInt;\n\t    d = i + 1;\n\t}\n        i+=1;\n    }\n    println(d)\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject F extends App {\n    val n = readInt()\n    val a = readLine().split(\" \").map(_.toInt)\n    var mx = 4e9.toLong;\n    var d = 1;\n    var i = 0;\n    while(i<n) {\n        var x = a(i);\n\tvar l = 1.toLong;\n        var r = 4e9.toLong;\n\tvar pv = 0;\n        var nxt = 0;\n\tvar j = 1;\n        while (j<=21) {\n\t    if ((i + 1 + n*(j-1)) % 7 == 0) {\n\t\tif (pv > 0) {\n           \t\tnxt = j;\n                        j = 25;\n\t\t} else {\n\t\t        pv = j;\n                }\n\t    }\n            j += 1;\n\t}\n\twhile (l != r) {\n\t    var m = ((l + r) / 2).toLong;\n\t    var emptyC = 0.toLong;\n\t    if (m >= pv && pv > 0) {\n\t\temptyC = (m - pv) / (nxt - pv);\n\t\temptyC += 1;\n       \t    }\n\t    if (m - emptyC > x) {\n\t\tr = m.toLong;\n     \t    }\n            else {\n\t\tl = (m + 1).toLong;\n\t    }\n\t}\n\tif (l - 1 < mx) {\n \t    mx = (l - 1).toInt;\n\t    d = i + 1;\n\t}\n        i+=1;\n    }\n    println(d)\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject F extends App {\n    val n = readInt()\n    val a = readLine().split(\" \").map(_.toInt)\n    var mx = 2e9;\n    var d = 1;\n    var i = 0;\n    while(i<n) {\n        var x = a(i);\n\tvar l = 1;\n        var r = (x*1.5).toInt;\n\tvar pv = 0;\n        var nxt = 0;\n\tvar j = 1;\n        while (j<=21) {\n\t    if ((i + 1 + n*(j-1)) % 7 == 0) {\n\t\tif (pv > 0) {\n           \t\tnxt = j;\n                        j = 25;\n\t\t} else {\n\t\t        pv = j;\n                }\n\t    }\n            j += 1;\n\t}\n\twhile (l != r) {\n\t    var m = ((l + r) / 2).toInt;\n\t    var emptyC = 0;\n\t    if (m >= pv && pv > 0) {\n\t\temptyC = (m - pv) / (nxt - pv);\n\t\temptyC += 1;\n       \t    }\n\t    if (m - emptyC > x) {\n\t\tr = m;\n     \t    }\n            else {\n\t\tl = m + 1;\n\t    }\n\t}\n\tif (l - 1 < mx) {\n \t    mx = l - 1;\n\t    d = i + 1;\n\t}\n        i+=1;\n    }\n    println(d)\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject F extends App {\n    val n = readInt()\n    val a = readLine().split(\" \").map(_.toInt)\n  \tif (n % 7 == 0) {\n\t\tvar mn = 0;\n                var i = 0;\n\t\twhile(i<n) {\n\t\t\tif (i % 7 == 6 && a(i) < a(mn)) {\n\t\t\t\tmn = i;\n                        }\n                        i+=1;\n\t\t}\n\t\tprintln(mn+1);\n\t}\n\telse {\n\t\tvar mn = 0;\n                var i = 0;\n\t\twhile(i<n) {\n\t\t\tif (a(i) < a(mn)) {\n\t\t\t\tmn = i;\n\t\t\t}\n                        i+=1;\n\t\t}\n\t        var del = (a(mn) - 1) / 7 * 7;\n                i = 0;\n\t        while(i<n) {\n\t\t\ta(i) -= del;\n                        i+=1;\n\t\t}\n\t        var day = 0;\n\t\twhile (i<=n) {\n                        i = 0;\n\t\t\twhile(i<n) {\n\t\t\t        day+=1;\n\t\t\t\tif (day % 7 != 0) {\n\t\t\t\t\ta(i)-=1;\n\t\t\t\t}\n\t\t\t\tif (a(i) == 0) {\n\t\t\t\t\tprintln(i + 1);\n\t\t\t\t\ti = n+5;\n\t\t\t\t}\n                                i += 1;\n\t\t\t}\n\t\t}\n\t}\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject F extends App {\n    val n = readInt()\n    val a = readLine().split(\" \").map(_.toInt)\n    var mx = 1e9;\n    var d = 1;\n    var i = 0;\n    while(i<n) {\n        var x = a(i);\n\tvar l = 1;\n        var r = 1e9;\n\tvar pv = 0;\n        var nxt = 0;\n\tvar j = 1;\n        while (j<=21) {\n\t    if ((i + 1 + n*(j-1)) % 7 == 0) {\n\t\tif (pv > 0) {\n           \t\tnxt = j;\n                        j = 25;\n\t\t} else {\n\t\t        pv = j;\n                }\n\t    }\n            j += 1;\n\t}\n\twhile (l != r) {\n\t    var m = ((l + r) / 2).toInt;\n\t    var emptyC = 0;\n\t    if (m >= pv && pv > 0) {\n\t\temptyC = (m - pv) / (nxt - pv);\n\t\temptyC += 1;\n       \t    }\n\t    if (m - emptyC > x) {\n\t\tr = m;\n     \t    }\n            else {\n\t\tl = m + 1;\n\t    }\n\t}\n\tif (l - 1 < mx) {\n \t    mx = l - 1;\n\t    d = i + 1;\n\t}\n        i+=1;\n    }\n    println(d)\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject F extends App {\n    val n = readInt()\n    val a = readLine().split(\" \").map(_.toInt)\n    var mx = 4e9.toLong;\n    var d = 1;\n    var i = 0;\n    while(i<n) {\n        var x = a(i);\n\tvar l = 1.toLong;\n        var r = 4e9.toLong;\n\tvar pv = 0;\n        var nxt = 0;\n\tvar j = 1;\n        while (j<=21) {\n\t    if ((i + 1 + n*(j-1)) % 7 == 0) {\n\t\tif (pv > 0) {\n           \t\tnxt = j;\n                        j = 25;\n\t\t} else {\n\t\t        pv = j;\n                }\n\t    }\n            j += 1;\n\t}\n\twhile (l != r) {\n\t    var m = ((l + r) / 2).toLong;\n\t    var emptyC = 0.toLong;\n\t    if (m >= pv && pv > 0) {\n\t\temptyC = ((m - pv) / (nxt - pv)).toLong;\n\t\temptyC += 1;\n       \t    }\n\t    if (m - emptyC > x) {\n\t\tr = m.toLong;\n     \t    }\n            else {\n\t\tl = (m + 1).toLong;\n\t    }\n\t}\n\tif (l - 1 < mx) {\n \t    mx = (l - 1).toInt;\n\t    d = i + 1;\n\t}\n        i+=1;\n    }\n    println(d)\n}"}], "src_uid": "8054dc5dd09d600d7fb8d9f5db4dcaca"}
{"source_code": "import java.util.StringTokenizer\n\nimport scala.collection.mutable.Queue\n\nobject _450A extends App {\n  var token = new StringTokenizer(\"\")\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n  val n = next.toInt\n  val m = next.toInt\n  val a = (1 to n).map(i => next.toInt).toArray\n\n  def f(q: Queue[Int]): Int = {\n    if (q.tail == Nil) q.head + 1\n    else {\n      val i = q.head\n      if (a(i) <= m) f(q.tail)\n      else {\n        a(i) = a(i) - m\n        f(q.tail :+ i)\n      }\n    }\n  }\n  println(f(Queue[Int]() ++ (0 until n)))\n}\n", "positive_code": [{"source_code": "import scala.annotation.tailrec\n\nobject Main extends App {\n  val sc = new java.util.Scanner(System.in)\n  val n,m = sc.nextInt\n  val input = List.fill(n)(sc.nextInt)\n\n  def solve( m: Int, input: List[Int] ): Int = {\n\n    @tailrec\n    def dist(children: List[(Int, Int)]): Int = {\n      children match {\n\n        case List(x) =>  // size == 1\n          x._2 + 1\n\n        case x :: xs =>\n          val diff = x._1 - m\n          if (diff <= 0)\n            dist(xs)\n          else\n            dist( ( (diff, x._2) :: xs.reverse ).reverse )\n      }\n    }\n\n    dist( input.zipWithIndex )\n  }\n\n  println( solve( m, input ) )\n}\n"}, {"source_code": "import scala.annotation.tailrec\nimport scala.collection.mutable.ListBuffer\n\nobject Main extends App {\n  val sc = new java.util.Scanner(System.in)\n  val n,m = sc.nextInt\n  val children = List.fill(n)(sc.nextInt).zipWithIndex\n\n  @tailrec\n  def dist(children: List[(Int,Int)]): Unit = {\n    children match {\n      case Nil =>\n      case List(x) => println(x._2 + 1)\n      case x::xs =>\n        val diff = x._1 - m\n        if( diff <= 0 )\n          dist(xs)\n        else\n          dist( xs :+ (diff, x._2) )\n    }\n  }\n\n  dist(children)\n}\n"}, {"source_code": "object HelloWorld{\n  def giveCandies(xs: List[(Int, Int)], m:Int, lastSatisfied:Int):Int = xs match {\n    case Nil => lastSatisfied\n    case x::xs => if (x._1<=m) giveCandies(xs, m, x._2) else giveCandies(xs++List((x._1-m, x._2)), m, lastSatisfied)\n  }\n  def main(args: Array[String]){\n    val in = new java.util.Scanner(System.in)\n    val n = in.nextInt\n    val m = in.nextInt\n    in.nextLine\n    val q = in.nextLine.split(\" \").map(_.toInt).zipWithIndex.toList\n    print(giveCandies(q, m, -1)+1)\n  }\n}"}, {"source_code": "\n\nimport java.io.PrintWriter\nimport java.util.Scanner\n\n/**\n * Created by arseny on 19.07.14.\n */\nobject A extends App {\n  val home = true\n  val in = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  def nextInt = in.nextInt\n  def nextLong = in.nextLong\n  def nextDouble = in.nextDouble\n  def nextString = in.next\n\n  def solve() = {\n    val n = nextInt\n    val m = nextInt\n    val a = new Array[Int](n)\n    for (i <- 0 until n) {\n      val t = nextInt\n      a(i) = t / m\n      if (t % m != 0) {\n       a(i) = a(i) + 1\n      }\n    }\n    //println(a.toList)\n    var max = 0\n    for (i <- 0 until n) {\n      if (a(i) >= a(max)) {\n        max = i\n      }\n    }\n    out.println(max + 1)\n  }\n\n  try {\n    solve()\n  } catch {\n    case _: Exception => sys.exit(9999)\n  } finally {\n    out.flush()\n    out.close()\n  }\n}\n\n"}, {"source_code": "import java.util.Scanner\n\n/**\n * Created by kshim on 25/07/2014.\n */\nobject CF257A extends App {\n  def Process(m:Int, a:Seq[Int]):Int = {\n    val dvd = a.map(v => math.ceil(v / m.toDouble).toInt)\n    var maxi = -1\n    var max = -1\n    for(i <- 0 until dvd.length){\n      if(dvd(i) >= max){\n        max = dvd(i)\n        maxi = i\n      }\n    }\n    maxi + 1\n  }\n  val in = new Scanner(System.in)\n  val n = in.nextInt()\n  val m = in.nextInt()\n  val ai = (1 to n).map(_=>in.nextInt())\n  println(Process(m,ai.toArray))\n}\n"}, {"source_code": "object A450 {\n\n  import IO._\n\n  def main(args: Array[String]): Unit = {\n    val Array(n, m) = readInts(2)\n    val in = readInts(n).zipWithIndex\n    val q = collection.mutable.Queue[(Int, Int)]()\n    in.foreach(q.enqueue(_))\n    while(q.size > 1) {\n      var (cand, pos) = q.dequeue()\n      cand -= m\n      if(cand > 0)\n        q.enqueue((cand, pos))\n    }\n    println(q.dequeue._2 + 1)\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "object Children {\n\n  def splitter(as: String) = as.split(\"\\\\s+\") match {\n    case Array(n, m) => List(n.toInt, m.toInt)\n    case arr: Array[String] => arr.map(_.toInt).toList\n  }\n\n  def solve(l: List[(Int, Int)], m: Int): Int = l match {\n    case h :: Nil => h._2\n    case h :: t if (h._1 <= m) => solve(t, m)\n    case h :: t => solve(t :+ (h._1 - m, h._2), m)\n  }\n\n  def main(args: Array[String]) {\n    val List(nmStr, asStr) = io.Source.stdin.getLines.take(2).toList\n    val List(n, m) = splitter(nmStr)\n    val as = splitter(asStr).zipWithIndex\n    println(solve(as, m) + 1)\n  }\n}\n\n"}, {"source_code": "/**\n * @author Oleg Arshinsky\n */\nobject A extends App {{\n\n  val Array(_, m) = readLine()\n    .split(\" \")\n    .map(_.toInt)\n\n  val as: Array[Int] = readLine()\n    .split(\" \")\n    .map(_.toInt)\n\n  val max: Int = as.max\n\n  val res: Int =\n    if (max > m) {val bs = as.map(a => (a.toDouble / m).ceil.toInt); bs.lastIndexOf(bs.max)+1}\n\n    else\n      as.length\n\n  println(res)\n\n}}\n\n"}, {"source_code": "object Main {\n  def main(args: Array[String]): Unit = {\n    val nm = io.StdIn.readLine().split(\" \").map(x => Integer.parseInt(x))\n    val nums = io.StdIn.readLine().split(\" \").map { x=>\n      val i = Integer.parseInt(x)\n      if  (i % nm(1) != 0) i/nm(1) + 1 else i/nm(1)\n    }\n    \n    def indexOfMax( maxIndex: Int, index: Int): Int = {\n      if (index < 0) maxIndex\n      else indexOfMax(if (nums(index) > nums(maxIndex)) index else maxIndex, index - 1)\n    }\n    \n    println(indexOfMax(nm(0)-1, nm(0)-1) + 1)\n  }\n}"}], "negative_code": [{"source_code": "\n\nimport java.io.PrintWriter\nimport java.util.Scanner\n\n/**\n * Created by arseny on 19.07.14.\n */\nobject A extends App {\n  val home = true\n  val in = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  def nextInt = in.nextInt\n  def nextLong = in.nextLong\n  def nextDouble = in.nextDouble\n  def nextString = in.next\n\n  def solve() = {\n    val n = nextInt\n    val m = nextInt\n    val a = new Array[Int](n)\n    for (i <- 0 until n) {\n       a(i) = Math.max(nextInt / m, 1)\n    }\n    var max = 0\n    for (i <- 0 until n) {\n      if (a(i) >= a(max)) {\n        max = i\n      }\n    }\n    out.println(max + 1)\n  }\n\n  try {\n    solve()\n  } catch {\n    case _: Exception => sys.exit(9999)\n  } finally {\n    out.flush()\n    out.close()\n  }\n}\n\n"}, {"source_code": "\n\nimport java.io.PrintWriter\nimport java.util.Scanner\n\n/**\n * Created by arseny on 19.07.14.\n */\nobject A extends App {\n  val home = true\n  val in = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  def nextInt = in.nextInt\n  def nextLong = in.nextLong\n  def nextDouble = in.nextDouble\n  def nextString = in.next\n\n  def solve() = {\n    val n = nextInt\n    val m = nextInt\n    val a = new Array[Int](n)\n    for (i <- 0 until n) {\n       a(i) = (nextInt) / m\n    }\n    var max = 0\n    for (i <- 0 until n) {\n      if (a(i) >= a(max)) {\n        max = i\n      }\n    }\n    out.println(max + 1)\n  }\n\n  try {\n    solve()\n  } catch {\n    case _: Exception => sys.exit(9999)\n  } finally {\n    out.flush()\n    out.close()\n  }\n}\n\n"}, {"source_code": "import java.util.Scanner\n\n/**\n * Created by kshim on 25/07/2014.\n */\nobject CF257A extends App {\n  def Process(m:Int, a:Seq[Int]):Int = {\n    val dvd = a.map(_ / m)\n    var maxi = -1\n    var max = -1\n    for(i <- 0 until dvd.length){\n      if(dvd(i) >= max){\n        max = dvd(i)\n        maxi = i\n      }\n    }\n    maxi + 1\n  }\n  val in = new Scanner(System.in)\n  val n = in.nextInt()\n  val m = in.nextInt()\n  val ai = (1 to n).map(_=>in.nextInt())\n  println(Process(m,ai))\n}\n"}, {"source_code": "/**\n * @author Oleg Arshinsky\n */\nobject A extends App {{\n\n  val Array(_, m) = readLine()\n    .split(\" \")\n    .map(_.toInt)\n\n  val as: Array[Int] = readLine()\n    .split(\" \")\n    .map(_.toInt)\n\n  val max: Int = as.max\n\n  val res: Int =\n    if (max > m) {val bs = as.map(_ / m); bs.lastIndexOf(bs.max)+1}\n\n    else\n      as.length\n\n  println(res)\n\n}}\n\n"}, {"source_code": "/**\n * @author Oleg Arshinsky\n */\nobject A extends App {{\n\n  val line: String = readLine()\n\n  val asString: String = readLine()\n  val as: Array[Int] = asString.split(\" \")\n    .map(_.toInt)\n\n  val of: Int = as.lastIndexOf(as.max)\n\n  println(of+1)\n\n}}\n\n"}, {"source_code": "/**\n * @author Oleg Arshinsky\n */\nobject A extends App {{\n\n  val line: String = readLine()\n\n  val asString: String = readLine()\n  val as: Array[Int] = asString.split(\" \")\n    .map(_.toInt)\n\n  val of: Int = as.lastIndexOf(as.max)\n\n  println(of)\n\n}}\n\n"}, {"source_code": "/**\n * @author Oleg Arshinsky\n */\nobject A extends App {{\n\n  val line: String = readLine()\n  val Array(n, m) = line.split(\" \").map(_.toInt)\n\n  val asString: String = readLine()\n  val as: Array[Int] = asString.split(\" \")\n    .map(_.toInt)\n\n  val max: Int = as.max\n  val of: Int =\n    if (max > m)\n      as.lastIndexOf(max)\n    else\n      as.length-1\n\n  println(of+1)\n\n}}\n\n"}, {"source_code": "object Main {\n  def main(args: Array[String]): Unit = {\n    val nm = io.StdIn.readLine().split(\" \").map(x => Integer.parseInt(x))\n    val nums = io.StdIn.readLine().split(\" \")\n    def indexOfMax( maxIndex: Int, index: Int): Int = {\n      if (index < 0) maxIndex\n      else indexOfMax(if (nums(index) > nums(maxIndex)) index else maxIndex, index - 1)\n    }\n    println(indexOfMax(nm(0)-1, nm(0)-1) + 1)\n  }\n}"}, {"source_code": "import scala.annotation.tailrec\n\nobject Main extends App {\n  val sc = new java.util.Scanner(System.in)\n  val n,m = sc.nextInt\n  val children = List.fill(n)(sc.nextInt).zipWithIndex\n\n  @tailrec\n  def dist(children: List[(Int,Int)]): Unit = {\n    children match {\n      case Nil =>\n      case List(x) => println(x._2 + 1)\n      case x::xs =>\n        val diff = x._1 - m\n        if( diff < 0 )\n          dist(xs)\n        else\n          dist( ( (diff, x._2) :: xs).reverse )\n    }\n  }\n\n  dist(children)\n}\n"}], "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c"}
{"source_code": "object P131C extends App {\n  \n  val Array(n,m,t) = readLine.split(\" \").map(_.toInt)\n  \n  def fac(a:BigInt,n:Int):BigInt = if (n<=2) a*math.max(n,1) else fac(a*n,n-1)\n  def mofn(m:Int,n:Int) = fac(1,n) / fac(1,n-m) / fac(1,m)\n  \n  val combs = (for(boys <- 4 to n; girls <- 1 to m) yield((boys,girls))) filter ((x) => x._1 + x._2 == t)\n  \n  println(combs.map((x) => mofn(x._1,n) * mofn(x._2,m)).sum)\n  \n\n}", "positive_code": [{"source_code": "object P131C extends App {\n  val Array(n,m,t) = readLine.split(\" \").map(_.toInt)\n  def f(a:BigInt, n:Int):BigInt = if (n<=2) a*math.max(n,1) else f(a*n, n-1)\n  def m(m:Int, n:Int) = f(1,n)/f(1,n-m)/f(1,m)\n  val c = (for(b <- 4 to n; g <- 1 to m) yield((b,g))) filter ((x)=>x._1+x._2==t)\n  println(c.map((x) => m(x._1,n) * m(x._2,m)).sum)\n}"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val arr@Array(n, m, t) = in.next().split(' ').map(_.toInt)\n  val max = arr.max\n  val binom = Array.ofDim[Long](max + 1, max + 1)\n  (0 to max).foreach { i =>\n    binom(i)(0) = 1\n    (1 to i).foreach {j =>\n      binom(i)(j) = binom(i - 1)(j) + binom(i - 1)(j - 1)\n    }\n  }\n//  println(binom.map(_.mkString(\" \")).mkString(\"\\n\"))\n\n  println((1 to t - 4).foldLeft(0l) {\n    case(sum, i) =>\n      sum + binom(m)(i) * binom(n)(t - i)\n  })\n}\n"}, {"source_code": "\nobject Main {\n\n    def mkComb(n:Int) = {\n        val a = Array.ofDim[Long](n, n)\n        for (i <- 0 until n) {\n            a(i)(0) = 1L\n            a(i)(i) = 1L\n            for (j <- 1 until i)\n                a(i)(j) = a(i-1)(j) + a(i-1)(j-1)\n        }\n        a\n    }\n\n    def main(args: Array[String]) {\n        val comb = mkComb(31)\n        val n = nextInt()\n        val m = nextInt()\n        val actors = nextInt()\n        val ans = for ( boys <- 0 to actors;\n                        girls = actors - boys\n                        if boys >= 4 && boys <= n\n                        if girls >= 1 && girls <= m\n                      ) yield (comb(n)(boys) * comb(m)(girls))\n        println(ans.sum)\n    }\n\n    val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));\n    var st = new java.util.StringTokenizer(\"\");\n\n    def next() = {\n        while (!st.hasMoreTokens())\n            st = new java.util.StringTokenizer(in.readLine());\n        st.nextToken();\n    }\n\n    def nextInt() = java.lang.Integer.parseInt(next());\n    def nextDouble() = java.lang.Double.parseDouble(next());\n    def nextLong() = java.lang.Long.parseLong(next());\n}\n"}, {"source_code": "object C131 {\n\tdef fact(t: Int): BigInt = if (t <= 1) BigInt(1) else t * fact(t - 1)\n\timplicit def implfact(t: Int) = new { def ! = fact(t)}\n\n\tdef c(n: Int, k: Int): BigInt = (n!)/((k!) * ((n - k)!))\n\n\tdef main(args: Array[String]) {\n\t\tval s = readLine.split(\" \")\n\t\tval n = Integer.parseInt(s(0))\n\t\tval m = Integer.parseInt(s(1))\n\t\tval t = Integer.parseInt(s(2))\n\t\tvar res = BigInt(0)\n\t\tfor (i <- 4 to n)\n\t\t\tfor (j <- 1 to m)\n\t\t\t\tif (i + j == t)\n\t\t\t\t\tres += c(n, i) * c(m, j)\n\t\tprintln(res)\n\t}\n}"}, {"source_code": "object Main {\n  val cache: Array[Array[Long]] = (1 to 61).map(_ => (1L to 61L).toArray).toArray\n  for{\n    i <- 0 to 60\n    j <- 0 to 60\n  } {\n    (i, j) match {\n      case (n, 0) => cache(n)(0) = 1\n      case (0, k) => cache(0)(k) = 0\n      case (n, k) => cache(n)(k) = cache(n - 1)(k - 1) + cache(n - 1)(k)\n    }\n  }\n\n  def main(args: Array[String]) {\n    val Array(n, m, k) = readLine().split(\" \").map(_.toInt)\n    val sum = (4 to n.min(k - 1)).map(i => cache(n)(i) * cache(m)(k - i)).sum\n    println(sum)\n  }\n}"}], "negative_code": [{"source_code": "import scala.io.Source\n\nobject Solution extends App {\n\n  def factorial(n: Int) = (1 to n).foldLeft(1l) { case(acc, i) => acc * i }\n\n  def combinations(k: Int, n: Int) = factorial(n) / (factorial(k) * factorial(n - k))\n\n\n  val in = Source.stdin.getLines()\n  val Array(n, m, t) = in.next().split(' ').map(_.toInt)\n  println((1 to t - 4).foldLeft(0l) {\n    case(sum, i) => sum + combinations(i, m) * combinations(t - i, n)\n  })\n}\n"}], "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8"}
{"source_code": "import scala.io.StdIn._\n\nobject B extends App {\n  val Array(n) = readLine().split(\" \").map(_.toInt)\n\n  val M = 1000000007\n\n  def countMod(base: Int, power: Int): Long = {\n    var curr: Long = base\n    for (i <- 2 to power) {\n      curr *= base\n      if (curr > M) curr %= M\n    }\n    curr\n  }\n\n//  def countMod2(base: Int, power: Int): Long = {\n//    BigInt(base).modPow(power, M).toLong\n//  }\n\n  val answer = countMod(27, n) - countMod(7, n)\n  println(if (answer < 0) M + answer else answer)\n\n}\n", "positive_code": [{"source_code": "/**\n * @author netman\n */\n\n\nimport java.io._\nimport scala._\nimport scala.Array._\nimport java.util.ArrayList\nimport scala.collection.mutable._\nimport java.util.StringTokenizer\n\n\nobject HelloWorld {\n\n  class InputReader(reader: BufferedReader) {\n    \n    var tokenizer: StringTokenizer = null;\n    \n    def this(stream: InputStream) = {\n      this(new BufferedReader(new InputStreamReader(stream), (1 << 20)));\n    }\n    \n    def this(f: File) = {\n      this(new BufferedReader(new FileReader(f), (1 << 20)));\n    }\n    \n    def next(): String = {\n      while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n        tokenizer = new StringTokenizer(reader.readLine());\n      }\n      return tokenizer.nextToken();\n    }\n    \n    def nextInt(): Int = next().toInt\n  \n    def nextDouble(): Double = next().toDouble\n    \n    def close() = reader.close();\n  }\n  \n  class OutputWriter(writer: PrintWriter) {\n    def this(stream: OutputStream) {\n      this(new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream))));\n    }\n    \n    def this(f: File) = {\n      this(new PrintWriter(new BufferedWriter(new FileWriter(f))));\n    }\n    \n    def print(x: Any) = writer.print(x);\n    \n    def println(x: Any) = writer.println(x);\n    \n    def close() = writer.close();\n  }\n  \n  \n  val in = new InputReader(System.in)\n  val out = new OutputWriter(System.out)\n  \n  val P = 1000 * 1000 * 1000L + 7\n  \n  def main(args: Array[String]): Unit = {  \n    val n = in.nextInt\n    \n    var f = new Array[Long](2)\n    var fn = new Array[Long](2)\n    \n    f(0) = 1\n    \n    val coef = 7L\n    val all = 3 * 3 * 3L\n    \n    for (i <- 0 until n) {\n      fn(0) = f(0) * coef\n      fn(1) = f(1) * all + f(0) * (all - coef)\n      fn(0) %= P\n      fn(1) %= P\n      var tmp = f\n      f = fn\n      fn = tmp\n    }\n    \n    out.println(f(1))\n    \n    out.close\n  }\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n\n  val n = in.next().toInt\n  var ans = (BigInt(3).pow(3 * n) - BigInt(7).pow(n)) % 1000000007\n  println(ans.toLong)\n}\n"}], "negative_code": [{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n\n  val n = in.next().toLong\n  println((Math.pow(3, 3 * n) - Math.pow(7, n)).toLong % 1000000007)\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject B extends App {\n  val Array(n) = readLine().split(\" \").map(_.toInt)\n\n  val M = 1000000007\n\n  def countMod(base: Int, power: Int): Long = {\n    var curr: Long = base\n    for (i <- 2 to power) {\n      curr *= base\n      if (curr > M) curr %= M\n    }\n    curr\n  }\n\n  println(countMod(27, n) - countMod(7, n))\n\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject B extends App {\n  val Array(n) = readLine().split(\" \").map(_.toInt)\n\n  val M = 1000000007\n\n  def countMod(base: Int, power: Int): Long = {\n    var curr: Long = base\n    for (i <- 2 to power) {\n      curr *= base\n      if (curr > M) curr %= M\n    }\n    curr\n  }\n\n  val answer = countMod(27, n) - countMod(7, n)\n  println(if (answer < 0) M - answer else answer)\n\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject B extends App {\n  val Array(n) = readLine().split(\" \").map(_.toInt)\n\n  val M = 1000000007\n\n  def countMod(base: Int, power: Int): Long = {\n    var curr: Long = base\n    for (i <- 2 to power) {\n      curr *= base\n      if (curr > M) curr %= M\n    }\n    curr\n  }\n\n  def countMod2(base: Int, power: Int): Long = {\n    BigInt(base).modPow(power, M).toLong\n  }\n\n\n  val answer = countMod2(27, n) - countMod2(7, n)\n  println(if (answer < 0) M - answer else answer)\n\n}\n"}], "src_uid": "eae87ec16c284f324d86b7e65fda093c"}
{"source_code": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn._\n\nobject Main extends App {\n  readLine()\n  val a = readLine().split(\"0\", -1)\n  var res = \"\"\n  a.foreach(x => res += x.length)\n  println(res)\n}\n", "positive_code": [{"source_code": "object Main extends App {\n  val n = io.StdIn.readInt()\n  var s: String = io.StdIn.readLine()\n\n  var result = \"\"\n  while(!s.isEmpty){\n    if (s.head == '0') s = s.tail\n    val (head, tail) = s.span(_ == '1')\n    result += head.length.toString\n    s = tail\n  }\n  println(result)\n}"}, {"source_code": "object Main extends App {\n  scala.io.StdIn.readLine()\n  print(scala.io.StdIn.readLine().split(\"0\", -1).map(_.length).mkString(\"\"))\n}"}], "negative_code": [{"source_code": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn._\n\nobject Main extends App {\n  readLine()\n  val a = readLine().split('0')\n  var res = \"\"\n  a.foreach(x => res += x.length)\n  println(res)\n}\n"}, {"source_code": "object Main extends App {\n  scala.io.StdIn.readLine()\n  print(scala.io.StdIn.readLine().split(\"0\").map(_.length).mkString(\"\"))\n}"}], "src_uid": "a4b3da4cb9b6a7ed0a33a862e940cafa"}
{"source_code": "object A586 {\n\n  import IO._\n\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    val in = readInts(n).dropWhile(_ == 0).reverse.dropWhile(_ == 0).reverse\n    var res = 0\n    var curr = 0\n    for(i <- in.indices) {\n      if(in(i) == 0) {\n        curr += 1\n        res += 1\n      } else {\n        res += 1\n        if(curr > 1)\n          res -= curr\n        curr = 0\n      }\n    }\n    println(res)\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n", "positive_code": [{"source_code": "\nimport java.io._\n\n//32A, 586A\nobject A_AlenaSchedule {\n  \n  def main(args: Array[String]): Unit = {\n    val bis = new BufferedInputStream(System.in);\n    val br = new BufferedReader(new InputStreamReader(bis));\n\n    val number = br.readLine().trim().toInt\n    val pairsSrc = br.readLine().trim().split(\" \")\n    \n//    val number = 5\n//    val pairsSrc = \"0 1 0 1 1\".split(\" \")\n    \n//    val number = 7\n//    val pairsSrc = \"1 0 1 0 0 1 0\".split(\" \")\n    \n    \n    var pairs = List[Int]()\n    var break = true\n    var breakCandidate = false;\n    \n    for (i <- 0 until number) {\n      val value = pairsSrc(i).toInt \n      if (breakCandidate && value == 0) {\n        break = true\n        breakCandidate = false\n      } else if (break && value == 0) {\n        //skip\n      } else if (value == 1) {\n        break = false\n        if (breakCandidate) {\n          pairs = 0 :: pairs\n          breakCandidate = false\n        }\n        pairs = value :: pairs\n      } else if (!break && value == 0) {\n        if(!breakCandidate) {\n          breakCandidate = true\n        } \n      } \n    }\n    \n    println(pairs.size)\n\n  }\n}\n"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val n = in.next().toInt\n  val data = in.next().split(\" \").map(_.toInt).dropWhile(_ == 0).reverse.dropWhile(_ == 0).reverse\n  val res = data.foldLeft((0, 0)){\n    case((soFar, zeros), 1) if zeros < 2 => (soFar + zeros + 1, 0)\n    case((soFar, zeros), 1) => (soFar + 1, 0)\n    case((soFar, zeros), 0) => (soFar, zeros + 1)\n  }\n\n  println(res._1)\n\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject A extends App {\n  readInt()\n\n  val pairs = readLine().split(\" \").map(_.toInt).dropWhile(_ == 0).reverse.dropWhile(_ == 0)\n\n  var lastlast = 1\n  var last = 1\n  var zeros = 0\n  for (p <- pairs) {\n    if (p == 0) {\n      if (last == 0 && lastlast == 0) zeros += 1\n      else if (last == 0) zeros += 2\n    }\n\n    lastlast = last\n    last = p\n  }\n\n  println(pairs.length - zeros)\n}\n"}], "negative_code": [], "src_uid": "2896aadda9e7a317d33315f91d1ca64d"}
{"source_code": "import scala.collection._\n\nobject B extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(n, k) = readInts(2)\n\n  var res = 0L\n\n  val lim = math.min(k, n / 2)\n  for (i <- 1 to lim) {\n    val x = n - 2 * i\n    res += 2 * x + 1\n  }\n\n  println(res)\n}\n", "positive_code": [{"source_code": "import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._\n\nobject _645B extends CodeForcesApp {\n  override def apply(io: IO) = {\n    val n, k = io[Long]\n    io += solve(n, k, 0)\n  }\n\n  @tailrec\n  def solve(n: Long, k: Long, acc: Long): Long = {\n    //debug(n, k)\n    (n, k) match {\n      case (_, 0) => acc\n      case (1, _) | (0, _) => acc\n      case _ =>  solve(n - 2, k - 1, acc + (n - 2) + (n - 1))\n    }\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\nobject Utils {\n  import scala.collection.mutable, mutable.{Map => Dict}\n  implicit class GenericExtensions[A](val a: A) extends AnyVal {\n    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a\n  }\n  implicit class TraversableExtensions[A](val t: Traversable[A]) extends AnyVal {\n    def onlyElement: A = t.head.ensuring(t.size == 1)\n    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)\n    def duplicates: Traversable[A] = {\n      val elems = mutable.Set.empty[A]\n      t collect {case i if !elems.add(i) => i}\n    }\n    def zipWith[B](f: A => B): Traversable[(A, B)] = t map {i => i -> f(i)}\n    def mapTo[B](f: A => B): Map[A, B] = zipWith(f).toUniqueMap\n    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)\n    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}\n    def toMutableMultiSet: Dict[A, Int] = {\n      val c = map[A] to 0\n      t.foreach(i => c(i) += 1)\n      c\n    }\n    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap\n  }\n  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)\n  }\n  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)\n  }\n  implicit class IndexedSeqExtensions[A](val s: IndexedSeq[A]) extends AnyVal {\n    def withOffset(offset: Int): IndexedSeq[A] = Iterator.fill(offset)(null.asInstanceOf[A]) ++: s\n  }\n  implicit class PairsExtensions[A, B](val t: Traversable[(A, B)]) extends AnyVal {\n    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_._1).mapValues(_._2)\n    def toMultiMap: Map[A, Traversable[B]] = t.groupBy(_._1).mapValues(_.map(_._2))\n    def swap: Traversable[(B, A)] = t.map(_.swap)\n  }\n  implicit class MapExtensions[K, V](val m: Map[K, V]) extends AnyVal {\n    def invert: Map[V, Set[K]] = m.swap.toMultiMap.mapValues(_.toSet)\n    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}\n  }\n  implicit class LongExtensions(val x: Long) extends AnyVal {\n    def bitCount: Int = java.lang.Long.bitCount(x)\n  }\n  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {\n    import Numeric.Implicits._\n    def ^^(i: Int): A = if (i == 0) n.one else {\n      val h = x ^^ (i/2)\n      if (i%2 == 0) h * h else h * h * x\n    }\n    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)\n    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students.indexOf(\"Greg\").whenNegative Int.MaxValue\n  }\n  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {\n    import scala.collection.immutable.NumericRange, Integral.Implicits._\n    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x\n    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(n.min(x, y), n.max(x, y), n.one)\n  }\n  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)\n  def  asc[A](implicit order: Ordering[A]): Ordering[A] = order\n  def map[K] = new {\n    def to[V](default: V): Dict[K, V] = Dict.empty[K, V] withDefaultValue default\n  }\n  def memoize[I] = new {\n    def apply[O](f: I => O): I => O = new mutable.HashMap[I, O]() {\n      override def apply(key: I) = getOrElseUpdate(key, f(key))\n    }\n  }\n  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None\n  def repeat(n: Int)(f: => Unit): Unit = (1 to n).foreach(_ => f)\n  val mod: Int = (1e9 + 7).toInt\n}\n/***********************************[Scala I/O]*********************************************/\nimport Utils._, java.io._, java.util.StringTokenizer, scala.collection.generic.CanBuild\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends PrintWriter(out, true) with Iterator[String] {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    if (tokenizers.nonEmpty) Some(tokenizers.head) else None\n  }\n\n  def apply[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def apply[C[_], A: IO.Read](n: Int)(implicit builder: CanBuild[A, C[A]]): C[A] = (builder() ++= Iterator.fill(n)(apply)).result()\n\n  def till(delim: String): String = tokenizer().get.nextToken(delim)\n  def tillEndOfLine(): String = till(\"\\n\\r\")\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  var separator = \" \"\n  private[this] var isNewLine = true\n\n  def +=[A](x: A)(implicit write: IO.Write[A]): this.type = {\n    write(this)(x)\n    this\n  }\n  def appendNewLine(): this.type = {\n    println()\n    this\n  }\n\n  override def print(obj: Any) = {\n    if (isNewLine) isNewLine = false else super.print(separator)\n    super.print(obj)\n  }\n  override def println() = if (!isNewLine) {\n    super.println()\n    isNewLine = true\n  }\n  override def close() = {\n    flush()\n    in.close()\n    super.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: CanBuild[A, C[A]]): Read[C[A]]            = new Read(r => r[C, A](r[Int]))\n    implicit val string                                                  : Read[String]          = new Read(_.next())\n    implicit val char                                                    : Read[Char]            = string.map(_.toTraversable.onlyElement)\n    implicit val boolean                                                 : Read[Boolean]         = string.map(_.toBoolean)\n    implicit val int                                                     : Read[Int]             = string.map(_.toInt)\n    implicit val long                                                    : Read[Long]            = string.map(_.toLong)\n    implicit val bigInt                                                  : Read[BigInt]          = string.map(BigInt(_))\n    implicit val double                                                  : Read[Double]          = string.map(_.toDouble)\n    implicit val bigDecimal                                              : Read[BigDecimal]      = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                                : Read[(A, B)]          = new Read(r => (r[A], r[B]))\n    implicit def tuple3[A: Read, B: Read, C: Read]                       : Read[(A, B, C)]       = new Read(r => (r[A], r[B], r[C]))\n    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]              : Read[(A, B, C, D)]    = new Read(r => (r[A], r[B], r[C], r[D]))\n    implicit def tuple5[A: Read, B: Read, C: Read, D: Read, E: Read]     : Read[(A, B, C, D, E)] = new Read(r => (r[A], r[B], r[C], r[D], r[E]))\n  }\n  class Write[-A] {\n    def apply(out: PrintWriter)(x: A): Unit = out.print(x)\n  }\n  trait DefaultWrite {\n    implicit def any[A]: Write[A] = new Write[A]\n  }\n  object Write extends DefaultWrite {\n    def apply[A](f: A => String) = new Write[A] {\n      override def apply(out: PrintWriter)(x: A) = out.print(f(x))\n    }\n    implicit def iterable[A](implicit write: Write[A]): Write[Traversable[A]] = new Write[Traversable[A]] {\n      override def apply(out: PrintWriter)(xs: Traversable[A]) = {\n        xs foreach write(out)\n        out.println()\n      }\n    }\n  }\n}\n\n"}], "negative_code": [], "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0"}
{"source_code": "object Main extends App{\n  val in= readLine\n  val n =in.toInt\n  if(List(4,7,44,47,74,77,444,447,474,477,744,747,774,777).exists(t => n % t ==0)) \n    println(\"YES\")else println(\"NO\")\n}", "positive_code": [{"source_code": "object Divider{\n\n  def main(args: Array[String]): Unit = {\n    val n = readInt()\n\n    val list = List(4,7,47,74,444,447,474,477,744,774,747,777)\n\n    if(list.contains(n) || list.exists(x => n % x == 0) ) println(\"YES\") else print(\"NO\")\n  }\n}"}, {"source_code": "object One22A extends App {\n\n\timport java.io.PrintWriter\n\timport java.util.Scanner\n\n\tval in = new Scanner(System.in)\n\tval out = new PrintWriter(System.out)\n\n\tval n = in.nextInt\n\n\tlucky(n) match {\n\t\tcase true => yes\n\t\tcase false =>\n\t\t\t(4 to n - 1).exists(lucky) match {\n\t\t\t\tcase true => yes\n\t\t\t\tcase false => no\n\t\t\t}\n\t}\n\n\tin.close()\n\tout.close()\n\n\tdef yes = out.println(\"YES\")\n\tdef no = out.println(\"NO\")\n\tdef lucky(str: Int) = n % str == 0 && str.toString.forall(x => x == '4' || x == '7')\n\n}"}, {"source_code": "object CF0122A extends App {\n\n  val l = List(4, 7, 47, 74, 444, 447, 474, 744, 774, 747, 777)\n\n  def del(v: Int): Boolean = {\n\n    var t = false\n\n    l.foreach(n => {\n      if (v%n == 0) {\n        t = true\n      }\n    })\n\n    t\n  }\n\n  val str = readLine()\n  val value = str.toInt\n  if (value % 4 == 0 || value % 7 == 0 || del(value)) {\n    println(\"YES\")\n  } else {\n    val status = str.getBytes.forall(b => {\n      b == '4' || b == '7'\n    })\n\n    if (status) {\n      println(\"YES\")\n    } else {\n      println(\"NO\")\n    }\n  }\n\n}\n"}, {"source_code": "import scala.io.StdIn\n\nobject Task {\n\n  def main(args: Array[String]): Unit = {\n\n    val x: Int = StdIn.readInt()\n    if (solve(x)) {\n      println(\"YES\")\n    }\n    else {\n      println(\"NO\")\n    }\n\n  }\n\n  private def solve(x: Int): Boolean = {\n\n    val lucky: Array[Int] = Array(4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777)\n    for (l <- lucky) {\n      if (x % l == 0) {\n        return true\n      }\n    }\n    return false\n\n  }\n\n}\n"}, {"source_code": "import scala.collection.immutable\n\nobject Hello extends App {\n\n  import scala.io.StdIn._\n\n  val k = readInt()\n\n  def countNums(n: Int): Int = n.toString.length\n\n  def permutationsWithRepetitions[T](input : List[T], n : Int) : List[List[T]] = {\n    require(input.nonEmpty && n > 0)\n    n match {\n      case 1 => for (el <- input) yield List(el)\n      case _ => for (el <- input; perm <- permutationsWithRepetitions(input, n - 1)) yield el :: perm\n    }\n  }\n\n  def allPermutationsWithRepetitions[T](input : List[T], n : Int, result: List[List[List[T]]]): List[List[List[T]]] =\n    if (n == 0) result\n    else allPermutationsWithRepetitions(input, n - 1, result :+ permutationsWithRepetitions(input, n))\n\n  val nums: immutable.Seq[Int] = allPermutationsWithRepetitions(List(4, 7), countNums(k), List()).flatten.map(_.mkString(\"\")).map(Integer.parseInt)\n\n  if (nums.exists(k % _ == 0) || nums.contains(k)) println(\"YES\") else println(\"NO\")\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject HappyNum extends App {\n  val num = readInt\n  var ok = false\n\n  val list = List(4, 7, 44, 47, 74, 77, 444, 447, 477, 474, 744, 747, 774, 777)\n\n  if (list.contains(num)) {\n    ok = true\n  }else {\n    for(i <- list){\n      if (num % i == 0) ok = true\n    }\n  }\n\n  if (ok) print(\"YES\")\n  else print(\"NO\")\n\n}\n"}, {"source_code": "object a {\n\tdef main(args: Array[String]) {\n\t    val a = scala.io.StdIn.readInt()\n        var ans = List(4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777).\n            map(arg => a%arg).\n\t        exists(arg => arg == 0)\n\n        print(if (ans) \"YES\" else \"NO\")\n\t}\n}"}, {"source_code": "import scala.io.StdIn\nimport scala.util.control.Breaks\n\n/**\n  * @author traff\n  */\n\nobject Main extends App {\n  val n = StdIn.readLine().toInt\n\n  Breaks.breakable {\n    for (i <- 2 to n) {\n      if (n % i == 0 && !i.toString.exists(!\"47\".contains(_))) {\n        println(\"YES\")\n        Breaks.break()\n      }\n    }\n    println(\"NO\")\n  }\n}\n\n"}, {"source_code": "object Solution extends App{\n  val in = scala.io.Source.stdin.getLines()\n  val n = in.next().toInt\n  if (List(4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777).exists(t => n % t == 0)) \n    println(\"YES\") else println(\"NO\")\n}"}, {"source_code": "import scala.collection.mutable.ArrayBuffer\n\nobject Main {\n\n\n  def generateLuckyMumbers(buf: ArrayBuffer[Int], maxValue: Int, currentValue: Int): Unit = {\n    if (currentValue <= maxValue) {\n      buf.append(currentValue)\n      generateLuckyMumbers(buf, maxValue, currentValue * 10 + 4)\n      generateLuckyMumbers(buf, maxValue, currentValue * 10 + 7)\n    }\n  }\n\n\n  def main(args: Array[String]) {\n    val std = scala.io.StdIn\n    val number = std.readLine().toInt\n\n    val luckyNumbers = ArrayBuffer.empty[Int]\n    generateLuckyMumbers(luckyNumbers, number, 4)\n    generateLuckyMumbers(luckyNumbers, number, 7)\n    val result = luckyNumbers.exists(x => number % x == 0)\n    if (result) {\n      println(\"YES\")\n    }\n    else {\n      println(\"NO\")\n    }\n  }\n}"}, {"source_code": "import scala.io.StdIn\n\n/**\n * Created by richard on 2015/6/10.\n */\nobject cf112a {\n  def main(args: Array[String]): Unit = {\n    val num = Array(4,7,47,74,447,474,477,744,747,774,777)\n    val n = StdIn.readInt()\n    println(if (num.exists(n%_==0)) \"YES\" else \"NO\")\n  }\n}\n"}, {"source_code": "object A122 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val Array(num) = readBigs(1)\n    val lucky = Array(\"4\", \"7\", \"44\", \"47\", \"74\", \"77\", \"444\", \"447\", \"474\", \"477\", \"744\", \"747\", \"774\", \"777\").map(BigInt.apply)\n    if(lucky.exists{n => (num % n) == 0}) {\n      println(\"YES\")\n    } else {\n      println(\"NO\")\n    }\n  }\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P122A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val luckyNumbers = (1 to 1000).filter { n =>\n      n.toString.forall(c => c == '4' || c == '7')\n    }\n\n  def isAlmostLucky(i: Int): Boolean =\n    luckyNumbers.find(i % _ == 0) match {\n      case None => false\n      case Some(_) => true\n    }\n\n  def solve: String =\n    if (isAlmostLucky(sc.nextInt)) \"YES\"\n    else \"NO\"\n\n  out.println(solve)\n  out.close\n}\n"}, {"source_code": "\n\nobject LuckyDivision {\n\tdef main (args: Array[String]) {\n\t\tval scanner = new java.util.Scanner(System.in);\n\t\tval input = scanner.nextInt();\n\t\tif (isLucky(input)) {\n\t\t\tprintln(\"YES\")\n\t\t\tSystem.exit(0)\n\t\t}\n\t\tfor (i <- 1 to input / 2) {\n\t\t\tif (input % i == 0 && isLucky(i)) {\n\t\t\t\tprintln(\"YES\")\n\t\t\t\tSystem.exit(0)\n\t\t\t}\n\t\t}\n\t\tprintln(\"NO\")\n\t}\n\n\tdef isLucky(in: Int) : Boolean = {\n\t\t\tvar lucky = true;\n\t\t\tvar tmp = in;\n\t\t\twhile (lucky && tmp > 0) {\n\t\t\t\tval rem = tmp % 10;\n\t\t\t\tif (rem != 4 && rem != 7) {\n\t\t\t\t\tlucky = false\n\t\t\t\t}\n\t\t\t\ttmp /= 10\n\t\t\t}\n\t\t\tlucky\n\t}\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject LuckyDivision extends App {\n\n  def isLucky(i: Int): Boolean = i match {\n    case 0 => true\n    case _ => (i%10 == 4 || i%10 == 7) && isLucky(i / 10)\n  }\n\n  def isAlmostLucky(i: Int, d: Int): Boolean = d match {\n    case 0 => false\n    case _ => (i%d == 0 && isLucky(d)) || isAlmostLucky(i, d-1)\n  }\n\n  val s = readInt\n  println(if(isAlmostLucky(s, s)) \"YES\" else \"NO\")\n}\n"}, {"source_code": "object Codeforces122A extends App{\n\n  def CreateLuckyNumberSet:List[Int] = {\n    var luckyset:List[Int] = List()\n    luckyset = List(4,7,44,47,74,77,444,447,474,477,744,747,774,777)\n    return luckyset\n  }\n  def TestAlmostLuckyNumber(query:Int):Boolean={\n    val luckyset:List[Int] = CreateLuckyNumberSet\n    for (i <- luckyset){\n      if (query%i == 0){\n        return true\n      }\n    }\n    return false\n  }\n  var query:Int=scala.io.StdIn.readInt\n  var ans:Boolean = TestAlmostLuckyNumber(query)\n  if (ans == true){\n    println(\"YES\")\n  }\n  else {\n    println(\"NO\")\n  }\n}\n"}, {"source_code": "import java.io._\nimport scala.annotation.tailrec\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInt = reader.readLine().toInt\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n\n  def limitedStream(cur: Int, sqr: Int): Stream[Int] = if(cur * cur > sqr) Stream.Empty else cur #:: limitedStream(cur + 1, sqr)\n  def dividersStream(n: Int) = limitedStream(1, n).filter(n % _ == 0)\n  def allDividersStream(n: Int) = dividersStream(n).flatMap { x =>\n    Stream(x, n / x)\n  }\n  def beautifulInt(x: Int) = x.toString.forall(\"47\".contains(_))\n  def beautifulDividersStream(n: Int) = allDividersStream(n).filter(beautifulInt)\n\n  def main(a: Array[String]) {\n    println(if(beautifulDividersStream(readInt).isEmpty) \"NO\" else \"YES\")\n  }\n}\n"}, {"source_code": "object Main {\n  val happy: Stream[Int] = {\n    def nextGen(ls: List[Int], gen: Int): Stream[Int] = {\n      val nextLs = List(4, 7).flatMap(e => ls.map(e * gen +))\n      nextLs.toStream #::: nextGen(nextLs, gen * 10) \n    }\n    nextGen(List(0), 1)\n  }\n\n  def main(args: Array[String]) {\n    val num = readInt()\n    var isHappy = false\n    for(h <- happy.takeWhile(_ <= num)) {\n      if (num % h == 0) isHappy |= true\n    }\n    if (isHappy) println(\"YES\")\n    else println(\"NO\")\n  }\n}"}, {"source_code": "// Codeforces 122A\n\nobject _122A extends App {\n  val scanner = new java.util.Scanner(System.in)\n  val lucky_numbers = List(4, 7, 47, 74, 447, 474, 477, 747)\n  val n = scanner.nextInt\n  println(\n    if (lucky_numbers.exists(n%_ == 0)) \"YES\" else \"NO\"\n  )\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject A_122 extends App {\n  val n = readInt()\n\n  def isLucky(x: Int) = x.toString.toCharArray.toSet.forall(x => x == '4' || x == '7')\n\n  val L = 1 to 1000 filter isLucky\n\n  if (L.contains(n) || L.exists(l => n % l == 0)) println(\"YES\")\n  else println(\"NO\")\n}\n"}, {"source_code": "import scala.io.StdIn.readLine\nobject problem {\n  def main(args: Array[String]) {\n    val s = readLine.toInt\n  println(if(List(4,7,47,74,447,477,744,747).exists(s%_ == 0)) \"YES\" else \"NO\")\n  }\n}"}, {"source_code": "object JuanDavidRobles122A {\n    def main(args: Array[String]): Unit = {\n\n        import scala.io.StdIn\n    \n        var number: Int = Integer.parseInt(StdIn.readLine())\n        var string: String = \"\"\n        var out: String = \"NO\"\n    \n        string = String.valueOf(number)\n        string = string.replace(\"4\",\"\")\n        string = string.replace(\"7\",\"\")\n        if (string.equals(\"\")){\n            out = \"YES\"\n        }\n        \n        for (i <- 4 to number){\n        \n            string = String.valueOf(i)\n            string = string.replace(\"4\",\"\")\n            string = string.replace(\"7\",\"\")\n            if (string.equals(\"\") && number%i == 0){\n              out = \"YES\"\n            }\n        }\n    \n        println(out)\n\n  }\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject HelloWorldMain {\n\n  def main(args: Array[String]): Unit = {\n\n\n    val luckOrNot = readInt()\n\n    val allLuckies = for( i <- 1 to 1000 if i.toString.matches(\"(4|7)*\") )  yield i\n\n    var result = \"NO\"\n    allLuckies.foreach(i => if(luckOrNot % i == 0 ) result = \"YES\" )\n\n\n    println(result)\n\n\n\n  }\n}\n\n\n"}, {"source_code": "import scala.io.StdIn.readInt\n\n\nobject LuckyNumbers {\n  \n   def main(args: Array[String]) { \n     val n = readInt\n     if (Range(1,n).inclusive.\n        filter { p => p.toString().toSet subsetOf Set('4','7') }.\n        exists(n%_ == 0))\n       println(\"YES\")\n     else\n       println(\"NO\")\n   }\n  \n}"}, {"source_code": "import scala.io.StdIn._\n\nobject cf extends App\n{\n    val v = readInt\n    print(if(List(4,7,44,47,74,77,444,447,474,477,744,747,774,777).exists(kuy => v%kuy==0)) \"YES\" else \"NO\")\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject Task extends App{\n\tval N = readLine.split(\" \").map{_.toInt}.head\n\t\n\tdef isLucky(n:Int):Boolean = {\n    def aux(n:Int, div:String):Boolean = {\n      val d = div.toInt\n      \n      if(n < d)\n        false\n      else if(n % d == 0)\n        true\n      else {\n        aux(n, div + \"4\") || aux(n, div + \"7\")\n      }\n    }\n    \n    aux(n, \"4\") || aux(n, \"7\")\n\t}\n\t\n\tif(isLucky(N))\n\t  println(\"YES\")\n\telse\n\t  println(\"NO\")\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject Solution {\n\n\tvar n = readInt\n\n\tdef isLucky(n:Int):Boolean = {\n\t\tvar nst = n.toString\n\t\tvar ret = true\n\t\tfor(i <- 0 until nst.size) {\n\t\t\tif(nst(i) != '4' && nst(i) != '7') ret = false\n\t\t}\n\t\tret\n\t}\n\n\tdef main(args:Array[String]):Unit = {\n\t\tvar almostLucky = false\n\t\tfor(i <- 1 to n) {\n\t\t\tif(isLucky(i) && !almostLucky && n%i == 0) {\n\t\t\t\tprintln(\"YES\")\n\t\t\t\talmostLucky = true\n\t\t\t}\n\t\t}\n\t\tif(!almostLucky) println(\"NO\")\n\t}\n\n}\n"}], "negative_code": [{"source_code": "object HappyNum extends App {\n  val num = readLine()\n  val numnum = num.toInt\n  val listNum = num.toList\n  var ok = true\n\n  for(i <- listNum){\n    if (i != '4' && i != '7'){\n      ok = false\n    }\n  }\n  if (!ok && numnum % 7 == 0 || numnum % 4 == 0){\n    ok = true\n  }\n  if (ok) print(\"YES\")\n  else print(\"NO\")\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject HappyNum extends App {\n  val num = readInt\n  var ok = false\n\n  val list = List(4, 7, 44, 47, 74, 77, 444, 447, 474, 744, 747, 774, 777)\n\n  if (list.contains(num)) {\n    ok = true\n  }else {\n    for(i <- list){\n      if (num % i == 0) ok = true\n    }\n  }\n\n  if (ok) print(\"YES\")\n  else print(\"NO\")\n\n}"}, {"source_code": "\n\nobject LuckyDivision {\n\tdef main (args: Array[String]) {\n\t\tval scanner = new java.util.Scanner(System.in);\n\t\tval input = scanner.nextInt();\n\t\tif (isLucky(input)) {\n\t\t\tprintln(\"YES\")\n\t\t\tSystem.exit(0)\n\t\t}\n\t\tval sqrtInput = Math.round (Math.sqrt(input))\n\t\t\t\tfor (i <- 1 to sqrtInput.toInt) {\n\t\t\t\t\tif (isLucky(i) && input % i == 0) {\n\t\t\t\t\t\tprintln(\"YES\")\n\t\t\t\t\t\tSystem.exit(0)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\tprintln(\"NO\")\n\t}\n\n\tdef isLucky(in: Int) : Boolean = {\n\t\t\tvar lucky = true\n\t\t\t\t\tvar tmp = in\n\t\t\t\t\twhile (lucky && tmp > 0) {\n\t\t\t\t\t\tval rem = tmp % 10\n\t\t\t\t\t\t\t\tif (rem != 4 && rem != 7) {\n\t\t\t\t\t\t\t\t\tlucky = false\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\ttmp = tmp / 10\n\t\t\t\t\t}\n\t\t\tlucky\n\t}\n}"}, {"source_code": "\n\nobject LuckyDivision {\n\tdef main (args: Array[String]) {\n\t\tval scanner = new java.util.Scanner(System.in);\n\t\tval input = scanner.nextInt();\n\t\tif (isLucky(input)) {\n\t\t\tprintln(\"YES\")\n\t\t\tSystem.exit(0)\n\t\t}\n\t\tval sqrtInput = Math.round (Math.sqrt(input))\n\t\t\t\tfor (i <- 1 to sqrtInput.toInt + 1) {\n\t\t\t\t\tif (isLucky(i) && input % i == 0) {\n\t\t\t\t\t\tprintln(\"YES\")\n\t\t\t\t\t\tSystem.exit(0)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\tprintln(\"NO\")\n\t}\n\n\tdef isLucky(in: Int) : Boolean = {\n\t\t\tvar lucky = true\n\t\t\t\t\tvar tmp = in\n\t\t\t\t\twhile (lucky && tmp > 0) {\n\t\t\t\t\t\tval rem = tmp % 10\n\t\t\t\t\t\t\t\tif (rem != 4 && rem != 7) {\n\t\t\t\t\t\t\t\t\tlucky = false\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\ttmp = tmp / 10\n\t\t\t\t\t}\n\t\t\tlucky\n\t}\n}"}, {"source_code": "object CF0122A extends App {\n\n  val str = readLine()\n  val value = str.toInt\n  if (value % 4 == 0 || value % 7 == 0) {\n    println(\"YES\")\n  } else {\n    val status = str.getBytes.forall(b => {\n      b == '4' || b == '7'\n    })\n\n    if (status) {\n      println(\"YES\")\n    } else {\n      println(\"NO\")\n    }\n  }\n\n}\n"}], "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d"}
{"source_code": "object A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(n) = readInts(1)\n  val s = readLine\n\n  val ok = (!(s.contains(\"CC\") || s.contains(\"YY\") || s.contains(\"MM\"))) &&\n    (s.startsWith(\"?\") || s.endsWith(\"?\") || s.contains(\"??\") ||\n      s.contains(\"C?C\") || s.contains(\"Y?Y\") || s.contains(\"M?M\"))\n\n  println(if (ok) \"Yes\" else \"No\")\n}\n", "positive_code": [{"source_code": "object objecta {\n    import java.io.{BufferedReader, FileInputStream, InputStreamReader}\n    import scala.collection.mutable\n    import scala.util.control.Breaks._\n\n    val source = System.in\n    //new FileInputStream(\"D://in.txt\")\n    implicit val reader = new BufferedReader(new InputStreamReader(source))\n\n    def read()(implicit reader: BufferedReader): String = reader.readLine().split(\" \")(0)\n    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(\" \")\n    def readString()(implicit reader: BufferedReader): String = reader.readLine()\n\n    def main(args: Array[String]): Unit = {\n        val n = read.toInt\n        val s = readString\n\n        for (i <- 0 until n - 1)\n            if (s(i) != '?' && s(i) == s(i + 1)){\n                print(\"NO\")\n                return\n            }\n\n        if (s(0) == '?' || s(n - 1) == '?') {\n            print(\"YES\")\n            return\n        }\n\n        for (i <- 1 until n - 2)\n            if (s(i) == '?') {\n                if (s(i + 1) == '?') {\n                    print(\"YES\")\n                    return\n                } else if (s(i - 1) == s(i + 1)) {\n                                print(\"YES\")\n                                return\n                            }\n            }\n        print(\"NO\")\n    }\n}\n"}], "negative_code": [{"source_code": "object objecta {\n    import java.io.{BufferedReader, FileInputStream, InputStreamReader}\n    import scala.collection.mutable\n    import scala.util.control.Breaks._\n\n    val source = System.in\n    //new FileInputStream(\"D://in.txt\")\n    implicit val reader = new BufferedReader(new InputStreamReader(source))\n\n    def read()(implicit reader: BufferedReader): String = reader.readLine().split(\" \")(0)\n    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(\" \")\n    def readString()(implicit reader: BufferedReader): String = reader.readLine()\n\n    def main(args: Array[String]): Unit = {\n        val n = read.toInt\n        val s = readString\n\n        for (i <- 0 until n - 1)\n            if (s(i) == '?') {\n                if (s(i + 1) == '?') {\n                    print(\"YES\")\n                    return\n                } else if (i > 0 && s(i - 1) == s(i + 1)) {\n                    print(\"YES\")\n                    return\n                }\n            } else if (s(i) == s(i + 1)){\n                print(\"NO\")\n                return\n            }\n        print(\"NO\")\n    }\n}\n"}, {"source_code": "object objecta {\n    import java.io.{BufferedReader, FileInputStream, InputStreamReader}\n    import scala.collection.mutable\n    import scala.util.control.Breaks._\n\n    val source = System.in\n    //new FileInputStream(\"D://in.txt\")\n    implicit val reader = new BufferedReader(new InputStreamReader(source))\n\n    def read()(implicit reader: BufferedReader): String = reader.readLine().split(\" \")(0)\n    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(\" \")\n    def readString()(implicit reader: BufferedReader): String = reader.readLine()\n\n    def main(args: Array[String]): Unit = {\n        val n = read.toInt\n        val s = readString\n\n        for (i <- 0 until n - 1)\n            if (s(i) != '?' && s(i) == s(i + 1)){\n                print(\"NO\")\n                return\n            }\n        for (i <- 0 until n - 1)\n            if (s(i) == '?') {\n                if (s(i + 1) == '?') {\n                    print(\"YES\")\n                    return\n                } else if (i ==0) {\n                            print(\"YES\")\n                            return\n                        } else if (s(i - 1) == s(i + 1)) {\n                                print(\"YES\")\n                                return\n                            }\n            }\n        print(\"NO\")\n    }\n}\n"}, {"source_code": "object objecta {\n    import java.io.{BufferedReader, FileInputStream, InputStreamReader}\n    import scala.collection.mutable\n    import scala.util.control.Breaks._\n\n    val source = System.in\n    //new FileInputStream(\"D://in.txt\")\n    implicit val reader = new BufferedReader(new InputStreamReader(source))\n\n    def read()(implicit reader: BufferedReader): String = reader.readLine().split(\" \")(0)\n    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(\" \")\n    def readString()(implicit reader: BufferedReader): String = reader.readLine()\n\n    def main(args: Array[String]): Unit = {\n        val n = read.toInt\n        val s = readString\n\n        if (n == 1)\n            if (s(0) == '?') {\n                print(\"YES\")\n                return\n            } else {\n                print(\"NO\")\n                return\n            }\n\n        for (i <- 0 until n - 1)\n            if (s(i) != '?' && s(i) == s(i + 1)){\n                print(\"NO\")\n                return\n            }\n        for (i <- 0 until n - 1)\n            if (s(i) == '?') {\n                if (s(i + 1) == '?') {\n                    print(\"YES\")\n                    return\n                } else if (i ==0) {\n                            print(\"YES\")\n                            return\n                        } else if (s(i - 1) == s(i + 1)) {\n                                print(\"YES\")\n                                return\n                            }\n            }\n        print(\"NO\")\n    }\n}\n"}, {"source_code": "object objecta {\n    import java.io.{BufferedReader, FileInputStream, InputStreamReader}\n    import scala.collection.mutable\n    import scala.util.control.Breaks._\n\n    val source = System.in\n    //new FileInputStream(\"D://in.txt\")\n    implicit val reader = new BufferedReader(new InputStreamReader(source))\n\n    def read()(implicit reader: BufferedReader): String = reader.readLine().split(\" \")(0)\n    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(\" \")\n    def readString()(implicit reader: BufferedReader): String = reader.readLine()\n\n    def main(args: Array[String]): Unit = {\n        val n = read.toInt\n        val s = readString\n\n        for (i <- 0 until n - 1)\n            if (s(i) == s(i + 1)){\n                print(\"NO\")\n                return\n            }\n        for (i <- 0 until n - 1)\n            if (s(i) == '?') {\n                if (s(i + 1) == '?') {\n                    print(\"YES\")\n                    return\n                } else if (i ==0) {\n                            print(\"YES\")\n                            return\n                        } else if (s(i - 1) == s(i + 1)) {\n                                print(\"YES\")\n                                return\n                            }\n            }\n        print(\"NO\")\n    }\n}\n"}, {"source_code": "object objecta {\n    import java.io.{BufferedReader, FileInputStream, InputStreamReader}\n    import scala.collection.mutable\n    import scala.util.control.Breaks._\n\n    val source = System.in\n    //new FileInputStream(\"D://in.txt\")\n    implicit val reader = new BufferedReader(new InputStreamReader(source))\n\n    def read()(implicit reader: BufferedReader): String = reader.readLine().split(\" \")(0)\n    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(\" \")\n    def readString()(implicit reader: BufferedReader): String = reader.readLine()\n\n    def main(args: Array[String]): Unit = {\n        val n = read.toInt\n        val s = readString\n\n        for (i <- 0 until n - 1)\n            if (s(i + 1) != '?' && s(i) == s(i + 1)) {\n                print(\"NO\")\n                return\n            }\n        print(\"YES\")\n    }\n}\n"}, {"source_code": "object objecta {\n    import java.io.{BufferedReader, FileInputStream, InputStreamReader}\n    import scala.collection.mutable\n    import scala.util.control.Breaks._\n\n    val source = System.in\n    //new FileInputStream(\"D://in.txt\")\n    implicit val reader = new BufferedReader(new InputStreamReader(source))\n\n    def read()(implicit reader: BufferedReader): String = reader.readLine().split(\" \")(0)\n    def readArray()(implicit reader: BufferedReader): Array[String] = reader.readLine().split(\" \")\n    def readString()(implicit reader: BufferedReader): String = reader.readLine()\n\n    def main(args: Array[String]): Unit = {\n        val n = read.toInt\n        val s = readString\n\n        for (i <- 0 until n - 1)\n            if (s(i) == '?') {\n                if (s(i + 1) == '?') {\n                    print(\"YES\")\n                    return\n                } else if (i ==0) {\n                            print(\"YES\")\n                            return\n                        } else if (s(i - 1) == s(i + 1)) {\n                                print(\"YES\")\n                                return\n                            }\n            } else if (s(i) == s(i + 1)){\n                print(\"NO\")\n                return\n            }\n        print(\"NO\")\n    }\n}\n"}], "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3"}
{"source_code": "import annotation.tailrec, collection.mutable, util.control.Breaks._, math.Ordering.Implicits._\nimport CodeForcesApp._\nobject _560B extends CodeForcesApp[Boolean]({scanner => import scanner._\n  val List(a1, b1, a2, b2, a3, b3) = List.fill(6)(nextInt)\n  def fit(r: R) = {\n    val (x, y) = r\n    //debug(x, y, a1, b1)\n    (x <= a1 && y <= b1) || (x <= b1 && y <= a1)\n  }\n  type R = (Int, Int)\n  def join(r1: R, r2: R): R = (r1._1 + r2._1, r1._2 max r2._2)\n  def allSwapJoin(r1: R, r2: R): List[R] = join(r1, r2) :: join(r1, r2.swap) :: join(r1.swap, r2) :: join(r1.swap, r2.swap) :: Nil\n  def allJoin(r1: R, r2: R): List[R] = allSwapJoin(r1, r2) ::: allSwapJoin(r2, r1)\n  allJoin((a2, b2), (a3, b3)) exists fit\n}) {\n  override def format(result: Boolean) = if (result) \"YES\" else \"NO\"\n}\nimport java.util.Scanner\nabstract class CodeForcesApp[A](solver: Scanner => A) {\n  final def apply(problem: String): String = apply(new Scanner(problem))\n  final def apply(scanner: Scanner): String = format(solver(scanner))\n  def format(result: A): String = result.toString\n  final def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))\n}\nobject CodeForcesApp {\n  final def isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  final def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  final val modulus: Int = 1000000007\n  final val eps: Double = 1e-9\n  final def when[B](x: Boolean)(f: => B): Option[B] = if (x) Some(f) else None\n  final def counter[A] = collection.mutable.Map.empty[A, Int] withDefaultValue 0\n}", "positive_code": [{"source_code": "import io.StdIn._\n\nobject Solution {\n  def main(args: Array[String]) {\n    val p = readLine().split(\" \").map(_.toInt).sortBy(-_)\n    val a = readLine().split(\" \").map(_.toInt).sortBy(-_)\n    val b = readLine().split(\" \").map(_.toInt).sortBy(-_)\n\n    var found = false\n    if (p(0)-a(0)>=0 && p(1)-a(1)>=0) {\n      val r1 = Array(p(0)-a(0), p(1)).sortBy(-_)\n      if (r1(0)>=b(0) && r1(1)>=b(1)) found = true\n      else {\n        val r2 = Array(p(0), p(1)-a(1)).sortBy(-_)\n        if (r2(0)>=b(0) && r2(1)>=b(1)) found = true\n      }\n    }\n    if (p(0)-a(1)>=0 && p(1)-a(0)>=0) {\n      val r1 = Array(p(0)-a(1), p(1)).sortBy(-_)\n      if (r1(0)>=b(0) && r1(1)>=b(1)) found = true\n      else {\n        val r2 = Array(p(0), p(1)-a(0)).sortBy(-_)\n        if (r2(0)>=b(0) && r2(1)>=b(1)) found = true\n      }\n    }\n\n    if (found) println(\"YES\") else println(\"NO\")\n  }\n}\n"}], "negative_code": [{"source_code": "import annotation.tailrec, collection.mutable, util.control.Breaks._, math.Ordering.Implicits._\nimport CodeForcesApp._\nobject _560B extends CodeForcesApp[Boolean]({scanner => import scanner._\n  val List(a1, b1, a2, b2, a3, b3) = List.fill(6)(nextInt)\n  def fit(r: R) = {\n    val (x, y) = r\n    //debug(x, y, a1, b1)\n    (x <= a1 && y <= b1) || (x <= b1 && y <= a1)\n  }\n  type R = (Int, Int)\n  def join(r1: R, r2: R): R = (r1._1 + r2._1, r1._2 min r2._2)\n  def allSwapJoin(r1: R, r2: R): List[R] = join(r1, r2) :: join(r1, r2.swap) :: join(r1.swap, r2) :: join(r1.swap, r2.swap) :: Nil\n  def allJoin(r1: R, r2: R): List[R] = allSwapJoin(r1, r2) ::: allSwapJoin(r2, r1)\n  allJoin((a2, b2), (a3, b3)) exists fit\n}) {\n  override def format(result: Boolean) = if (result) \"YES\" else \"NO\"\n}\nimport java.util.Scanner\nabstract class CodeForcesApp[A](solver: Scanner => A) {\n  final def apply(problem: String): String = apply(new Scanner(problem))\n  final def apply(scanner: Scanner): String = format(solver(scanner))\n  def format(result: A): String = result.toString\n  final def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))\n}\nobject CodeForcesApp {\n  final def isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  final def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  final val modulus: Int = 1000000007\n  final val eps: Double = 1e-9\n  final def when[B](x: Boolean)(f: => B): Option[B] = if (x) Some(f) else None\n  final def counter[A] = collection.mutable.Map.empty[A, Int] withDefaultValue 0\n}\n"}], "src_uid": "2ff30d9c4288390fd7b5b37715638ad9"}
{"source_code": "import scala.io.Source\n\nobject Solution extends App {\n\n  def ceil(a: Long): String = {\n    val str = a.toBinaryString\n    val zeroCount = str.count(_ == '0')\n    if (zeroCount == 1) str\n    else if (zeroCount == 0) \"10\" + \"1\" * (str.length - 1)\n    else {\n      val ones = str.takeWhile(_ == '1').length\n      \"1\" * ones + \"0\" + \"1\" * (str.length - ones - 1)\n    }\n  }\n\n  def floor(a: Long): String = {\n    val str = a.toBinaryString\n    val zeroCount = str.count(_ == '0')\n    if (zeroCount == 1) str\n    else if (zeroCount == 0) str.dropRight(1) + '0'\n    else {\n      val ones = str.takeWhile(_ == '1').length\n      if (ones == 1)\n        \"1\" * (str.length - 2) + \"0\"\n      else\n        \"1\" * (ones - 1) + \"0\" + \"1\" * (str.length - ones)\n    }\n  }\n\n  def count(aSize: Int, aZeroPosition: Int, bSize: Int, bZeroPosition: Int): Int = {\n    if (aSize > bSize || (aZeroPosition > bZeroPosition && aSize == bSize)) 0\n    else if (aSize == bSize && aZeroPosition == bZeroPosition) 1\n    else if (aZeroPosition == aSize) count(aSize + 1, 1, bSize, bZeroPosition)\n    else 1 + count(aSize, aZeroPosition + 1, bSize, bZeroPosition)\n  }\n\n  val in = Source.stdin.getLines()\n  val Array(a, b) = in.next().split(' ').map(_.toLong)\n  val c = ceil(a)\n  val f = floor(b)\n//  println(a.toBinaryString)\n//  println(c)\n//  println(b.toBinaryString)\n//  println(f)\n  println(count(c.length, c.indexOf('0'), f.length, f.indexOf('0')))\n}", "positive_code": [{"source_code": "import scala.collection._\n\nobject B extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(a, b) = readLongs(2)\n  var res = 0L\n\n  for (l <- 1 to 62) {\n    val x = (1L << l) - 1\n    for (j <- 0 until l - 1) {\n      val y = x ^ (1L << j)\n      if (a <= y && y <= b) {\n        res += 1\n      }\n    }\n  }\n  println(res)\n}\n"}, {"source_code": "import io.StdIn._\nimport scala.collection.mutable._\n\nobject Solution {\n\n  def main(args: Array[String]) {\n    val Array(n, m) = readLine().split(\" \").map(_.toLong)\n\n    var num = 0\n\n    for (i <- 2 to 63) {\n      for (j <- 0 to i-2) {\n        val y = ((1.toLong<<i) - 1) ^ (1.toLong<<j)\n\n        if (y >= n && y <= m) {\n          num += 1\n//          println(i+\"..\"+j+\"..\"+y)\n        }\n      }\n    }\n\n    println(num)\n\n  }\n}"}, {"source_code": "import java.util.Scanner\nimport java.lang.Long.parseLong\n\nobject Main{\n  def main (args: Array[String]){\n    val sc = new Scanner(System.in)\n    val a = sc.nextLong()\n    val b = sc.nextLong()\n\n    //\n    val a_2 = a.toBinaryString\n    val b_2 = b.toBinaryString\n\n    val a_2l = a_2.length\n    var shaku = \"10\"\n    var flag = true\n    var ans = 0L\n    var digi_cnt = 1\n    while(flag){\n      val tn = parseLong(shaku, 2)\n\n      if(a <= tn){\n        if(b >= tn)\n          ans += 1\n        else\n          flag = false\n      }\n\n      digi_cnt += 1\n      val sl = shaku.length\n      if(sl == digi_cnt){\n        shaku = shaku.updated(digi_cnt - 1, '1')\n        shaku = shaku ++ \"1\"\n        shaku = shaku.updated(1, '0')\n        digi_cnt = 1\n      }\n      else{\n        shaku = shaku.updated(digi_cnt - 1, '1')\n        shaku = shaku.updated(digi_cnt, '0')\n      }\n    }\n\n    println(ans)\n  }\n}\n\n \n"}], "negative_code": [{"source_code": "import scala.io.Source\n\nobject Solution extends App {\n\n  def ceil(a: Long): String = {\n    val str = a.toBinaryString\n    val zeroCount = str.count(_ == '0')\n    if (zeroCount == 1) str\n    else if (zeroCount == 0) str + '0'\n    else {\n      val ones = str.takeWhile(_ == '1').length\n      \"1\" * ones + \"0\" + \"1\" * (str.length - ones - 1)\n    }\n  }\n\n  def floor(a: Long): String = {\n    val str = a.toBinaryString\n    val zeroCount = str.count(_ == '0')\n    if (zeroCount == 1) str\n    else if (zeroCount == 0) str.dropRight(1) + '0'\n    else {\n      val ones = str.takeWhile(_ == '1').length\n      if (ones == 1)\n        \"1\" * (str.length - 2) + \"0\"\n      else\n        \"1\" * (ones - 1) + \"0\" + \"1\" * (str.length - ones)\n    }\n  }\n\n  def count(aSize: Int, aZeroPosition: Int, bSize: Int, bZeroPosition: Int): Int = {\n    if (aSize > bSize || (aZeroPosition > bZeroPosition && aSize == bSize)) 0\n    else if (aSize == bSize && aZeroPosition == bZeroPosition) 1\n    else if (aZeroPosition == aSize) count(aSize + 1, 0, bSize, bZeroPosition)\n    else 1 + count(aSize, aZeroPosition + 1, bSize, bZeroPosition)\n  }\n\n  val in = Source.stdin.getLines()\n  val Array(a, b) = in.next().split(' ').map(_.toLong)\n  val c = ceil(a)\n  val f = floor(b)\n  println(count(c.length, c.indexOf('0'), f.length, f.indexOf('0')))\n}"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n\n  def ceil(a: Long): String = {\n    val str = a.toBinaryString\n    val zeroCount = str.count(_ == '0')\n    if (zeroCount == 1) str\n    else if (zeroCount == 0) str + '0'\n    else {\n      val ones = str.takeWhile(_ == '1').length\n      \"1\" * ones + \"0\" + \"1\" * (str.length - ones - 1)\n    }\n  }\n\n  def floor(a: Long): String = {\n    val str = a.toBinaryString\n    val zeroCount = str.count(_ == '0')\n    if (zeroCount == 1) str\n    else if (zeroCount == 0) str.dropRight(1) + '0'\n    else {\n      val ones = str.takeWhile(_ == '1').length\n      if (ones == 1)\n        \"1\" * (str.length - 2) + \"0\"\n      else\n        \"1\" * (ones - 1) + \"0\" + \"1\" * (str.length - ones)\n    }\n  }\n\n  def count(aSize: Int, aZeroPosition: Int, bSize: Int, bZeroPosition: Int): Int = {\n    if (aSize > bSize) 0\n    else if (aSize == bSize && aZeroPosition == bZeroPosition) 1\n    else if (aZeroPosition == aSize) count(aSize + 1, 1, bSize, bZeroPosition)\n    else 1 + count(aSize, aZeroPosition + 1, bSize, bZeroPosition)\n  }\n\n  val in = Source.stdin.getLines()\n  val Array(a, b) = in.next().split(' ').map(_.toLong)\n  val c = ceil(a)\n  val f = floor(b)\n  println(count(c.length, c.indexOf('0'), f.length, f.indexOf('0')))\n}"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n\n  def ceil(a: Long): String = {\n    val str = a.toBinaryString\n    val zeroCount = str.count(_ == '0')\n    if (zeroCount == 1) str\n    else if (zeroCount == 0) str + '0'\n    else {\n      val ones = str.takeWhile(_ == '1').length\n      \"1\" * ones + \"0\" + \"1\" * (str.length - ones - 1)\n    }\n  }\n\n  def floor(a: Long): String = {\n    val str = a.toBinaryString\n    val zeroCount = str.count(_ == '0')\n    if (zeroCount == 1) str\n    else if (zeroCount == 0) str.dropRight(1) + '0'\n    else {\n      val ones = str.takeWhile(_ == '1').length\n      if (ones == 1)\n        \"1\" * (str.length - 2) + \"0\"\n      else\n        \"1\" * (ones - 1) + \"0\" + \"1\" * (str.length - ones)\n    }\n  }\n\n  def count(aSize: Int, aZeroPosition: Int, bSize: Int, bZeroPosition: Int): Int = {\n    if (aSize > bSize || (aZeroPosition > bZeroPosition && aSize == bSize)) 0\n    else if (aSize == bSize && aZeroPosition == bZeroPosition) 1\n    else if (aZeroPosition == aSize) count(aSize + 1, 1, bSize, bZeroPosition)\n    else 1 + count(aSize, aZeroPosition + 1, bSize, bZeroPosition)\n  }\n\n  val in = Source.stdin.getLines()\n  val Array(a, b) = in.next().split(' ').map(_.toLong)\n  val c = ceil(a)\n  val f = floor(b)\n  println(count(c.length, c.indexOf('0'), f.length, f.indexOf('0')))\n}"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n\n  def ceil(a: Long): String = {\n    val str = a.toBinaryString\n    val zeroCount = str.count(_ == '0')\n    if (zeroCount == 1) str\n    else if (zeroCount == 0) str + '0'\n    else {\n      val ones = str.takeWhile(_ == '1').length\n      \"1\" * ones + \"0\" + \"1\" * (str.length - ones - 1)\n    }\n  }\n\n  def floor(a: Long): String = {\n    val str = a.toBinaryString\n    val zeroCount = str.count(_ == '0')\n    if (zeroCount == 1) str\n    else if (zeroCount == 0) str.dropRight(1) + '0'\n    else {\n      val ones = str.takeWhile(_ == '1').length\n      if (ones == 1)\n        \"1\" * (str.length - 2) + \"0\"\n      else\n        \"1\" * (ones - 1) + \"0\" + \"1\" * (str.length - ones)\n    }\n  }\n\n  def count(aSize: Int, aZeroPosition: Int, bSize: Int, bZeroPosition: Int): Int = {\n    if (aSize > bSize || (aZeroPosition < bZeroPosition && aSize == bSize)) 0\n    else if (aSize == bSize && aZeroPosition == bZeroPosition) 1\n    else if (aZeroPosition == aSize) count(aSize + 1, 1, bSize, bZeroPosition)\n    else 1 + count(aSize, aZeroPosition + 1, bSize, bZeroPosition)\n  }\n\n  val in = Source.stdin.getLines()\n  val Array(a, b) = in.next().split(' ').map(_.toLong)\n  val c = ceil(a)\n  val f = floor(b)\n  println(count(c.length, c.indexOf('0'), f.length, f.indexOf('0')))\n}"}], "src_uid": "581f61b1f50313bf4c75833cefd4d022"}
{"source_code": "import java.io._\nimport java.util.Scanner\nimport scala.language.implicitConversions\n\nobject AcmICPC {\n\n  class Lazy[A](x: => A) {\n    lazy val value = x\n    override def toString(): String = value.toString()\n  }\n\n  object Lazy {\n    def apply[A](x: => A) = new Lazy(x)\n    implicit def fromLazy[A](z: Lazy[A]): A = z.value\n    implicit def toLazy[A](x: => A): Lazy[A] = Lazy(x)\n  }\n\n  import Lazy._\n\n  def main(args: Array[String]): Unit = {\n    val sc = new Scanner(System.in)\n\n    val A = sc.nextLine().split(\" \").map(str => str.toInt)\n    val sum = A.sum\n    val answer = A.combinations(3).exists(combination => combination.sum * 2 == sum)\n\n    println(if(answer) \"YES\" else \"NO\")\n\n  }\n}", "positive_code": [{"source_code": "object A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val as = readInts(6)\n\n  var can = false\n  for (bs <- as.permutations) {\n    if (bs.take(3).sum == bs.drop(3).sum) can = true\n  }\n\n  println(if (can) \"YES\" else \"NO\")\n\n  Console.flush\n}\n"}, {"source_code": "/**\n  * @see http://codeforces.com/contest/890/problem/A\n  */\n\nobject AACM extends App {\n  val a = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n  val s = a sum\n  val n = 6\n\n  val vs = for {\n    i <- 0 to 5\n    j <- i to 5\n    k <- j to 5\n    if i != j && j != k && i != k && s - a(i) - a(j) - a(k) == a(i) + a(j) + a(k)\n  } yield (i, j, k)\n\n  if (vs.isEmpty) println(\"NO\")\n  else println(\"YES\")\n}\n"}], "negative_code": [{"source_code": "import scala.annotation.tailrec\n\nobject A extends App {\n  val a = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n  val n = 6\n  val s = a.sum\n\n  @tailrec\n  def check(i: Int = 0, j: Int = 0, k: Int = 0): Boolean =\n    if (i == n || j == n || k == n) false\n    else if (s - a(i) - a(j) - a(k) == a(i) + a(j) + a(k)) true\n    else check(i + (j + (k + 1) / n) / n, (j + (k + 1) / n) % n, (k + 1) % n)\n\n  if (check()) println(\"YES\")\n  else println(\"NO\")\n}\n"}], "src_uid": "2acf686862a34c337d1d2cbc0ac3fd11"}
{"source_code": "object CF915B extends App{\n  val sc = new java.util.Scanner(System.in)\n  val n, pos, l, r = sc.nextInt\n  val move = if (l == 1) {\n    if (r == n) 0 else (r-pos abs) + 1\n  } else {\n    if (r == n) (pos-l abs) + 1 else  ((pos-l min  r-pos) abs) + (r - l) + 2\n  }\n  println(move)\n}", "positive_code": [{"source_code": "object CF915B extends App{\n  val sc = new java.util.Scanner(System.in)\n  val n, pos, l, r = sc.nextInt\n  val move = if (l == 1) {\n    if (r == n) 0 else (r-pos abs) + 1\n  } else {\n    if (r == n) (pos-l abs) + 1 else  ((pos-l min  r-pos) abs) + (r - l) + 2\n  }\n  println(move)\n}\n"}, {"source_code": "\nobject B extends App {\n  val Array(n, pos, l, r) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n\n  def seconds(i: Int, a: Int, b: Int, t: Int = 0): Int =\n    if (a == l && b == r) t\n    else if (a == l) seconds(r, a, r, t + (r - i).abs + 1)\n    else if (b == r) seconds(l, l, b, t + (i - l).abs + 1)\n    else {\n      if (i <= l) seconds(l, l, b, t + l - i + 1)\n      else if (i >= r) seconds(r, a, r, t + i - r + 1)\n      else {\n        if (r - i < i - l) seconds(r, a, b, t + r - i)\n        else seconds(l, a, b, t + i - l)\n      }\n    }\n\n  println(seconds(pos, 1, n))\n}\n"}], "negative_code": [{"source_code": "\nobject B extends App {\n  val Array(n, pos, l, r) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n\n  def seconds(i: Int, a: Int, b: Int, t: Int = 0): Int =\n    if (a == l && b == r) t\n    else if (a == l) seconds(r, a, r, t + r - i + 1)\n    else if (b == r) seconds(l, l, b, t + i - l + 1)\n    else {\n      if (i <= l) seconds(l, l, b, t + l - i + 1)\n      else if (i >= r) seconds(r, a, r, t + i - r + 1)\n      else {\n        if (r - i < i - l) seconds(r, a, b, t + r - i)\n        else seconds(l, a, b, t + i - l)\n      }\n    }\n\n  println(seconds(pos, 1, n))\n}\n"}, {"source_code": "object CF915B extends App{\n  val sc = new java.util.Scanner(System.in)\n  val n, pos, l, r = sc.nextInt\n  val move = if (l == 1) {\n    if (r == n) 0 else r-pos + 1\n  } else {\n    if (r == n) pos-l + 1 else (pos-l min  r-pos) + (r - l) + 2\n  }\n  println(move)\n}"}], "src_uid": "5deaac7bd3afedee9b10e61997940f78"}
{"source_code": "\n/**\n  * Created by octavian on 18/02/2016.\n  */\nobject Game {\n\n  def main(args: Array[String]) {\n   // System.setIn(new FileInputStream(\"src/game.in\"))\n    //System.setOut(new PrintStream(new FileOutputStream(\"src/game.out\")))\n\n    var n = readLong()\n    if(n % 2 == 0) {\n      println(2)\n    }\n    else {\n      println(1)\n    }\n\n  }\n\n}\n", "positive_code": [{"source_code": "import scala.io.StdIn\n\nobject Game {\n\n  def main(args: Array[String]) {\n    val n = StdIn.readLong()\n    print(2 - (n % 2))\n  }\n  \n}\n"}, {"source_code": "import java.util.Scanner\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main {\n\n  def sqr(x: Long) = x * x\n\n  def powmod(x: Long, n: Long, p: Long): Long = {\n    if (n == 1) x\n    else if (n % 2 == 1) (powmod(x, n - 1, p) * x) % p\n    else sqr(powmod(x, n / 2, p)) % p\n  }\n\n  def C(n: Int, k: Int) = {\n    var res = BigInt(1)\n    for (i <- n - k + 1 to n) {\n      res = res * i\n    }\n    for (i <- 1 to k.toInt) {\n      res = res / i\n    }\n    res\n  }\n\n  def fact(n: Int) = {\n    var res = BigInt(1)\n    for (i <- 1 to n) {\n      res = res * i\n    }\n    res\n  }\n\n  def gcd(a: Long, b: Long): Long = if (b == 0) a else gcd(b, a % b)\n\n  def lcm(a: Long, b: Long) = a / gcd(a, b) * b\n\n  def main(args: Array[String]): Unit = {\n    val in = new Scanner(System.in)\n\n    val n = in.nextLong()\n\n    println((n + 1) % 2 + 1)\n  }\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  println(2 - in.next().last.asDigit % 2)\n}"}], "negative_code": [], "src_uid": "816ec4cd9736f3113333ef05405b8e81"}
{"source_code": "import scala.io.StdIn.readLine\nobject problem {\n  def main(args: Array[String]) {\n  val s = readLine\n    println(if(s.distinct.size%2 ==0) \"CHAT WITH HER!\" else \"IGNORE HIM!\")\n  }\n}", "positive_code": [{"source_code": "object Main {\n\n  def distinct(x: List[Char]): List[Char] = {\n    x.foldLeft(List.empty[Char])((acc, c) => if (acc.contains(c)) acc else c :: acc)\n  }\n  \n  def gender(nick: String): String = {\n    val chars = distinct(nick.toList)\n    if (chars.size % 2 == 0) \"CHAT WITH HER!\"\n    else \"IGNORE HIM!\"\n  }\n  \n  def main(args: Array[String]) = {\n    print (gender(readLine))\n  }\n}"}, {"source_code": "object a{def main(args:Array[String]){if(readLine.distinct.size%2==0)print(\"CHAT WITH HER!\")else print(\"IGNORE HIM!\")}}"}, {"source_code": "//2.12 | CodeForces.Com\nobject Solution {\n    def main(args: Array[String]) {\n        if(readLine.distinct.size % 2 == 0)\n            print(\"CHAT WITH HER!\")\n        else\n            print(\"IGNORE HIM!\")\n    }\n}"}, {"source_code": "//rextester.com:2.11.7--codeforces.com:2.11.8\nobject a extends App{\n    if(readLine.distinct.size%2==0)print(\"CHAT WITH HER!\")else print(\"IGNORE HIM!\")\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject Task extends App{\n\tval name = readLine.toSet\n\t\n\tif(name.size % 2 == 0)\n\t  println(\"CHAT WITH HER!\")\n\telse\n\t  println(\"IGNORE HIM!\")\n}"}, {"source_code": "object A00236 extends App {\n  val str = Console.readLine()\n  val message = if (str.distinct.length % 2 == 1) \"IGNORE HIM!\" else \"CHAT WITH HER!\"\n  println(message)\n}\n"}, {"source_code": "object JuanDavidRobles236A {\n\n  def main(args: Array[String]): Unit = {\n\n    import scala.io.StdIn\n    import java.util\n\n    var string: String = StdIn.readLine()\n    var words: Array[Char] = new Array[Char](30)\n    var count: Int = 0\n\n    for (i <- 0 until string.length){\n      if (!arrayContains(words, string.charAt(i))){\n        words(count) = string.charAt(i)\n        count += 1\n      }\n    }\n\n    if (count%2 == 0){\n      println(\"CHAT WITH HER!\")\n    } else {\n      println(\"IGNORE HIM!\")\n    }\n\n  }\n\n  def arrayContains(myString: Array[Char], char: Char): Boolean ={\n    var boolean: Boolean = false\n    for (i <- 0 until myString.length){\n\n      if (myString.charAt(i) == char){\n        boolean = true\n      }\n    }\n\n    boolean\n  }\n}"}, {"source_code": "\nimport scala.io.StdIn.readLine\n\nobject BoyOrGirl {\n  def main(args: Array[String]) { \n    if (readLine.toSet.size % 2 == 0)\n      println(\"CHAT WITH HER!\")\n    else \n      println(\"IGNORE HIM!\")\n  }\n  \n}"}, {"source_code": "object Main extends App{\n    if(readLine.distinct.size %2==0)\n    println(\"CHAT WITH HER!\")else\n    println(\"IGNORE HIM!\")\n}"}, {"source_code": "import scala.collection.immutable.Set\nobject TEST extends App{\n    var al = Set[Char]()\n    readLine.foreach(i => al += i)\n    print (if(al.size%2==0) \"CHAT WITH HER!\" else \"IGNORE HIM!\")\n}"}, {"source_code": "object test5 extends App {\n    val name=readLine\n    if(name.distinct.size%2==0)\n    \tprintln(\"CHAT WITH HER!\")\n    else\n    \tprintln(\"IGNORE HIM!\")\n    \n}   \n\n"}, {"source_code": "/**\n * Created by richard on 2015/6/10.\n */\nimport scala.io.StdIn\nobject cf236a {\n  def main(args: Array[String]): Unit = {\n    val name = StdIn.readLine()\n    println(if (name.distinct.size%2==1) \"IGNORE HIM!\" else \"CHAT WITH HER!\")\n  }\n}\n"}, {"source_code": "object I {\n  \n  def main(args : Array[String]): Unit = {\n    var s = readLine\n    var used=false\n    var cnt = 1\n    for (i <- 1 to s.length()-1; j <- i-1 to 0 by -1){\n    \tif (s.charAt(i)==s.charAt(j))used = true\n    \tif (j==0){\n    \t  if (!used)cnt += 1\n    \t used = false    \t  \n    \t}\n      }\n//    println(cnt)\n    if (cnt % 2 == 0)\n      println(\"CHAT WITH HER!\")\n     else println(\"IGNORE HIM!\")\n  }\n\n}"}, {"source_code": "object A236 extends App {\n  var name: String = readLine\n  var count = 0;\n  while (!name.isEmpty()) {\n    name = name.filterNot((a: Char) => a == name.charAt(0))\n    count += 1;\n  }\n  if (count % 2 == 0)\n    println(\"CHAT WITH HER!\")\n  else println(\"IGNORE HIM!\")\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]): Unit = {\n    val s = readLine\n    if (s.toList.distinct.length % 2 == 0) {\n      println(\"CHAT WITH HER!\")\n    } else {\n      println(\"IGNORE HIM!\")\n    }\n  }\n}\n"}, {"source_code": "\nobject Main extends App {\n  val sc = new java.util.Scanner(System.in)\n  val name = sc.next()\n\n  println(if (name.toSet.size % 2 == 0) \"CHAT WITH HER!\" else \"IGNORE HIM!\")\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P236A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val name = sc.nextLine\n\n  def solve: String =\n    if (name.groupBy(identity[Char]).size % 2 == 0) \"CHAT WITH HER!\"\n    else \"IGNORE HIM!\"\n\n  out.println(solve)\n  out.close\n}\n"}, {"source_code": "\n\nobject BoyOrGirl {\n\tdef main (args: Array[String]) {\n\t\tval scanner = new java.util.Scanner(System.in);\n\t\tval input = scanner.nextLine;\n\t\tvar theList: List[Char] = Nil\n\t\tfor (c <- input) {\n\t\t  if (!theList.contains(c)) {\n\t\t    theList = c::theList;\n\t\t  }\n\t\t}\n\t\tif (theList.size % 2 == 0) {\n\t\t  println(\"CHAT WITH HER!\")\n\t\t}\n\t\telse {\n\t\t  println(\"IGNORE HIM!\")\n\t\t}\n\t}\n}"}, {"source_code": "object A {\n  def main(args: Array[String]) {\n    val input = readLine()\n    val chars = input.iterator.toSet\n    print(\n      if ((chars.iterator.length % 2) == 0)\n        \"CHAT WITH HER!\"\n      else\n        \"IGNORE HIM!\")\n  }\n\n}\n"}, {"source_code": "// codeforces 236A\n\nobject DevYun extends App {\n  val nm = Console.readLine()\n  val sch: Set[Char] = nm toSet\n  val devush = (sch.size % 2) == 0\n  val answer = if (devush) \"CHAT WITH HER!\" else \"IGNORE HIM!\"\n  println(answer)\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]): Unit = {\n      val str = readLine()\n      if (str.distinct.length % 2 == 0) println(\"CHAT WITH HER!\") else println(\"IGNORE HIM!\")\n  }\n}"}, {"source_code": "object Two36A extends App {\n\tval str = readLine\n\tval a = 'a'\n\tval arr = new Array[Int](26)\n\tstr.foreach { x =>\n\t\tarr(x - a) += 1\n\t}\n\tval size = arr.filter(_ > 0).size\n\tif (size % 2 != 0) {\n\t\tprintln(\"IGNORE HIM!\")\n\t} else {\n\t\tprintln(\"CHAT WITH HER!\")\n\t}\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject BoyorGirl {\n  def main(args: Array[String]): Unit = {\n    val name = readLine().toSet\n    val ans = if (name.size % 2 == 0) \"CHAT WITH HER!\" else \"IGNORE HIM!\"\n    println(ans)\n  }\n}"}, {"source_code": "object Main extends App{\n    if(readLine.distinct.size %2==0)\n    println(\"CHAT WITH HER!\")else\n    println(\"IGNORE HIM!\")\n}"}, {"source_code": "object BoyGirl extends App {\n\n\tval uniqueCharacters = \n\t\tscala.io.StdIn.readLine()\n\t\t.toSet.size\n\n\tif (uniqueCharacters % 2 != 0) println(\"IGNORE HIM!\")\n\t\telse println(\"CHAT WITH HER!\")\n\n}"}, {"source_code": "import java.util.Scanner\n\nobject Try1 {\n  def main(args: Array[String]) {\n    val in = new Scanner(System.in)\n    var a,b,len,x, m, k, n, j, i: Int = 0\n\n//    val lb = \"abcdefghijklmnopqrstuvwxyz\"\n//    val lc = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n    var v = new Array[Int](26)\n    i=0\n    while (i<26){\n      v(i)=0\n      i+=1\n    }\n//    n = in.nextInt()\n//    k = in.nextInt()\n//    x=0\n    val la = in.nextLine()\n    a=0\n    b=0\n    m = la.length()\n    i=0\n    while (i<m) {\n      v(la(i)-'a')=1\n      i+=1\n    }\n    i=0\n    while (i<26){\n      a+=v(i)\n      i+=1\n    }\n    a=a%2\n    if (a==0) println(\"CHAT WITH HER!\")\n    else println(\"IGNORE HIM!\")\n//    if (a>=b)\n//      {\n//        i=0\n//        while (i<m)\n//        {\n//          if (la(i)>='a' && la(i)<='z') print(la(i))\n//          else print(lb(la(i)-'A'))\n//          i+=1\n//        }\n//      }\n//    else\n//      {\n//        i=0\n//        while (i<m)\n//        {\n//          if (la(i)>='a' && la(i)<='z') print(lc(la(i)-'a'))\n//          else print(la(i))\n//          i+=1\n//        }\n//      }\n//    m = la.compareToIgnoreCase(lb)  //不区分大小写判断字符串是否相等\n\n\n//    i=0\n//    n=line.length()\n//    while (i<n-2 && line(i)=='W' && line(i+1)=='U' && line(i+2)=='B') i+=3\n//    while (n>2 && line(n-3)=='W' && line(n-2)=='U' && line(n-1)=='B') n-=3\n//    while (i<n) {\n//      if (line(i)=='W') {\n//        if (i<n-2) {\n//          if (line(i+1)=='U' && line(i+2)=='B') {\n//            print(' ')\n//           i+=2\n//          }\n//          else print(line(i))\n//        }\n//        else print(line(i))\n//      }\n//      else print(line(i))\n//      i+=1\n//    }\n\n  }\n}"}, {"source_code": "object Main extends App{\n    if(readLine.distinct.size %2==0)\n    println(\"CHAT WITH HER!\")else\n    println(\"IGNORE HIM!\")\n}"}, {"source_code": "object Codeforces236A extends App{\n\n  def Check(quer:String):String={\n    var ans:Int=1\n    val nquer:String=quer.toArray.sorted.mkString\n    for (i <- 0 until nquer.length-1){\n      if (nquer(i) != nquer(i+1)) ans+=1\n    }\n    if (ans % 2 == 1) return \"IGNORE HIM!\"\n    else return \"CHAT WITH HER!\"\n  }\n\n  val username:String=scala.io.StdIn.readLine\n  println(Check(username))\n\n}\n"}, {"source_code": "object Main extends App {\n  val str = readLine()\n\n  val r = str.toLowerCase().groupBy(_.toChar).map { case (k, v) => (k, v.size) }\n\n  if (r.size % 2 == 0) println(\"CHAT WITH HER!\")\n  else println(\"IGNORE HIM!\")\n}\n"}, {"source_code": "import java.io._\nimport scala.annotation.tailrec\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInt = reader.readLine().toInt\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n\n  def ans = Array(\"CHAT WITH HER!\", \"IGNORE HIM!\").apply(reader.readLine().groupBy(x => x).size % 2)\n\n  def main(a: Array[String]) {\n    println(ans)\n  }\n}\n"}, {"source_code": "object Task236A {\n  def main(args: Array[String]): Unit = {\n    println(if (scala.io.StdIn.readLine().foldLeft(Set[Char]())((x, y) => x + y).size % 2 == 0) \"CHAT WITH HER!\" else \"IGNORE HIM!\")\n  }\n}"}, {"source_code": "object CF0236A extends App {\n\n  var str = readLine().toList\n\n  val size = str.toSet.size\n\n  if(size % 2 == 0) {\n    println(\"CHAT WITH HER!\")\n  } else {\n    println(\"IGNORE HIM!\")\n  }\n}\n"}, {"source_code": "object Solution236A extends App {\n\n  val ans = Map(0 -> \"CHAT WITH HER!\", 1 -> \"IGNORE HIM!\")\n\n  def solution() {\n    println(ans(_string.groupBy(c => c).size % 2))\n  }\n\n  //////////////////////////////////////////////////\n  import java.util.Scanner\n  val SC: Scanner = new Scanner(System.in)\n  def _line: String = SC.nextLine\n  def _int: Int = SC.nextInt\n  def _long: Long = SC.nextLong\n  def _string: String = SC.next\n  solution()\n}"}, {"source_code": "import scala.io.StdIn\n\nobject BoyAndGirlMain {\n  def main(args: Array[String]): Unit = {\n    val userName = StdIn.readLine().toArray\n    val lol = userName.groupBy(_.charValue())\n\n    if (lol.size % 2 == 0 )\n      print (\"CHAT WITH HER!\")\n    else print(\"IGNORE HIM!\")\n  }\n\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val s = readLine().toSet\n    if (s.size % 2 == 0) println(\"CHAT WITH HER!\")\n    else println(\"IGNORE HIM!\")\n  }\n}"}, {"source_code": "// Codeforces 236A\n\nobject _236A extends App {\n  val scanner = new java.util.Scanner(System.in)\n  val user_name = scanner.next\n  println(\n    if (user_name.distinct.size % 2 == 0) \"CHAT WITH HER!\"\n    else \"IGNORE HIM!\"\n  )\n}\n\n"}, {"source_code": "import scala.io.StdIn._\n\nobject Main {\n  def main(args: Array[String]): Unit = {\n    val s = readLine\n    if (s.toSeq.distinct.size % 2 == 0) println(\"CHAT WITH HER!\") else println(\"IGNORE HIM!\")\n  }\n}\n"}, {"source_code": "object Solution extends App {\n  if (readLine().distinct.size % 2 == 0)\n    println(\"CHAT WITH HER!\")\n  else\n    println(\"IGNORE HIM!\")\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject A_236 extends App {\n  println(if (readLine().toCharArray.toSet.size % 2 == 1) \"IGNORE HIM!\" else \"CHAT WITH HER!\")\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val std = scala.io.StdIn\n    val userName = std.readLine()\n    val result = if (userName.distinct.length % 2 == 0) {\n      \"CHAT WITH HER!\"\n    }\n    else {\n      \"IGNORE HIM!\"\n    }\n    println(result)\n  }\n}"}, {"source_code": "import scala.io.StdIn\n\nobject BoyOrGirl extends App {\n\n  val name = StdIn.readLine()\n\n  if (impl(name))\n    print(\"CHAT WITH HER!\")\n  else\n    print(\"IGNORE HIM!\")\n\n  def impl(name: String): Boolean = {\n    name.distinct.length % 2 == 0\n  }\n\n}\n"}, {"source_code": "import scala.io.StdIn.readLine\nobject BoyOrGirl extends App\n{\n    val input = readLine()\n    val sort = input.distinct.length\n    if(sort % 2 == 0)\n    {\n        println(\"CHAT WITH HER!\")\n    } else println(\"IGNORE HIM!\")\n}"}], "negative_code": [{"source_code": "object Main {\n  def main(args: Array[String]): Unit = {\n      val str = readLine()\n      println(str.distinct.length)\n  }\n}"}, {"source_code": "object BoyGirl extends App {\n\n\tval uniqueCharacters = \n\t\tscala.io.StdIn.readLine()\n\t\t.toSet.size\n\n\tif (uniqueCharacters % 2 == 0) println(\"IGNORE HIM!\")\n\t\telse println(\"CHAT WITH HER!\")\n\n}"}, {"source_code": "object Main extends App {\n  val str = readLine()\n\n  val r = str.toLowerCase().groupBy(_.toChar).map { case (k, v) => (k, v.size) }.\n    filter { case (k, v) => v == 1 }.filterNot { case (k, v) => k == ' ' }.size\n\n  if (r % 2 == 0) println(\"IGNORE HIM!\")\n  else println(\"CHAT WITH HER!\")\n}"}, {"source_code": "import scala.io.StdIn\n\nobject BoyAndGirlMain {\n  def main(args: Array[String]): Unit = {\n    val userName = StdIn.readLine().toArray\n    val lol = userName.groupBy(_.charValue())\n\n    println(lol .size)\n    if (lol.size % 2 == 0 )\n      print (\"CHAT WITH HER!\")\n    else print(\"IGNORE HIM!\")\n  }\n\n}\n"}, {"source_code": "/**\n * Created by richard on 2015/6/10.\n */\nimport scala.io.StdIn\nobject cf236a {\n  def main(args: Array[String]): Unit = {\n    val name = StdIn.readLine()\n    println(if (name.size%2==1) \"IGNORE HIM!\" else \"CHAT WITH HER!\")\n  }\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val s = readLine().toSet\n    println(s)\n    if (s.size % 2 == 0) println(\"CHAT WITH HER!\")\n    else println(\"IGNORE HIM!\")\n  }\n}"}, {"source_code": "// Codeforces 236A\n\nobject _236A extends App {\n  val scanner = new java.util.Scanner(System.in)\n  val user_name = scanner.next\n  println(\n    if (user_name.distinct.size % 2 == 0) \"CHAT WITH HER\"\n    else \"IGNORE HIM\"\n  )\n}\n\n"}, {"source_code": "object JuanDavidRobles236A {\n  def main(args: Array[String]): Unit = {\n\n    import scala.io.StdIn\n\n    var string: String = StdIn.readLine()\n    var words: Array[Char] = new Array[Char](30)\n\n    var count: Int = 0\n\n    for (i <- 0 until string.length; j <- 0 until words.length()){\n\n      if (words(j).equals(string.charAt(i))){\n        words(count) = string.charAt(i)\n        count = count + 1\n      }\n    }\n\n    if (count%2 == 0){\n      println(\"CHAT WITH HER!\")\n    } else {\n      println(\"IGNORE HIM!\")\n    }\n\n  }\n}"}], "src_uid": "a8c14667b94b40da087501fd4bdd7818"}
{"source_code": "object A extends App {\n  val n = scala.io.StdIn.readInt()\n  val a = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n  val t = a.foldLeft((0, 0))((t, i) => {\n    if (i < 0 ) (t._1, t._2 + i)\n    else if (i > 0) (t._1 + i, t._2)\n    else t\n  })\n\n  println(t._1 - t._2)\n}\n", "positive_code": [{"source_code": "object _946A extends CodeForcesApp {\n  import Utils._, annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._, Math._\n\n  override def apply(io: IO): io.type = {\n    val a = io.read[Seq[Int]]\n    val (b, c) = a.partition(_ > 0)\n    io.write(b.sum - c.sum)\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\nobject Utils {\n  import scala.collection.mutable, mutable.{Map => Dict}\n  type Point = java.awt.geom.Point2D.Double\n  implicit class GenericExtensions[A](val a: A) extends AnyVal {\n    def in(set: collection.Set[A]): Boolean = set(a)\n    def some: Option[A] = Some(a)\n    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a\n  }\n  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {\n    def onlyElement: A = assuming(t.size == 1)(t.head)\n    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)\n    def duplicates(implicit b: C of A): C[A] = {\n      val elems = mutable.Set.empty[A]\n      (t collect {case i if !elems.add(i) => i}).to[C]\n    }\n    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}\n    def maxWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.max)\n    def minWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.min)\n    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]\n    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap\n    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)\n    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}\n    def toMutableMultiSet: Dict[A, Int] = {\n      val c = map[A] to 0\n      t.foreach(i => c(i) += 1)\n      c\n    }\n    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0\n    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)\n  }\n  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {\n    def sort(from: Int = 0, until: Int = a.length)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)\n  }\n  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {\n    def sort(from: Int = 0, until: Int = a.length)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)\n  }\n  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {\n    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t\n  }\n  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {\n    def key = p._1\n    def value = p._2\n    def toSeq(implicit ev: B =:= A): Seq[A] = Seq(p._1, ev(p._2))\n  }\n  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {\n    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)\n    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C]).withDefaultValue(b().result())\n    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]\n  }\n  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {\n    def lastKeyOption: Option[K] = m.lastOption.map(_.key)\n    def firstKeyOption: Option[K] = m.headOption.map(_.key)\n    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap\n    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}\n    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m\n    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\n  }\n  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {\n    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)\n    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)\n    private def removeNode(kv: (K, V)): (K, V) = {\n      m -= kv.key\n      kv\n    }\n  }\n  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {\n    def notContains(x: A): Boolean = !(s contains x)\n    def toMutable = mutable.Set.empty[A] ++ s\n  }\n  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {\n    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}\n    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)\n    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)\n    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}\n    //def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)\n  }\n  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {\n    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero\n    def toEnglish = if(x) \"Yes\" else \"No\"\n  }\n  implicit class IntExtensions(val x: Int) extends AnyVal {\n    import java.lang.{Integer => JInt}\n    def withHighestOneBit: Int = JInt.highestOneBit(x)\n    def withLowestOneBit: Int = JInt.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)\n    def bitCount: Int = JInt.bitCount(x)\n    def setLowestBits(n: Int): Int = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Int = x & left(n, ~0)\n    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Int = x | left(i)\n    def clearBit(i: Int): Int = x & ~left(i)\n    def toggleBit(i: Int): Int = x ^ left(i)\n    def getBit(i: Int): Int = (x >> i) & 1\n    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)\n    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)\n  }\n  implicit class LongExtensions(val x: Long) extends AnyVal {\n    import java.lang.{Long => JLong}\n    def withHighestOneBitSet: Long = JLong.highestOneBit(x)\n    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)\n    def bitCount: Int = JLong.bitCount(x)\n    def setLowestBits(n: Int): Long = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Long = x & left(n, ~0L)\n    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Long = x | left(i)\n    def clearBit(i: Int): Long = x & ~left(i)\n    def toggleBit(i: Int): Long = x ^ left(i)\n    def getBit(i: Int): Long = (x >> i) & 1\n    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)\n  }\n  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {\n    import Numeric.Implicits._\n    def **(i: Int): A = if (i == 0) n.one else {\n      val h = x ** (i/2)\n      if (i%2 == 0) h * h else h * h * x\n    }\n    def distance(y: A) = (x - y).abs()\n    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)\n    def whenNegative(f: => A): A = nonNegative.getOrElse(f)   //e.g. students.indexOf(\"Greg\").whenNegative(Int.MaxValue)\n  }\n  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {\n    import scala.collection.immutable.NumericRange, Integral.Implicits._\n    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x\n    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)\n    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)\n  }\n  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new Point(n.toDouble(p._1), n.toDouble(p._2))\n  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)\n  def asc[A](implicit order: Ordering[A]): Ordering[A] = order\n  def map[K] = new {\n    def to[V](default: => V): Dict[K, V] = using(_ => default)\n    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {\n      override def apply(key: K) = getOrElseUpdate(key, f(key))\n    }\n  }\n  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]\n  def memoize[A, B](f: A => B): A ==> B = map[A] using f\n  implicit class FuzzyDouble(val x: Double) extends AnyVal {\n    def  >~(y: Double) = x > y + eps\n    def >=~(y: Double) = x >= y + eps\n    def  ~<(y: Double) = y >=~ x\n    def ~=<(y: Double) = y >~ x\n    def  ~=(y: Double) = (x distance y) <= eps\n  }\n  def toPolygon(points: Traversable[(Int, Int)]): java.awt.Polygon = {\n    val (xs, ys) = points.unzip\n    new java.awt.Polygon(xs.toArray, ys.toArray, points.size)\n  }\n  def toShape(points: Traversable[(Double, Double)]): java.awt.geom.GeneralPath = {\n    val shape = new java.awt.geom.GeneralPath()\n    points.headOption foreach {case (x, y) => shape.moveTo(x, y)}\n    points.tail foreach {case (x, y) => shape.lineTo(x, y)}\n    shape.closePath()\n    shape\n  }\n  def isPrime(n: Int): Boolean = BigInt(n).isProbablePrime(31)\n  def until(until: Int): Range = 0 until until\n  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}\n  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}\n  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None\n  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)\n  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]\n  type ==>[A, B] = collection.Map[A, B]\n  val mod: Int = (1e9 + 7).toInt\n  val eps: Double = 1e-9\n}\n/***********************************[Scala I/O]*********************************************/\nimport Utils._, java.io._, java.util.StringTokenizer\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    when(tokenizers.nonEmpty)(tokenizers.head)\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  def readAll[A: IO.Read]: (Int, Vector[A]) = {\n    val data = read[Vector[A]]\n    (data.length, data)\n  }\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any): this.type = {\n    printer.print(obj)\n    this\n  }\n  def writeLine(): this.type = {\n    printer.println()\n    this\n  }\n  def writeLine(obj: Any): this.type = {\n    printer.println(obj)\n    this\n  }\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n  def query[A: IO.Read](question: Any): A = writeLine(question).read\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                       : Read[String]       = new Read(_.next())\n    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)\n    implicit val int                                          : Read[Int]          = string.map(_.toInt)\n    implicit val long                                         : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                       : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                      : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n"}, {"source_code": "object CF946A extends App {\n  import scala.io.StdIn._\n  readLine()\n\n  val nums: List[Int] = readLine().split(\" \").map(Integer.parseInt(_)).toList\n\n  val (pos, neg) = nums.partition(_ > 0)\n\n  val res = pos.sum - neg.sum\n\n  println(res)\n\n}\n"}, {"source_code": "object A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(n) = readInts(1)\n  val xs = readInts(n)\n  val sum = xs.sum\n  var max = Int.MinValue\n\n  for (d <- -101 to 101) {\n    max = Math.max(max, Math.abs(xs.filter(_ <= d).sum - xs.filter(_ > d).sum))\n  }\n\n  println(max)\n\n  Console.flush\n}\n"}, {"source_code": "object APartition extends App {\n  val n = scala.io.StdIn.readInt()\n  val a = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n\n  val t = a.foldLeft(0)(_ + _.abs)\n\n  println(t)\n}\n"}], "negative_code": [{"source_code": "object A extends App {\n  val n = scala.io.StdIn.readInt()\n  val a = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n\n  val t = a.reduce(_.abs + _.abs)\n\n  println(t)\n}\n"}], "src_uid": "4b5d14833f9b51bfd336cc0e661243a5"}
{"source_code": "object A80 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def main(args: Array[String]): Unit = {\n    val Array(n, m) = readInts(2)\n    val primes = genPrimes(100)\n    if(primes.contains(n) && primes.contains(m)) {\n      val nPos = primes.indexOf(n)\n      val mPos = primes.indexOf(m)\n      if(mPos == nPos+1) {\n        out.println(\"YES\")\n      } else {\n        out.println(\"NO\")\n      }\n    } else {\n      out.println(\"NO\")\n    }\n    out.close()\n  }\n\n  def genPrimes(till: Int): Array[Int] = {\n    val isPrime = Array.fill[Boolean](till+1)(true)\n    isPrime(0) = false\n    isPrime(1) = true // not composite\n    for(i <- 4 to till by 2) {\n      isPrime(i) = false\n    }\n    for(i <- 3 to till by 2 if isPrime(i)) {\n      for(j <- i+i to till by i) isPrime(j) = false\n    }\n    isPrime.zipWithIndex.filter(_._1).map(_._2)\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(\"src/input\")))\n    val out = new java.io.PrintWriter(System.out)\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n", "positive_code": [{"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P80A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  def nextPrime(n: Int): Int = {\n    def isPrime(x: Int): Boolean = (2 until x).forall(x % _ > 0)\n\n    @tailrec\n    def loop(i: Int): Int =\n      if (isPrime(i)) i\n      else loop(i + 1)\n\n    loop(n + 1)\n  }\n\n  val N, M = sc.nextInt\n  val answer = if (M == nextPrime(N)) \"YES\" else \"NO\"\n\n  out.println(answer)\n  out.close\n}\n"}, {"source_code": "object APanoramixsPrediction extends App {\n  import scala.io.StdIn._\n\n  lazy val primes: Stream[Int] =\n    2 #:: Stream.iterate(3)(_ + 2).filter(isPrime)\n\n  def isPrime(number: Int): Boolean =\n    primes.takeWhile(prime => prime * prime <= number).forall(number % _ != 0)\n\n  val Array(n, m) = readLine().split(\" \").map(_.toInt)\n\n  val ans = isPrime(m) && primes.indexOf(n) + 1 == primes.indexOf(m) match {\n    case true => \"YES\"\n    case _    => \"NO\"\n  }\n\n  println(ans)\n}\n"}, {"source_code": "import java.io._\nimport java.util.Locale\nimport scala.annotation.tailrec\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInt = reader.readLine().toInt\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readLongs = reader.readLine().split(\" \").map(_.toLong)\n\n  def sqStream(current: Int, ceil: Int): Stream[Int] = if(current * current > ceil) Stream.Empty else current #:: sqStream(current + 1, ceil)\n  def isPrime(x: Int) = sqStream(2, x).filter(x % _ == 0).isEmpty\n  @tailrec\n  def nextPrime(n: Int): Int = if(isPrime(n)) n else nextPrime(n + 1)\n  val Array(m, n) = readInts\n  def ans = nextPrime(m + 1) == n\n  val yesNoAns = Map(true -> \"YES\", false -> \"NO\")\n\n  def main(a: Array[String]) {\n    println(yesNoAns(ans))\n  }\n}\n"}, {"source_code": "object Main {\n  def sieve(n: Int) = {\n    val primes = scala.collection.mutable.BitSet.empty ++ (2 to n)\n    for {\n      candidate <- 2 until Math.sqrt(n).ceil.toInt\n      if primes contains candidate\n    } primes --= candidate * candidate to n by candidate\n    primes \n  } \n  \n  val primes = sieve(51).zipWithIndex\n\n  def main(args: Array[String]) {\n    val nm = readLine().split(\" \").map(_.toInt)\n    val n = nm(0)\n    val m = nm(1)\n    val i = primes.find(_._1 == n).get._2\n    val j = primes.find(_._1 == m).map(_._2)\n    if (j.map(_ - i).getOrElse(0) == 1) println(\"YES\")\n    else println(\"NO\")\n  }\n}"}, {"source_code": "object Panoramix extends App {\n\n  val Array(n, m) = readLine.split(' ').map(_.toInt)\n\n  val primes: Array[Int] = Array(\n    2, 3, 5, 7, 11, 13,\n    17, 19, 23, 29, 31,\n    37, 41, 43, 47\n  )\n\n  val result: Boolean = \n    primes.contains(n) && primes.contains(m) &&\n      primes.indexOf(m) - primes.indexOf(n) == 1\n  println(if (result) \"YES\" else \"NO\")\n\n}\n"}, {"source_code": "object Flask {\n  \n  def isPrime(n: Int): Boolean = List.range(2, n / 2 + 1).forall(n % _ != 0)\n\n  def main(args: Array[String]): Unit = {\n    var input = Console.readLine.split(\" \").map(_.toInt)\n    var n = input(0); var m = input(1)\n    var result = isPrime(m) && List.range(n + 1, m).forall(x => !isPrime(x))\n    println(if (result) \"YES\" else \"NO\")\n  }\n}"}, {"source_code": "import scala.io.Source\n\nobject a11 {\n  def main(args: Array[String]): Unit = {\n    val a =  Seq.iterate((List[Int](),(2 to 50).toArray),5)(a=>(((a._2.head)::a._1), a._2.filter(b => b % (a._2.head) != 0))).last\n    val primes = a._1.reverse.toArray ++ a._2\n    val line = Source.stdin.getLines().take(1).map(_.split(' ').map(_.toInt)).toArray.head\n    val (b,c) = (line(0), line(1))\n    println(if (!primes.contains(c) || primes(primes.indexOf(b)+1) != c)\n      \"NO\"\n    else\n      \"YES\")\n  }\n}"}, {"source_code": "object Solution extends App {\n  def simple(a: Int) =\n    a % 2 != 0 && (3 to Math.sqrt(a).toInt by 2).forall(a % _ != 0) || a == 2\n\n  val in = scala.io.Source.stdin.getLines()\n  val Array(n, m) = in.next().split(\" \").map(_.toInt)\n  if (simple(m) && (n + 1 until m).forall(t => !simple(t)))\n    println(\"YES\")\n  else\n    println(\"NO\")\n}"}], "negative_code": [{"source_code": "object Solution extends App {\n  def simple(a: Int) = {\n    a % 2 == 0 && (a == 2 || (3 to Math.sqrt(a).toInt).forall(a % _ != 0))\n  }\n\n  val in = scala.io.Source.stdin.getLines()\n  val Array(n, m) = in.next().split(\" \").map(_.toInt)\n  if (simple(m) && (n + 1 until m).forall(t => !simple(t)))\n    println(\"YES\")\n  else\n    println(\"NO\")\n}"}, {"source_code": "object Main {\n  def sieve(n: Int) = {\n    val primes = scala.collection.mutable.BitSet.empty ++ (2 to n)\n    for {\n      candidate <- 2 until Math.sqrt(n).toInt\n      if primes contains candidate\n    } primes --= candidate * candidate to n by candidate\n    primes \n  } \n  \n  val primes = sieve(50).zipWithIndex\n\n  def main(args: Array[String]) {\n    val nm = readLine().split(\" \").map(_.toInt)\n    val n = nm(0)\n    val m = nm(1)\n    val i = primes.find(_._1 == n).get._2\n    val j = primes.find(_._1 == m).map(_._2)\n    if (j.map(_ - i).getOrElse(0) == 1) println(\"YES\")\n    else println(\"NO\")\n  }\n}"}, {"source_code": "object Main {\n  def sieve(n: Int) = {\n    val primes = scala.collection.mutable.BitSet.empty ++ (2 to n)\n    for {\n      candidate <- 2 until Math.sqrt(n).ceil.toInt\n      if primes contains candidate\n    } primes --= candidate * candidate to n by candidate\n    primes \n  } \n  \n  val primes = sieve(51).zipWithIndex\n\n  def main(args: Array[String]) {\n    val nm = readLine().split(\" \").map(_.toInt)\n    val n = nm(0)\n    val m = nm(1)\n    val i = primes.find(_._1 == n).get._2\n    val j = primes.find(_._1 == m).map(_._2)\n    println(\"i = \" + i)\n    println(\"j = \" + j)\n    if (j.map(_ - i).getOrElse(0) == 1) println(\"YES\")\n    else println(\"NO\")\n  }\n}"}], "src_uid": "9d52ff51d747bb59aa463b6358258865"}
{"source_code": "import java.util.Scanner\n\nobject R273_RandomTeams {\n  def main(args: Array[String]) = {\n    val in = new Scanner(System.in).nextLine().split(\" \").map(_.toInt)\n    val (n, m) = (in(0), in(1))\n    val (p, q) = (n / m, n % m)\n\n    val min = combination2(p) * (m - q) + combination2(p + 1) * q\n    val max = combination2(n - m + 1)\n    println(min + \" \" + max)\n   }\n\n  def combination2(n: Long): Long = {\n    (n * (n - 1)) / 2\n  }\n}\n", "positive_code": [{"source_code": "import java.util.Scanner\n\nobject Solution {\n    def countPairs(n: Long): Long = n * (n - 1) / 2\n    \n    def main(args: Array[String]) = {\n\tval in = new Scanner(System.in)\n\tval people = in.nextLong()\n\tval teams = in.nextLong()\n\tval max = countPairs(people - teams + 1)\n\tval size = people / teams\n\tval bigCount = people - size * teams \n\tval smallCount = teams - bigCount\n\tval min = countPairs(size + 1) * bigCount + countPairs(size) * smallCount\n\tprintln(min + \" \" + max)\n    }\n}"}, {"source_code": "import java.util.Scanner\n\nobject Main extends App {\n  val in = (new Scanner(System.in)).nextLine().split(\" \").map(_.toInt)\n  val n = in(0)\n  val m = in(1)\n\n  def nC2(n: Int): Long = {\n    if(n == 1) 0\n    else\n      n.toLong * (n-1) / 2\n  }\n\n  val mi = n/m\n  val mi2_count = if( mi*m != n ) n - mi*m else 0\n  val mi_count = m - mi2_count\n  val ans1 = (nC2(mi)*mi_count + nC2(mi+1)*mi2_count)\n\n  val mx = n - (m-1)\n  val ans2 = nC2(mx)\n\n  println(ans1.toString + \" \" + ans2.toString)\n}\n"}, {"source_code": "import java.util.StringTokenizer\n\nobject _478B extends App {\n  var token = new StringTokenizer(\"\")\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n  val n = next.toLong\n  val m = next.toLong\n  def choose(a: Long) = a * (a - 1) / 2\n  val max = choose(n - (m - 1))\n  val min = (m - n % m) * choose(n / m) + (n % m) * choose(n / m + 1)\n  println(min + \" \" + max)\n}\n"}, {"source_code": "object Solution extends App {\n  def f(n: Long) = n * (n - 1) / 2\n\n\n  val in = scala.io.Source.stdin.getLines()\n  val Array(n, m) = in.next().split(\" \").map(_.toLong)\n  val c = n / m\n  val min = (n % m) * f(c + 1) + (m - n % m) * f(c)\n  val max = f(n - m + 1)\n  println(min + \" \" + max)\n}"}, {"source_code": "object B478 {\n  @inline def read = scala.io.StdIn.readLine\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val Array(n, m) = readLongs(2)\n    val min = {\n      val mod = n%m\n      mod * ((n/m + 1) *(n/m)) /2 + (m-mod) * ((n/m) * (n/m -1 )) / 2\n    }\n    val max = ((n-m+1) * (n-m))/2\n    println(s\"$min $max\")\n  }\n}"}, {"source_code": "object P478B {\n\tdef edges(n: Int) : BigInt = ((BigInt(n) * n) - n) / 2\n\n\tdef main(args: Array[String]) {\n\t\tval Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\t\tval min = (n % m) * edges((n / m) + 1) + (m - (n % m)) * edges(n / m)\n\t\tval max = edges(n - m + 1)\n\t\tprintln(List(min, max).mkString(\" \"))\n\t}\n}\n"}], "negative_code": [{"source_code": "import java.util.StringTokenizer\n\nobject _478B extends App {\n  var token = new StringTokenizer(\"\")\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n  val n = next.toLong\n  val m = next.toLong\n  def choose(a: Long) = a * (a - 1) / 2\n  val max = choose(n - (m - 1))\n  val min = {\n    if (n % m == 0) m * choose(n / m)\n    else (m - 1) * choose(n / m) + choose(n - n / m * (m - 1))\n  }\n  println(min + \" \" + max)\n}\n"}, {"source_code": "object Solution extends App {\n  def f(n: Int) = n * (n - 1) / 2\n\n\n  val in = scala.io.Source.stdin.getLines()\n  val Array(n, m) = in.next().split(\" \").map(_.toInt)\n  val c = n / m\n  val min = (n % m) * f(c + 1) + (m - n % m) * f(c)\n  val max = f(n - m + 1)\n  println(max + \" \" + min)\n}"}, {"source_code": "object Solution extends App {\n  def f(n: Int) = n * (n - 1) / 2\n\n  val in = scala.io.Source.stdin.getLines()\n  val Array(n, m) = in.next().split(\" \").map(_.toInt)\n  val c = n / m\n  val min = (n % m) * f(c + 1) + (m - n % m) * f(c)\n  val max = f(n - m + 1)\n  println(min + \" \" + max)\n}"}, {"source_code": "object Solution extends App {\n  def f(n: Int) = n * (n + 1) / 2\n  \n\n  val in = scala.io.Source.stdin.getLines()\n  val Array(n, m) = in.next().split(\" \").map(_.toInt)\n  val c = n / m\n  val min = (n % m) * f(c + 1) + (m - n % m) * f(c)\n  val max = f(n - m)\n  println(max + \" \" + min)\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject R273_RandomTeams {\n  def main(args: Array[String]) = {\n    val in = new Scanner(System.in).nextLine().split(\" \").map(_.toInt)\n    val (n, m) = (in(0), in(1))\n    val (p, q) = (n / m, n % m)\n\n    val min = combination2(p) * (m - q) + (combination2(p) + 1) * q\n    val max = combination2(n - m + 1)\n    println(min + \" \" + max)\n   }\n\n  def combination2(n: Long): Long = {\n    (n * (n - 1)) / 2\n  }\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject R273_RandomTeams {\n  def main(args: Array[String]) = {\n    val in = new Scanner(System.in).nextLine().split(\" \").map(_.toInt)\n    val n = in(0)\n    val m = in(1)\n    val p = n / m\n    val q = n % m\n\n    val min = combination2(p) * (m - q) + (combination2(p) + 1) * q\n    val max = combination2(n - m + 1)\n    println(min + \" \" + max)\n   }\n\n  def combination2(n: Int): Int = {\n    (n / 2) * (n - 1)\n  }\n\n  def fact(n: Int): Int = {\n    Range(1, n + 1).toList.product\n  }\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject R273_RandomTeams {\n  def main(args: Array[String]) = {\n    val in = new Scanner(System.in).nextLine().split(\" \").map(_.toInt)\n    val n = in(0)\n    val m = in(1)\n    val p = n / m\n    val q = n % m\n\n    val min = combination2(p) * (m - q) + (combination2(p) + 1) * q\n    val max = combination2(n - m + 1)\n    println(min + \" \" + max)\n   }\n\n  def combination2(n: Int): Int = {\n    (n * (n - 1)) / 2\n  }\n\n  def fact(n: Int): Int = {\n    Range(1, n + 1).toList.product\n  }\n}\n"}, {"source_code": "object P478B {\n\tdef edges(n: Int) : BigInt = ((BigInt(n) * n) - n) / 2\n\n\tdef main(args: Array[String]) {\n\t\tval Array(n, m) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n\t\tval min = (n % m) * edges((n / m) + 1) + (m - (n % m)) * edges(n / m)\n\t\tval max = edges(n - m + 1)\n\t\tprintln(min, max)\n\t}\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject Solution {\n    def countPairs(n: Long): Long = n * (n - 1) / 2\n    \n    def main(args: Array[String]) = {\n\tval in = new Scanner(System.in)\n\tval people = in.nextLong()\n\tval teams = in.nextLong()\n\tval max = countPairs(people - teams + 1) + teams - 1\n\tval size = people / teams\n\tval bigCount = people - size * teams \n\tval smallCount = teams - bigCount\n\tval min = countPairs(size + 1) * bigCount + countPairs(size) * smallCount\n\tprintln(min + \" \" + max)\n    }\n}"}, {"source_code": "import java.util.Scanner\n\nobject Main extends App {\n  val in = (new Scanner(System.in)).nextLine().split(\" \").map(_.toInt)\n  val n = in(0)\n  val m = in(1)\n\n  def nCm(n: Int, m: Int): Long = {\n    if(n == 1) 0\n    else {\n      val nt = (1 to n).reverse.take(m).product\n      val mt = (1 to m).reverse.product\n      (nt / mt).toLong\n    }\n  }\n\n  val mi = n/m\n  val mi2_count = if( mi*m != n ) n - mi*m else 0\n  val mi_count = m - mi2_count\n  val ans1 = (nCm(mi,2)*mi_count + nCm(mi+1,2)*mi2_count)\n\n  val mx = n - (m-1)\n  val ans2 = nCm(mx,2)\n\n  print(Math.min(ans1, ans2))\n  print(\" \")\n  println(Math.max(ans1, ans2))\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject Main extends App {\n  val in = (new Scanner(System.in)).nextLine().split(\" \").map(_.toInt)\n  val n = in(0)\n  val m = in(1)\n\n  def nCm(n: Int, m: Int): Long = {\n    if(n == 1) 1\n    else {\n      val nt = (1 to n).reverse.take(m).product\n      val mt = (1 to m).reverse.product\n      (nt / mt).toLong\n    }\n  }\n\n  val mi = n/m\n  val mi2_count = if( mi*m != n ) n - mi*m else 0\n  val mi_count = m - mi2_count\n  val ans1 = (nCm(mi,2)*mi_count + nCm(mi+1,2)*mi2_count)\n\n  val mx = n - (m-1)\n  val ans2 = nCm(mx,2)\n\n  print(Math.min(ans1, ans2))\n  print(\" \")\n  println(Math.max(ans1, ans2))\n}\n"}], "src_uid": "a081d400a5ce22899b91df38ba98eecc"}
{"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val first = in.next() match {\n    case \"monday\" => 0\n    case \"tuesday\" => 1\n    case \"wednesday\" => 2\n    case \"thursday\" => 3\n    case \"friday\" => 4\n    case \"saturday\" => 5\n    case \"sunday\" => 6\n  }\n  val second = in.next() match {\n    case \"monday\" => 0\n    case \"tuesday\" => 1\n    case \"wednesday\" => 2\n    case \"thursday\" => 3\n    case \"friday\" => 4\n    case \"saturday\" => 5\n    case \"sunday\" => 6\n  }\n  val candidates = List(first + 28, first + 30, first + 31).map(_ % 7)\n  if (candidates.contains(second))\n    println(\"YES\")\n  else\n    println(\"NO\")\n}\n", "positive_code": [{"source_code": "import java.io._\n\nobject ProblemA {\n  def main(args: Array[String]): Unit = processStdInOut()\n\n  def processStdInOut(): Unit = {\n    val src = io.Source.fromInputStream(System.in)\n    try {\n      val bw = new BufferedWriter(new OutputStreamWriter(System.out));\n      try {\n        val lines = src.getLines()\n        processLines(lines, bw)\n      } finally {\n        bw.flush()\n        bw.close()\n      }\n    } finally {\n      src.close();\n    }\n  }\n\n  // Standard code above, custom code below\n\n  def processLines(lines: Iterator[String], bw: BufferedWriter): Unit = {\n    val day1 = lines.next()\n    val day2 = lines.next()\n    val hasSolution = solve(day1, day2)\n    if (hasSolution) { bw.write(\"YES\") } else {bw.write(\"NO\") };\n    bw.newLine()\n  }\n\n  def solve(day1: String, day2: String): Boolean = {\n    val dayNames = List(\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\")\n    def getDayIndex(dayName: String): Int = dayNames.indexOf(dayName)\n    val day1Index = getDayIndex(day1)\n    val day2Index = getDayIndex(day2)\n    val dayOffset = (7 + day2Index - day1Index) % 7  // Add 7 to prevent negative remainders\n    val monthLengths = List(28, 30, 31)\n    monthLengths.exists(dayOffset == _ % 7)\n  }\n}\n"}, {"source_code": "object A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n\n  val dows = Array(\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\")\n  val ms = Array(28, 30, 31)\n\n  val s1, s2 = readLine\n\n  val d1 = dows.indexWhere(_ == s1)\n  val d2 = dows.indexWhere(_ == s2)\n\n  val can = ms.exists(d => (d1 + d) % 7 == d2)\n\n  println(if (can) \"YES\" else \"NO\")\n}\n"}, {"source_code": "import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._, collection.Searching._\n\nobject _724A extends CodeForcesApp {\n  override def apply(io: IO) = {import io.{read, write, writeAll, writeLine}\n    val d1, d2 = read[String]\n\n    val months = Seq(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)\n    val firstDayOfMonth = months.init.scanLeft(0)(_ + _)\n\n    val days = IndexedSeq(\"monday\", \"tuesday\", \"wednesday\", \"thursday\", \"friday\", \"saturday\", \"sunday\")\n\n    val ans = days.zipWithIndex exists {case (start, k) =>\n      val calendar = Seq.tabulate(365)(i => days((i + k)%days.length))\n      firstDayOfMonth.sliding(2) exists {\n        case Seq(m1, m2) => calendar(m1) == d1 && calendar(m2) == d2\n      }\n    }\n\n    write(ans.toEnglish)\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\nobject Utils {\n  import scala.collection.mutable, mutable.{Map => Dict}\n  implicit class GenericExtensions[A](val a: A) extends AnyVal {\n    def in(set: collection.Set[A]): Boolean = set(a)\n    def some: Option[A] = Some(a)\n    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a\n  }\n  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {\n    def onlyElement: A = assuming(t.size == 1)(t.head)\n    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)\n    def duplicates(implicit b: C of A): C[A] = {\n      val elems = mutable.Set.empty[A]\n      (t collect {case i if !elems.add(i) => i}).to[C]\n    }\n    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}\n    def maxWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.max)\n    def minWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.min)\n    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]\n    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap\n    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)\n    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}\n    def toMutableMultiSet: Dict[A, Int] = {\n      val c = map[A] to 0\n      t.foreach(i => c(i) += 1)\n      c\n    }\n    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0\n    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)\n  }\n  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)\n  }\n  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)\n  }\n  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {\n    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t\n  }\n  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {\n    def key = p._1\n    def value = p._2\n  }\n  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {\n    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)\n    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])\n    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]\n  }\n  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {\n    def lastKeyOption: Option[K] = m.lastOption.map(_.key)\n    def firstKeyOption: Option[K] = m.headOption.map(_.key)\n    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap\n    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}\n    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m\n  }\n  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {\n    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)\n    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)\n    private def removeNode(kv: (K, V)): (K, V) = {\n      m -= kv.key\n      kv\n    }\n  }\n  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {\n    def notContains(x: A): Boolean = !(s contains x)\n    def toMutable = mutable.Set.empty[A] ++ s\n  }\n  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {\n    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)\n    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)\n    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}\n    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)\n  }\n  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {\n    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero\n    def toEnglish = if(x) \"YES\" else \"NO\"\n  }\n  implicit class IntExtensions(val x: Int) extends AnyVal {\n    import java.lang.{Integer => JInt}\n    def withHighestOneBit: Int = JInt.highestOneBit(x)\n    def withLowestOneBit: Int = JInt.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)\n    def bitCount: Int = JInt.bitCount(x)\n    def setLowestBits(n: Int): Int = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Int = x & left(n, ~0)\n    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Int = x | left(i)\n    def clearBit(i: Int): Int = x & ~left(i)\n    def toggleBit(i: Int): Int = x ^ left(i)\n    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1\n    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)\n    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)\n  }\n  implicit class LongExtensions(val x: Long) extends AnyVal {\n    import java.lang.{Long => JLong}\n    def withHighestOneBitSet: Long = JLong.highestOneBit(x)\n    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)\n    def bitCount: Int = JLong.bitCount(x)\n    def setLowestBits(n: Int): Long = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Long = x & left(n, ~0L)\n    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Long = x | left(i)\n    def clearBit(i: Int): Long = x & ~left(i)\n    def toggleBit(i: Int): Long = x ^ left(i)\n    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1\n    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)\n  }\n  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {\n    import Numeric.Implicits._\n    def **(i: Int): A = if (i == 0) n.one else {\n      val h = x ** (i/2)\n      if (i%2 == 0) h * h else h * h * x\n    }\n    def distance(y: A) = (x - y).abs()\n    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)\n    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf \"Greg\" whenNegative Int.MaxValue\n  }\n  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {\n    import scala.collection.immutable.NumericRange, Integral.Implicits._\n    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x\n    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)\n    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)\n  }\n  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)\n  def asc[A](implicit order: Ordering[A]): Ordering[A] = order\n  def map[K] = new {\n    def to[V](default: => V): Dict[K, V] = using(_ => default)\n    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {\n      override def apply(key: K) = getOrElseUpdate(key, f(key))\n    }\n  }\n  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]\n  def memoize[A, B](f: A => B): A ==> B = map[A] using f\n  implicit class FuzzyDouble(val x: Double) extends AnyVal {\n    def  >~(y: Double) = x > y + eps\n    def >=~(y: Double) = x >= y + eps\n    def  ~<(y: Double) = y >=~ x\n    def ~=<(y: Double) = y >~ x\n    def  ~=(y: Double) = (x distance y) <= eps\n  }\n  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))\n  def toPolygon(points: Traversable[(Int, Int)]): java.awt.Polygon = {\n    val (xs, ys) = points.unzip\n    new java.awt.Polygon(xs.toArray, ys.toArray, points.size)\n  }\n  def toShape(points: Traversable[(Double, Double)]): java.awt.geom.GeneralPath = {\n    val shape = new java.awt.geom.GeneralPath()\n    points.headOption foreach {case (x, y) => shape.moveTo(x, y)}\n    points.tail foreach {case (x, y) => shape.lineTo(x, y)}\n    shape.closePath()\n    shape\n  }\n  def until(until: Int): Range = 0 until until\n  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}\n  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}\n  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None\n  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)\n  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]\n  type ==>[A, B] = collection.Map[A, B]\n  val mod: Int = (1e9 + 7).toInt\n  val eps: Double = 1e-9\n}\n/***********************************[Scala I/O]*********************************************/\nimport Utils._, java.io._, java.util.StringTokenizer\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    when(tokenizers.nonEmpty)(tokenizers.head)\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any): this.type = {\n    printer.print(obj)\n    this\n  }\n  def writeLine(): this.type = {\n    printer.println()\n    this\n  }\n  def writeLine(obj: Any): this.type = {\n    printer.println(obj)\n    this\n  }\n  def writeAll(obj: Traversable[Any], separator: String = \"\\n\"): this.type = write(obj mkString separator)\n  def query[A: IO.Read](question: Any): A = writeLine(question).read\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                       : Read[String]       = new Read(_.next())\n    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)\n    implicit val int                                          : Read[Int]          = string.map(_.toInt)\n    implicit val long                                         : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                       : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                      : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n"}, {"source_code": "//package me.code4fun\n\nimport scala.io.StdIn\n\nobject A {\n\n  def dayOfWeek(dayStr: String): Int =\n    dayStr match {\n      case \"monday\" => 0\n      case \"tuesday\" => 1\n      case \"wednesday\" => 2\n      case \"thursday\" => 3\n      case \"friday\" => 4\n      case \"saturday\" => 5\n      case \"sunday\" => 6\n      case _ => throw new IllegalArgumentException(s\"$dayStr is not a day of week\")\n    }\n\n  val nbDaysInWeek = 7\n\n  val possibleOffsets = Seq(28, 30, 31).map(_ % nbDaysInWeek)\n\n  def posMod(a: Int, b: Int): Int = {\n    val mod = a % b\n    if (mod >= 0) mod else (mod + b)\n  }\n\n  def areConsecutiveDays(firstDay: String, secondDay: String): Boolean = {\n    val fst = dayOfWeek(firstDay)\n    val snd = dayOfWeek(secondDay)\n    val diff = posMod(snd - fst, nbDaysInWeek)\n    possibleOffsets.contains(diff)\n  }\n\n  def main(args: Array[String]): Unit = {\n    val fst = StdIn.readLine()\n    val snd = StdIn.readLine()\n    if (areConsecutiveDays(fst, snd))\n      Console.out.println(\"YES\")\n    else\n      Console.out.println(\"NO\")\n  }\n}\n"}], "negative_code": [], "src_uid": "2a75f68a7374b90b80bb362c6ead9a35"}
{"source_code": "//package me.jetblack.cf\n\nimport java.util.Scanner\n\nobject TreesCount extends App {\n\n  val s = new Scanner(System.in)\n\n  val maxn = s.nextInt()\n  val maxh = s.nextInt()\n\n  val dp = Array.ofDim[Long](maxn + 1, maxn + 1)\n  dp(0)(0) = 1\n  for {\n    h <- (1 until maxn + 1)\n    i <- (1 until maxn + 1)\n    j <- (1 to i)\n  } yield {\n    val left1 = dp(h - 1)(j - 1)\n    val right1 = (0 until h).map(h1 => dp(h1)(i - j)).sum\n    val left2 = (0 until h - 1).map(h1 => dp(h1)(j - 1)).sum\n    val right2 = dp(h - 1)(i - j)\n    dp(h)(i) += (left1 * right1) + left2 * right2\n  }\n\n  val result = (maxh to maxn).map(dp(_)(maxn)).sum\n  println(result)\n\n}\n", "positive_code": [{"source_code": "import java.util._\nimport java.io._\n\nobject D {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def sumOfTrees(dp: Array[Array[Long]], h: Int, n: Int): Long = {\n    var temp: Long = 0\n    for (i <- 0 to h) {\n      temp += dp(i)(n)\n    }\n    temp\n  }\n\n  def solve = {\n    val n = nextInt\n    val h = nextInt\n    val dp = new Array[Array[scala.Long]](36)\n    for (i <- 0 to 35) {\n      dp(i) = new Array[scala.Long](36)\n      Arrays.fill(dp(i), 0)\n    }\n    dp(0)(0) = 1L\n    for (i <- 1 to h) {\n      dp(i)(0) = 0L\n    }\n    for (i <- 1 to n) {\n      dp(0)(i) = 0L\n    }\n    for (i <- 1 to 35) {\n      for (j <- 1 to 35) {\n        var temp: Long = 0\n        for (m <- 1 to j) {\n          temp += dp(i - 1)(m - 1) * sumOfTrees(dp, i - 1, j - m) + dp(i - 1)(j - m) * sumOfTrees(dp, i - 2, m - 1)\n        }\n        dp(i)(j) = temp\n      }\n    }\n    var ans: Long = 0\n    for (i <- h to n) {\n      ans += dp(i)(n)\n    }\n    out.println(ans)\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n"}], "negative_code": [{"source_code": "//package me.jetblack.cf\n\nimport java.util.Scanner\n\nobject TreesCount extends App {\n\n  val s = new Scanner(System.in)\n\n  val maxn = s.nextInt()\n  val maxh = s.nextInt()\n\n  val dp = Array.ofDim[Int](maxn + 1, maxn + 1)\n  dp(0)(0) = 1\n  for {\n    h <- (1 until maxn + 1)\n    i <- (1 until maxn + 1)\n    j <- (1 to i)\n  } yield {\n    val left1 = dp(h - 1)(j - 1)\n    val right1 = (0 until h).map(h1 => dp(h1)(i - j)).sum\n    val left2 = (0 until h - 1).map(h1 => dp(h1)(j - 1)).sum\n    val right2 = dp(h - 1)(i - j)\n    dp(h)(i) += (left1 * right1) + left2 * right2\n  }\n\n  val result = (maxh to maxn).map(dp(_)(maxn)).sum\n  println(result)\n\n}\n"}], "src_uid": "faf12a603d0c27f8be6bf6b02531a931"}
{"source_code": "import scala.io.StdIn._\n\nobject Main extends App {\n  val a =\n    (for (_ <- 0 until 10)\n      yield readLine()).toArray\n\n  if (check((0, 1)) || check((1, 0)) || check((1, 1)) || check((1, -1)))\n    println(\"YES\")\n  else\n    println(\"NO\")\n\n  def good(x: Int): Boolean = x >= 0 && x < 10\n\n  def check(diff: (Int, Int)): Boolean = {\n    for (i <- 0 until 10; j <- 0 until 10) {\n      var (x, y, cnt, free) = (j, i, 0, 0)\n      for (z <- 0 until 5) {\n        if (good(x) && good(y))\n          if (a(y)(x) == 'X')\n            cnt += 1\n          else if (a(y)(x) == '.')\n            free += 1\n        y += diff._1\n        x += diff._2\n      }\n      if (cnt == 4 && free == 1)\n        return true\n    }\n    false\n  }\n}\n", "positive_code": [{"source_code": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn._\n\nobject Main extends App {\n  val a = ArrayBuffer[ArrayBuffer[Char]]()\n  for (i <- 0 until 10) {\n    a.append(readLine().toCharArray.to[ArrayBuffer])\n  }\n\n  if (check(a, (0, 1)) || check(a, (1, 0)) || check(a, (1, 1)) || check(a, (1, -1)))\n    println(\"YES\")\n  else\n    println(\"NO\")\n\n  def good(x: Int): Boolean = x >= 0 && x < 10\n\n  def check(a: ArrayBuffer[ArrayBuffer[Char]], diff: (Int, Int)): Boolean = {\n    for (i <- 0 until 10) {\n      for (j <- 0 until 10) {\n        var x = j\n        var y = i\n        var cnt = 0\n        var free = 0\n        for (z <- 0 until 5) {\n          if (good(x) && good(y))\n            if (a(y)(x) == 'X')\n              cnt += 1\n            else if (a(y)(x) == '.')\n              free += 1\n          y += diff._1\n          x += diff._2\n        }\n        if (cnt == 4 && free == 1)\n          return true\n      }\n    }\n    false\n  }\n}\n"}], "negative_code": [{"source_code": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn._\n\nobject Main extends App {\n  val a = ArrayBuffer[ArrayBuffer[Char]]()\n  for (i <- 0 until 10) {\n    a.append(readLine().toCharArray.to[ArrayBuffer])\n  }\n\n  if (check(a) || check(a.transpose) || check2(a, (1, 1)) || check2(a, (1, -1)))\n    println(\"YES\")\n  else\n    println(\"NO\")\n\n\n  def check(a: ArrayBuffer[ArrayBuffer[Char]]): Boolean = {\n    for (i <- 0 until 10) {\n      for (j <- 0 to 5) {\n        var cnt = 0\n        for (z <- j until j + 5) {\n          if (a(i)(z) == 'X')\n            cnt += 1\n          else if (a(i)(z) == 'O')\n            cnt = -5\n        }\n        if (cnt == 4)\n          return true\n      }\n    }\n    false\n  }\n\n  def good(x: Int): Boolean = x >= 0 && x < 10\n\n  def check2(a: ArrayBuffer[ArrayBuffer[Char]], diff: (Int, Int)): Boolean = {\n    for (i <- 0 until 10) {\n      for (j <- 0 until 10) {\n        var x = j\n        var y = i\n        var cnt = 0\n        for (z <- 0 until 5) {\n          y += diff._1\n          x += diff._2\n          if (good(x) && good(y))\n            if (a(y)(x) == 'X')\n              cnt += 1\n            else if (a(y)(x) == 'O')\n              cnt = -5\n        }\n        if (cnt == 4)\n          return true\n      }\n    }\n    false\n  }\n}\n"}, {"source_code": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn._\n\nobject Main extends App {\n  val a = ArrayBuffer[ArrayBuffer[Char]]()\n  for (i <- 0 until 10) {\n    a.append(readLine().toCharArray.to[ArrayBuffer])\n  }\n\n  if (check(a, (0, 1)) || check(a, (1, 0)) || check(a, (1, 1)) || check(a, (1, -1)))\n    println(\"YES\")\n  else\n    println(\"NO\")\n\n  def good(x: Int): Boolean = x >= 0 && x < 10\n\n  def check(a: ArrayBuffer[ArrayBuffer[Char]], diff: (Int, Int)): Boolean = {\n    for (i <- 0 until 10) {\n      for (j <- 0 until 10) {\n        var x = j\n        var y = i\n        var cnt = 0\n        var free = 0\n        for (z <- 0 until 5) {\n          y += diff._1\n          x += diff._2\n          if (good(x) && good(y))\n            if (a(y)(x) == 'X')\n              cnt += 1\n            else if (a(y)(x) == '.')\n              free += 1\n        }\n        if (cnt == 4 && free == 1)\n          return true\n      }\n    }\n    false\n  }\n}\n"}], "src_uid": "d5541028a2753c758322c440bdbf9ec6"}
{"source_code": "import Array._\nimport scala.io.StdIn.readLine\nobject problem {\n  def main(args: Array[String]) {\n  val n = readLine.toInt\n    var A = ofDim[Int](n + 1, n + 1)\n      for(i <- 1 to n) A(1)(i) = 1\n    for(i <- 2 to n){\n      for(j <- 1 to n) A(i)(j) = A(i - 1)(j) + A(i)(j - 1)\n    }\n//    for(i <- 1 to n){\n//      for(j <- 1 to n) print(A(i)(j) + \" \"); println()\n//    }\n        for(i <- n to n){\n          for(j <- n to n) print(A(i)(j) + \" \"); println()\n        }\n  }\n}", "positive_code": [{"source_code": "object S509A {\n    def main(args: Array[String]) {\n        var i: Int = 0\n        var j: Int = 0\n        var n = readInt()\n        val a = Array.ofDim[Int](n, n)\n        for (i <- 0 until n) {\n            a(i)(0) = 1\n            a(0)(i) = 1\n        }\n        for (i <- 1 until n) {\n            for (j <- 1 until n)\n                a(i)(j) = a(i - 1)(j) + a(i)(j - 1)\n        }\n        println(a(n - 1)(n - 1))\n    }\n}\n\n"}, {"source_code": "object A509 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    val res = Array.ofDim[Int](n, n)\n    for(i <- 0 until n; j <- 0 until n) {\n      if(i == 0 || j == 0) {\n        res(i)(j) = 1\n      } else {\n        res(i)(j) = res(i-1)(j) + res(i)(j-1)\n      }\n    }\n    println(res(n-1)(n-1))\n  }\n}"}, {"source_code": "\nimport scala.io.StdIn.readLine\nimport scala.io.StdIn.readInt\n\n\nobject MaximumInTable {\n  \n   def readInts() : Array[Int] =\n     readLine.split(' ').map(_.toInt)\n   \n   def readLongs() : Array[Long] = \n      readLine.split(' ').map(_.toLong)\n   \n   def readTuple() : (Int,Int) = {\n     val line = readInts\n     (line(0),line(1))\n   }\n   def readTupleLong() : (Long,Long) = {\n     val line = readLongs\n     (line(0),line(1))\n   }\n   \n   def readTriple() : (Int,Int,Int) = {\n     val line = readInts\n     (line(0),line(1),line(2))\n   }\n   def readQuad() : (Int,Int,Int,Int) = {\n     val line = readInts\n     (line(0),line(1),line(2),line(3))\n   }\n   \n   def solve(n : Int) : Int = {\n     def go(r: Int, c: Int) : Int = {\n       if (r == 1 || c == 1) 1 \n       else go(r-1,c)+go(r,c-1)\n     }\n     go(n,n)\n   }\n   \n                            \n   def main(args: Array[String]) {\n     val n = readInt\n     println(solve(n))\n   }\n  \n}"}, {"source_code": "object main extends App with fastIO {\n  \n  def C(n: Int, m: Int): Int = {\n    (n, m) match {\n      case (1, m) => 1\n      case (n, 1) => 1\n      case (n, m) => C(n - 1, m) + C(n, m - 1)\n    }\n  }\n  \n  val n = nextInt \n  \n  println(C(n, n))\n  flush  \n}\n\ntrait fastIO {\n  import java.io._\n  \n  val isFile = false\n  val input = \"io.in\"\n  val output = \"io.out\"\n  \n  val bf = new BufferedReader(if(isFile) new FileReader(input) else new InputStreamReader(System.in))\n  val in = new StreamTokenizer(bf)\n  val out = new PrintWriter(if(isFile)new FileWriter(output) else new OutputStreamWriter(System.out))\n\n  def next: String = {\n    in.ordinaryChars('0', '9')\n    in.wordChars('0', '9')\n    in.nextToken()\n    in.sval\n  }\n  \n  def nextInt: Int = {\n    in.nextToken()\n    in.nval.toInt\n  }\n  \n  def nextLong:Long ={\n    in.nextToken()\n    in.nval.toLong\n  }\n  \n  def nextDouble: Double = {\n    in.nextToken()\n    in.nval\n  }\n    \n  def readLine: String = bf.readLine()\n  def println(o:Any) = out.println(o)\n  def print(o:Any) = out.print(o)\n  def printf(s:String,o:Any*) = out.printf(s,o)\n  def flush() = out.flush()  \n}"}, {"source_code": "import scala.util.Sorting\nimport scala.io.StdIn\n\nobject App {\n\n\n  def main(args: Array[String]) {\n\n\n    val n = StdIn.readInt()\n    val A = Array.ofDim[Array[Int]](n)\n    for (i <- 0 to n - 1) {\n      A(i) = new Array[Int](n)\n      A(i)(0) = 1\n      A(0)(i) = 1\n    }\n\n    for (i <- 1 to n - 1) {\n      for (j <- 1 to n - 1) {\n        A(i)(j) = A(i-1)(j) + A(i)(j-1)\n      }\n    }\n\n    println(A(n-1)(n-1))\n  }\n\n\n\n\n}\n"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  var n = in.next().toInt\n  var previous = Array.fill(n){1}\n  Range(0, n - 1).foreach { i =>\n    val current = Array.ofDim[Int](n)\n    current(0) = 1\n    Range(1, n).foreach {\n      i => current(i) = current(i - 1) + previous(i)\n    }\n    previous = current\n  }\n  print(previous.max)\n}\n"}], "negative_code": [], "src_uid": "2f650aae9dfeb02533149ced402b60dc"}
{"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val n = in.next().toLong\n\n  def findK(n: Long): Long = {\n    var k = 3l\n    while (n % k == 0) {\n      k *= 3\n    }\n    k\n  }\n\n  val k = findK(n)\n  println( n / k + (if (n % k != 0) 1 else 0))\n\n\n}\n", "positive_code": [{"source_code": "object CF333A {\n    def main(argv: Array[String]) {\n        def calc(n: Long): Long = {\n            if (n % 3 == 0) calc(n / 3)\n            else (n + 2) / 3\n        }\n        println(calc(readLine.toLong))\n    }\n}"}, {"source_code": "/**\n * User: Oleg Nizhnik\n * Date: 29.07.13\n * Time: 1:49\n */\nobject C_Secrets extends App {\n  def find(n: Long, k: Long = 1): Long = if (n % k == 0) find(n, k * 3) else (n + k - 1) / k\n  println(find(readLine().toLong))\n\n}\n"}, {"source_code": "/**\n * User: Oleg Nizhnik\n * Date: 29.07.13\n * Time: 1:49\n */\nobject C_Secrets {\n  def find(n: Long, k: Long = 1): Long = if (n % k == 0) find(n, k * 3) else (n + k - 1) / k\n  def main(args: Array[String]) = println(find(readLine().toLong))\n}\n"}, {"source_code": "import scala.collection.mutable._\nimport scala.math._\nimport scala.util._\nimport scala.util.control.Breaks.break\nimport scala.util.control.Breaks.breakable\nimport java.util._\nimport java.math.BigInteger\nobject Main extends App {\n  val sc = new Scanner(System.in)\n  def count3(n: BigInt): BigInt = {\n    if(n % 3 != 0) return 0\n    return 1 + count3(n / 3)\n  }\n  def pow(a: BigInt, b: BigInt): BigInt = {\n    if(b == 0) return 1\n    else return a * pow(a, b-1)\n  }\n  val n = new BigInt(sc.nextBigInteger)\n  val m = pow(3, count3(n)+1)\n  println(n / m + (if((n % m) == 0) 0 else 1))\n}\n"}, {"source_code": "/**\n * Created by Notebook on 14.02.2015.\n */\nobject AplusB extends App{\n      var a =readLong()\n      while(a%3==0) a /= 3\n      println(a/3+1)\n}\n"}, {"source_code": "object A extends App {\n\n  def readString = Console.readLine\n\n  val n = BigInt(readString)\n\n  var i = BigInt(3)\n  \n  while (i <= n && n % i == 0) i *= 3\n  \n  println(n / i + 1)\n}"}, {"source_code": "object Main extends App {\n\n        def calc(n: Long): Long = {\n            if (n % 3 == 0) calc(n / 3)\n            else (n + 2) / 3\n        }\n        println(calc(readLine.toLong))\n    }\n\n"}], "negative_code": [{"source_code": "import scala.collection.mutable._\nimport scala.math._\nimport scala.util._\nimport scala.util.control.Breaks.break\nimport scala.util.control.Breaks.breakable\nimport java.util._\nimport java.math.BigInteger\nobject Main extends App {\n  val sc = new Scanner(System.in)\n  val v = new BigInt(sc.nextBigInteger)\n  println(v / 3 + (if((v % 3) == 0) 0 else 1))\n}\n"}, {"source_code": "import scala.collection.mutable._\nimport scala.math._\nimport scala.util._\nimport scala.util.control.Breaks.break\nimport scala.util.control.Breaks.breakable\nimport java.util._\nobject Main extends App {\n  val sc = new Scanner(System.in)\n  println(ceil(readLong/3.0).toLong)\n}\n"}, {"source_code": "import scala.collection.mutable._\nimport scala.math._\nimport scala.util._\nimport scala.util.control.Breaks.break\nimport scala.util.control.Breaks.breakable\nimport java.util._\nimport java.math.BigInteger\nobject Main extends App {\n  val sc = new Scanner(System.in)\n  val v = new BigInt(sc.nextBigInteger)\n  println(v / 3 + ceil((v % 3).toInt * 0.1).toInt)\n}\n"}, {"source_code": "/**\n * Author: Odomontois\n * Date: 29.07.13\n * Time: 9:53\n * To change this template use File | Settings | File Templates.\n */\nobject C_Secrets extends App {\n  val in = java.lang.Long.toString(readLine().toLong, 3).reverse\n  println((in(0) match {\n    case '1' => in.drop(1).dropWhile(_ == '2')\n    case '0' | '2' => in.dropWhile(_ == '0').dropWhile(_ == '2')\n  }).map(Map('0' -> 0, '1' -> 1, '2' -> 2)).sum + 1)\n}\n"}, {"source_code": "/**\n * Author: Odomontois\n * Date: 29.07.13\n * Time: 9:53\n * To change this template use File | Settings | File Templates.\n */\nobject C_Secrets extends App {\n  val in = java.lang.Long.toString(readLine().toLong, 3).reverse.dropWhile(_ == '0')\n  println((in(0) match {\n    case '1' => in.drop(1)\n    case '2' => in\n  }).dropWhile(_ == '2').map(Map('0' -> 0, '1' -> 1, '2' -> 2)).sum + 1)\n}\n"}], "src_uid": "7e7b59f2112fd200ee03255c0c230ebd"}
{"source_code": "\nimport scala.io.StdIn\n\nobject BearAndRaspberryMain {\n  def main(args: Array[String]): Unit ={\n    val nc = StdIn.readLine().split(\" \").map(_.toInt)\n    val n = nc(0)\n    val c = nc(1)\n    val elements = StdIn.readLine().split(\" \").map(_.toInt)\n    var LOL = 0\n    for(i <- 0 to n-2){\n      val d  =  elements(i) - c - elements(i+1)\n      if( LOL < d)\n        LOL = d\n    }\n    print(LOL)\n  }\n}", "positive_code": [{"source_code": "import java.util.StringTokenizer\n\nobject _385A extends App {\n  var token = new StringTokenizer(\"\")\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n  val n = next.toInt\n  val c = next.toInt\n  val a = (1 to n).map(i => next.toInt)\n  val b = (1 until n).map(i => a(i - 1) - a(i)).max\n  val ans = (b - c) max 0\n  println(ans)\n}\n"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val Array(n, c) = in.next().split(\" \").map(_.toInt)\n  val ans = Math.max(0, in.next().split(\" \").map(_.toInt).sliding(2).map(t => t.head - t.last - c).max)\n  println(ans)\n}"}, {"source_code": "import java.util.Scanner\n\nobject P385A {\n    def main(args: Array[String]) {\n        val scanner = new Scanner(System.in)\n        val n = scanner.nextInt()\n        val c = scanner.nextInt()\n        val prices = for (i <- 1 to n) yield scanner.nextInt()\n        val gains = for ((prev, next) <- prices.init zip prices.tail) yield prev - next - c\n        val ans = if (gains.max > 0) gains.max else 0\n        println(ans)\n    }\n}\n"}, {"source_code": "object A385 {\n\n  import IO._\n\n  def main(args: Array[String]): Unit = {\n    val Array(n, c) = readInts(2)\n    val in = readInts(n)\n    var res = 0\n    for(i <- 0 until n-1) {\n      val cal = in(i) - in(i+1) - c\n      res = math.max(res, cal)\n    }\n    println(res)\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P385A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n  val N, C = sc.nextInt\n  val X = List.fill(N)(sc.nextInt)\n  \n  val gain = (X, X.tail).zipped.map(_ - _).max - C\n  val answer = if (gain > 0) gain\n               else 0\n  \n  out.println(answer)\n  out.close\n}\n"}, {"source_code": "//package codeforces\n\n/**\n * TODO: describe\n *\n * @author keks\n */\nobject T385A {\n  def main(args: Array[String]) {\n    val rent = readArray.last\n    print(getRasp(readArray, rent))\n  }\n\n  def getRasp(a: Array[Int], rent: Int) = {\n    val total = ((0, a.head) /: a.tail)(\n      (acc, prev) => (if (acc._1 < acc._2 - prev) acc._2 - prev else acc._1, prev)\n    )._1\n    if (total > rent) total - rent else 0\n  }\n\n  def readArray = readLine().split(' ').map(_.toInt)\n}\n"}, {"source_code": "object A extends App {\n  val sc = new java.util.Scanner(System.in)\n  val n, c = sc.nextInt()\n  val x = Array.fill(n)(sc.nextInt())\n  var ans = 0\n  for (i <- 0 until n-1) {\n    ans = ans.max(x(i)-x(i+1)-c)\n  }\n  println(ans)\n}\n"}], "negative_code": [], "src_uid": "411539a86f2e94eb6386bb65c9eb9557"}
{"source_code": "object Solver {\n    def main(args: Array[String]) {\n        val (first, second) = (Console.readLine, Console.readLine)\n        val success = first.length == second.length && List.range(0, first.length).forall(i => first(i) == second(first.length - i - 1))\n\n        println(if (success) \"YES\" else \"NO\")\n    }\n}\n", "positive_code": [{"source_code": "object Main extends App {\n  val str1 = readLine()\n  val str2 = readLine()\n\n  if (str1 == str2.reverse) println(\"YES\")\n  else println(\"NO\")\n}"}, {"source_code": "object CF0041A extends App {\n\n  val f = readLine()\n  val s = readLine()\n\n  if( f == s.reverse) {\n    println(\"YES\")\n  } else {\n    println(\"NO\")\n  }\n\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject TEST extends App{\n    val sc = new Scanner(System.in)\n    print (if(readLine.reverse == readLine)\"YES\" else \"NO\")\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject Task extends App{\n  val w1 = readLine\n  val w2 = readLine\n  \n  if(w1.reverse == w2)\n    println(\"YES\")\n  else\n    println(\"NO\")\n}"}, {"source_code": "import scala.io.StdIn\n\nobject Main {\n  def main(args: Array[String]): Unit = {\n    if (StdIn.readLine() == StdIn.readLine().reverse) println(\"YES\") else println(\"NO\")\n  }\n}\n"}, {"source_code": "import java.util.Scanner\n\n\nobject HelloWorldMain {\n\n  def main(args: Array[String]): Unit = {\n    val sc = new Scanner(System.in)\n\n    val str = sc.next()\n\n    val strShouldBeReverse = sc.next()\n\n    if(str.reverse equalsIgnoreCase strShouldBeReverse )println(\"YES\")\n    else println(\"NO\")\n\n\n  }\n}\n\n\n\n"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  var str = in.next()\n  var str2 = in.next()\n  if (str.length != str2.length || str.zip(str2.reverse).exists(t => t._1 != t._2))\n    println(\"NO\")\n  else\n    println(\"YES\")\n}"}, {"source_code": "object Main {\n\n  def main(args: Array[String]) {\n    val std = scala.io.StdIn\n\n    val areTheSame = std.readLine().equals(std.readLine().reverse)\n    if (areTheSame) {\n      println(\"YES\")\n    }\n    else {\n      println(\"NO\")\n    }\n  }\n}"}, {"source_code": "object A41 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val input1 = scala.io.StdIn.readLine\n    val input2 = scala.io.StdIn.readLine\n    if(input1.reverse.compareTo(input2) == 0) {\n      println(\"YES\")\n    } else {\n      println(\"NO\")\n    }\n  }\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P41A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val S, T = sc.nextLine\n  val answer = if (S == T.reverse) \"YES\" else \"NO\"\n\n  out.println(answer)\n  out.close\n}\n"}, {"source_code": "\n\nobject Translation {\n\tdef main (args: Array[String]) {\n\t\tval scanner = new java.util.Scanner(System.in);\n\t\tval word1 = scanner.nextLine;\n\t\tval word2 = scanner.nextLine;\n\t\tvar leftIndex = 0;\n\t\tvar rightIndex = word2.length - 1;\n\t\tvar equal = true;\n\t\twhile (equal && leftIndex < word1.length() && rightIndex >= 0) {\n\t\t\tequal = word1(leftIndex) == word2(rightIndex)\n\t\t\tleftIndex += 1; rightIndex-=1\n\t\t}\n\t\tif (equal) {\n\t\t\tprintln(\"YES\")\n\t\t}\n\t\telse\n\t\t\tprintln(\"NO\")\n\t}\n}"}, {"source_code": "import scala.io._\nimport scala.collection.mutable._\nimport java.io.FileWriter\nimport java.io.PrintWriter\n\nobject HelloWorld {\n\n  def main(args: Array[String]): Unit = {\n    var t = readLine;\n    var s = readLine;\n    if (t == s.reverse) {\n      println(\"YES\");\n    } else {\n      println(\"NO\");\n    }\n  }  \n}"}, {"source_code": "import annotation.tailrec\nimport java.io._\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readInt = reader.readLine().toInt\n\n  def ans = if(reader.readLine() == reader.readLine().reverse) \"YES\" else \"NO\"\n\n  def main(args: Array[String]) {\n    println(ans)\n  }\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val s1 = readLine()\n    val s2 = readLine()\n    if (s1.reverse == s2) println(\"YES\")\n    else println(\"NO\")\n  }\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject A_41 extends App {\n  val a = readLine()\n  val b = readLine()\n\n  println(\n    if (a == b.reverse) \"YES\" else \"NO\"\n  )\n}\n"}, {"source_code": "import scala.io.StdIn.readLine\nobject problem {\n  def main(args: Array[String]) {\n  val s = readLine\n  val t = readLine\n    if(t == s.reverse) println(\"YES\") else println(\"NO\")\n  }\n}"}, {"source_code": "import scala.io.StdIn.readLine\nimport scala.io.StdIn.readInt\n\n\nobject Translation {\n  \n   def readInts() : Array[Int] =\n     readLine.split(' ').map(_.toInt)\n  \n   def main(args: Array[String]) {\n     val s = readLine\n     val t = readLine\n     if (s == t.reverse) println(\"YES\") else println(\"NO\")\n   }\n  \n}"}, {"source_code": "object P041A extends App {\n  val t = readLine()\n  val s = readLine()\n  println(if (t.reverse == s) \"YES\" else \"NO\")\n}\n"}, {"source_code": "object Translation extends App{\n    val berlandish = scala.io.StdIn.readLine()\n    val birlandish = scala.io.StdIn.readLine()\n\n    if (birlandish.reverse == berlandish) println(\"YES\")\n    else println(\"NO\")\n  \n}\n"}], "negative_code": [{"source_code": "object P041A extends App {\n  val t = readLine()\n  val s = readLine()\n  println(if (t.reverse == s) \"YES\" else \"No\")\n}\n"}], "src_uid": "35a4be326690b58bf9add547fb63a5a5"}
{"source_code": "import scala.io.StdIn\n\nobject Main {\n  def main(args: Array[String]): Unit = {\n    val string = StdIn.readLine()\n    val valuesOtherThanOneOrFour = string.exists(char => char != '1' && char != '4')\n    val startsWithValueOtherThanOne = !string.startsWith(\"1\")\n    val containsThreeConsecutiveFours = string.indexOf(\"444\") != -1\n    if (valuesOtherThanOneOrFour || startsWithValueOtherThanOne || containsThreeConsecutiveFours) println(\"NO\") else println(\"YES\")\n  }\n}\n", "positive_code": [{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val str = in.next()\n  if (str.forall(ch => ch == '1' || ch == '4') &&\n      str.head != '4' && !str.contains(\"444\"))\n    println(\"YES\")\n  else\n    println(\"NO\")\n}"}, {"source_code": "object A320 {\n\n  import IO._\n\n  def main(args: Array[String]): Unit = {\n    val num = read\n    val dummy = Array.fill[Char](num.length)('x').mkString(\"\")\n    val res = num.replaceAll(\"144\", \"xxx\").replaceAll(\"14\", \"xx\").replaceAll(\"1\", \"x\")\n    if(res.equals(dummy)) {\n      println(\"YES\")\n    } else {\n      println(\"NO\")\n    }\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P320A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n  \n\n  def solve(): String = {\n\n    @tailrec\n    def loop(cs: List[Char]): String = cs match {\n        case Nil                 => \"YES\"\n        case '1' :: '4' :: '4' :: rest => loop(rest)\n        case '1' :: '4' :: rest        => loop(rest)\n        case '1' :: rest               => loop(rest)\n        case _                         => \"NO\"\n      }\n\n    loop(sc.nextLine.toList)\n  }\n\n  out.println(solve)\n  out.close\n}\n"}, {"source_code": "import java.io._\nimport java.util.Locale\nimport scala.annotation.tailrec\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInt = reader.readLine().toInt\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readLongs = reader.readLine().split(\" \").map(_.toLong)\n\n  val ans = reader.readLine().matches(\"(14{0,2})+\")\n  val yesNoAns = Map(true -> \"YES\", false -> \"NO\")\n\n  def main(a: Array[String]) {\n    println(yesNoAns(ans))\n  }\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val s = readLine()\n    val r = s.replaceAll(\"144\", \"a\").replaceAll(\"14\", \"a\").replaceAll(\"1\", \"a\")\n    if (r.matches(\"a*\")) println(\"YES\")\n    else println(\"NO\")\n  }\n}"}, {"source_code": "object CF320A extends App {\n    override def main(args: Array[String]) {\n      val s:String = readLine()\n      var i = 0\n      while (i < s.length()) {\n        if (i+3 <= s.length() && s.substring(i, i+3) == \"144\")\n          i += 3 \n        else if (i + 2 <= s.length() && s.substring(i, i+2) == \"14\") i += 2\n        else if (s.charAt(i) == '1') i += 1\n        else {\n          println(\"NO\")\n          return\n        } \n      }\n      println(\"YES\")\n    }   \n}"}, {"source_code": "object MagicNumbers {\n   def main(args:Array[String]):Unit={\n     val str=readLine\n     println(solve(str))\n   }\n  def solve(str:String):String={\n//    str.toCharArray.toList match {\n//      case(\"144\"::string)=> solve(string)\n//      case (\"14\"::string)=>solve(string)\n//      case(\"1\"::string)=>solve(string)\n//      case(str.length==0)=>\"YES\"\n//      case(_)=>\"NO\"\n//    }\n    if(str.startsWith(\"144\")) solve(str.substring(3))\n    else if(str.startsWith(\"14\")) solve(str.substring(2))\n    else if(str.startsWith(\"1\")) solve(str.substring(1))\n    else if(str.length==0) \"YES\"\n    else \"NO\"\n  }\n}"}], "negative_code": [{"source_code": "object A320 {\n\n  import IO._\n\n  def main(args: Array[String]): Unit = {\n    val num = read\n    if(num.replaceAll(\"144\", \"\").replaceAll(\"14\", \"\").replaceAll(\"1\", \"\").isEmpty) {\n      println(\"YES\")\n    } else {\n      println(\"NO\")\n    }\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val s = readLine()\n    val r = s.replaceAll(\"144\", \"\").replaceAll(\"14\", \"\").replaceAll(\"1\", \"\")\n    if (r.size == 0) println(\"YES\")\n    else println(\"NO\")\n  }\n}"}, {"source_code": "import scala.io.StdIn\n\nobject Main {\n  def main(args: Array[String]): Unit = {\n    if (StdIn.readLine.forall(char => char == '4' || char == '1')) print(\"YES\") else print(\"NO\")\n  }\n}\n"}, {"source_code": "import scala.io.StdIn\n\nobject Main {\n  def main(args: Array[String]): Unit = {\n    var string = StdIn.readLine()\n    while (string.contains(\"144\")) {\n      string = string.replace(\"144\", \"\")\n    }\n    while (string.contains(\"14\")) {\n      string = string.replace(\"14\", \"\")\n    }\n    if (string.forall(_ == '1')) println(\"YES\") else println(\"NO\")\n  }\n}\n"}, {"source_code": "import scala.io.StdIn\n\nobject Main {\n  def main(args: Array[String]): Unit = {\n    val string = StdIn.readLine()\n    if (string.exists(char => char != '4' && char != '1') || !string.startsWith(\"1\")) print(\"NO\") else print(\"YES\")\n  }\n}\n"}], "src_uid": "3153cfddae27fbd817caaf2cb7a6a4b5"}
{"source_code": "object Main {\n  import java.io.{BufferedReader, InputStream, InputStreamReader}\n  import java.util.StringTokenizer\n  import scala.reflect.ClassTag\n\n  def main(args: Array[String]): Unit = {\n    val out = new java.io.PrintWriter(System.out)\n    new Main(out, new InputReader(System.in)).solve()\n    out.flush()\n  }\n\n  private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n  def DEBUG(f: => Unit): Unit = {\n    if (!oj){ f }\n  }\n  def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n  def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n  def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n  def debugDim(m: Array[Array[Long]]): Unit = if (!oj){\n    REP(m.length) { i =>\n      debug(m(i))\n    }\n  }\n  def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n    REP(m(0).length) { j =>\n      REP(m.length) { i =>\n        System.err.print(m(i)(j))\n        System.err.print(\" \")\n      }\n      System.err.println()\n    }\n  }\n  def debug(s: => String): Unit = DEBUG {\n    System.err.println(s)\n  }\n  def debugL(num: => Long): Unit = DEBUG {\n    System.err.println(num)\n  }\n\n  class InputReader(val stream: InputStream) {\n    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n    private var tokenizer: StringTokenizer = _\n\n    def next(): String = {\n      while (tokenizer == null || !tokenizer.hasMoreTokens)\n        tokenizer = new StringTokenizer(reader.readLine)\n      tokenizer.nextToken\n    }\n\n    def nextInt(): Int = Integer.parseInt(next())\n    def nextLong(): Long = java.lang.Long.parseLong(next())\n    def nextChar(): Char = next().charAt(0)\n\n    def ni(): Int = nextInt()\n    def nl(): Long = nextLong()\n    def nc(): Char = nextChar()\n    def ns(): String = next()\n    def ns(n: Int): Array[Char] = ns().toCharArray\n    def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n    def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n      val A1, A2 = Array.ofDim[Int](n)\n      REP(n) { i =>\n        A1(i) = ni() + offset\n        A2(i) = ni() + offset\n      }\n      (A1, A2)\n    }\n    def nm(n: Int, m: Int): Array[Array[Int]] = {\n      val A = Array.ofDim[Int](n, m)\n      REP(n) { i =>\n        REP(m) { j =>\n          A(i)(j) = ni()\n        }\n      }\n      A\n    }\n    def nal(n: Int): Array[Long] = map(n)(_ => nl())\n    def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n  }\n\n  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = offset\n    val N = n + offset\n    while(i < N) { f(i); i += 1 }\n  }\n  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = n - 1 + offset\n    while(i >= offset) { f(i); i -= 1 }\n  }\n  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n    REP(to - from + 1, from) { i =>\n      f(i)\n    }\n  }\n  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n    val res = Array.ofDim[A](n)\n    REP(n)(i => res(i) = f(i + offset))\n    res\n  }\n\n  def sumL(as: Array[Int]): Long = {\n    var s = 0L\n    REP(as.length)(i => s += as(i))\n    s\n  }\n  def cumSum(as: Array[Int]): Array[Long] = {\n    val cum = Array.ofDim[Long](as.length + 1)\n    REP(as.length) { i =>\n      cum(i + 1) = cum(i) + as(i)\n    }\n    cum\n  }\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n  import sc._\n  import Main._\n  import java.util.Arrays.sort\n\n  import scala.collection.mutable\n  import math.{abs, max, min}\n  import mutable.ArrayBuffer\n\n  // toIntとか+7とかするならvalにしろ\n  @inline private def MOD = 1000000007\n\n  def solve(): Unit = {\n    val N = ni()\n    val A = na(N)\n\n    val Inf = 1e9.toInt\n    var ans = sumL(map(N - 1) { i =>\n      (A(i), A(i + 1)) match {\n        case (1, 2) => 3\n        case (1, 3) => 4\n        case (2, 1) => 3\n        case (2, 3) => Inf\n        case (3, 1) => 4\n        case (3, 2) => Inf\n      }\n    })\n\n    ans += sumL(map(N - 2) { i =>\n      (A(i), A(i + 1), A(i + 2)) match {\n        case (3, 1, 2) => -1\n        case _ => 0\n      }\n    })\n\n    if (ans >= Inf) out.println(\"Infinite\")\n    else {\n      out.println(\"Finite\")\n      out.println(ans)\n    }\n  }\n}", "positive_code": [{"source_code": "object Main extends App {\n    val n = readInt \n    val a = readLine.split(\" \").map(_.toInt)\n    val result = a.foldLeft((0, 0, 0))((acc, next) => {\n      if (acc._3 == -1) (0, 0, -1)\n      else {\n        (acc._1, acc._2,  next) match {\n          case (3, 1, 2) => (acc._2, next, acc._3 + 2)\n          case (_, 1, 2) => (acc._2, next, acc._3 + 3)\n          case (_, 1, 3) => (acc._2, next, acc._3 + 4)\n          case (_, 2, 1) => (acc._2, next, acc._3 + 3)\n          case (_, 3, 1) => (acc._2, next, acc._3 + 4)\n          case (_, 0, _) => (acc._2, next, 0)\n          case _ => (0, 0, -1)\n        }\n      }\n    })\n\n    if (result._3 < 0) {\n      println(\"Infinite\")\n    } else {\n      println(\"Finite\")\n      println(result._3)\n    }\n}"}, {"source_code": "import java.util.Scanner\n\nimport scala.io.StdIn\n\nobject Figures extends App {\n  val line = new Scanner(StdIn.readLine())\n  val n = line.nextInt()\n  val a = StdIn.readLine().split(' ').map(_.toInt)\n  var points = 0\n  for(i <- 0 until n-1) {\n    if (a(i) == 1) {\n      if (a(i+1) == 2) {\n        points += 3\n      }\n      if (a(i+1) == 3) {\n        points += 4\n      }\n    }\n    if (a(i) == 2) {\n      if (a(i+1) == 1) {\n        points += 3\n      }\n      if (a(i+1) == 3) {\n        println(\"Infinite\")\n        System.exit(0)\n      }\n    }\n    if (a(i) == 3) {\n      if (a(i+1) == 1) {\n        points += 4\n        if (i+2 < n && a(i+2) == 2) {\n          points -= 1\n        }\n      }\n      if (a(i+1) == 2) {\n        println(\"Infinite\")\n        System.exit(0)\n      }\n    }\n  }\n  println(\"Finite\")\n  println(points)\n\n}\n"}], "negative_code": [{"source_code": "object Main {\n  import java.io.{BufferedReader, InputStream, InputStreamReader}\n  import java.util.StringTokenizer\n  import scala.reflect.ClassTag\n\n  def main(args: Array[String]): Unit = {\n    val out = new java.io.PrintWriter(System.out)\n    new Main(out, new InputReader(System.in)).solve()\n    out.flush()\n  }\n\n  private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n  def DEBUG(f: => Unit): Unit = {\n    if (!oj){ f }\n  }\n  def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n  def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n  def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n  def debugDim(m: Array[Array[Long]]): Unit = if (!oj){\n    REP(m.length) { i =>\n      debug(m(i))\n    }\n  }\n  def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n    REP(m(0).length) { j =>\n      REP(m.length) { i =>\n        System.err.print(m(i)(j))\n        System.err.print(\" \")\n      }\n      System.err.println()\n    }\n  }\n  def debug(s: => String): Unit = DEBUG {\n    System.err.println(s)\n  }\n  def debugL(num: => Long): Unit = DEBUG {\n    System.err.println(num)\n  }\n\n  class InputReader(val stream: InputStream) {\n    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n    private var tokenizer: StringTokenizer = _\n\n    def next(): String = {\n      while (tokenizer == null || !tokenizer.hasMoreTokens)\n        tokenizer = new StringTokenizer(reader.readLine)\n      tokenizer.nextToken\n    }\n\n    def nextInt(): Int = Integer.parseInt(next())\n    def nextLong(): Long = java.lang.Long.parseLong(next())\n    def nextChar(): Char = next().charAt(0)\n\n    def ni(): Int = nextInt()\n    def nl(): Long = nextLong()\n    def nc(): Char = nextChar()\n    def ns(): String = next()\n    def ns(n: Int): Array[Char] = ns().toCharArray\n    def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n    def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n      val A1, A2 = Array.ofDim[Int](n)\n      REP(n) { i =>\n        A1(i) = ni() + offset\n        A2(i) = ni() + offset\n      }\n      (A1, A2)\n    }\n    def nm(n: Int, m: Int): Array[Array[Int]] = {\n      val A = Array.ofDim[Int](n, m)\n      REP(n) { i =>\n        REP(m) { j =>\n          A(i)(j) = ni()\n        }\n      }\n      A\n    }\n    def nal(n: Int): Array[Long] = map(n)(_ => nl())\n    def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n  }\n\n  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = offset\n    val N = n + offset\n    while(i < N) { f(i); i += 1 }\n  }\n  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = n - 1 + offset\n    while(i >= offset) { f(i); i -= 1 }\n  }\n  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n    REP(to - from + 1, from) { i =>\n      f(i)\n    }\n  }\n  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n    val res = Array.ofDim[A](n)\n    REP(n)(i => res(i) = f(i + offset))\n    res\n  }\n\n  def sumL(as: Array[Int]): Long = {\n    var s = 0L\n    REP(as.length)(i => s += as(i))\n    s\n  }\n  def cumSum(as: Array[Int]): Array[Long] = {\n    val cum = Array.ofDim[Long](as.length + 1)\n    REP(as.length) { i =>\n      cum(i + 1) = cum(i) + as(i)\n    }\n    cum\n  }\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n  import sc._\n  import Main._\n  import java.util.Arrays.sort\n\n  import scala.collection.mutable\n  import math.{abs, max, min}\n  import mutable.ArrayBuffer\n\n  // toIntとか+7とかするならvalにしろ\n  @inline private def MOD = 1000000007\n\n  def solve(): Unit = {\n    val N = ni()\n    val A = na(N)\n\n    val Inf = 1e9.toInt\n    val ans = sumL(map(N - 1) { i =>\n      (A(i), A(i + 1)) match {\n        case (1, 2) => 3\n        case (1, 3) => 4\n        case (2, 1) => 3\n        case (2, 3) => Inf\n        case (3, 1) => 4\n        case (3, 2) => Inf\n      }\n    })\n\n    if (ans >= Inf) out.println(\"Infinite\")\n    else {\n      out.println(\"Finite\")\n      out.println(ans)\n    }\n  }\n}"}, {"source_code": "object Main extends App {\n    val n = readInt \n    val a = readLine.split(\" \").map(_.toInt)\n    val result = a.foldLeft((0, 0, 0))((acc, next) => {\n      if (acc._3 == -1) (0, 0, -1)\n      else {\n        (acc._1, acc._2,  next) match {\n          case (2, 1, 3) => (acc._2, next, acc._3 + 3)\n          case (_, 1, 2) => (acc._2, next, acc._3 + 3)\n          case (_, 1, 3) => (acc._2, next, acc._3 + 4)\n          case (_, 2, 1) => (acc._2, next, acc._3 + 3)\n          case (_, 3, 1) => (acc._2, next, acc._3 + 4)\n          case (_, 0, _) => (acc._2, next, 0)\n          case _ => (0, 0, -1)\n        }\n      }\n    })\n\n    if (result._3 < 0) {\n      println(\"Infinite\")\n    } else {\n      println(\"Finite\")\n      println(result._3)\n    }\n}"}, {"source_code": "object Main extends App {\n    val n = readInt \n    val a = readLine.split(\" \").map(_.toInt)\n    val result = a.foldLeft((0, 0))((acc, next) => {\n      if (acc._2 == -1) (0, -1)\n      else {\n        (acc._1, next) match {\n          case (1, 2) => (next, acc._2 + 3)\n          case (2, 1) => (next, acc._2 + 3)\n          case (1, 3) => (next, acc._2 + 4)\n          case (3, 1) => (next, acc._2 + 4)\n          case (0, _) => (next, 0)\n          case (_, _) => (0, -1)\n        }\n      }\n    })\n\n    if (result._2 < 0) {\n      println(\"Infinite\")\n    } else {\n      println(\"Finite\")\n      println(result._2)\n    }\n}"}], "src_uid": "6c8f028f655cc77b05ed89a668273702"}
{"source_code": "object Main {\n  def main(args: Array[String]): Unit = {\n    val s = new Main()\n    s.solve()\n    s.out.flush()\n  }\n}\n\nclass Main {\n  import java.io._\n  import java.util.StringTokenizer\n\n  import scala.collection.mutable\n  import scala.util.Sorting\n  import math.{abs, max, min}\n  import mutable.{ArrayBuffer, ListBuffer}\n  import scala.reflect.ClassTag\n\n  val MOD = 1000000007\n  val out = new PrintWriter(System.out)\n\n  def solve(): Unit = {\n    val N = ni()\n    if (N == 1) {\n      out.println(s\"1 0\")\n    } else {\n      val f = factorize(N)\n      val mul = f.keys.product\n      val maxPow = f.values.max\n      val minPow = f.values.min\n      val lg = if (maxPow == 1 ) 0 else log2(maxPow - 1) + 1\n      val cnt = lg + (if (minPow == maxPow && isPow2(maxPow)) 0 else 1)\n      out.println(s\"$mul $cnt\")\n    }\n  }\n\n  def isPow2(n: Int): Boolean = {\n    Integer.highestOneBit(n) == n\n  }\n\n  /**\n    * *注意* IntをLongにして使わないこと\n    */\n  def factorize(n: Int): mutable.Map[Int, Int] = {\n    import scala.collection.mutable\n    val res = mutable.Map[Int, Int]() withDefaultValue 0\n\n    def minFactor(n0: Int, rt: Int, i: Int): Int = {\n      if (i > rt) n0 // √n まで見つからなかったら n0は素数か1\n      else if (n0 % i == 0) i\n      else minFactor(n0, rt, i + 1)\n    }\n\n    def step(n0: Int): Unit = {\n      minFactor(n0, math.sqrt(n0).toInt, 2) match {\n        case 1 =>\n        case f =>\n          res(f) = res(f) + 1\n          step(n0 / f)\n      }\n    }\n\n    step(n)\n    res\n  }\n\n  /**\n    * log2して小数点切り捨てたもの\n    */\n  def log2(x: Int): Int = {\n    var a = Integer.highestOneBit(x)\n    var i = 0\n    while(a > 1) {\n      i += 1\n      a >>>= 1\n    }\n    i\n  }\n\n  class InputReader(val stream: InputStream) {\n    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n    private var tokenizer: StringTokenizer = _\n\n    def next(): String = {\n      while (tokenizer == null || !tokenizer.hasMoreTokens)\n        tokenizer = new StringTokenizer(reader.readLine)\n      tokenizer.nextToken\n    }\n\n    def nextInt(): Int = next().toInt\n    def nextLong(): Long = next().toLong\n    def nextChar(): Char = next().charAt(0)\n  }\n  val sc = new InputReader(System.in)\n  def ni(): Int = sc.nextInt()\n  def nl(): Long = sc.nextLong()\n  def nc(): Char = sc.nextChar()\n  def ns(): String = sc.next()\n  def ns(n: Int): Array[Char] = ns().toCharArray\n  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n    val A1, A2 = Array.ofDim[Int](n)\n    rep(n) { i =>\n      A1(i) = ni() + offset\n      A2(i) = ni() + offset\n    }\n    (A1, A2)\n  }\n  def nm(n: Int, m: Int): Array[Array[Int]] = {\n    val A = Array.ofDim[Int](n, m)\n    rep(n) { i =>\n      rep(m) { j =>\n        A(i)(j) = ni()\n      }\n    }\n    A\n  }\n  def nal(n: Int): Array[Long] = map(n)(_ => nl())\n  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = offset\n    val N = n + offset\n    while(i < N) { f(i); i += 1 }\n  }\n  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = n - 1 + offset\n    while(i >= offset) { f(i); i -= 1 }\n  }\n\n  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n    val res = Array.ofDim[A](n)\n    rep(n)(i => res(i) = f(i + offset))\n    res\n  }\n\n\n  def sumL(as: Array[Int]): Long = {\n    var s = 0L\n    rep(as.length)(i => s += as(i))\n    s\n  }\n\n  def cumSum(as: Array[Int]) = {\n    val cum = Array.ofDim[Int](as.length + 1)\n    rep(as.length) { i =>\n      cum(i + 1) = cum(i) + as(i)\n    }\n    cum\n  }\n}", "positive_code": [{"source_code": "//package codeforce520\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject B {\n  def main(args: Array[String]): Unit = {\n    val reader = scala.io.StdIn\n\n    val n = reader.readInt()\n\n    val sieve = ArrayBuffer.fill(n + 1)(1)\n    sieve(0) = 0\n    sieve(1) = 0\n\n    (2 until sieve.size) foreach {i =>\n      if (sieve(i) == 1) {\n        val j = i\n        var c = 2\n        while (j * c < sieve.size) {\n          sieve(j * c) = 0\n          c += 1\n        }\n      }\n    }\n\n    val prime = sieve.zipWithIndex.filter(_._1 == 1).map(_._2)\n\n    val factor = prime.map{p =>\n      var c = 0\n      var t = n\n\n      while (t % p == 0 && t > 0) {\n        c += 1\n        t = t / p\n      }\n\n      (p , c)\n    }.filter(_._2 > 0)\n    //println(factor.mkString(\" \"))\n\n    val minValue = factor.map(_._1).foldLeft(1)(_ * _)\n    val need1Operation = factor.map(_._2).toSet.size == 1\n    var mult = true\n\n    var maxP = if (factor.size > 0) factor.map(_._2).max else 0\n    var minO = 0\n    var pick = 1\n    while(pick < maxP) {\n      minO += 1\n      pick *= 2\n    }\n\n    if (pick > maxP) {\n      minO += 1\n      mult = false\n    }\n\n    if (!need1Operation && mult == true) minO += 1\n\n    if (n <= 3) {\n      println(s\"$n 0\")\n    }\n    else {\n      println(s\"$minValue $minO\")\n    }\n\n  }\n}\n"}, {"source_code": "import scala.collection.mutable\nimport scala.io.StdIn\n\nobject Codeforces1062B {\n\n  def getMinimumOperation(n: Int): (Int, Int) = {\n    val primeFactors = getPrimeFactorization(n)\n\n    if (isUniquePrimeFactors(primeFactors))\n      return (multiply(primeFactors.keys), 0)\n\n    var totalSteps = 0\n\n    val maxPower = primeFactors.values.max\n    if (!isPowerOfTwo(maxPower) || !primeFactors.values.forall(_ == maxPower)) {\n      totalSteps += 1\n    }\n    val powerOfTwo = getNextPowerOfTwo(maxPower)\n    totalSteps += powerOfTwo\n\n    (multiply(primeFactors.keys), totalSteps)\n  }\n\n  def isPowerOfTwo(n: Int): Boolean = (n & (n - 1)) == 0\n\n  def getNextPowerOfTwo(n: Int): Int = {\n    var poweredNumber = 2L\n    var power = 1\n    while (poweredNumber < n) {\n      poweredNumber *= 2\n      power += 1\n    }\n    power\n  }\n\n  def multiply(numbers: Iterable[Int]): Int = {\n    var result = 1\n    for (number <- numbers) result *= number\n    result\n  }\n\n\n  def isUniquePrimeFactors(primeFactors: mutable.Map[Int, Int]): Boolean =\n    primeFactors.values.forall(_ == 1)\n\n  def getPrimeFactorization(n: Int): mutable.Map[Int, Int] = {\n    val primeFactors = new mutable.HashMap[Int, Int]()\n    var remainingNumber = n\n    val sqrtN = math.sqrt(n).toInt\n    for (primeCandidate <- 2 to sqrtN) {\n      if (remainingNumber % primeCandidate == 0) {\n        primeFactors(primeCandidate) = 0\n        while (remainingNumber % primeCandidate == 0) {\n          primeFactors(primeCandidate) += 1\n          remainingNumber /= primeCandidate\n        }\n      }\n    }\n\n    if (remainingNumber != 1) {\n      primeFactors(remainingNumber) = 1\n    }\n\n    primeFactors\n  }\n\n  def main(args: Array[String]): Unit = {\n    val n = StdIn.readLine.trim.toInt\n\n    val result = getMinimumOperation(n)\n\n    println(s\"${result._1} ${result._2}\")\n  }\n}\n"}], "negative_code": [{"source_code": "object Main {\n  def main(args: Array[String]): Unit = {\n    val s = new Main()\n    s.solve()\n    s.out.flush()\n  }\n}\n\nclass Main {\n  import java.io._\n  import java.util.StringTokenizer\n\n  import scala.collection.mutable\n  import scala.util.Sorting\n  import math.{abs, max, min}\n  import mutable.{ArrayBuffer, ListBuffer}\n  import scala.reflect.ClassTag\n\n  val MOD = 1000000007\n  val out = new PrintWriter(System.out)\n\n  def solve(): Unit = {\n    val N = ni()\n    if (N == 1) {\n      out.println(s\"1 0\")\n    } else {\n      val f = factorize(N)\n      val mul = f.keys.product\n      val maxPow = f.values.max\n      val minPow = f.values.min\n      val lg = if (maxPow == 1 ) 0 else log2(maxPow - 1) + 1\n      val cnt = lg + (if (minPow == maxPow) 0 else 1)\n      out.println(s\"$mul $cnt\")\n    }\n  }\n\n  /**\n    * *注意* IntをLongにして使わないこと\n    */\n  def factorize(n: Int): mutable.Map[Int, Int] = {\n    import scala.collection.mutable\n    val res = mutable.Map[Int, Int]() withDefaultValue 0\n\n    def minFactor(n0: Int, rt: Int, i: Int): Int = {\n      if (i > rt) n0 // √n まで見つからなかったら n0は素数か1\n      else if (n0 % i == 0) i\n      else minFactor(n0, rt, i + 1)\n    }\n\n    def step(n0: Int): Unit = {\n      minFactor(n0, math.sqrt(n0).toInt, 2) match {\n        case 1 =>\n        case f =>\n          res(f) = res(f) + 1\n          step(n0 / f)\n      }\n    }\n\n    step(n)\n    res\n  }\n\n  /**\n    * log2して小数点切り捨てたもの\n    */\n  def log2(x: Int): Int = {\n    var a = Integer.highestOneBit(x)\n    var i = 0\n    while(a > 1) {\n      i += 1\n      a >>>= 1\n    }\n    i\n  }\n\n  class InputReader(val stream: InputStream) {\n    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n    private var tokenizer: StringTokenizer = _\n\n    def next(): String = {\n      while (tokenizer == null || !tokenizer.hasMoreTokens)\n        tokenizer = new StringTokenizer(reader.readLine)\n      tokenizer.nextToken\n    }\n\n    def nextInt(): Int = next().toInt\n    def nextLong(): Long = next().toLong\n    def nextChar(): Char = next().charAt(0)\n  }\n  val sc = new InputReader(System.in)\n  def ni(): Int = sc.nextInt()\n  def nl(): Long = sc.nextLong()\n  def nc(): Char = sc.nextChar()\n  def ns(): String = sc.next()\n  def ns(n: Int): Array[Char] = ns().toCharArray\n  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n    val A1, A2 = Array.ofDim[Int](n)\n    rep(n) { i =>\n      A1(i) = ni() + offset\n      A2(i) = ni() + offset\n    }\n    (A1, A2)\n  }\n  def nm(n: Int, m: Int): Array[Array[Int]] = {\n    val A = Array.ofDim[Int](n, m)\n    rep(n) { i =>\n      rep(m) { j =>\n        A(i)(j) = ni()\n      }\n    }\n    A\n  }\n  def nal(n: Int): Array[Long] = map(n)(_ => nl())\n  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = offset\n    val N = n + offset\n    while(i < N) { f(i); i += 1 }\n  }\n  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = n - 1 + offset\n    while(i >= offset) { f(i); i -= 1 }\n  }\n\n  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n    val res = Array.ofDim[A](n)\n    rep(n)(i => res(i) = f(i + offset))\n    res\n  }\n\n\n  def sumL(as: Array[Int]): Long = {\n    var s = 0L\n    rep(as.length)(i => s += as(i))\n    s\n  }\n\n  def cumSum(as: Array[Int]) = {\n    val cum = Array.ofDim[Int](as.length + 1)\n    rep(as.length) { i =>\n      cum(i + 1) = cum(i) + as(i)\n    }\n    cum\n  }\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]): Unit = {\n    val s = new Main()\n    s.solve()\n    s.out.flush()\n  }\n}\n\nclass Main {\n  import java.io._\n  import java.util.StringTokenizer\n\n  import scala.collection.mutable\n  import scala.util.Sorting\n  import math.{abs, max, min}\n  import mutable.{ArrayBuffer, ListBuffer}\n  import scala.reflect.ClassTag\n\n  val MOD = 1000000007\n  val out = new PrintWriter(System.out)\n\n  def solve(): Unit = {\n    val N = ni()\n    if (N == 1) {\n      out.println(s\"1 0\")\n    } else {\n      val f = factorize(N)\n      val mul = f.keys.product\n      val maxPow = f.values.max\n      val minPow = f.values.min\n      val cnt = log2(maxPow - 1) + 1 + (if (minPow == maxPow) 0 else 1)\n      out.println(s\"$mul $cnt\")\n    }\n  }\n\n  /**\n    * *注意* IntをLongにして使わないこと\n    */\n  def factorize(n: Int): mutable.Map[Int, Int] = {\n    import scala.collection.mutable\n    val res = mutable.Map[Int, Int]() withDefaultValue 0\n\n    def minFactor(n0: Int, rt: Int, i: Int): Int = {\n      if (i > rt) n0 // √n まで見つからなかったら n0は素数か1\n      else if (n0 % i == 0) i\n      else minFactor(n0, rt, i + 1)\n    }\n\n    def step(n0: Int): Unit = {\n      minFactor(n0, math.sqrt(n0).toInt, 2) match {\n        case 1 =>\n        case f =>\n          res(f) = res(f) + 1\n          step(n0 / f)\n      }\n    }\n\n    step(n)\n    res\n  }\n\n  /**\n    * log2して小数点切り捨てたもの\n    */\n  def log2(x: Int): Int = {\n    var a = Integer.highestOneBit(x)\n    var i = 0\n    while(a > 1) {\n      i += 1\n      a >>>= 1\n    }\n    i\n  }\n\n  class InputReader(val stream: InputStream) {\n    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n    private var tokenizer: StringTokenizer = _\n\n    def next(): String = {\n      while (tokenizer == null || !tokenizer.hasMoreTokens)\n        tokenizer = new StringTokenizer(reader.readLine)\n      tokenizer.nextToken\n    }\n\n    def nextInt(): Int = next().toInt\n    def nextLong(): Long = next().toLong\n    def nextChar(): Char = next().charAt(0)\n  }\n  val sc = new InputReader(System.in)\n  def ni(): Int = sc.nextInt()\n  def nl(): Long = sc.nextLong()\n  def nc(): Char = sc.nextChar()\n  def ns(): String = sc.next()\n  def ns(n: Int): Array[Char] = ns().toCharArray\n  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n    val A1, A2 = Array.ofDim[Int](n)\n    rep(n) { i =>\n      A1(i) = ni() + offset\n      A2(i) = ni() + offset\n    }\n    (A1, A2)\n  }\n  def nm(n: Int, m: Int): Array[Array[Int]] = {\n    val A = Array.ofDim[Int](n, m)\n    rep(n) { i =>\n      rep(m) { j =>\n        A(i)(j) = ni()\n      }\n    }\n    A\n  }\n  def nal(n: Int): Array[Long] = map(n)(_ => nl())\n  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = offset\n    val N = n + offset\n    while(i < N) { f(i); i += 1 }\n  }\n  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = n - 1 + offset\n    while(i >= offset) { f(i); i -= 1 }\n  }\n\n  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n    val res = Array.ofDim[A](n)\n    rep(n)(i => res(i) = f(i + offset))\n    res\n  }\n\n\n  def sumL(as: Array[Int]): Long = {\n    var s = 0L\n    rep(as.length)(i => s += as(i))\n    s\n  }\n\n  def cumSum(as: Array[Int]) = {\n    val cum = Array.ofDim[Int](as.length + 1)\n    rep(as.length) { i =>\n      cum(i + 1) = cum(i) + as(i)\n    }\n    cum\n  }\n}"}, {"source_code": "//package codeforce520\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject B {\n  def main(args: Array[String]): Unit = {\n    val reader = scala.io.StdIn\n\n    val n = reader.readInt()\n\n    val sieve = ArrayBuffer.fill(n + 1)(1)\n    sieve(0) = 0\n    sieve(1) = 0\n\n    (2 until sieve.size) foreach {i =>\n      if (sieve(i) == 1) {\n        val j = i\n        var c = 2\n        while (j * c < sieve.size) {\n          sieve(j * c) = 0\n          c += 1\n        }\n      }\n    }\n\n    val prime = sieve.zipWithIndex.filter(_._1 == 1).map(_._2)\n\n    val factor = prime.map{p =>\n      var c = 0\n      var t = n\n\n      while (t % p == 0 && t > 0) {\n        c += 1\n        t = t / p\n      }\n\n      (p , c)\n    }.filter(_._2 > 0)\n    //println(factor.mkString(\" \"))\n\n    val minValue = factor.map(_._1).foldLeft(1)(_ * _)\n    val need1Operation = factor.map(_._2).toSet.size == 1\n    var mult = false\n\n    var maxP = if (factor.size > 0) factor.map(_._2).max else 0\n    var minO = 0\n    var pick = 1\n    while(pick < maxP) {\n      minO += 1\n      pick *= 2\n    }\n\n    if (pick > maxP) minO += 1\n\n    if (!need1Operation || mult == true) minO += 1\n\n    if (n <= 3) {\n      println(s\"$n 0\")\n    }\n    else {\n      println(s\"$minValue $minO\")\n    }\n\n  }\n}\n"}, {"source_code": "//package codeforce520\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject B {\n  def main(args: Array[String]): Unit = {\n    val reader = scala.io.StdIn\n\n    val n = reader.readInt()\n    val length = (n + 1) / 2\n\n    val sieve = ArrayBuffer.fill(length + 1)(1)\n    sieve(0) = 0\n    sieve(1) = 0\n\n    (2 until sieve.size) foreach {i =>\n      if (sieve(i) == 1) {\n        val j = i\n        var c = 2\n        while (j * c < sieve.size) {\n          sieve(j * c) = 0\n          c += 1\n        }\n      }\n    }\n\n    val prime = sieve.zipWithIndex.filter(_._1 == 1).map(_._2)\n\n    val factor = prime.map{p =>\n      var c = 0\n      var t = n\n      while (t % p == 0 && t > 0) {\n        c += 1\n        t = t / p\n      }\n\n      (p , c)\n    }.filter(_._2 > 0)\n\n    val minValue = factor.map(_._1).foldLeft(1)(_ * _)\n    val need1Operation = factor.map(_._2).toSet.size == 1\n    var minOperation = (factor.map(_._2).max / 2)\n    if (!need1Operation) minOperation += 1\n    println(s\"$minValue $minOperation\")\n  }\n}\n"}, {"source_code": "//package codeforce520\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject B {\n  def main(args: Array[String]): Unit = {\n    val reader = scala.io.StdIn\n\n    val n = reader.readInt()\n\n    val sieve = ArrayBuffer.fill(n + 1)(1)\n    sieve(0) = 0\n    sieve(1) = 0\n\n    (2 until sieve.size) foreach {i =>\n      if (sieve(i) == 1) {\n        val j = i\n        var c = 2\n        while (j * c < sieve.size) {\n          sieve(j * c) = 0\n          c += 1\n        }\n      }\n    }\n\n    val prime = sieve.zipWithIndex.filter(_._1 == 1).map(_._2)\n\n    val factor = prime.map{p =>\n      var c = 0\n      var t = n\n\n      while (t % p == 0 && t > 0) {\n        c += 1\n        t = t / p\n      }\n\n      (p , c)\n    }.filter(_._2 > 0)\n    //println(factor.mkString(\" \"))\n\n    val minValue = factor.map(_._1).foldLeft(1)(_ * _)\n    val need1Operation = factor.map(_._2).toSet.size == 1\n    var mult = false\n\n    var maxP = if (factor.size > 0) factor.map(_._2).max else 0\n    var minO = 0\n    while(maxP > 1) {\n      if (maxP % 2 == 0) {\n        maxP = maxP / 2\n      }\n      else {\n        maxP = maxP - 1\n        mult = true\n      }\n      minO += 1\n    }\n\n    if (!need1Operation || mult == true) minO += 1\n\n    if (n <= 3) {\n      println(s\"$n 0\")\n    }\n    else {\n      println(s\"$minValue $minO\")\n    }\n\n  }\n}\n"}, {"source_code": "//package codeforce520\n\nimport scala.collection.mutable.ArrayBuffer\n\nobject B {\n  def main(args: Array[String]): Unit = {\n    val reader = scala.io.StdIn\n\n    val n = reader.readInt()\n\n    val sieve = ArrayBuffer.fill(n + 1)(1)\n    sieve(0) = 0\n    sieve(1) = 0\n\n    (2 until sieve.size) foreach {i =>\n      if (sieve(i) == 1) {\n        val j = i\n        var c = 2\n        while (j * c < sieve.size) {\n          sieve(j * c) = 0\n          c += 1\n        }\n      }\n    }\n\n    val prime = sieve.zipWithIndex.filter(_._1 == 1).map(_._2)\n\n    val factor = prime.map{p =>\n      var c = 0\n      var t = n\n\n      while (t % p == 0 && t > 0) {\n        c += 1\n        t = t / p\n      }\n\n      (p , c)\n    }.filter(_._2 > 0)\n    //println(factor.mkString(\" \"))\n\n    val minValue = factor.map(_._1).foldLeft(1)(_ * _)\n    val need1Operation = factor.map(_._2).toSet.size == 1\n    var mult = false\n\n    var maxP = if (factor.size > 0) factor.map(_._2).max else 0\n    var minO = 0\n    while(maxP > 1) {\n      if (maxP % 2 == 0) {\n        maxP = maxP / 2\n      }\n      else {\n        maxP = maxP - 1\n        mult = true\n      }\n      minO += 1\n    }\n\n    if (!need1Operation || mult == true) minO += 1\n\n    println(s\"$minValue $minO\")\n  }\n}\n"}, {"source_code": "import scala.collection.mutable\nimport scala.io.StdIn\n\nobject Codeforces1062B {\n\n  def getMinimumOperation(n: Int): (Int, Int) = {\n    val primeFactors = getPrimeFactorization(n)\n\n    var totalSteps = 0\n\n    val maxPower = primeFactors.values.max\n    if (!isPowerOfTwo(maxPower) || !primeFactors.values.forall(_ == maxPower)) {\n      totalSteps += 1\n    }\n    val powerOfTwo = getNextPowerOfTwo(maxPower)\n    totalSteps += powerOfTwo\n\n    (multiply(primeFactors.keys), totalSteps)\n  }\n\n  def isPowerOfTwo(n: Int): Boolean = (n & (n - 1)) == 0\n\n  def getNextPowerOfTwo(n: Int): Int = {\n    var poweredNumber = 2L\n    var power = 1\n    while (poweredNumber < n) {\n      poweredNumber *= 2\n      power += 1\n    }\n    power\n  }\n\n  def multiply(numbers: Iterable[Int]): Int = {\n    var result = 1\n    for (number <- numbers) result *= number\n    result\n  }\n\n\n  def isUniquePrimeFactors(primeFactors: mutable.Map[Int, Int]): Boolean =\n    primeFactors.values.forall(_ == 1)\n\n  def getPrimeFactorization(n: Int): mutable.Map[Int, Int] = {\n    val primeFactors = new mutable.HashMap[Int, Int]()\n    var remainingNumber = n\n    val sqrtN = math.sqrt(n).toInt\n    for (primeCandidate <- 2 to sqrtN) {\n      if (remainingNumber % primeCandidate == 0) {\n        primeFactors(primeCandidate) = 0\n        while (remainingNumber % primeCandidate == 0) {\n          primeFactors(primeCandidate) += 1\n          remainingNumber /= primeCandidate\n        }\n      }\n    }\n\n    if (remainingNumber != 1) {\n      primeFactors(remainingNumber) = 1\n    }\n\n    primeFactors\n  }\n\n  def main(args: Array[String]): Unit = {\n    val n = StdIn.readLine.trim.toInt\n\n    val result = getMinimumOperation(n)\n\n    println(s\"${result._1} ${result._2}\")\n  }\n}\n"}], "src_uid": "212cda3d9d611cd45332bb10b80f0b56"}
{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val Array(n, k) = in.next().split(' ').map(_.toInt)\n  val count = n - Math.min(n, k - 2 * n)\n  println(count)\n}\n", "positive_code": [{"source_code": "object A194 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def main(args: Array[String]): Unit = {\n    var Array(n, k) = readInts(2)\n    k -= 2*n\n    if(k <= n) {\n      println(n-k)\n    } else {\n      println(\"0\")\n    }\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "object Main {\n\tdef main(args: Array[String]) {\n\t\tval result = {\n\t\t\tval (n, k) = {\n\t\t\t\tval line = readLine()\n\t\t\t\tval sp = line.split(' ')\n\t\t\t\tval p = sp.map(Integer.parseInt(_))\n\t\t\t\t(p(0), p(1))\n\t\t\t}\n\t\t\tval lowest = k / n\n\t\t\tif (lowest > 2) 0\n\t\t\telse n*3 - k\n\t\t}\n\t\tprint(result)\n\t}\n}"}, {"source_code": "import java.util._\n\nobject Main {\n\n    def main(args: Array[String]) {\n        val in = new Scanner(System.in)\n        val n = in.nextInt\n        val s = in.nextInt - 2 * n\n        if (s >= n) {\n            println(0)\n        } else {\n            println(n - s)\n        }\n    }\n\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val Array(n, k) = readLine().split(\" \").map(_.toInt)\n    if (k / 3 >= n) println(\"0\")\n    else println(n - (k - (k / n) * n))\n  }\n}"}, {"source_code": "object Main extends App{\n  val in = readLine\n  val Array(n, k)=in.split(' ').map(_.toInt)\n  val count = n -Math.min(n, k -2* n)\n  println(count)\n}"}, {"source_code": "import java.util.Scanner\nimport math.min\nimport math.max\n\nobject Main {\n\n    def main(args:Array[String]) {\n        val scanner = new Scanner(System.in)\n        val n, k = scanner.nextInt()\n        val ans = max (0, min (n, 3 * n - k))\n        println (ans)\n    }\n\n}\n\n// vim: set ts=4 sw=4 et:\n"}], "negative_code": [{"source_code": "object Main {\n  def main(args: Array[String]) {\n    val Array(n, k) = readLine().split(\" \").map(_.toInt)\n    if (k / 3 >= n) println(\"0\")\n    else println(n - (k - (k / 2) * 2))\n  }\n}"}], "src_uid": "5a5e46042c3f18529a03cb5c868df7e8"}
{"source_code": "import scala.io.StdIn\n\nobject Codeforces1030A extends App {\n  val n = StdIn.readLine().toInt\n  val hard = StdIn.readLine().split(\"\\\\s\").map(n => n == \"1\")\n\n  val allEasy = !hard.contains(true)\n\n  printf(if (allEasy) \"EASY\" else \"HARD\")\n}\n", "positive_code": [{"source_code": "import scala.io.StdIn\nobject EasyProblem extends App\n{\n    val numOfPersons = StdIn.readInt()\n    val input = StdIn.readLine().split(' ').map(_.toInt)\n    var hard = 0\n    for(i <- input.indices)\n    {\n        if(input(i) == 1)\n        {\n            hard += 1\n        }\n    }\n    if(hard > 0)\n    {\n        println(\"HARD\")\n    } else println(\"EASY\")\n}"}, {"source_code": "import scala.io.StdIn\n\nobject cf1030a {\n  def main(args: Array[String]): Unit = {\n    val _ = StdIn.readInt()\n    val in = StdIn.readLine().split(' ').map(_.toInt)\n\n    if (in.sum > 0) {\n      println(\"HARD\")\n    } else {\n      println(\"EASY\")\n    }\n  }\n}\n"}, {"source_code": "import scala.io.StdIn.readLine\n\nobject A1030 {\n  def main(args: Array[String]): Unit = {\n    val _ = readLine\n    val answer = if (Helper.readToListInts.contains(1)) \"HARD\" else \"EASY\"\n    println(answer)\n  }\n}\n\nobject Helper {\n  def readInt: Int = readLine.toInt\n  def readToListInts: List[Int] = readLine.split(\" \").map(_.toInt).toList\n  def readToVectorInts: Vector[Int] = readLine.split(\" \").map(_.toInt).toVector\n}\n"}, {"source_code": "import scala.io.StdIn\n\nobject Main {\n  def main(args: Array[String]): Unit = {\n    val n = StdIn.readLine()\n    val s = StdIn.readLine()\n    if(solve(s)) println(\"HARD\")\n    else println(\"EASY\")\n  }\n\n  def solve(s: String): Boolean = {\n    s.contains('1')\n  }\n}"}, {"source_code": "import io.StdIn._\nobject InSearchOfEasyproblem {\n\n  def main(args: Array[String]): Unit = {\n    var number = readInt()\n    var inputs: Array[Int] = readLine().split(\" \").map(t => s\"$t\".toInt)\n    val answer = inputs.sum match {\n      case 0 => \"EASY\"\n      case _ => \"HARD\"\n    }\n    println(answer)\n  }\n\n}"}, {"source_code": "object InSearchofanEasyProblem1030A extends App{\n  import java.io.{InputStream, PrintStream}\n  import java.util.Scanner\n  solve(System.in,System.out)\n  def solve(in: InputStream, out: PrintStream): Unit = {\n    val scanner = new Scanner(in)\n    val n = scanner.nextInt()\n    val isHard = (1 to n).foldLeft(0){case (current,_) => current + scanner.nextInt()} > 0\n    out.println(s\"${if(isHard) \"HARD\" else  \"EASY\"}\")\n\n  }\n}\n"}, {"source_code": "import scala.io.StdIn\n\nobject Main2 extends App {\n  val personNumber = StdIn.readInt()\n  val difficulties = StdIn.readLine()\n  println(if (difficulties.contains(\"1\")) \"hard\" else \"easy\")\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject TaskA extends App {\n  readInt\n  println(if (readLine.split(\" \").contains(\"1\")) \"HARD\" else \"EASY\")\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]): Unit = {\n    val s = new Main()\n    s.solve()\n    s.out.flush()\n  }\n}\n\nclass Main {\n  import java.io._\n  import java.util.StringTokenizer\n\n  import scala.collection.mutable\n  import scala.util.Sorting\n  import math.{abs, max, min}\n  import mutable.{ArrayBuffer, ListBuffer}\n  import scala.reflect.ClassTag\n\n  val MOD = 1000000007\n  val out = new PrintWriter(System.out)\n\n  def solve(): Unit = {\n    val N = ni()\n    val A = na(N)\n    val ok = A.forall(_ == 0)\n    val ans = if(ok) \"EASY\" else \"HARD\"\n    out.println(ans)\n  }\n\n\n  class InputReader(val stream: InputStream) {\n    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n    private var tokenizer: StringTokenizer = _\n\n    def next(): String = {\n      while (tokenizer == null || !tokenizer.hasMoreTokens)\n        tokenizer = new StringTokenizer(reader.readLine)\n      tokenizer.nextToken\n    }\n\n    def nextInt(): Int = next().toInt\n    def nextLong(): Long = next().toLong\n    def nextChar(): Char = next().charAt(0)\n  }\n  val sc = new InputReader(System.in)\n  def ni(): Int = sc.nextInt()\n  def nl(): Long = sc.nextLong()\n  def nc(): Char = sc.nextChar()\n  def ns(): String = sc.next()\n  def ns(n: Int): Array[Char] = ns().toCharArray\n  def na(n: Int): Array[Int] = map(n)(_ => ni())\n  def nal(n: Int): Array[Long] = map(n)(_ => nl())\n  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = offset\n    val N = n + offset\n    while(i < N) { f(i); i += 1 }\n  }\n  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = n - 1 + offset\n    while(i >= offset) { f(i); i -= 1 }\n  }\n\n  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {\n    val res = Array.ofDim[A](n)\n    rep(n)(i => res(i) = f(i))\n    res\n  }\n\n  def sumL(as: Array[Int]): Long = {\n    var s = 0L\n    rep(as.length)(i => s += as(i))\n    s\n  }\n}\n"}, {"source_code": "object A {\n  def main(args: Array[String]) = {\n    val n = scala.io.StdIn.readInt()\n    if (scala.io.StdIn.readLine().split(\" \").map(_.toInt).sum > 0) {\n      System.out.println(\"HARD\")\n    } else {\n      System.out.println(\"EASY\")\n    }\n  }\n}\n"}, {"source_code": "import java.util.Scanner\nimport scala.io.StdIn\nobject Toto extends App {\n  val n = StdIn.readInt()\n  val data = new Scanner (StdIn.readLine())\n  val hard =\n    (1 to n).foldLeft(false) {\n      (acc, _) =>\n        val x = data.nextInt()\n        acc || (x == 1)\n    }\n  if (hard){println(\"HARD\")} else {println(\"EASY\")}\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject Solution {\n\tval n = readLine.toInt\n\tvar r = readLine.split(\" \").map(_.toInt)\n\n\tdef main(args:Array[String]):Unit = {\n\t\tvar response = \"EASY\"\n\t\tfor(i <- 0 until n) {\n\t\t\tif(r(i) == 1) response = \"HARD\"\n\t\t}\n\t\tprintln(response)\n\t}\n}\n"}], "negative_code": [{"source_code": "object Toto extends App {\n  println(\"HARD\")\n}\n"}], "src_uid": "060406cd57739d929f54b4518a7ba83e"}
{"source_code": "import java.util.Scanner\n\n/**\n  * Created by Orhan on 3/7/2017.\n  */\nobject StringTask extends App{\n  val line = new Scanner(System.in)\n  var word = line.next().toLowerCase()\n  val vowels = Array(\"a\", \"o\", \"y\", \"e\", \"u\", \"i\")\n  print(word.split(\"\").filter( w => !vowels.contains(w)).map(w => \".\" + w).mkString(\"\"))\n}\n", "positive_code": [{"source_code": "object Main {\n  def main(args: Array[String]): Unit = {\n    val isVowel = Set('a', 'e', 'i', 'o', 'u', 'y')\n\n    val line = readLine.toLowerCase\n\n    val out1 = line.filterNot(isVowel)\n    val out = out1 map {x => \".\"+x}\n    println(out.mkString)\n  }\n}\n"}, {"source_code": "object A {\n\n  def main(args: Array[String]): Unit = {\n    println(readLine().toLowerCase().replaceAll(\"[aoyeui]\", \"\").map(s => \".\" + s).mkString(\"\"))\n  }\n\n}"}, {"source_code": "import scala.io.StdIn\n\nobject  Test {\n  val vovels = \"AOUYIE\".toLowerCase.toCharArray\n  def main(args1: Array[String]) {\n//    val args = Console.readLine().split(\" \")\n//    val (v: Long, y: Long, z: Long) = (args(0).toLong, args(1).toLong, args(2).toLong)\n\n\n      val line = StdIn.readLine\n      val chars = line.toCharArray\n      val res = chars.map(s => s.toLower).filter(s => !isVovel(s)).map(s => s\".$s\")\n\n\n//    val res = balls.size\n    res.foreach(print)\n  }\n\n  def isVovel(char: Char): Boolean = {\n    return vovels.contains(char)\n  }\n}"}, {"source_code": "object OneOneEightA {\n\n\tdef main(args : Array[String]) : Unit = {\n\t\tvar vovels=Array('a', 'o', 'y', 'e', 'u', 'i','A', 'O', 'Y', 'E', 'U', 'I')\n\t\tvar input=readLine.toCharArray\n\t\tvar strBuff=new StringBuilder\n\t\tfor(i<-input){\n\t\t\tif(!vovels.contains(i)){\n\t\t\t\tstrBuff.append(\".\"+i.toLower)\n\t\t\t}\n\t\t}\n\t\tprintln(strBuff.toString)\n\t}\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject StringTask {\n  def main(args: Array[String]): Unit = {\n    val vowels = Set('a', 'o', 'y', 'e', 'u', 'i')\n    val s = readLine().toLowerCase().filter(x => !vowels.contains(x))\n    val ans = s.map(x => \".\" + x).foldLeft(\"\")((acc, x) => acc + x)\n    println(ans)\n  }\n}"}, {"source_code": "/*input\nxnhcigytnqcmy\n*/\n\nimport java.util.Scanner\nimport scala.io.StdIn\n\nobject Solution {\n\tdef main(args: Array[String]): Unit = {\n\n\t\tval str = StdIn.readLine().map(_.toLower);\n\t\tstr.foreach((x: Char) => {\n\t\t\tif(!(\"aeiouy\".contains(x))) {\n\t\t\t\tprint('.');\n\t\t\t\tprint(x);\n\t\t\t}\n\t\t})\n\n\t}\n\n}"}, {"source_code": "object main extends App {\n    var s = readLine().toLowerCase().replaceAll(\"([aoyeui])\", \"\")\n    s.foreach((c) => print(\".\" + c))\n}"}, {"source_code": "object CF118A extends App {\n    import scala.io.StdIn.readLine\n    import scala.collection.immutable.HashSet\n    val s = readLine.toLowerCase.toCharArray\n    val vowels:HashSet[Char] = HashSet('a','e','i','o','u','y')\n    s.filter(!vowels(_)).foreach(x => print(\".\"+x.toString))\n}"}, {"source_code": "object StringTask extends App {\n\n\t\n\tval input = scala.io.StdIn.readLine().toLowerCase()\n\n    val noVowel = input.replaceAll(\"([aeiouy])+\", \"\")\n    val output = noVowel.map(x => s\".$x\").mkString\n    \n\tprintln(output)\n\n}"}, {"source_code": "object Main extends App {\n  val inputString = readLine.toList\n\n  def replaceLiterals(list: List[Char]): List[Char] = list match {\n    case List() => List()\n    case e :: rest => \n      e match {\n        case 'a' | 'e' | 'i' | 'o' | 'u' |'y' | 'A' | 'E' | 'I' | 'O' | 'U' | 'Y' => replaceLiterals(rest)\n        case _ => '.' :: e.toLower :: replaceLiterals(rest)\n      }      \n  }\n\n  println(replaceLiterals(inputString).mkString)\n}\n"}, {"source_code": "object Main extends App {\n  val str = readLine().toList\n  val vovels = \"AOYEUIaoyeui\"\n\n  def helper(xs: List[Char]): List[Char] = xs match {\n    case (x :: ys) if vovels.contains(x) => helper(ys)\n    case (x :: ys)                => '.' :: x.toLower :: helper(ys)\n    case _                        => Nil\n  }\n\n  println(helper(str).mkString)\n}"}, {"source_code": "object CF0118A extends App {\n\n  val gl = List(\"a\", \"o\", \"y\", \"e\", \"u\", \"i\")\n\n  val str = readLine()\n\n  var result = new StringBuilder\n\n  for (ch <- str) {\n    if (!(gl contains(ch.toString.toLowerCase))) {\n      result ++= \".\" + ch.toString.toLowerCase\n    }\n  }\n\n  println(result)\n\n}\n"}, {"source_code": "import scala.io.StdIn\n\n/** A. String Task\n  *\n  * @author Yuichiroh Matsubayashi\n  *         Created on 15/01/19.\n  */\nobject P118A extends App {\n  val vowels = Seq('a', 'o', 'y', 'e', 'u', 'i')\n  val word = StdIn.readLine().toLowerCase\n\n  def solution = word.filterNot(vowels.contains(_)).map(c => \".\" + c).mkString\n\n  println(solution)\n}"}, {"source_code": "import java.io._\n\nobject Main {\n\n  val in = new BufferedReader(new InputStreamReader(System.in))\n  val out = new PrintWriter(System.out)\n  sys.addShutdownHook(out.close())\n\n  @inline def nextInt = in.readLine().toInt\n  @inline def nextInts = in.readLine().split(\" +\").map(_.toInt)\n  @inline def println[T](x: T) = out.println(x)\n\n  def main(args: Array[String]): Unit = {\n    val s = in.readLine()\n    val ans = s.\n      toLowerCase.\n      replace(\"a\",\"\").\n      replace(\"e\",\"\").\n      replace(\"i\",\"\").\n      replace(\"o\",\"\").\n      replace(\"u\",\"\").\n      replace(\"y\",\"\").\n      mkString(\".\", \".\", \"\")\n\n    println(ans)\n\n  }\n}"}, {"source_code": "object HelloWorld {\n  def main(args: Array[String]): Unit = {\n  \tvar s = readLine()\n  \ts = s.map(c => c.toLower)\n  \ts = s.replaceAll( \"[eyuioa]\", \"\") \n  \tvar str = \"\"\n  \tfor(i <-0 until s.length())\n  \t\tstr = str + \".\" + s(i)\n  \tprintln(str)\n  }\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject task1 {\n  def main(args: Array[String]): Unit = {\n    val input = readLine()\n    val letters = List('A', 'O', 'Y', 'E', 'U', 'I').map(_.toLower)\n    val result = input.filterNot(el2 => letters.contains(el2.toLower)).map{ el =>\n      s\".$el\"\n    }.mkString(\"\").toLowerCase\n    println(result)\n  }\n\n}\n"}, {"source_code": "object task158A {\n  def stripChars(s:String, ch:String)= s filterNot (ch contains _)\n  def main(args:Array[String]) {\n    for (c<-stripChars(io.Source.stdin.getLines.toList(0).toLowerCase,\"aoyeui\")) {\n      print(\".\"+c)\n    }\n    println\n  }\n}"}, {"source_code": "object pratise {\n    def main(args : Array[String]) {\n        val str = readLine().toLowerCase().replaceAll(\"([aoyeui])\",\"\")\n        str.foreach(c => print(\".\"+c))\n    }\n}\n"}, {"source_code": "object cf extends App{\n  val vowels = Set('a', 'e', 'i', 'o', 'u', 'y')\n  var s = readLine().toLowerCase()\n  var res = \"\"\n  for (i <- 0 to s.length()-1) {\n    if (!vowels(s(i))) {\n      res += \".\" + s(i)\n    }\n  }\n  println(res)\n}"}, {"source_code": "object StringTask extends App {\n  val str = readLine().toLowerCase\n  val vowels = List('a', 'e', 'o', 'u', 'y', 'i')\n  val consonants = List('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z')\n\n  def filterVowels(c: Char) = if (!vowels.contains(c)) true else false\n\n  def mapConsonants(c: Char) = if (consonants.contains(c)) \".\" + c else c\n\n  println(str.toList.filter(c => filterVowels(c)).map(c => mapConsonants(c)).mkString(\"\"))\n}\n"}, {"source_code": "object Solution {\n    val vowels = Array(\"A\", \"O\", \"Y\", \"E\", \"U\", \"I\")\n    def split(line: String) = line.grouped(1).toList\n    def consonants(chars: List[String]) = chars filter (c => ! (vowels contains (c toUpperCase)))\n    def withDots(chars: List[String]) = chars flatMap (c => Array(\".\", c))\n    def solve(line: String) = withDots (consonants (split(line toLowerCase))) mkString\n    def main(args: Array[String]) = println(solve(readLine))\n}"}, {"source_code": "object Solution {\n    val vowels = Array(\"A\", \"O\", \"Y\", \"E\", \"U\", \"I\")\n    def split(line: String) = line grouped 1\n    def consonants(chars: Iterator[String]) = chars filter (c => ! (vowels contains (c toUpperCase)))\n    def withDots(chars: Iterator[String]) = chars flatMap (c => List(\".\", c))\n    def solve(line: String) = withDots (consonants (split(line toLowerCase))) mkString\n    def main(args: Array[String]) = println(solve(readLine))\n}"}, {"source_code": "object Solution {\n    val vowels = Array(\"A\", \"O\", \"Y\", \"E\", \"U\", \"I\") map (_ charAt 0)\n    def isVowel(c: Char) = ! (vowels contains (Character.toUpperCase(c)))\n    def consonants(chars: Seq[Char]) = chars filter isVowel\n    def withDots(chars: Seq[Char]) = chars flatMap (c => List('.', c))\n    def solve(line: String) = withDots(consonants(line.toLowerCase)).mkString\n    def main(args: Array[String]) = println(solve(readLine))\n}"}, {"source_code": "object Solution {\n    val vowels = Array(\"A\", \"O\", \"Y\", \"E\", \"U\", \"I\") map (_ charAt 0)\n    def isVowel(c: Char) = ! (vowels contains (Character.toUpperCase(c)))\n    def consonants(chars: Seq[Char]) = chars filter isVowel\n    def withDots(chars: Seq[Char]) = chars flatMap (c => List('.', c))\n    def solve(line: String) = withDots (consonants (line toLowerCase)) mkString\n    def main(args: Array[String]) = println(solve(readLine))\n}"}, {"source_code": "object Solution118A extends Application {\n\n  def solution() {\n    println(_string.toLowerCase.replaceAll(\"[aoyeui]\", \"\").map(c => \".\" + c).mkString)\n  }\n\n  //////////////////////////////////////////////////\n  import java.util.Scanner\n  val SC: Scanner = new Scanner(System.in)\n  def _line: String = SC.nextLine\n  def _int: Int = SC.nextInt\n  def _long: Long = SC.nextLong\n  def _string: String = SC.next\n  solution()\n}"}, {"source_code": "object Cf118A extends App {\n  val s = readLine()\n  println(s.toLowerCase.replaceAll(\"[ayeoiu]\", \"\").map(\".\" + _).mkString)\n}"}, {"source_code": "\nobject Main {\n  def main(args: Array[String]): Unit = {\n    print(readLine().split(\"\")\n      .map(el => if (!\"AOYEUI\".contains(el.toUpperCase())) \".\" + el.toLowerCase() else \"\")\n      .mkString(\"\"))\n  }\n}"}, {"source_code": "import scala.collection.mutable._\nimport scala.math._\nimport scala.util.control.Breaks.break\nimport scala.util.control.Breaks.breakable\nimport java.util._\nobject Main extends App {\n  for(i <- readLine.replaceAll(\"[AOYEUIaoyeui]\", \"\").toLowerCase) print(\".\"+i)\n  println\n}\n"}, {"source_code": "// http://codeforces.com/problemset/problem/118/A\n\nimport scala.io.StdIn.readLine\n\nobject StringTask {\n    def main(args: Array[String]): Unit = {\n        val vowels: Set[Char] = \"aeiouy\".toSet\n\n        var line: String = readLine().toLowerCase()\n        line = line.filterNot(vowels.contains(_))\n        val dotted: String = line.mkString(\".\")\n        println(f\".${dotted}%s\")\n    }\n}"}, {"source_code": "object Solution extends App {\n  val vowel = List('a', 'e', 'o', 'u', 'i', 'y')\n  println(readLine().toLowerCase.filterNot(vowel.contains).mkString(\".\", \".\", \"\"))\n}"}, {"source_code": "import scala.collection.immutable.IndexedSeq\n\nobject Problem118A {\n  def main(a: Array[String]) = {\n    val vowels = Set('A', 'O', 'Y', 'E', 'U', 'I', 'a', 'o', 'y', 'e', 'u', 'i')\n\n    val vowelsDeleted: String = readLine().filter(c => ! vowels.contains(c))\n    val pointsToLowerCase: IndexedSeq[String] = vowelsDeleted.map(c => \".\" + c.toLower.toString())\n    val result: String = pointsToLowerCase.foldLeft(\"\")((s: String, t: String) => s + t)\n\n    println(result)\n  }\n}\n"}, {"source_code": "object Cf118a extends App {\n  val vowels = List('a', 'o', 'y', 'e', 'u', 'i')\n  val word = readLine\n  val result = word.toLowerCase.filterNot(vowels.contains).mkString(\".\", \".\", \"\")\n  println(result)\n}\n"}, {"source_code": "object Main {\n\timport java.{util=>ju}\n\timport scala.annotation._\n\timport scala.collection._\n\timport scala.collection.{mutable => mu}\n\timport scala.collection.JavaConverters._\n\timport scala.math._\n\n\tdef main(args:Array[String])\n\t{\n\t\tval sc = new ju.Scanner(System.in)\n\t\tval input = sc.next();\n\n\t\tinput.map{\n\t\t\tcase n if n == 'A' => \"\"\n\t\t\tcase n if n == 'O' => \"\"\n\t\t\tcase n if n == 'Y' => \"\"\n\t\t\tcase n if n == 'E' => \"\"\n\t\t\tcase n if n == 'U' => \"\"\n\t\t\tcase n if n == 'I' => \"\"\n\t\t\tcase n if n == 'a' => \"\"\n\t\t\tcase n if n == 'o' => \"\"\n\t\t\tcase n if n == 'y' => \"\"\n\t\t\tcase n if n == 'e' => \"\"\n\t\t\tcase n if n == 'u' => \"\"\n\t\t\tcase n if n == 'i' => \"\"\n\t\t\tcase n if n.isLowerCase => \".\"+n\n\t\t\tcase n if n.isUpperCase => \".\"+n.toLowerCase\n\t\t\tcase n => n\n\t\t}.foreach{\n\t\t\tprint(_)\n\t\t}\n\n\n\t}\n}\n"}, {"source_code": "/**\n * Created by mikhailvarnavskikh on 04.04.15.\n */\nobject Main {\n\n  def main(args: Array[String]) {\n    val std = scala.io.StdIn\n    val n = std.readLine()\n    val vowels = \"aoiuey\"\n    val res = n.toLowerCase.filter( x => !vowels.contains( x ) ).foldLeft( \"\" )( (r, c) => r + \".\" + c )\n    println( res )\n  }\n\n}\n"}, {"source_code": "\nimport scala.io.StdIn\n\nobject StringTask extends App {\n\n  val input = StdIn.readLine()\n  print(impl(input))\n\n  def impl(word: String) = {\n    val wordReform = new StringBuilder\n    for (char <- word) {\n      val lower = char.toLower\n      if (isConsonant(lower)) {\n        wordReform.append(\".\").append(lower)\n      }\n    }\n    wordReform.toString()\n  }\n\n  private\n  def isConsonant(char: Char): Boolean = {\n    char match {\n      case 'a' | 'e' | 'i' | 'o' | 'u' | 'y' => false\n      case _ => true\n    }\n  }\n}"}, {"source_code": "import scala.io.StdIn\nobject solution extends App{\n    \n   val text = StdIn.readLine\n   val vowels = \"aeiouy\"\n   \n   \n   val output = text.foldLeft(\"\")((a,b) => {\n        val lower = b.toString.toLowerCase\n        if(vowels.contains(lower)) a+\"\"\n        else a +\".\"+ lower\n   } )\n    println(output)\n}"}, {"source_code": "\n\nobject CF118A extends App {\n  import scala.io.Source\n  //val src = Source.fromFile(\"data.txt\")\n  val src = Source.stdin\n  val lines = src.getLines\n  \n  def readString(): String =  {\n    val line = if (lines.hasNext) lines.next else null\n    if (line == null) throw new RuntimeException(\"Premature end of source encountered\")\n    line\n  }\n  \n  val st = readString().toLowerCase().\n             filterNot(x => x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u' || x == 'y').\n              toList.map(x => s\".$x\").mkString\n             \n  println(st)\n  \n}"}, {"source_code": "object A118 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val input = scala.io.StdIn.readLine\n    def isVowel(char: Char) = {\n      Array('A', 'E', 'I', 'O', 'U', 'Y').contains(char) || Array('A', 'E', 'I', 'O', 'U', 'Y').map(_.toLower).contains(char)\n    }\n    println(input\n      .filter(!isVowel(_))\n      .toCharArray\n      .map(x => if (x.isUpper) x.toLower else x)\n      .flatMap{x => Array('.', x)}.mkString(\"\"))\n  }\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P118A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val Vowels = List('a', 'o', 'y', 'e', 'u', 'i')\n  def solve: String = \".\" + sc.nextLine.toLowerCase.filterNot(Vowels.contains(_)).mkString(\".\")\n\n  out.println(solve)\n  out.close\n}\n"}, {"source_code": "import java.util.Scanner\nimport scala.collection.mutable.StringBuilder\n\nobject R118_A extends App {\n  val sc = new Scanner(System.in)\n\n  val w = sc.nextLine()\n  println(process(w))\n  def process(w:String):String = {\n    val nw = w.toLowerCase().replaceAll(\"[aiueoy]\", \"\")\n    val b = new StringBuilder\n    nw.foreach(c=>{\n      b.append('.')\n      b.append(c)\n    })\n    b.result\n  }\n}"}, {"source_code": "object StringTask {\n  \tdef main (args: Array[String]) {\n\t\tval scanner = new java.util.Scanner(System.in)\n\t\t\t\tval word = scanner.nextLine().toLowerCase()\n\t\t\t\tword.toCharArray()\n\t\t\t\tvar output : String = \"\"\n\t\t\t\tfor (i <- 0 to word.length()-1) {\n\t\t\t\t  val current =\n\t\t\t\t  word(i) match {\n\t\t\t\t    case 'a' | 'e' | 'y' | 'u' | 'i' | 'o' => \"\"\n\t\t\t\t    case whatever => \".\"+whatever\n\t\t\t\t  }\n\t\t\t\t  output = output + current\n\t\t\t\t}\n\t\t\t\tprintln(output)\n\t}\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject ScalaTest{\n  def main(args: Array[String]): Unit = {\n\n    val list = List('a','e','i','o','u','y')\n    val input = readLine().toLowerCase.filterNot{ch =>\n        list.contains(ch)\n    }.mkString(\".\")\n    println(\".\" + input)\n  }\n}"}, {"source_code": "object A118 {\n\tdef main(args: Array[String]) = {\n\t\tval vow = List('a', 'e', 'i', 'u', 'y', 'o')\n\t\tfor (c <- readLine.toLowerCase.toCharArray)\n\t\t\tif (!vow.exists(c == _))\n\t\t\t\tprint(\".\" + c)\n\t}\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject test {\n  def main(args: Array[String]): Unit = {\n    val input = readLine()\n\n    println(codeForees(input))\n\n  }\n\n  def codeForees(text: String) = {\n      text.toLowerCase.filterNot (a => a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o' ||a == 'y').map(a => s\".$a\" ).mkString\n  }\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject Try1 {\n  def main(args: Array[String]) {\n    val in = new Scanner(System.in)\n    var len,x, m, k, n, j, i: Int = 0\n//    var a = new Array[Int](51)\n//    n = in.nextInt()\n//    k = in.nextInt()\n//    x=0\n    var line = in.nextLine()\n    val al = \"AOYEUIaeiouy\"\n    val b = \"abcdefghijklmnopqrstuvwxyz\"\n    n=line.length()\n    for (i <- 0 until n) {\n      j=0\n      while (j<12 && al(j)!=line(i)) j+=1\n      if (j==12) {\n        print('.')\n        if (line(i)>='A' && line(i)<='Z') print(b(line(i)-'A'))\n        else print(line(i))\n      }\n    }\n  }\n}"}, {"source_code": "import java.io._\n\nobject Main {\n  val in = new BufferedReader(new InputStreamReader(System.in))\n  def main(args: Array[String]) {\n    println(in.readLine().toLowerCase().filterNot(c => \"aeiuyo\".contains(c)).map(\".\" + _).mkString)\n  }\n}"}, {"source_code": "object StringTask {\n  val vowels = Set('A', 'O', 'Y', 'E', 'U', 'I')\n  def isVowel(c:Char) = vowels.contains(c.toUpper)\n  def main(args: Array[String]): Unit = {\n    val s = io.StdIn.readLine()\n    var rs = \"\"\n\n    for {c <- s} {\n      c match {\n        case _ if isVowel(c) =>\n        case _ => rs += \".\" + c.toLower\n      }\n    }\n    Console.println(rs)\n  }\n}\n"}, {"source_code": "object Codeforces118A extends App{\n\n  def WordConvert(word:String):String={\n    val restrictedlist:String=\"aAeEiIoOuUyY\"\n    var ans:Array[Char]=new Array[Char](0)\n    for (i<-word){\n      if (!restrictedlist.contains(i)){\n        ans=ans:+'.'\n        ans=ans:+i.toLower\n      }\n    }\n    return String.valueOf(ans)\n  }\n\n  val s:String=scala.io.StdIn.readLine\n  println(WordConvert(s))\n\n}\n"}, {"source_code": "import scala.io.StdIn\n\nobject H {\n  def main(args: Array[String]): Unit = {\n//    var Array(n) = StdIn.readLine().split(\" \").map(_.toInt)\n\n    val pp = (s: Char) => {\n      if (s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u' || s == 'y') {\n\n      }\n      else {\n        print('.')\n        print(s)\n      }\n    }\n\n    var s = StdIn.readLine()\n    for (c <- s.toLowerCase().toCharArray)\n      pp(c)\n  }\n}\n"}, {"source_code": "import java.io._\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def main(args: Array[String]) {\n    println(reader.readLine().toLowerCase().filterNot(c => \"aeiuyo\".contains(c)).map(\".\" + _).mkString)\n  }\n}\n"}, {"source_code": "/**\n * Created by vol on 9/16/14.\n */\nobject A118 extends App{\n  val vowels = List('A', 'O', 'Y', 'E', 'U', 'I')\n  val str:String = readLine()\n  val noVowels = str.filter((e:Char) =>  !vowels.contains(e.toUpper))\n\n\n  println(noVowels.map((e:Char) => \".\" + e.toLower).mkString)\n\n\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val str = readLine()\n    val replaced = str.toLowerCase.replaceAll(\"[aoyeui]\", \"\").replaceAll(\"([^aoyeiu])\", \".$1\")\n    println(replaced)\n  }\n}"}, {"source_code": "object _118A extends App {\n  def is_vowel(c: Char): Boolean =\n    c == 'a' || c == 'o' || c == 'y' || c == 'e' || c == 'u' || c == 'i'\n\n  val string = readLine()\n  println(\n    string.map(c => c.toLower).\n      filterNot(c => is_vowel(c)).\n      foldLeft(\"\")((accm, c) => accm + '.' + c))\n}\n\n\n\n"}, {"source_code": "object _118A_StringTask extends App {\n  import scala.io.StdIn._\n\n  val s = readLine()\n\n  def solve = {\n    s filterNot { c =>\n      Array('a', 'o', 'y', 'e', 'u', 'i').contains(c.toLower)\n    } flatMap { c =>\n      \".\" + c.toLower.toString\n    }\n  }\n\n  println(solve)\n\n}\n"}, {"source_code": "object Main extends App{\n    var t = readLine().toLowerCase().replaceAll(\"[aeyuio]\",\"\")\n    t.foreach( (c) => print(\".\" + c ) )\n} "}, {"source_code": "object Main extends App{\n    \n    var t = readLine().toLowerCase().replaceAll(\"[aeyuio]\",\"\")\n    t.foreach( (c) => print(\".\" + c ) )\n    \n} "}, {"source_code": "object JuanDavidRobles {\n  def main(args: Array[String]): Unit = {\n\n    import scala.io.StdIn\n\n    var line : String = StdIn.readLine()\n\n    var string : String = \"\"\n\n    var char : Char = 'a'\n\n    for (i <- 0 until line.length){\n      char = line.charAt(i)\n      if (!char.equals('a') && !char.equals('e') &&\n        !char.equals('i') && !char.equals('o') &&\n        !char.equals('u') && !char.equals('y') &&\n        !char.equals('A') && !char.equals('E') &&\n        !char.equals('I') && !char.equals('O') &&\n        !char.equals('U') && !char.equals('Y')){\n\n        if (char.toInt >= 65 && char <= 90){\n          char = (char.toInt+32).toChar\n        }\n        string = string + \".\" + char.toString\n      }\n    }\n    println(string)\n  }\n}\n"}, {"source_code": "import scala.io.StdIn\n\nobject Main {\n\n  val vowels = Array('A', 'I', 'U', 'E', 'O', 'Y')\n\n  def isVowel(char: Char) : Boolean =  {\n    vowels contains char\n  }\n\n  def main(args: Array[String]): Unit = {\n    val s = StdIn.readLine()\n\n    println(s.map(_.toUpper).filter(!isVowel(_)).map(\".\"+ _.toLower).mkString)\n  }\n}\n"}, {"source_code": "import scala.io.StdIn.readLine\n\n\nobject StringTask {\n  \n  def main(args: Array[String]) {\n    val line = readLine\n    println(line.toLowerCase()\n        .filterNot { List('a','o','y','e','u','i').contains(_) }\n        .flatMap { x => \".\" + x }\n    )\n        \n  }\n  \n}"}, {"source_code": "object Main extends App {\nval vovels = List('a', 'i', 'u', 'e', 'o', 'y')\nval s = readLine()\nval res = s.toLowerCase.filter(!vovels.contains(_)).flatMap(x=>\".\" + x)\nprintln(res)\n}"}, {"source_code": "object Main extends App {\n  val help =List('a','e','o','u','i','y')\n  println(readLine().toLowerCase.filterNot(help.contains).mkString(\".\",\".\",\"\"))\n}"}, {"source_code": "object Main extends App {\n  val vowels = List('A', 'O', 'Y', 'E', 'U', 'I') ++ List('a', 'o', 'y', 'e', 'u', 'i')\n  def isVowel(c: Char): Boolean = vowels exists { _ == c }\n  def isConsonant(c: Char): Boolean = !isVowel(c)\n  def insertDot(c: Char): String = \".\"+ c\n  def solve(s: String): String = s filterNot isVowel flatMap insertDot toLowerCase\n\n  println(solve(readLine()))\n}\n"}, {"source_code": "object StringTask {\n  val vowels = Array('a', 'e', 'i', 'o', 'u', 'y')\n\n  def main(args: Array[String]) {\n    val sb = new StringBuilder\n\n    Console.readLine.foreach { ch =>\n      val lower = ch.toLower\n      if (!vowels.contains(lower)) {\n        sb.append(\".\").append(lower)\n      }\n    }\n\n    println(sb.toString)\n  }\n}\n"}, {"source_code": "object test\n{\n    def main(args : Array[String])\n    {\n        print(readLine.toLowerCase.replaceAll(\"[aeiouy]\",\"\").map(\".\"+_).mkString)\n    }\n}\n"}, {"source_code": "object Main {\n\n  def main(args: Array[String]): Unit = {\n    println(readLine().map(_.toUpperCase).filter(!\"AOYEUI\".contains(_)).map(\".\"+_.toLowerCase).reduce(_+_))\n  }\n\n}"}, {"source_code": "object test {\n\tdef main(args: Array[String]){\n\t\tprint(readLine.toLowerCase.replaceAll(\"[aeiouy]\",\"\").map(\".\"+_).mkString)\n\t}\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject StringTask_118A extends App{\n\tval str = readLine\n\tval vowels = Set('a', 'e', 'i', 'o', 'u', 'y')\n\t\n\tprintln(str.map(_.toLower).filter(!vowels.contains(_)).flatMap(\".\" + _))\n}"}, {"source_code": "object StringTask {\n  import io.StdIn.{readLine => rl}\n  def rnum() = rl().split(\" \").map(_.toLong)\n  def main(args : Array[String]) {\n    val iscons = (c:Char) => !\"aoyeui\".contains(c)\n    println (rl.toLowerCase.filter(iscons).fold(\"\")((h,t) => h + \".\" + t))\n  }\n}\n"}, {"source_code": "object main extends App{\n    var s = readLine.toLowerCase().replaceAll(\"[aeyuio]\",\"\")\n    s.foreach((c) => print(\".\" + c))\n}"}, {"source_code": "import java.util.Scanner\n\nobject A00118 extends App {\n  println(Console.readLine().filterNot(\"aeiouyAEIOUY\".contains(_)).map(x => \".\" + x).map(x => x.toLowerCase()).mkString)\n}\n"}], "negative_code": [{"source_code": "import scala.io.StdIn\n\nobject Main {\n\n  val vowels = Array('A', 'I', 'U', 'E', 'O', 'I')\n\n  def isVowel(char: Char) : Boolean =  {\n    vowels contains char\n  }\n\n  def main(args: Array[String]): Unit = {\n    val s = StdIn.readLine()\n\n    println(s.map(_.toUpper).filter(!isVowel(_)).map(\".\"+ _.toLower).mkString)\n  }\n}\n"}, {"source_code": "object Main extends App {\n  val vowels = List('A', 'O', 'Y', 'E', 'U', 'I') ++ List('a', 'o', 'y', 'e', 'u', 'i')\n  def isVowel(c: Char): Boolean = vowels exists { _ == c }\n  def isConsonant(c: Char): Boolean = !isVowel(c)\n  def insertDot(c: Char): String = \".\"+ c\n  def solve(s: String): String = s filterNot isVowel flatMap insertDot toLowerCase\n\n  assert(solve(\"tour\") == \".t.r\")\n  assert(solve(\"Codeforces\") == \".c.d.f.r.c.s\")\n  assert(solve(\"aBAcAba\") == \".b.c.b\")\n}\n"}, {"source_code": "object StringTask {\n  val vowels = Array('a', 'e', 'i', 'o', 'u')\n\n  def main(args: Array[String]) {\n    val sb = new StringBuilder\n\n    Console.readLine.foreach { ch =>\n      val lower = ch.toLower\n      if (!vowels.contains(lower)) {\n        sb.append(\".\").append(lower)\n      }\n    }\n\n    println(sb.toString)\n  }\n}\n"}, {"source_code": "object test\n{\n    def main(args : Array[String])\n    {\n        print(readLine.toLowerCase.replaceAll(\"[aeiou]\",\"\").map(\".\"+_).mkString)\n    }\n}\n"}, {"source_code": "object A00118 extends App {\n  println(Console.readLine().filterNot(\"aeiouAEIOU\".contains(_)).map(x => \".\" + x).map(x => x.toLowerCase()).mkString)\n}\n"}, {"source_code": "/*input\nTata\n*/\n\nimport java.util.Scanner\nimport scala.io.StdIn\n\nobject Solution {\n\tdef main(args: Array[String]): Unit = {\n\n\t\tval str = StdIn.readLine().map(_.toLower);\n\t\tstr.foreach((x: Char) => {\n\t\t\tif(!(\"aeiou\".contains(x))) {\n\t\t\t\tprint('.');\n\t\t\t\tprint(x);\n\t\t\t}\n\t\t})\n\n\t}\n\n}"}, {"source_code": "object CF118A extends App {\n    import scala.io.StdIn.readLine\n    import scala.collection.immutable.HashSet\n    val s = readLine.toLowerCase.toCharArray\n    val vowels:HashSet[Char] = HashSet('a','e','i','o','u')\n    s.filter(!vowels(_)).foreach(x => print(\".\"+x.toString))\n}\n"}, {"source_code": "object StringTask extends App {\n\n\tval vowels = List(\"a\", \"o\", \"y\", \"e\", \"u\", \"i\")\n\tval input = scala.io.StdIn.readLine().toLowerCase()\n\n\tval output = input.foreach(x =>\n\t\tif (vowels.contains(x)) input.replaceAll(x.toString(), \"\")\n\t\telse input.replaceAll(x.toString(), s\"\\\\.$x\")\n\t)\n\n\tprintln(output)\n\n}"}, {"source_code": "object StringTask extends App {\n\n\t\n\tval input = scala.io.StdIn.readLine().toLowerCase()\n\n    val noVowel = input.replaceAll(\"([aeiou])+\", \"\")\n    val output = noVowel.map(x => s\".$x\").mkString\n    \n\tprintln(output)\n\n}"}, {"source_code": "object Main extends App {\n  val inputString = readLine.toList\n\n  def replaceLiterals(list: List[Char]): List[Char] = list match {\n    case List() => List()\n    case e :: rest => \n      e match {\n        case 'a' | 'e' | 'i' | 'o' | 'u' | 'A' | 'E' | 'I' | 'O' | 'U' => replaceLiterals(rest)\n        case _ => '.' :: e.toLower :: replaceLiterals(rest)\n      }      \n  }\n\n  println(replaceLiterals(inputString).mkString)\n}\n"}, {"source_code": "object Main extends App {\n  val inputString = readLine.toList\n\n  def replaceLiterals(list: List[Char]): List[Char] = list match {\n    case List() => List()\n    case e :: rest => \n      e match {\n        case 'a' | 'e' | 'i' | 'o' | 'u' | 'A' | 'E' | 'I' | 'O' | 'U' => '.' :: replaceLiterals(rest)\n        case _ => e.toLower :: replaceLiterals(rest)\n      }      \n  }\n\n  println(replaceLiterals(inputString).mkString)\n}\n"}, {"source_code": "object CF0118A extends App {\n\n  val gl = List(\"a\", \"o\", \"y\", \"e\", \"u\", \"i\")\n\n  val str = readLine()\n\n  var result = new StringBuilder\n\n  for (ch <- str) {\n    if (!(gl contains(ch.toString))) {\n      result ++= \".\" + ch.toString.toLowerCase\n    }\n  }\n\n  println(result)\n\n}\n"}, {"source_code": "object HelloWorld {\n  def main(args: Array[String]): Unit = {\n  \tvar s = readLine()\n  \ts = s.replaceAll( \"[eyuioa]\", \"\") \n  \tvar str = \"\"\n  \tfor(i <-0 until s.length())\n  \t\tstr = str + \".\" + s(i)\n  \tstr = str.map(c => c.toLower)\n  \tprintln(str)\n  }\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject task1 {\n  def main(args: Array[String]): Unit = {\n    val input = readLine()\n    val letters = List('A', 'O', 'Y', 'E', 'U', 'I').map(_.toLower)\n    val result = input.filterNot(el2 => letters.contains(el2)).map{ el =>\n      s\".$el\"\n    }.mkString(\"\").toLowerCase\n    println(result)\n  }\n\n}\n"}, {"source_code": "object cf extends App{\n  val vowels = Set('a', 'e', 'i', 'o', 'u', 'y')\n  var s = readLine().toLowerCase()\n  var res = \"\"\n  for (i <- 0 to s.length()-1) {\n    if (!vowels(s(i))) {\n      res += \".\" + s(i)\n    }\n  }\n}"}, {"source_code": "object Solution {\n    val vowels = Array(\"A\", \"O\", \"Y\", \"E\", \"U\", \"I\") map (_ charAt 0)\n    def isVowel(c: Char) = vowels contains (Character.toUpperCase(c))\n    def consonants(chars: Seq[Char]) = chars filter isVowel\n    def withDots(chars: Seq[Char]) = chars flatMap (c => List('.', c))\n    def solve(line: String) = withDots (consonants (line toLowerCase)) mkString\n    def main(args: Array[String]) = println(solve(readLine))\n}"}, {"source_code": "object Solution extends App {\n  val vowel = List('a', 'e', 'o', 'u', 'i')\n  println(readLine().toLowerCase.filterNot(vowel.contains).mkString(\".\"))\n}"}, {"source_code": "object Solution extends App {\n  val vowel = List('a', 'e', 'o', 'u', 'i')\n  println(readLine().toLowerCase.filterNot(vowel.contains).mkString(\".\", \".\", \"\"))\n}"}, {"source_code": "object Main {\n\timport java.{util=>ju}\n\timport scala.annotation._\n\timport scala.collection._\n\timport scala.collection.{mutable => mu}\n\timport scala.collection.JavaConverters._\n\timport scala.math._\n\n\tdef main(args:Array[String])\n\t{\n\t\tval sc = new ju.Scanner(System.in)\n\t\tval input = sc.next();\n\n\t\tinput.map{\n\t\t\tcase n if n == 'A' => \"\"\n\t\t\tcase n if n == 'O' => \"\"\n\t\t\tcase n if n == 'Y' => \"\"\n\t\t\tcase n if n == 'E' => \"\"\n\t\t\tcase n if n == 'I' => \"\"\n\t\t\tcase n if n == 'a' => \"\"\n\t\t\tcase n if n == 'o' => \"\"\n\t\t\tcase n if n == 'y' => \"\"\n\t\t\tcase n if n == 'e' => \"\"\n\t\t\tcase n if n == 'u' => \"\"\n\t\t\tcase n if n == 'i' => \"\"\n\t\t\tcase n if n.isLowerCase => \".\"+n\n\t\t\tcase n if n.isUpperCase => \".\"+n.toLowerCase\n\t\t\tcase n => n\n\t\t}.foreach{\n\t\t\tprint(_)\n\t\t}\n\n\n\t}\n}\n"}, {"source_code": "import scala.io.StdIn\nobject solution extends App{\n    \n   val text = StdIn.readLine\n   val vowels = \"aeiouy\"\n   \n   \n   text.foldLeft(\"\")((a,b) => {\n        val lower = b.toString.toLowerCase\n        if(vowels.contains(lower)) a\n        else a +\".\"+ b\n   } )\n    \n}"}, {"source_code": "import scala.io.StdIn\nobject solution extends App{\n    \n   val text = StdIn.readLine\n   val vowels = \"aeiouy\"\n   \n   \n   text.foldLeft(\"\")((a,b) => {\n        val lower = b.toString.toLowerCase\n        if(vowels.contains(lower)) a+\"\"\n        else a +\".\"+ b\n   } )\n    \n}"}, {"source_code": "import scala.io.StdIn\nobject solution extends App{\n    \n   val text = StdIn.readLine\n   val vowels = \"aeiou\"\n   \n   \n   text.foldLeft(\"\")((a,b) => {\n        val lower = b.toString.toLowerCase\n        if(vowels.contains(lower)) a+\"\"\n        else a +\".\"+ b\n   } )\n    \n}"}, {"source_code": "import scala.io.StdIn\nobject solution extends App{\n    \n   val text = StdIn.readLine\n   val vowels = \"aeiouy\"\n   \n   \n  val output =  text.foldLeft(\"\")((a,b) => {\n        val lower = b.toString.toLowerCase\n        if(vowels.contains(lower)) a+\"\"\n        else a +\".\"+ b\n   } )\n   \n   println(output)\n    \n}"}, {"source_code": "import scala.io.StdIn\nobject solution extends App{\n    \n   val text = StdIn.readLine\n   val vowels = \"aeiouy\"\n   \n   \n   text.foldLeft(\"\")((a,b) => {\n        val lower = b.toString.toLowerCase\n        if(vowels.contains(lower)) a+\"\"\n        else a +\".\"+ lower\n   } )\n    \n}"}, {"source_code": "import scala.io.StdIn._\n\nobject ScalaTest{\n  def main(args: Array[String]): Unit = {\n\n    val list = List('a','e','i','o','u')\n    val input = readLine().toLowerCase.filterNot{ch =>\n        list.contains(ch)\n    }.mkString(\".\")\n    println(\".\" + input)\n  }\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject ScalaTest{\n  def main(args: Array[String]): Unit = {\n\n    val list = List('A','a','E','e','I','i','O','o','U','u')\n    val input = readLine().filterNot{ch =>\n      list.contains(ch)\n    }.mkString(\".\")\n    println(\".\" + input)\n  }\n}"}, {"source_code": "import scala.io.StdIn\n\nobject H {\n  def main(args: Array[String]): Unit = {\n//    var Array(n) = StdIn.readLine().split(\" \").map(_.toInt)\n\n    val pp = (s: Char) => {\n      if (s == 'a' || s == 'e' || s == 'i' || s == 'o' || s == 'u') {\n\n      }\n      else {\n        print('.')\n        print(s)\n      }\n    }\n\n    var s = StdIn.readLine()\n    for (c <- s.toLowerCase().toCharArray)\n      pp(c)\n  }\n}\n"}], "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b"}
{"source_code": "import io.StdIn._\nimport scala.collection.mutable._\n\nobject Solution extends App {\n  val nks = readLine().split(\" \")\n  val nk = nks.map(_.toInt)\n  val TempArr = Array( 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ) \n  \n  val a = nk(0)\n  val b = nk(1)\n  var ans = 0\n  \n  for ( i <- a to b ) {\n  \n    var temp = i\n    \n    while ( temp != 0 ) {\n      ans = ans + TempArr( temp % 10 ) \n      temp = temp / 10\n    }\n  \n  }\n  \n  \n  \n  println ( ans ) \n  \n  \n}", "positive_code": [{"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val map = Map('0' -> 6, '1' -> 2, '2' -> 5, '3' -> 5, '4' -> 4, '5' -> 5, '6' -> 6, '7' -> 3, '8' -> 7, '9' -> 6)\n\n  val in = Source.stdin.getLines()\n  val Array(a, b) = in.next().split(' ').map(_.toInt)\n  println((a to b).foldLeft(0l) {\n    case (acc, i) => acc + i.toString.map(map).sum\n  })\n}"}, {"source_code": "import io.StdIn._\nimport scala.collection.mutable._\n\nobject Solution {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  @inline def segments(a: Int): Int = {\n    val s = Array(6, 2, 5, 5, 4, 5, 6, 3, 7, 6)\n    var n = a\n    var res = 0\n    while (n > 0) {\n      res += s(n%10)\n      n /= 10\n    }\n    res\n  }\n  def main(args: Array[String]) {\n    val Array(a, b) = readInts(2)\n\n    println((a to b).foldLeft(0)( _ + segments(_)))\n\n\n//    Console.withOut(new java.io.BufferedOutputStream(Console.out))\n//    println(res.mkString(\"\\n\"))\n//    Console.flush\n  }\n}"}, {"source_code": "import scala.math._\nimport scala.Console\nobject Object {\n \n  def main(args : Array[String]){\n    \n    val Array(a, b) = readLine.split(\" \").map{_.toInt }\n    var tl = 0\n    \n    for(i <- a to b){\n     val li = i.toString.map(_.asDigit)\n     li.map { i => i match{\n        case 1 => tl += 2\n        case 2|3|5 => tl += 5\n        case 6|9|0 => tl += 6\n        case 4 => tl += 4\n        case 7 => tl += 3\n        case 8 => tl += 7\n        }\n     }\n    }\n    println(tl)\n  }\n}"}], "negative_code": [{"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val map = Map('0' -> 6, '1' -> 2, '2' -> 5, '3' -> 5, '4' -> 4, '5' -> 5, '6' -> 6, '7' -> 3, '8' -> 7, '9' -> 6)\n\n  val in = Source.stdin.getLines()\n  val Array(a, b) = in.next().split(' ').map(_.toInt)\n  (a to b).foldLeft(0l) {\n    case (acc, i) => acc + i.toString.map(map).sum\n  }\n}"}], "src_uid": "1193de6f80a9feee8522a404d16425b9"}
{"source_code": "object B450 {\n\n  import IO._\n  import collection.{mutable => cu}\n  val MOD = 1000000007L\n  def main(args: Array[String]): Unit = {\n    val Array(x, y) = readLongs(2)\n    val a = Array(x, y, y-x,-x,-y,x-y).map(x => (x + 2*MOD)% MOD)\n    val Array(n) = readInts(1)\n    println(a((n-1)%6))\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n", "positive_code": [{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val Array(x, y) = in.next().split(\" \").map(_.toInt)\n  val mod = 1000000007\n  val n = (in.next().toInt - 1) % 6\n  val k = n % 3\n  val res = k match {\n    case 0 => x\n    case 1 => y\n    case 2 => y - x\n  }\n\n  if (n < 3) println((res % mod + mod) % mod) else {\n    println((-res % mod + mod) % mod)\n  }\n}"}, {"source_code": "import java.util.Scanner\n\n/**\n * Created by kshim on 25/07/2014.\n */\nobject CF257B extends App {\n  def Process(x:Long, y:Long, n:Long):Long = {\n    val fn:Long = (n-1) % 6 match {\n      case 0 => x\n      case 1 => y\n      case 2 => y - x\n      case 3 => -x\n      case 4 => -y\n      case 5 => -y + x\n    }\n    val r = fn % (1000000000L + 7L)\n    if(r < 0) {\n      r + (1000000000L + 7L)\n    } else {\n      r\n    }\n  }\n  val in = new Scanner(System.in)\n  val x = in.nextInt()\n  val y = in.nextInt()\n  val n = in.nextInt()\n  println(Process(x, y, n))\n}\n"}, {"source_code": "object Sequences {\n\n  def splitter(as: String) = as.split(\"\\\\s+\") match {\n    case Array(n, m) => List(n.toLong, m.toLong)\n  }\n\n  def solve(x: Long, y: Long, n: Long): Long = (n % 6) match {\n    case 1 => x\n    case 2 => y\n    case 3 => y-x\n    case 4 => -x\n    case 5 => -y\n    case 0 => x-y\n  }\n\n  def main(args: Array[String]) {\n    val N = 1e9.toLong + 7\n    val List(xyStr, nStr) = io.Source.stdin.getLines.take(2).toList\n    val List(x, y) = splitter(xyStr)\n    val n = nStr.toLong\n    val f = solve(x, y, n)\n    val fModN = f % N\n    val res: Long = if (fModN>=0) fModN else fModN + N\n    println(res)\n  }\n}\n\n"}, {"source_code": "/**\n * @author Oleg Arshinsky\n */\nobject B extends App {{\n\n  val Array(x, y) = readLine().split(\" \").map(_.toInt)\n  val n = readLine().toInt\n\n  def _1 = x\n  def _2 = y\n  def _3 = y-x\n  def _4 = -x\n  def _5 = -y\n  def _6 = x-y\n\n  val functions = Array(_1, _2, _3, _4, _5, _6)\n\n  val intermediate = n % 6\n\n  val function_n = if (intermediate == 0) 6-1 else intermediate-1\n\n  val f_n = functions(function_n)\n\n  val a = f_n\n  val b = 1000000007\n\n  println((a - (a.toDouble/b).floor * b).toInt)\n\n\n\n}}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]): Unit = {\n    val N = 1000000007\n    val halfN = 500000003\n    val xy = io.StdIn.readLine().split(\" \").map { s =>\n      val i = Integer.parseInt(s)\n      if (i < 0 ) i + N else i\n    }\n    val n = (io.StdIn.readInt() -1) % 6\n    def compute(k: Int): Long = {\n      if (k > 2) -1 * compute(k - 3)\n      else if (k ==2) xy(1) - xy(0)\n      else xy(k)\n    }\n    val fn = compute(n) % N\n    println(if (fn < 0) fn + N else fn)\n  }\n}"}, {"source_code": "import scala.math.BigInt\n\nobject Main extends App {\n  val sc = new java.util.Scanner(System.in)\n  val x, y, n = sc.nextInt\n\n  def solve( x: Int, y: Int, n: Int ): Int = {\n    val M: Int = 1e9.toInt + 7\n\n    val newN = (n-1) % 6\n\n    def tail(a: BigInt, b: BigInt): Stream[BigInt] = a #:: tail(b, b - a)\n    val res = tail(x, y)(newN)\n    ( ( ( res % M ) + M ) mod M ).toInt\n  }\n\n  println( solve( x, y, n ) )\n}\n"}, {"source_code": "import scala.math.BigInt\n\nobject Main extends App {\n  val sc = new java.util.Scanner(System.in)\n  val x, y, n = sc.nextInt\n\n  def solve2( x: Int, y: Int, n: Int ): Int = {\n    val M: Int = 1e9.toInt + 7\n\n    val newN = (n-1) % 6\n\n    def tail(a: BigInt, b: BigInt): Stream[BigInt] = a #:: tail(b, b - a)\n    val res = tail(x, y)(newN)\n    ( ( ( res % M ) + M ) mod M ).toInt\n  }\n\n  def solve( x: Int, y: Int, n: Int ): Int = {\n    val M: Int = 1e9.toInt + 7\n\n    val newN = (n-1) % 6\n\n    var memo = new Array[Int](6)\n    memo(0) = x\n    memo(1) = y\n    for( i <- (2 until 6) ) {\n      memo(i) = ( memo(i-1) - memo(i-2) ) % M\n    }\n\n    ( ( memo(newN) % M ) + M ) % M\n  }\n\n  println( solve( x, y, n ) )\n}\n"}, {"source_code": "object HelloWorld{\n  def computeSeq(x: Int, y:Int, l:Int):List[Int] = l match {\n    case 0 => List()\n    case _ => (y-x)::computeSeq(y, y-x, l-1)\n  }\n  def main(args: Array[String]){\n    val in = new java.util.Scanner(System.in)\n    val x = in.nextInt\n    val y = in.nextInt\n    val n = in.nextInt-1\n    val seq = x::y::computeSeq(x, y, 4)\n    println(floorMod(1000*1000*1000+7)(seq(n%6)))\n  }\n  def floorMod(m: Int)(n: Int) = (((n % m) + m) % m)\n}"}, {"source_code": "\n\nimport java.io.PrintWriter\nimport java.util.Scanner\n\n/**\n * Created by arseny on 19.07.14.\n */\nobject B extends App {\n  val home = true\n  val in = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  def nextInt = in.nextInt\n  def nextLong = in.nextLong\n  def nextDouble = in.nextDouble\n  def nextString = in.next\n\n  def solve() = {\n    val x = nextLong\n    val y = nextLong\n    val p: Long = 1000 * 1000 * 1000 + 7\n    val n = nextLong % 6\n    val ans: Long = n match {\n      case 0 => x - y\n      case 1 => x\n      case 2 => y\n      case 3 => y - x\n      case 4 => -x\n      case 5 => - y\n    }\n    out.println((ans + 3 * p) % p)\n  }\n\n  try {\n    solve()\n  } catch {\n    case _: Exception => sys.exit(9999)\n  } finally {\n    out.flush()\n    out.close()\n  }\n}\n"}], "negative_code": [{"source_code": "import java.util.Scanner\n\n/**\n * Created by kshim on 25/07/2014.\n */\nobject CF257B extends App {\n  def Process(x:Long, y:Long, n:Long):Long = {\n    val fn:Long = (n-1) % 6 match {\n      case 0 => x\n      case 1 => y\n      case 2 => y - x\n      case 3 => -x\n      case 4 => -y\n      case 5 => -y + x\n    }\n    if(fn < 0) {\n      (fn % (1000000000L + 7L)) + (1000000000L + 7L)\n    } else {\n      fn % (1000000000L + 7L)\n    }\n  }\n  val in = new Scanner(System.in)\n  val x = in.nextInt()\n  val y = in.nextInt()\n  val n = in.nextInt()\n  println(Process(x, y, n))\n}\n"}, {"source_code": "object B450 {\n\n  import IO._\n  import collection.{mutable => cu}\n  val MOD = 100000007L\n  def main(args: Array[String]): Unit = {\n    val Array(x, y) = readLongs(2)\n    val a = Array(x, y, y-x,-x,-y,x-y).map(x => (x + 2*MOD)% MOD)\n    val Array(n) = readInts(1)\n    println(a((n-1)%6))\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "object Sequences {\n\n  def splitter(as: String) = as.split(\"\\\\s+\") match {\n    case Array(n, m) => List(n.toLong, m.toLong)\n  }\n\n  def solve(x: Long, y: Long, n: Long): Long = (n % 6) match {\n    case 1 => x\n    case 2 => y\n    case 3 => y-x\n    case 4 => -x\n    case 5 => -y\n    case 0 => x-y\n  }\n\n  def main(args: Array[String]) {\n    val N = 1e9.toLong + 7\n    val List(xyStr, nStr) = io.Source.stdin.getLines.take(2).toList\n    val List(x, y) = splitter(xyStr)\n    val n = nStr.toLong\n    val f = solve(x, y, n)\n    val res: Long = if (f>=0) f % N else (f + N) % N\n    println(res)\n  }\n}\n\n"}, {"source_code": "object Sequences {\n\n  def splitter(as: String) = as.split(\"\\\\s+\") match {\n    case Array(n, m) => List(n.toLong, m.toLong)\n  }\n\n  def solve(x: Long, y: Long, n: Long): Long = (n % 6) match {\n    case 1 => x\n    case 2 => y\n    case 3 => y-x\n    case 4 => -x\n    case 5 => -y\n    case 0 => x-y\n  }\n\n  def main(args: Array[String]) {\n    val N = 1e9.toLong + 7\n    val List(xyStr, nStr) = io.Source.stdin.getLines.take(2).toList\n    val List(x, y) = splitter(xyStr)\n    val n = nStr.toLong\n    val f = solve(x, y, n)\n    val res: Long = if (f>=0) f % N else (f % N) + N\n    println(res)\n  }\n}\n\n"}, {"source_code": "object Main {\n  def main(args: Array[String]): Unit = {\n    val N = 1000000007\n    val halfN = 500000003\n    val xy = io.StdIn.readLine().split(\" \").map { s =>\n      val i = Integer.parseInt(s)\n      if (i > halfN) i - N else i\n    }\n    val n = (io.StdIn.readInt() -1) % 6\n    def compute(k: Int): Long = {\n      if (k > 2) -1 * compute(5 - k)\n      else if (k == 0) xy(0)\n      else if (k == 1) xy(1)\n      else xy(1) - xy(0)\n    }\n    val fn = compute(n) % N\n    println(if (fn < 0) fn + N else fn)\n  }\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]): Unit = {\n    val N = 1000000007\n    val halfN = 500000003\n    val xy = io.StdIn.readLine().split(\" \").map { s =>\n      val i = Integer.parseInt(s)\n      if (i > halfN) i - N else i\n    }\n    val n = io.StdIn.readLong()\n    val fn = (xy(1) - ((n - 2) % N) * xy(0)) % N\n    println(if (fn < 0) fn + N else fn)\n  }\n}"}, {"source_code": "import scala.math.BigInt\n\nobject Main extends App {\n  val sc = new java.util.Scanner(System.in)\n  val x, y, n = sc.nextInt\n\n  def solve( x: Int, y: Int, n: Int ): Int = {\n    val M: Int = 1e9.toInt + 7\n\n    val newN = (n-1) % 6\n\n    def tail(a: BigInt, b: BigInt): Stream[BigInt] = a #:: tail(b, b - a)\n    val res = tail(x, y)(newN-1)\n    ( ( ( res % M ) + M ) mod M ).toInt\n  }\n\n  println( solve( x, y, n ) )\n}\n"}, {"source_code": "import scala.math.BigInt\n\nobject Main extends App {\n  val sc = new java.util.Scanner(System.in)\n  val x, y, n = sc.nextInt\n\n  def solve( x: Int, y: Int, n: Int ): Int = {\n    val M: Int = 1e9.toInt + 7\n\n    val newN = (n-1) % 6\n\n    def tail(a: BigInt, b: BigInt): Stream[BigInt] = a #:: tail(b, b - a)\n    val res = tail(x, y)(newN)\n    ( ( ( res % M ) + M ) mod M ).toInt\n  }\n\n  def solve2( x: Int, y: Int, n: Int ): Int = {\n    val M: Int = 1e9.toInt + 7\n\n    val newN = (n-1) % 6\n\n    var memo = new Array[Int](6)\n    memo(0) = x\n    memo(1) = y\n    for( i <- (2 until 6) ) {\n      memo(i) = ( ( ( memo(i-1) + memo(i-2) ) % M ) + M ) % M\n    }\n\n    memo(newN)\n  }\n\n  println( solve2( x, y, n ) )\n}\n"}, {"source_code": "import scala.math.BigInt\n\nobject Main extends App {\n  val sc = new java.util.Scanner(System.in)\n  val x, y, n = sc.nextInt\n\n  def solve( x: Int, y: Int, n: Int ): Int = {\n    val M: Int = 1e9.toInt + 7\n\n    val newN = (n-1) % 6\n\n    def tail(a: BigInt, b: BigInt): Stream[BigInt] = a #:: tail(b, b - a)\n    val res = tail(x, y)(newN)\n    ( ( ( res % M ) + M ) mod M ).toInt\n  }\n\n  def solve2( x: Int, y: Int, n: Int ): Int = {\n    val M: Int = 1e9.toInt + 7\n\n    val newN = (n-1) % 6\n\n    var memo = new Array[Int](6)\n    memo(0) = x\n    memo(1) = y\n    for( i <- (2 until 6) ) {\n      memo(i) = ( ( ( memo(i-1) - memo(i-2) ) % M ) + M ) % M\n    }\n\n    memo(newN)\n  }\n\n  println( solve2( x, y, n ) )\n}\n"}], "src_uid": "2ff85140e3f19c90e587ce459d64338b"}
{"source_code": "import java.util._\nimport java.lang._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return Long.parseLong(next)\n  }\n\n  def solve = {\n    val y = nextInt\n    val w = nextInt\n    val x = 6 - Math.max(y, w) + 1\n    if (x % 6 == 0) {\n      out.println(x / 6 + \"/\" + 1)\n    } else if (x % 3 == 0) {\n      out.println(x / 3 + \"/\" + 2)\n    } else if (x % 2 == 0) {\n      out.println(x / 2 + \"/\" + 3)\n    } else {\n      out.println(x + \"/\" + 6)\n    }\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}", "positive_code": [{"source_code": "//package me.jetblack.cf\n\nimport java.util.Scanner\n\nobject DiceRoll extends App {\n\n  val s = new Scanner(System.in)\n\n  val y = s.nextInt()\n  val w = s.nextInt()\n\n  val t = 6 - (math.max(y, w) - 1)\n  if (t == 4) {\n    println(\"2/3\")\n  } else if (t == 3) {\n    println(\"1/2\")\n  } else if (t == 2) {\n    println(\"1/3\")\n  } else if (t == 6) {\n    println(\"1/1\")\n  } else {\n    println(s\"$t/6\")\n  }\n\n}"}, {"source_code": "import scala.io._\nimport scala.collection.mutable._\nimport java.util.StringTokenizer\n\nobject HelloWorld {\n\n  def main(args: Array[String]): Unit = {\n    var Array(y, w) = readLine.split(\" \").map(_.toInt);\n    var max = math.max(y, w);\n    if (max == 1) {\n      println(\"1/1\");\n    } else if (max == 2) {\n      println(\"5/6\");\n    } else if (max == 3) {\n      println(\"2/3\");\n    } else if (max == 4) {\n      println(\"1/2\");\n    } else if (max == 5) {\n      println(\"1/3\");\n    } else {\n      println(\"1/6\");\n    }\n  }\n\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val max = readLine.split(\" \").map(_.toInt).max\n    max match {\n      case 1 => println(\"1/1\")\n      case 2 => println(\"5/6\")\n      case 3 => println(\"2/3\")\n      case 4 => println(\"1/2\")\n      case 5 => println(\"1/3\")\n      case 6 => println(\"1/6\")\n      case _ => // to make scalac happy\n    }\n  }\n}"}, {"source_code": "object P9A {\n    import io.StdIn._\n\n    def main(args:Array[String]) {\n        println(readLine.split(' ').map{_.toInt}.max match {\n            case 1 => \"1/1\"\n            case 2 => \"5/6\"\n            case 3 => \"2/3\"\n            case 4 => \"1/2\"\n            case 5 => \"1/3\"\n            case 6 => \"1/6\"\n        })\n    }\n}\n"}, {"source_code": "//package me.jetblack.cf\n\nimport java.util.Scanner\n\nobject DiceRoll extends App {\n\n  val s = new Scanner(System.in)\n\n  val y = s.nextInt()\n  val w = s.nextInt()\n\n  val t = 6 - (math.max(y, w) - 1)\n  if (t == 4) {\n    println(\"2/3\")\n  } else if (t == 3) {\n    println(\"1/2\")\n  } else if (t == 2) {\n    println(\"1/3\")\n  } else if (t == 6) {\n    println(\"1/1\")\n  } else {\n    println(s\"$t/6\")\n  }\n\n}"}, {"source_code": "object dieroll extends App {\n  val Array(a, b) = readLine split ' ' map (_.toInt)\n\n  @scala.annotation.tailrec def gcd(a: Int, b: Int): Int = b match {\n    case 0 => a\n    case _ => gcd(b, a % b)\n  }\n\n  val total = 7 - math.max(a, b)\n  val g = gcd(total, 6)\n\n  println(s\"${total/g}/${6/g}\")\n}\n"}, {"source_code": "import java.util.StringTokenizer\n\nobject _9A extends App {\n  var token = new StringTokenizer(\"\")\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n  val cb = 7 - (next.toInt max next.toInt)\n  if (cb == 0) println(\"0/1\")\n  else if (cb == 1) println(\"1/6\")\n  else if (cb == 2) println(\"1/3\")\n  else if (cb == 3) println(\"1/2\")\n  else if (cb == 4) println(\"2/3\")\n  else if (cb == 5) println(\"5/6\")\n  else println(\"1/1\")\n}\n"}, {"source_code": "//package me.jetblack.cf\n\nimport java.util.Scanner\n\nobject DiceRoll extends App {\n\n  val s = new Scanner(System.in)\n\n  val y = s.nextInt()\n  val w = s.nextInt()\n\n  val t = 6 - (math.max(y, w) - 1)\n  if (t == 4) {\n    println(\"2/3\")\n  } else if (t == 3) {\n    println(\"1/2\")\n  } else if (t == 2) {\n    println(\"1/3\")\n  } else if (t == 6) {\n    println(\"1/1\")\n  } else {\n    println(s\"$t/6\")\n  }\n\n}\n"}, {"source_code": "object A9 {\n\n  import IO._\n\n  def main(args: Array[String]): Unit = {\n    val score = readInts(2)\n    val max = score.max\n    val ans = Array(\"0/1\", \"1/1\", \"5/6\", \"2/3\", \"1/2\", \"1/3\", \"1/6\")\n    println(ans(max))\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.util.Random\n\nobject P009A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  def solve(): String = {\n    val target: Int = List.fill(2)(sc.nextInt).max\n    List(\"dummy\", \"1/1\", \"5/6\", \"2/3\", \"1/2\", \"1/3\", \"1/6\")(target)\n  }\n  \n  out.println(solve)\n  out.close\n}\n"}], "negative_code": [{"source_code": "import java.util.StringTokenizer\n\nobject _9A extends App {\n  var token = new StringTokenizer(\"\")\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n  val cb = 6 - next.toInt max next.toInt + 1\n  if (cb == 0) println(\"0/1\")\n  else if (cb == 1) println(\"1/6\")\n  else if (cb == 2) println(\"1/3\")\n  else if (cb == 3) println(\"1/2\")\n  else if (cb == 4) println(\"2/3\")\n  else if (cb == 5) println(\"5/6\")\n  else println(\"1/1\")\n}\n"}, {"source_code": "import java.util._\nimport java.lang._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return Long.parseLong(next)\n  }\n\n  def solve = {\n    val y = nextInt\n    val w = nextInt\n    val x = 6 - Math.max(y, w) + 1\n    if (x % 2 == 0) {\n      out.println(x / 2 + \"/\" + 3)\n    } else if (x % 3 == 0) {\n      out.println(x / 3 + \"/\" + 2)\n    } else if (x % 6 == 0) {\n      out.println(x / 6 + \"/\" + 1)\n    } else {\n      out.println(x / 6)\n    }\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n"}, {"source_code": "import java.util._\nimport java.lang._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return Long.parseLong(next)\n  }\n\n  def solve = {\n    val y = nextInt\n    val w = nextInt\n    val x = 6 - Math.max(y, w) + 1\n    if (x % 2 == 0) {\n      out.println(x / 2 + \"/\" + 3)\n    } else if (x % 3 == 0) {\n      out.println(x / 3 + \"/\" + 2)\n    } else if (x % 6 == 0) {\n      out.println(x / 6 + \"/\" + 1)\n    } else {\n      out.println(x + \"/\" + 6)\n    }\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n"}, {"source_code": "object P9A {\n    import io.StdIn._\n\n    def main(args:Array[String]) {\n        println(readLine.split(' ').map{_.toInt}.max match {\n            case 1 => \"1/0\"\n            case 2 => \"5/6\"\n            case 3 => \"2/3\"\n            case 4 => \"1/2\"\n            case 5 => \"1/3\"\n            case 6 => \"1/6\"\n        })\n    }\n}\n"}], "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414"}
{"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\nobject P006A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val f: PartialFunction[List[Int], String] = {\n    case List(p, q, r, s) if p + q > r || q + r > s => \"TRIANGLE\"\n    case List(p, q, r, s) if p + q == r || q + r == s => \"SEGMENT\"\n    case _ => \"IMPOSSIBLE\"\n  }\n  val res: String = f(List.fill(4)(sc.nextInt).sorted)\n \n  out.println(res)\n  out.close\n}\n\n\n\n\n\n", "positive_code": [{"source_code": "object Solution6A extends Application {\n\n  def isTriangle(a: Int, b: Int, c: Int): Boolean = a + b > c && a + c > b && b + c > a\n\n  def isSegment(a: Int, b: Int, c: Int): Boolean = a + b == c || a + c == b || b + c == a\n\n  def solution() {\n    val a1 = _int\n    val a2 = _int\n    val a3 = _int\n    val a4 = _int\n\n    if (isTriangle(a1, a2, a3)) {\n      println(\"TRIANGLE\")\n      return\n    }\n    if (isTriangle(a1, a2, a4)) {\n      println(\"TRIANGLE\")\n      return\n    }\n    if (isTriangle(a1, a4, a3)) {\n      println(\"TRIANGLE\")\n      return\n    }\n    if (isTriangle(a4, a2, a3)) {\n      println(\"TRIANGLE\")\n      return\n    }\n\n\n    if (isSegment(a1, a2, a3)) {\n      println(\"SEGMENT\")\n      return\n    }\n    if (isSegment(a1, a2, a4)) {\n      println(\"SEGMENT\")\n      return\n    }\n    if (isSegment(a1, a4, a3)) {\n      println(\"SEGMENT\")\n      return\n    }\n    if (isSegment(a4, a2, a3)) {\n      println(\"SEGMENT\")\n      return\n    }\n\n    println(\"IMPOSSIBLE\")\n  }\n\n  //////////////////////////////////////////////////\n  import java.util.Scanner\n  val SC: Scanner = new Scanner(System.in)\n  def _line: String = SC.nextLine\n  def _int: Int = SC.nextInt\n  def _long: Long = SC.nextLong\n  def _string: String = SC.next\n  solution()\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  var data = in.next().split(\" \").map(_.toInt).toList.sorted\n\n  def triangle(list: Seq[Int]): Int = {\n    val sorted = list.sorted\n    if (sorted(0) + sorted(1) == sorted(2)) 1\n    else if (sorted(0) + sorted(1) > sorted(2)) 2\n    else 0\n  }\n\n  val max = data.combinations(3).map(triangle).max\n  if (max == 2)\n    println(\"TRIANGLE\")\n  else if (max == 1)\n    println(\"SEGMENT\")\n  else\n    println(\"IMPOSSIBLE\")\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject ATriangle extends App {\n\n  val scanner = new Scanner(System.in)\n\n  val in = (0 until 4).map(i => scanner.nextInt().toDouble)\n\n  val res = (0 until 4).foldLeft(\"IMPOSSIBLE\")((r: String, c: Int) =>\n    r match {\n      case \"TRIANGLE\" => \"TRIANGLE\"\n      case t if t ==\"IMPOSSIBLE\" || t == \"SEGMENT\"  =>\n        val s = co(in.remove(c).toList)\n        if (math.abs(s) == 1.0) \"SEGMENT\"\n        else if (t == \"SEGMENT\" && math.abs(s) > 1.0) \"SEGMENT\"\n        else if (math.abs(s) < 1.0) \"TRIANGLE\"\n        else \"IMPOSSIBLE\"\n\n    }\n  )\n\n  println(res)\n\n  implicit class ListExt[T](src: Seq[T]) {\n    def remove(idx: Int): Seq[T] = src.take(idx) ++ src.drop(idx + 1)\n  }\n\n\n  def co(a:List[Double]): Double = (math.pow(a(0), 2) + math.pow(a(1), 2) - math.pow(a(2), 2)) / (2 * a(0) * a(1))\n\n\n}\n"}, {"source_code": "object A6 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def main(args: Array[String]): Unit = {\n    val in = readInts(4)\n    val tri = in.permutations.exists{ arr =>\n      val t = arr.take(3)\n      arr(0)+arr(1) > arr(2) && arr(1)+arr(2) > arr(0) && arr(0)+arr(2) > arr(1)\n    }\n    if(tri) {\n      println(\"TRIANGLE\")\n    } else {\n      val deg = in.permutations.exists{ arr =>\n        val t = arr.take(3)\n        arr(0)+arr(1) >= arr(2) && arr(1)+arr(2) >= arr(0) && arr(0)+arr(2) >= arr(1)\n      }\n      if(deg) {\n        println(\"SEGMENT\")\n      } else {\n        println(\"IMPOSSIBLE\")\n      }\n    }\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "import java.util.Scanner\nimport scala.util.Sorting.quickSort\nimport scala.math.max;\n\nobject Main {\n\n  val TRIANGLE = 2\n  val SEGMENT = 1\n  val IMPOSSIBLE = 0\n  val map = Array(\"IMPOSSIBLE\", \"SEGMENT\", \"TRIANGLE\")\n\n  def main(args: Array[String]) {\n    val in = new Scanner(System.in)\n    def next = in.next.toInt\n\n    println(map(canMakeTriangle(Array(next, next, next, next))))\n  }\n\n  def canMakeTriangle(sides: Array[Int]): Int = {\n    quickSort(sides)\n    max(classifyTriangle(sides(0), sides(1), sides(2)), classifyTriangle(sides(1), sides(2), sides(3)))\n  }\n\n  def classifyTriangle(s0: Int, s1: Int, s2: Int) = {\n    val s = s0 + s1;\n    if (s < s2) IMPOSSIBLE\n    else if (s == s2) SEGMENT\n    else TRIANGLE\n  }\n}\n"}, {"source_code": "\n/**\n * Created by yangchaozhong on 3/10/15.\n */\nobject CF6A extends App {\n  import java.util.{Scanner}\n  import java.io.{PrintWriter}\n\n  val in = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  def nextInt = in.nextInt\n  def nextLong = in.nextLong\n  def nextDouble = in.nextDouble\n  def nextString = in.next\n  def nextLine = in.nextLine\n\n  def solve = {\n    val lines = Array.ofDim[Int](4)\n\n    (0 until 4).foreach { i =>\n      lines(i) = nextInt\n    }\n\n    val combinations = lines.combinations(3)\n    var c1 = 0\n    var c2 = 0\n    combinations.foreach { arr =>\n      val sortedArr = arr.sortWith(_ > _)\n      if (sortedArr(1) + sortedArr(2) > sortedArr(0)) {\n        c1 += 1\n      } else if (sortedArr(1) + sortedArr(2) == sortedArr(0)) {\n        c2 += 1\n      }\n    }\n\n    if (c1 > 0) {\n      out.println(\"TRIANGLE\")\n    } else if (c2 > 0) {\n      out.println(\"SEGMENT\")\n    } else {\n      out.println(\"IMPOSSIBLE\")\n    }\n  }\n\n  try {\n    solve\n  } catch {\n    case _: Exception => sys.exit(9999)\n  } finally {\n    out.flush\n    out.close\n  }\n}\n"}, {"source_code": "import java.util._\nimport java.lang._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return Long.parseLong(next)\n  }\n\n  def solve = {\n    val len = new Array[Int](4)\n    for (i <- 0 until 4) {\n      len(i) = nextInt\n    }\n    var flag = false\n    for (i <- 0 until 4) {\n      for (j <- 0 until 4) {\n        for (k <- 0 until 4) {\n          if (i != j && j != k && i != k) {\n            if (len(i) < len(j) + len(k) &&\n              len(j) < len(i) + len(k) &&\n              len(k) < len(j) + len(i) && !flag) {\n              out.println(\"TRIANGLE\")\n              flag = true\n            }\n          }\n        }\n      }\n    }\n    if (!flag) {\n      for (i <- 0 until 4) {\n        for (j <- 0 until 4) {\n          for (k <- 0 until 4) {\n            if (i != j && j != k && i != k) {\n              if ((len(i) <= len(j) + len(k) &&\n                len(j) <= len(i) + len(k) &&\n                len(k) <= len(j) + len(i)) && !flag) {\n                out.println(\"SEGMENT\")\n                flag = true\n              }\n            }\n          }\n        }\n      }\n    }\n    if (!flag) {\n      out.println(\"IMPOSSIBLE\")\n    }\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n"}, {"source_code": "object P6A {\n    def main(args : Array[String]) {\n        val a = readLine split ' ' map {_.toInt}\n        val answer = () match {\n            case _ if (a combinations 3) exists {\n                case Array(u, v, w) => u + v > w && v + w > u && w + u > v\n            } => \"TRIANGLE\"\n            case _ if (a combinations 3) exists {\n                case Array(u, v, w) => u + v >= w && v + w >= u && w + u >= v\n            } => \"SEGMENT\"\n            case _ => \"IMPOSSIBLE\"\n        }\n        println(answer)\n    }\n}"}, {"source_code": "import scala.io._\nimport scala.collection.mutable._\n\nobject HelloWorld {\n  def main(args: Array[String]) = {\n    var arr = readLine.split(\" \").map(_.toInt);\n    var result = 0;\n    val buffer = ArrayBuffer[Int](arr(0), arr(1), arr(2), arr(3)).sorted;\n    for (i <- 0 until buffer.length) {\n      val temp = buffer.clone;\n      temp.remove(i);\n      if (temp(0) + temp(1) > temp(2)) {\n        result = math.max(result, 2);\n      } else if (temp(0) + temp(1) == temp(2)) {\n        result = math.max(result, 1);\n      } else {\n        result = math.max(result, 0);\n      }\n    }\n    if (result == 0) {\n      println(\"IMPOSSIBLE\");\n    } else if (result ==1) {\n      println(\"SEGMENT\");\n    } else {\n      println(\"TRIANGLE\");\n    }\n  }\n\n}"}, {"source_code": "import scala.io._\nimport scala.collection.mutable._\n\nobject HelloWorld {\n  def main(args: Array[String]) = {\n    var arr = readLine.split(\" \").map(_.toInt);\n    val list = List(arr(0), arr(1), arr(2), arr(3)).sorted;\n    var result = 0;\n    val buffer = ArrayBuffer[Int](arr(0), arr(1), arr(2), arr(3)).sorted;\n    for (i <- 0 until buffer.length) {\n      val temp = buffer.clone;\n      temp.remove(i);\n//      println(\"LIST_LENGTH = \" + buffer.length);\n//      println(\"TEMP = \" + temp.toString);\n//      println(\"LIST = \" + buffer.toString);\n      if (temp(0) + temp(1) > temp(2)) {\n        result = math.max(result, 2);\n      } else if (temp(0) + temp(1) == temp(2)) {\n    \tresult = math.max(result, 1);\n      } else {\n        result = math.max(result, 0);\n      }\n    }\n    if (result == 0) {\n      println(\"IMPOSSIBLE\");\n    } else if (result ==1) {\n      println(\"SEGMENT\");\n    } else {\n      println(\"TRIANGLE\");\n    }\n  }\n\n}"}, {"source_code": "object Main { \n  def main(args: Array[String]) {\n    val a = readLine().split(\" \").map(_.toInt).sorted\n    \n    var traingle = false\n    var segment = false\n    for{\n      i <- 0 to 3\n      j <- i + 1 to 3\n      k <- j + 1 to 3      \n    } {\n      if (a(i) + a(j) > a(k)) traingle = true\n      else if (a(i) + a(j) == a(k)) segment = true\n    }\n    if (traingle ) println(\"TRIANGLE\")\n    else if (segment) println(\"SEGMENT\")\n    else println(\"IMPOSSIBLE\")\n  }\n}"}, {"source_code": "object Main{\n  def main(args: Array[String]) {\n    def solve(list: List[Int]): String ={\n\n      (list(0), list(1), list(2), list(3)) match {\n        case _ if list(0) + list(1) > list(2) => \"TRIANGLE\"\n        case _ if list(0) + list(1) > list(3) => \"TRIANGLE\"\n        case _ if list(0) + list(2) > list(3) => \"TRIANGLE\"\n        case _ if list(1) + list(2) > list(3) => \"TRIANGLE\"\n\n        case _ if list(0) + list(1) == list(2) => \"SEGMENT\"\n        case _ if list(0) + list(1) == list(3) => \"SEGMENT\"\n        case _ if list(0) + list(2) == list(3) => \"SEGMENT\"\n        case _ if list(1) + list(2) == list(3) => \"SEGMENT\"\n\n        case _ => \"IMPOSSIBLE\"\n      }\n    }\n\n    val line = scala.io.StdIn.readLine()\n    val nums = line.split(\" \").map(x => x.toInt).toList.sorted\n\n    println(solve(nums))\n  }\n}"}, {"source_code": "object P6A {\n    def main(args : Array[String]) {\n        val a = readLine split ' ' map {_.toInt}\n        val answer = () match {\n            case _ if (a combinations 3) exists {\n                case Array(u, v, w) => u + v > w && v + w > u && w + u > v\n            } => \"TRIANGLE\"\n            case _ if (a combinations 3) exists {\n                case Array(u, v, w) => u + v >= w && v + w >= u && w + u >= v\n            } => \"SEGMENT\"\n            case _ => \"IMPOSSIBLE\"\n        }\n        println(answer)\n    }\n}\n"}, {"source_code": "object P6A {\n    def main(args : Array[String]) {\n        val a = readLine split ' ' map {_.toInt}\n        val answer = () match {\n            case _ if (a combinations 3) exists {\n                case Array(u, v, w) => u + v > w && v + w > u && w + u > v\n            } => \"TRIANGLE\"\n            case _ if (a combinations 3) exists {\n                case Array(u, v, w) => u + v >= w && v + w >= u && w + u >= v\n            } => \"SEGMENT\"\n            case _ => \"IMPOSSIBLE\"\n        }\n        println(answer)\n    }\n}"}], "negative_code": [{"source_code": "object Solution6A extends Application {\n\n  def isTriangle(a: Int, b: Int, c: Int): Boolean = a + b > c && a + c > b && b + c > a\n\n  def isSegment(a: Int, b: Int, c: Int): Boolean = !isTriangle(a, b, c) && a + b == c && a + c == b && b + c == a\n\n  def solution() {\n    val a1 = _int\n    val a2 = _int\n    val a3 = _int\n    val a4 = _int\n\n    if (isTriangle(a1, a2, a3)) {\n      println(\"TRIANGLE\")\n      return\n    }\n    if (isTriangle(a1, a2, a4)) {\n      println(\"TRIANGLE\")\n      return\n    }\n    if (isTriangle(a1, a4, a3)) {\n      println(\"TRIANGLE\")\n      return\n    }\n    if (isTriangle(a4, a2, a3)) {\n      println(\"TRIANGLE\")\n      return\n    }\n\n\n    if (isSegment(a1, a2, a3)) {\n      println(\"SEGMENT\")\n      return\n    }\n    if (isSegment(a1, a2, a4)) {\n      println(\"SEGMENT\")\n      return\n    }\n    if (isSegment(a1, a4, a3)) {\n      println(\"SEGMENT\")\n      return\n    }\n    if (isSegment(a4, a2, a3)) {\n      println(\"SEGMENT\")\n      return\n    }\n\n    println(\"IMPOSSIBLE\")\n  }\n\n  //////////////////////////////////////////////////\n  import java.util.Scanner\n  val SC: Scanner = new Scanner(System.in)\n  def _line: String = SC.nextLine\n  def _int: Int = SC.nextInt\n  def _long: Long = SC.nextLong\n  def _string: String = SC.next\n  solution()\n}"}, {"source_code": "\n/**\n * Created by yangchaozhong on 3/10/15.\n */\nobject CF6A extends App {\n  import java.util.{Scanner}\n  import java.io.{PrintWriter}\n\n  val in = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  def nextInt = in.nextInt\n  def nextLong = in.nextLong\n  def nextDouble = in.nextDouble\n  def nextString = in.next\n  def nextLine = in.nextLine\n\n  def solve = {\n    val lines = Array.ofDim[Int](4)\n\n    (0 until 4).foreach { i =>\n      lines(i) = nextInt\n    }\n\n    val combinations = lines.combinations(3)\n    var c1 = 0\n    var c2 = 0\n    combinations.foreach { x =>\n      x.permutations.foreach { y =>\n        if (y(0) + y(1) > y(2) && y(0) + y(1) < y(2)) {\n          c1 += 1\n        } else if (y(0) + y(1) == y(2)) {\n          c2 += 1\n        }\n      }\n    }\n\n    if (c1 > 0) {\n      out.println(\"TRIANGLE\")\n    } else if (c2 > 0) {\n      out.println(\"SEGMENT\")\n    } else {\n      out.println(\"IMPOSSIBLE\")\n    }\n  }\n\n  try {\n    solve\n  } catch {\n    case _: Exception => sys.exit(9999)\n  } finally {\n    out.flush\n    out.close\n  }\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\nobject P006A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val isTriangle: PartialFunction[List[Int], Boolean] = {\n    case List(x, y, z) => x + y > z\n  }\n\n  val res = List.fill(4)(sc.nextInt).sorted.sliding(3).find(isTriangle) match {\n      case Some(x) => \"TRIANGLE\"\n      case None    => \"SEGMENT\"\n    }\n\n  out.println(res)\n  out.close\n}\n\n\n\n\n\n"}, {"source_code": "import java.util._\nimport java.lang._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return Long.parseLong(next)\n  }\n\n  def solve = {\n    val len = new Array[Int](4)\n    for (i <- 0 until 4) {\n      len(i) = nextInt\n    }\n    var flag = false\n    for (i <- 0 until 4) {\n      for (j <- 0 until 4) {\n        for (k <- 0 until 4) {\n          if (i != j && j != k && i != k) {\n            if (len(i) < len(j) + len(k) &&\n              len(j) < len(i) + len(k) &&\n              len(k) < len(j) + len(i) && !flag) {\n              out.println(\"TRIANGLE\")\n              flag = true\n            }\n          }\n        }\n      }\n    }\n    if (!flag) {\n      for (i <- 0 until 4) {\n        for (j <- 0 until 4) {\n          for (k <- 0 until 4) {\n            if (i != j && j != k && i != k) {\n              if ((len(i) <= len(j) + len(k) &&\n                len(j) <= len(i) + len(k) ||\n                len(k) <= len(j) + len(i)) && !flag) {\n                out.println(\"SEGMENT\")\n                flag = true\n              }\n            }\n          }\n        }\n      }\n    }\n    if (!flag) {\n      out.println(\"IMPOSSIBLE\")\n    }\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n"}], "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a"}
{"source_code": "object C3 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def wins(b: Array[Array[Char]], char: Char): Boolean = {\n    b.exists(_.forall(_==char)) || {\n      (0 until 3).exists(j => Array(b(0)(j), b(1)(j), b(2)(j)).forall(_==char))\n    } || {\n      Array(b(0)(0), b(1)(1), b(2)(2)).forall(_==char)\n    } || {\n      Array(b(0)(2), b(1)(1), b(2)(0)).forall(_==char)\n    }\n  }\n\n  def main(args: Array[String]): Unit = {\n    val b = Array.fill(3)(read.toCharArray)\n    val x = b.flatten.count(_ == 'X')\n    val zero = b.flatten.count(_ == '0')\n    if(x != zero && x != zero+1) {\n      println(\"illegal\") //also both can't win\n    } else {\n      if (wins(b, 'X') && wins(b, '0')) {\n        println(\"illegal\")\n      } else if (wins(b, 'X')){\n        if(x == zero+1)\n          println(\"the first player won\")\n        else\n          println(\"illegal\")\n      } else if (wins(b, '0')){\n        if(x == zero)\n          println(\"the second player won\")\n        else\n          println(\"illegal\")\n      } else {\n        if(b.flatten.contains('.')) {\n          if(x == zero) {\n            println(\"first\")\n          } else {\n            println(\"second\")\n          }\n        } else {\n          println(\"draw\")\n        }\n      }\n    }\n\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n", "positive_code": [{"source_code": "object cf3C extends App {\n  val s = readLine + readLine + readLine\n  val numX = s count {_ == 'X'}\n  val num0 = s count {_ == '0'}\n  val toX = numX== num0\n  val to0 = numX== num0+1\n  val filled = s forall {_!='.'}\n  val lines = Array(\n    Array(0, 1, 2), Array(3, 4, 5), Array(6, 7, 8),\n    Array(0, 3, 6), Array(1, 4, 7), Array(2, 5, 8),\n    Array(0, 4, 8), Array(2, 4, 6))\n  val winX = lines exists {_ forall {s(_) == 'X'}}\n  val win0 = lines exists {_ forall {s(_) == '0'}}\n  val answer = () match {\n    case _ if !toX && !to0 || toX && winX || to0 && win0 => \"illegal\"\n    case _ if winX => \"the first player won\"\n    case _ if win0 => \"the second player won\"\n    case _ if filled => \"draw\"\n    case _ if toX => \"first\"\n    case _ if to0 => \"second\"\n  }\n  println(answer)\n}"}, {"source_code": "object P3C {\n    def main(args : Array[String]) {\n        val s = readLine + readLine + readLine\n        val numX = s count {_ == 'X'}\n        val num0 = s count {_ == '0'}\n        val toX = numX == num0\n        val to0 = numX == num0 + 1\n        val filled = s forall {_ != '.'}\n        val lines = Array(\n            Array(0, 1, 2), Array(3, 4, 5), Array(6, 7, 8),\n            Array(0, 3, 6), Array(1, 4, 7), Array(2, 5, 8),\n            Array(0, 4, 8), Array(2, 4, 6))\n        val winX = lines exists {_ forall {s(_) == 'X'}}\n        val win0 = lines exists {_ forall {s(_) == '0'}}\n        val answer = () match {\n            case _ if !toX && !to0 || toX && winX || to0 && win0 => \"illegal\"\n            case _ if winX => \"the first player won\"\n            case _ if win0 => \"the second player won\"\n            case _ if filled => \"draw\"\n            case _ if toX => \"first\"\n            case _ if to0 => \"second\"\n        }\n        println(answer)\n    }\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject ZeroCross extends App {\n\n  /*val a = b.map(a => a.zipWithIndex).flatten.groupBy(_._2).values.map(_.map(_._1)).map(_.mkString)\n  println(a.mkString(\" \"))\n*/\n\n\n  val b = Array.ofDim[Int](3, 3)\n\n  val scanner = new Scanner(System.in)\n  (0 until 3).foreach {\n    i =>\n      b(i) = scanner.next.toCharArray.map(convert)\n  }\n\n  def convert(ch: Char): Int = {\n    if (ch == '.') 0\n    else if (ch == '0') 1\n    else 2\n  }\n\n\n  val board = Board(b)\n\n  if (board.xWon && board.zeroWon) {\n    println(\"illegal\")\n  } else if (board.count(2) < board.count(1)) {\n    println(\"illegal\")\n  } else if (board.count(2) - board.count(1) > 1) {\n    println(\"illegal\")\n  } else if (board.zeroWon && board.count(2) > board.count(1)) {\n    println(\"illegal\")\n  } else if (board.xWon && board.count(2) == board.count(1)) {\n    println(\"illegal\")\n  } else if (board.xWon) {\n    println(\"the first player won\")\n  } else if (board.zeroWon) {\n    println(\"the second player won\")\n  } else if (board.draw) {\n    println(\"draw\")\n  } else if (board.count(1) == board.count(2)) {\n    println(\"first\")\n  } else if (board.count(2) - board.count(1) == 1) {\n    println(\"second\")\n  } else {\n    println(\"illegal\")\n  }\n\n\n  case class Board(arr: Array[Array[Int]]) {\n\n    def xWon: Boolean = won(2)\n\n    def zeroWon: Boolean = won(1)\n\n    def won(item: Int): Boolean = {\n      wonHorizontal(item) || wonVertical(item) || wonDiagonal(item)\n    }\n\n    def count(item: Int): Int = arr.flatten.count(_ == item)\n\n    def draw: Boolean = count(1) == 4 && count(2) == 5\n\n    def wonDiagonal(item: Int) = {\n      val diag = for {x <- 0 until 3\n                      st = arr(x)(x)\n                      rev = arr(x)(2 - x)} yield (st, rev)\n      val res = diag.foldLeft((\"\", \"\"))((acc, t) => (acc._1 + t._1, acc._2 + t._2))\n      List(res._1, res._2).contains(item.toString * 3)\n    }\n\n    def wonHorizontal(item: Int): Boolean = arr.map(a => a.mkString).contains(item.toString * 3)\n\n    def wonVertical(item: Int): Boolean = b.map(a => a.zipWithIndex).flatten.groupBy(_._2).values.map(_.map(_._1)).map(_.mkString).toList.contains(item.toString * 3)\n\n  }\n\n\n}\n"}], "negative_code": [{"source_code": "import java.util.Scanner\n\nobject ZeroCross extends App {\n\n  /*val a = b.map(a => a.zipWithIndex).flatten.groupBy(_._2).values.map(_.map(_._1)).map(_.mkString)\n  println(a.mkString(\" \"))\n*/\n\n\n  val b = Array.ofDim[Int](3, 3)\n\n  val scanner = new Scanner(System.in)\n  (0 until 3).foreach {\n    i =>\n      b(i) = scanner.next.toCharArray.map(convert)\n  }\n\n  def convert(ch: Char): Int = {\n    if (ch == '.') 0\n    else if (ch == '0') 1\n    else 2\n  }\n\n\n  val board = Board(b)\n\n  if (board.xWon && board.zeroWon) {\n    println(\"illegal\")\n  } else if (board.count(2) < board.count(1)) {\n    println(\"illegal\")\n  } else if (board.count(2) - board.count(1) > 1) {\n    println(\"illegal\")\n  } else if (board.zeroWon && board.count(2) > board.count(1)) {\n    println(\"illegal\")\n  } else if (board.xWon && board.count(2) == board.count(1)) {\n    println(\"illegal\")\n  } else if (board.xWon) {\n    println(\"the first player won\")\n  } else if (board.zeroWon) {\n    println(\"the second player won\")\n  } else if (board.draw) {\n    println(\"draw\")\n  } else if (board.count(1) == board.count(2)) {\n    println(\"first\")\n  } else if (board.count(2) - board.count(1) == 1) {\n    println(\"second\")\n  } else {\n    println(\"illegal\")\n  }\n\n\n  case class Board(arr: Array[Array[Int]]) {\n\n    def xWon: Boolean = won(2)\n\n    def zeroWon: Boolean = won(1)\n\n    def won(item: Int): Boolean = {\n      wonHorizontal(item) || wonVertical(item) || wonDiagonal(item)\n    }\n\n    def count(item: Int): Int = arr.flatten.count(_ == item)\n\n    def draw: Boolean = count(1) == 4 && count(2) == 5\n\n    def wonDiagonal(item: Int) = {\n      val diag = for {x <- 0 until 3\n                      st = arr(x)(x)\n                      rev = arr(2 - x)(2 - x)} yield (st, rev)\n      val res = diag.foldLeft((\"\", \"\"))((acc, t) => (acc._1 + t._1, acc._2 + t._1))\n      List(res._1, res._2).contains(item.toString * 3)\n    }\n\n    def wonHorizontal(item: Int): Boolean = arr.map(a => a.mkString).contains(item.toString * 3)\n\n    def wonVertical(item: Int): Boolean = b.map(a => a.zipWithIndex).flatten.groupBy(_._2).values.map(_.map(_._1)).map(_.mkString).toList.contains(item.toString * 3)\n\n  }\n\n\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject ZeroCross extends App {\n\n  /*val a = b.map(a => a.zipWithIndex).flatten.groupBy(_._2).values.map(_.map(_._1)).map(_.mkString)\n  println(a.mkString(\" \"))\n*/\n\n\n  val b = Array.ofDim[Int](3, 3)\n\n  val scanner = new Scanner(System.in)\n  (0 until 3).foreach {\n    i =>\n      b(i) = scanner.next.toCharArray.map(convert)\n  }\n\n  def convert(ch: Char): Int = {\n    if (ch == '.') 0\n    else if (ch == '0') 1\n    else 2\n  }\n\n\n  val board = Board(b)\n\n  if (board.xWon && board.zeroWon) {\n    println(\"illegal\")\n  } else if (board.count(2) < board.count(1)) {\n    println(\"illegal\")\n  } else if (board.count(2) - board.count(1) > 1) {\n    println(\"illegal\")\n  } else if (board.zeroWon && board.count(2) > board.count(1)) {\n    println(\"illegal\")\n  } else if (board.xWon && board.count(2) == board.count(1)) {\n    println(\"illegal\")\n  } else if (board.xWon) {\n    println(\"the first player won\")\n  } else if (board.zeroWon) {\n    println(\"the second player won\")\n  } else if (board.draw) {\n    println(\"draw\")\n  } else if (board.count(1) == board.count(2)) {\n    println(\"first\")\n  } else if (board.count(2) - board.count(1) == 1) {\n    println(\"second\")\n  } else {\n    println(\"illegal\")\n  }\n\n\n  case class Board(arr: Array[Array[Int]]) {\n\n    def xWon: Boolean = won(2)\n\n    def zeroWon: Boolean = won(1)\n\n    def won(item: Int): Boolean = {\n      wonHorizontal(item) || wonVertical(item) || wonDiagonal(item)\n    }\n\n    def count(item: Int): Int = arr.flatten.count(_ == item)\n\n    def draw: Boolean = count(1) == 4 && count(2) == 5\n\n    def wonDiagonal(item: Int) = {\n      val diag = for {x <- 0 until 3\n                      st = arr(x)(2 - x)\n                      rev = arr(2 - x)(2)} yield (st, rev)\n      val res = diag.foldLeft((\"\", \"\"))((acc, t) => (acc._1 + t._1, acc._2 + t._1))\n      List(res._1, res._2).contains(item.toString * 3)\n    }\n\n    def wonHorizontal(item: Int): Boolean = arr.map(a => a.mkString).contains(item.toString * 3)\n\n    def wonVertical(item: Int): Boolean = b.map(a => a.zipWithIndex).flatten.groupBy(_._2).values.map(_.map(_._1)).map(_.mkString).toList.contains(item.toString * 3)\n\n  }\n\n\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject ZeroCross extends App {\n\n  /*val a = b.map(a => a.zipWithIndex).flatten.groupBy(_._2).values.map(_.map(_._1)).map(_.mkString)\n  println(a.mkString(\" \"))\n*/\n\n\n  val b = Array.ofDim[Int](3, 3)\n\n  val scanner = new Scanner(System.in)\n  (0 until 3).foreach {\n    i =>\n      b(i) = scanner.next.toCharArray.map(convert)\n  }\n\n  def convert(ch: Char): Int = {\n    if (ch == '.') 0\n    else if (ch == '0') 1\n    else 2\n  }\n\n\n  val board = Board(b)\n\n  if (board.xWon && board.zeroWon) {\n    println(\"illegal\")\n  } else if (board.count(2) < board.count(1)) {\n    println(\"illegal\")\n  } else if (board.count(2) - board.count(1) > 1) {\n    println(\"illegal\")\n  } else if (board.zeroWon && board.count(2) > board.count(1)) {\n    println(\"illegal\")\n  } else if (board.xWon) {\n    println(\"the first player won\")\n  } else if (board.zeroWon) {\n    println(\"the second player won\")\n  } else if (board.draw) {\n    println(\"draw\")\n  } else if (board.count(1) == board.count(2)) {\n    println(\"first\")\n  } else if (board.count(2) - board.count(1) == 1) {\n    println(\"second\")\n  } else {\n    println(\"illegal\")\n  }\n\n\n  case class Board(arr: Array[Array[Int]]) {\n\n    def xWon: Boolean = won(2)\n\n    def zeroWon: Boolean = won(1)\n\n    def won(item: Int): Boolean = {\n      wonHorizontal(item) || wonVertical(item) || wonDiagonal(item)\n    }\n\n    def count(item: Int): Int = arr.flatten.count(_ == item)\n\n    def draw: Boolean = count(1) == 4 && count(2) == 5\n\n    def wonDiagonal(item: Int) = {\n      val diag = for {x <- 0 until 3\n                      st = arr(x)(x)\n                      rev = arr(2 - x)(2 - x)} yield (st, rev)\n      val res = diag.foldLeft((\"\", \"\"))((acc, t) => (acc._1 + t._1, acc._2 + t._1))\n      List(res._1, res._2).contains(item.toString * 3)\n    }\n\n    def wonHorizontal(item: Int): Boolean = arr.map(a => a.mkString).contains(item.toString * 3)\n\n    def wonVertical(item: Int): Boolean = b.map(a => a.zipWithIndex).flatten.groupBy(_._2).values.map(_.map(_._1)).map(_.mkString).toList.contains(item.toString * 3)\n\n  }\n\n\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject ZeroCross extends App {\n\n  /*val a = b.map(a => a.zipWithIndex).flatten.groupBy(_._2).values.map(_.map(_._1)).map(_.mkString)\n  println(a.mkString(\" \"))\n*/\n\n\n  val b = Array.ofDim[Int](3, 3)\n\n  val scanner = new Scanner(System.in)\n  (0 until 3).foreach { i =>\n    b(i) = scanner.next.toCharArray.map(convert)\n  }\n\n  def convert(ch: Char):Int = {\n    if (ch == '.') 0\n    else if (ch == '0') 1\n    else 2\n  }\n\n\n  val board = Board(b)\n\n  if (board.xWon && board.zeroWon) {\n    println(\"illegal\")\n  } else if (board.count(2) < board.count(1)) {\n    println(\"illegal\")\n  } else if (board.count(2) - board.count(1) > 1) {\n    println(\"illegal\")\n  } else if (board.xWon) {\n    println(\"the first player won\")\n  } else if (board.zeroWon) {\n    println(\"the second player won\")\n  } else if (board.draw) {\n    println(\"draw\")\n  } else if (board.count(1) == board.count(2)) {\n    println(\"first\")\n  } else if (board.count(2) - board.count(1) == 1) {\n    println(\"second\")\n  } else {\n    println(\"illegal\")\n  }\n\n\n\n  case class Board(arr: Array[Array[Int]]) {\n\n    def xWon: Boolean = won(2)\n\n    def zeroWon: Boolean = won(1)\n\n    def won(item: Int): Boolean = {\n      wonHorizontal(item) || wonVertical(item) || wonDiagonal(item)\n    }\n\n    def count(item: Int):Int = arr.flatten.count(_ == item)\n\n    def draw:Boolean = count(1) == 4 && count(2) == 5\n\n    def wonDiagonal(item: Int) = {\n      val diag = for {x <- 0 until 3\n                        st = arr(x)(x)\n                        rev = arr(2 - x)(2 - x)} yield (st, rev)\n      val res = diag.foldLeft((\"\",\"\"))((acc, t) => (acc._1 + t._1, acc._2 + t._1))\n      List(res._1, res._2).contains(item.toString * 3)\n    }\n\n    def wonHorizontal(item: Int): Boolean = arr.map(a => a.mkString).contains(item.toString * 3)\n\n    def wonVertical(item: Int): Boolean = b.map(a => a.zipWithIndex).flatten.groupBy(_._2).values.map(_.map(_._1)).map(_.mkString).toList.contains(item.toString * 3)\n\n  }\n\n\n}\n"}, {"source_code": "object C3 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def wins(b: Array[Array[Char]], char: Char): Boolean = {\n    b.exists(_.forall(_==char)) || {\n      (0 until 3).exists(j => Array(b(0)(j), b(1)(j), b(2)(j)).forall(_==char))\n    } || {\n      Array(b(0)(0), b(1)(1), b(2)(2)).forall(_==char)\n    } || {\n      Array(b(0)(2), b(1)(1), b(2)(0)).forall(_==char)\n    }\n  }\n\n  def main(args: Array[String]): Unit = {\n    val b = Array.fill(3)(read.toCharArray)\n    val x = b.flatten.count(_ == 'X')\n    val zero = b.flatten.count(_ == '0')\n    if(x != zero || x != zero+1) {\n      println(\"illegal\") //also both can't win\n    } else {\n      if (wins(b, 'X') && wins(b, '0')) {\n        println(\"illegal\")\n      } else if (wins(b, 'X')){\n        if(x == zero+1)\n          println(\"the first player won\")\n        else\n          println(\"illegal\")\n      } else if (wins(b, '0')){\n        if(x == zero)\n          println(\"the second player won\")\n        else\n          println(\"illegal\")\n      } else {\n        if(b.flatten.contains('.')) {\n          if(x == zero) {\n            println(\"first\")\n          } else {\n            println(\"second\")\n          }\n        } else {\n          println(\"draw\")\n        }\n      }\n    }\n\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "object C3 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def wins(b: Array[Array[Char]], char: Char): Boolean = {\n    b.exists(_.forall(_==char)) || {\n      (0 until 3).exists(j => Array(b(0)(j), b(1)(j), b(2)(j)).forall(_==char))\n    } || {\n      Array(b(0)(0), b(1)(1), b(2)(2)).forall(_==char)\n    } || {\n      Array(b(0)(2), b(1)(1), b(2)(0)).forall(_==char)\n    }\n  }\n\n  def main(args: Array[String]): Unit = {\n    val b = Array.fill(3)(read.toCharArray)\n    val x = b.flatten.count(_ == 'X')\n    val zero = b.flatten.count(_ == '0')\n    if(x < zero) {\n      println(\"illegal\") //also both can't win\n    } else {\n      if (wins(b, 'X') && wins(b, '0')) {\n        println(\"illegal\")\n      } else if (wins(b, 'X')){\n        if(x == zero+1)\n          println(\"the first player won\")\n        else\n          println(\"illegal\")\n      } else if (wins(b, '0')){\n        if(x == zero)\n          println(\"the second player won\")\n        else\n          println(\"illegal\")\n      } else {\n        if(b.flatten.contains('.')) {\n          if(x == zero) {\n            println(\"first\")\n          } else {\n            println(\"second\")\n          }\n        } else {\n          println(\"draw\")\n        }\n      }\n    }\n\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "object C3 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def wins(b: Array[Array[Char]], char: Char): Boolean = {\n    b.exists(_.forall(_==char)) || {\n      (0 until 3).exists(j => Array(b(0)(j), b(1)(j), b(2)(j)).forall(_==char))\n    } || {\n      Array(b(0)(0), b(1)(1), b(2)(2)).forall(_==char)\n    } || {\n      Array(b(0)(2), b(1)(1), b(2)(0)).forall(_==char)\n    }\n  }\n\n  def main(args: Array[String]): Unit = {\n    val b = Array.fill(3)(read.toCharArray)\n    if(b.flatten.count(_ == 'X') < b.flatten.count(_ == '0') || (wins(b, 'X') && wins(b, '0')) ) {\n      println(\"illegal\") //also both can't win\n    } else if (wins(b, 'X')){\n      println(\"the first player won\")\n    } else if (wins(b, 'X')){\n      println(\"the second player won\")\n    } else {\n      if(b.flatten.contains('.')) {\n        if(b.flatten.count(_ == 'X') == b.flatten.count(_ == '0')) {\n          println(\"first\")\n        } else {\n          println(\"second\")\n        }\n      } else {\n        println(\"draw\")\n      }\n    }\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "object P3C {\n    def main(args : Array[String]) {\n        val s = readLine + readLine + readLine\n        val numX = s count {_ == 'X'}\n        val num0 = s count {_ == '0'}\n        val filled = s forall {_ != '.'}\n        val lines = Array(\n            Array(0, 1, 2), Array(3, 4, 5), Array(6, 7, 8),\n            Array(0, 3, 6), Array(1, 4, 7), Array(2, 5, 8),\n            Array(0, 4, 8), Array(2, 4, 6))\n        val winX = lines exists {_ forall {s(_) == 'X'}}\n        val win0 = lines exists {_ forall {s(_) == '0'}}\n        val answer = () match {\n            case _ if numX < num0 || num0 + 1 < numX => \"Illegal\"\n            case _ if winX && win0 => \"Illegal\"\n            case _ if winX => \"the first player won\"\n            case _ if win0 => \"the second player won\"\n            case _ if filled => \"draw\"\n            case _ if numX == num0 => \"first\"\n            case _ => \"second\"\n        }\n        println(answer)\n    }\n}\n"}, {"source_code": "object P3C {\n    def main(args : Array[String]) {\n        val s = readLine + readLine + readLine\n        val numX = s count {_ == 'X'}\n        val num0 = s count {_ == '0'}\n        val filled = s forall {_ != '.'}\n        val lines = Array(\n            Array(0, 1, 2), Array(3, 4, 5), Array(6, 7, 8),\n            Array(0, 3, 6), Array(1, 4, 7), Array(2, 5, 8),\n            Array(0, 4, 8), Array(2, 4, 6))\n        val winX = lines exists {_ forall {s(_) == 'X'}}\n        val win0 = lines exists {_ forall {s(_) == '0'}}\n        val answer = () match {\n            case _ if numX < num0 || num0 + 1 < numX => \"illegal\"\n            case _ if winX && win0 => \"illegal\"\n            case _ if winX => \"the first player won\"\n            case _ if win0 => \"the second player won\"\n            case _ if filled => \"draw\"\n            case _ if numX == num0 => \"first\"\n            case _ => \"second\"\n        }\n        println(answer)\n    }\n}\n"}], "src_uid": "892680e26369325fb00d15543a96192c"}
{"source_code": "import java.util._\nimport java.io._\nimport java.util\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    var k = nextInt\n    out.println(\"+------------------------+\")\n    val ans = new Array[util.ArrayList[Char]](4)\n    for (i <- 0 until 4) {\n      ans(i) = new util.ArrayList[Char]()\n      ans(i).add('|')\n    }\n    for (j <- 0 until 11) {\n      for (i <- 0 until 4) {\n        if (k > 0) {\n          if (i == 2) {\n            if (j == 0) {\n              ans(i).add('O')\n              ans(i).add('.')\n              k -= 1\n            } else {\n              ans(i).add('.')\n              ans(i).add('.')\n            }\n          }\n          else {\n            ans(i).add('O')\n            ans(i).add('.')\n            k -= 1\n          }\n        }\n        else {\n          if (i == 2 && j > 0) {\n            ans(i).add('.')\n            ans(i).add('.')\n          } else {\n            ans(i).add('#')\n            ans(i).add('.')\n          }\n        }\n      }\n    }\n    ans(0).add('|')\n    ans(0).add('D')\n    ans(0).add('|')\n    ans(0).add(')')\n    ans(1).add('|')\n    ans(1).add('.')\n    ans(1).add('|')\n    ans(2).add('.')\n    ans(2).add('.')\n    ans(2).add('|')\n    ans(3).add('|')\n    ans(3).add('.')\n    ans(3).add('|')\n    ans(3).add(')')\n    for (i <- 0 until 4) {\n      for (j <- 0 until ans(i).size()) {\n        out.print(ans(i).get(j))\n      }\n      out.println\n    }\n    out.println(\"+------------------------+\")\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n", "positive_code": [{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  var n = in.next().toInt\n  val left = if (n == 0) 0\n    else if (n < 5) 1\n    else 1 + ((n - 5) / 3 + 1)\n  val middleleft = if (n < 2) 0\n    else if (n < 6) 1\n    else 1 + ((n - 6) / 3 + 1)\n  val middleright = if (n < 3) 0 else 1\n  val right = if (n < 4) 0\n    else if (n < 7) 1\n  else 1 + ((n - 7) / 3 + 1)\n  println(\"+------------------------+\")\n  println(\"|\" + (\"O.\" * left) + (\"#.\" * (11 - left)) + \"|D|)\")\n  println(\"|\" + (\"O.\" * middleleft) + (\"#.\" * (11 - middleleft)) + \"|.|\")\n  println(\"|\" + (if (middleright == 0) \"#.\" else \"O.\") + (\"..\" * 10) + \"..|\")\n  println(\"|\" + (\"O.\" * right) + (\"#.\" * (11 - right)) + \"|.|)\")\n  println(\"+------------------------+\")\n\n}"}, {"source_code": "object  BY2015_1 extends App {\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  val Array(n) = readInts(1)\n  val arr = Array.ofDim[String](34)\n  for(i <- 0 until n) {\n    arr(i) = \"O\"\n  }\n  for(i <- n until 34){\n    arr(i) = \"#\"\n  }\n  println(\"+------------------------+\\n\" +\n    s\"|${arr(0)}.${arr(4)}.${arr(7)}.${arr(10)}.${arr(13)}.${arr(16)}.${arr(19)}.${arr(22)}.${arr(25)}.${arr(28)}.${arr(31)}.|D|)\\n\" +\n    s\"|${arr(1)}.${arr(5)}.${arr(8)}.${arr(11)}.${arr(14)}.${arr(17)}.${arr(20)}.${arr(23)}.${arr(26)}.${arr(29)}.${arr(32)}.|.|\\n\" +\n    s\"|${arr(2)}.......................|\\n\" +\n    s\"|${arr(3)}.${arr(6)}.${arr(9)}.${arr(12)}.${arr(15)}.${arr(18)}.${arr(21)}.${arr(24)}.${arr(27)}.${arr(30)}.${arr(33)}.|.|)\\n+------------------------+\")\n}\n"}, {"source_code": "import scala.collection._\n\nobject A extends App {\n  \n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(n) = readInts(1)\n\n  val seats = Array.fill(4, 11)(false)\n  var used = 0\n  \n  for (r <- 0 until 11) {\n    for (c <- 0 until 4 if r == 0 || c != 2) {\n      if (used < n) {\n        seats(c)(r) = true\n        used += 1\n      }\n    }\n  }\n  \n  \n  println(\"+------------------------+\")\n  \n  print(\"|\")\n  for (s <- seats(0)) print(if (s) \"O.\" else \"#.\")\n  println(\"|D|)\")\n\n  print(\"|\")\n  for (s <- seats(1)) print(if (s) \"O.\" else \"#.\")\n  println(\"|.|\")\n  \n  print(\"|\")\n  if (seats(2)(0)) print(\"O\") else print(\"#\")\n  println(\".......................|\")\n  \n  print(\"|\")\n  for (s <- seats(3)) print(if (s) \"O.\" else \"#.\")\n  println(\"|.|)\")\n\n  println(\"+------------------------+\")\n \n//|O.O.O.#.#.#.#.#.#.#.#.|D|)\n//|O.O.O.#.#.#.#.#.#.#.#.|.|\n//|O.......................|\n//|O.O.#.#.#.#.#.#.#.#.#.|.|)\n//+------------------------+\n}"}, {"source_code": "object main{\n\n\n  def work(n:Int): Unit ={\n    var s = \"+------------------------+\\n|#.#.#.#.#.#.#.#.#.#.#.|D|)\\n|#.#.#.#.#.#.#.#.#.#.#.|.|\\n|#.......................|\\n|#.#.#.#.#.#.#.#.#.#.#.|.|)\\n+------------------------+\"\n    var x = n\n\n    var arr = s.split('\\n').map( _.toList.toIndexedSeq)\n    for {\n      column <- 0 until arr(0).length\n      row <- 0 until 6\n    } {\n      val ch = arr(row)(column)\n      if ('#' == ch && x >0){\n        arr = arr.updated(row, arr(row).updated(column,'O'))\n        x -= 1\n      }\n    }\n    val s2 = (arr map (_.mkString)).mkString(\"\\n\")\n\n    println(s2)\n  }\n\n  def main(args:Array[String]) = {\n    val n = readInt()\n    work(n)\n  }\n\n\n\n}\n"}, {"source_code": "import java.io.PrintWriter\nimport java.util.Scanner\n\n/**\n * Created by arseny on 05.10.14.\n */\nobject A extends App {\n  val in = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  def nextInt = in.nextInt\n  def nextLong = in.nextLong\n  def nextDouble = in.nextDouble\n  def nextString = in.next\n\n  def solve() = {\n    val k = nextInt\n    var r1 = \"+------------------------+\"\n    var r2 = \"|#.#.#.#.#.#.#.#.#.#.#.|D|)\"\n    var r3 = \"|#.#.#.#.#.#.#.#.#.#.#.|.|\"\n    var r4 = \"|#.......................|\"\n    var r5 = \"|#.#.#.#.#.#.#.#.#.#.#.|.|)\"\n    var r6 = \"+------------------------+\"\n\n    if (k >= 1) {\n      r2 = r2.updated(1, 'O')\n    }\n    if (k >= 2) {\n      r3 = r3.updated(1, 'O')\n    }\n    if (k >= 3) {\n      r4 = r4.updated(1, 'O')\n    }\n    if (k >= 4) {\n      r5 = r5.updated(1, 'O')\n    }\n    if (k >= 5) {\n      val m = (k - 4) / 3\n      for (i <- 0 until m) {\n        r2 = r2.updated((i + 1) * 2 + 1, 'O')\n        r3 = r3.updated((i + 1) * 2 + 1, 'O')\n        r5 = r5.updated((i + 1) * 2 + 1, 'O')\n      }\n      val t = (k - 4) % 3\n      if (t >= 1) {\n       r2 = r2.updated(2 * m + 3, 'O')\n      }\n      if (t >= 2) {\n        r3 = r3.updated(2 * m + 3, 'O')\n      }\n    }\n\n    out.println(r1)\n    out.println(r2)\n    out.println(r3)\n    out.println(r4)\n    out.println(r5)\n    out.println(r6)\n\n  }\n\n  try {\n    solve()\n  } catch {\n    case _: Exception => sys.exit(9999)\n  } finally {\n    out.flush()\n    out.close()\n  }\n}"}], "negative_code": [{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  var n = in.next().toInt\n  val left = if (n == 0) 0\n    else if (n < 5) 1\n    else 1 + ((n - 5) / 3 + 1)\n  val middleleft = if (n < 2) 0\n    else if (n < 6) 1\n    else 1 + ((n - 6) / 3 + 1)\n  val middleright = if (n < 3) 0 else 1\n  val right = if (n < 4) 0\n    else if (n < 7) 1\n  else 1 + ((n - 7) / 3 + 1)\n  println(\"|+------------------------+\")\n  println(\"||\" + (\"0.\" * left) + (\"#.\" * (11 - left)) + \"|D|)\")\n  println(\"||\" + (\"0.\" * middleleft) + (\"#.\" * (11 - middleleft)) + \"|.|)\")\n  println(\"||\" + (\"0.\" * middleright) + (\"..\" * (11 - middleright)) + \"..|\")\n  println(\"||\" + (\"0.\" * right) + (\"#.\" * (11 - right)) + \"|.|)\")\n  println(\"|+------------------------+\")\n\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  var n = in.next().toInt\n  val left = if (n == 0) 0\n    else if (n < 5) 1\n    else 1 + ((n - 5) / 3 + 1)\n  val middleleft = if (n < 2) 0\n    else if (n < 6) 1\n    else 1 + ((n - 6) / 3 + 1)\n  val middleright = if (n < 3) 0 else 1\n  val right = if (n < 4) 0\n    else if (n < 7) 1\n  else 1 + ((n - 7) / 3 + 1)\n  println(\"|+------------------------+\")\n  println(\"||\" + (\"O.\" * left) + (\"#.\" * (11 - left)) + \"|D|)\")\n  println(\"||\" + (\"O.\" * middleleft) + (\"#.\" * (11 - middleleft)) + \"|.|)\")\n  println(\"||\" + (\"O.\" * middleright) + (\"..\" * (11 - middleright)) + \"..|\")\n  println(\"||\" + (\"O.\" * right) + (\"#.\" * (11 - right)) + \"|.|)\")\n  println(\"|+------------------------+\")\n\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  var n = in.next().toInt\n  val left = if (n == 0) 0\n    else if (n < 5) 1\n    else 1 + ((n - 5) / 3 + 1)\n  val middleleft = if (n < 2) 0\n    else if (n < 6) 1\n    else 1 + ((n - 6) / 3 + 1)\n  val middleright = if (n < 3) 0 else 1\n  val right = if (n < 4) 0\n    else if (n < 7) 1\n  else 1 + ((n - 7) / 3 + 1)\n  println(\"|+------------------------+\")\n  println(\"||\" + (\"O.\" * left) + (\"#.\" * (11 - left)) + \"|D|)\")\n  println(\"||\" + (\"O.\" * middleleft) + (\"#.\" * (11 - middleleft)) + \"|.|\")\n  println(\"||\" + (\"O.\" * middleright) + (\"..\" * (11 - middleright)) + \"..|\")\n  println(\"||\" + (\"O.\" * right) + (\"#.\" * (11 - right)) + \"|.|)\")\n  println(\"|+------------------------+\")\n\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  var n = in.next().toInt\n  val left = if (n == 0) 0\n    else if (n < 5) 1\n    else 1 + ((n - 5) / 3 + 1)\n  val middleleft = if (n < 2) 0\n    else if (n < 6) 1\n    else 1 + ((n - 6) / 3 + 1)\n  val middleright = if (n < 3) 0 else 1\n  val right = if (n < 4) 0\n    else if (n < 7) 1\n  else 1 + ((n - 7) / 3 + 1)\n  println(\"+------------------------+\")\n  println(\"|\" + (\"O.\" * left) + (\"#.\" * (11 - left)) + \"|D|)\")\n  println(\"|\" + (\"O.\" * middleleft) + (\"#.\" * (11 - middleleft)) + \"|.|\")\n  println(\"|\" + (if (middleright == 0) \"#.\" else \"O.\") + (\"..\" * (11 - middleright)) + \"..|\")\n  println(\"|\" + (\"O.\" * right) + (\"#.\" * (11 - right)) + \"|.|)\")\n  println(\"+------------------------+\")\n\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  var n = in.next().toInt\n  val left = if (n == 0) 0\n    else if (n < 5) 1\n    else 1 + ((n - 5) / 3 + 1)\n  val middleleft = if (n < 2) 0\n    else if (n < 6) 1\n    else 1 + ((n - 6) / 3 + 1)\n  val middleright = if (n < 3) 0 else 1\n  val right = if (n < 4) 0\n    else if (n < 7) 1\n  else 1 + ((n - 7) / 3 + 1)\n  println(\"+------------------------+\")\n  println(\"|\" + (\"O.\" * left) + (\"#.\" * (11 - left)) + \"|D|)\")\n  println(\"|\" + (\"O.\" * middleleft) + (\"#.\" * (11 - middleleft)) + \"|.|\")\n  println(\"|\" + (if (middleright == 0) \"#.\" else \"O.\") + (\"..\" * (10 - middleright)) + \"..|\")\n  println(\"|\" + (\"O.\" * right) + (\"#.\" * (11 - right)) + \"|.|)\")\n  println(\"+------------------------+\")\n\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  var n = in.next().toInt\n  val left = if (n == 0) 0\n    else if (n < 5) 1\n    else 1 + ((n - 5) / 3 + 1)\n  val middleleft = if (n < 2) 0\n    else if (n < 6) 1\n    else 1 + ((n - 6) / 3 + 1)\n  val middleright = if (n < 3) 0 else 1\n  val right = if (n < 4) 0\n    else if (n < 7) 1\n  else 1 + ((n - 7) / 3 + 1)\n  println(\"+------------------------+\")\n  println(\"|\" + (\"O.\" * left) + (\"#.\" * (11 - left)) + \"|D|)\")\n  println(\"|\" + (\"O.\" * middleleft) + (\"#.\" * (11 - middleleft)) + \"|.|\")\n  println(\"|\" + (\"O.\" * middleright) + (\"..\" * (11 - middleright)) + \"..|\")\n  println(\"|\" + (\"O.\" * right) + (\"#.\" * (11 - right)) + \"|.|)\")\n  println(\"+------------------------+\")\n\n}"}], "src_uid": "075f83248f6d4d012e0ca1547fc67993"}
{"source_code": "import scala.io.StdIn\n\nobject DW extends App {\n\n  val required = StdIn.readLine().toCharArray.map {\n    case '+' => 1\n    case '-' => -1\n  }.sum\n  val (actual, uncertain) = StdIn.readLine().toCharArray.map {\n    case '+' => (1, 0)\n    case '-' => (-1, 0)\n    case '?' => (0, 1)\n  }.fold(0,0) {\n    case ((a1, b1), (a2, b2)) => (a1 + a2, b1 + b2)\n  }\n  val miss = math.abs(required - actual)\n  if (\n    required > (actual + uncertain) ||\n    required < (actual - uncertain) ||\n    miss == 0 && uncertain % 2 != 0\n  ) println(0.0d)\n  else {\n\n    val pluses = miss + (uncertain - miss) / 2\n    println(\n      math.pow(0.5f, uncertain) * factorial(uncertain) / (factorial(pluses) * factorial(math.abs(uncertain - pluses)))\n    )\n  }\n\n  def factorial(n: Int): Int = {\n    var res = 1\n    for (i  <- 1 to n) {\n      res *= i\n    }\n    res\n  }\n}", "positive_code": [{"source_code": "import scala.io.StdIn._\n\nobject Wifi\n{\n\tvar original, total, correct: Int = 0\n\t\n\tdef main(args: Array[String])\n\t{\n\t\tval a, b = readLine\n\t\t\n\t\tfor (c <- a) c match\n\t\t{\n\t\t\tcase '+' => original += 1\n\t\t\tcase '-' => original -= 1\n\t\t}\n\t\t\n\t\tparse(b, 0)\n\t\tprintf(\"%1$.12f\", correct.toDouble / total)\n\t}\n\t\n\tdef parse(str: String, _pos: Int)\n\t{\n\t\tif (str isEmpty)\n\t\t{\n\t\t\tif (_pos == original) correct += 1\n\t\t\ttotal += 1\n\t\t\treturn\n\t\t}\n\t\tvar pos = _pos\n\t\t\n\t\tfor (i <- 0 until str.size) str(i) match\n\t\t{\n\t\t\tcase '+' => pos += 1\n\t\t\tcase '-' => pos -= 1\n\t\t\tcase '?' => {\n\t\t\t\t\t\t\tparse(str.substring(i + 1), pos + 1)\n\t\t\t\t\t\t\tparse(str.substring(i + 1), pos - 1)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t}\n\t\t\n\t\tif (pos == original) correct += 1\n\t\ttotal += 1\n\t}\n}"}, {"source_code": "object B476 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val s1 = scala.io.StdIn.readLine\n    val s2 = scala.io.StdIn.readLine\n    val total = math.pow(2.0, s2.count(_ == '?'))\n    val count = gen(0, s2.toCharArray, calc(s1.toCharArray))\n    println(count.toDouble/total)\n  }\n\n  def calc(str: Array[Char]): Int = {\n    val ret = str.foldLeft(0) { case (sum, ch) =>\n      if(ch == '+') {\n        sum + 1\n      } else {\n        sum - 1\n      }\n    }\n    ret\n  }\n\n  def gen(ind: Int, str: Array[Char], finalPos: Int): Int = {\n    if(ind == str.length) {\n      if(calc(str) == finalPos) 1 else 0\n    } else if (str(ind) != '?'){\n      gen(ind + 1, str, finalPos)\n    } else {\n      var score = 0\n\n      str(ind) = '+'\n      score = gen(ind + 1, str, finalPos)\n\n      str(ind) = '-'\n      score += gen(ind + 1, str, finalPos)\n\n      str(ind) = '?'\n\n      score\n    }\n  }\n}"}, {"source_code": "object Main extends App {\n  def step(acc: Array[Int], op: Char): Array[Int] = \n    if (op == '+') acc.map(_ + 1)\n    else if (op == '-') acc.map(_ - 1)\n    else acc.flatMap(x => Array(x - 1, x + 1))\n    \n  val orig = readLine\n  val endPos = orig.foldLeft(Array(0))(step)(0)\n  \n  val recieved = readLine\n  val sampleSpace = recieved.foldLeft(Array(0))(step)\n  \n  println(sampleSpace.count(_ == endPos) / sampleSpace.size.toDouble)\n}"}], "negative_code": [{"source_code": "object B476 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val s1 = scala.io.StdIn.readLine\n    val s2 = scala.io.StdIn.readLine\n    val total = s2.count(_ == '?').toDouble\n    if(total == 0) {\n      println(1.0d)\n    } else {\n      val count = gen(0, s2.toCharArray, calc(s1.toCharArray))\n      println(count.toDouble/total)\n    }\n  }\n\n  def calc(str: Array[Char]): Int = {\n    str.foldLeft(0) { case (sum, ch) =>\n      if(ch == '+') {\n        sum + 1\n      } else {\n        sum - 1\n      }\n    }\n  }\n\n  def gen(ind: Int, str: Array[Char], finalPos: Int): Int = {\n    if(ind == str.length) {\n      if(calc(str) == finalPos) 1 else 0\n    } else if (str(ind) != '?'){\n      gen(ind + 1, str, finalPos)\n    } else {\n      var score = 0\n\n      str(ind) = '+'\n      score = gen(ind + 1, str, finalPos)\n\n      str(ind) = '-'\n      score += gen(ind + 1, str, finalPos)\n\n      score\n    }\n  }\n}"}, {"source_code": "object B476 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val s1 = scala.io.StdIn.readLine\n    val s2 = scala.io.StdIn.readLine\n    val total = math.pow(2.0, s2.count(_ == '?'))\n    val count = gen(0, s2.toCharArray, calc(s1.toCharArray))\n    println(count.toDouble/total)\n  }\n\n  def calc(str: Array[Char]): Int = {\n    str.foldLeft(0) { case (sum, ch) =>\n      if(ch == '+') {\n        sum + 1\n      } else {\n        sum - 1\n      }\n    }\n  }\n\n  def gen(ind: Int, str: Array[Char], finalPos: Int): Int = {\n    if(ind == str.length) {\n      if(calc(str) == finalPos) 1 else 0\n    } else if (str(ind) != '?'){\n      gen(ind + 1, str, finalPos)\n    } else {\n      var score = 0\n\n      str(ind) = '+'\n      score = gen(ind + 1, str, finalPos)\n\n      str(ind) = '-'\n      score += gen(ind + 1, str, finalPos)\n\n      score\n    }\n  }\n}"}], "src_uid": "f7f68a15cfd33f641132fac265bc5299"}
{"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val Array(day, of, period) = in.next().split(' ')\n  val d = day.toInt\n  if (period == \"week\") {\n    d match {\n      case 6 => println(53)\n      case 5 => println(53)\n      case _ => println(52)\n    }\n  } else {\n    d match {\n      case 31 => println(7)\n      case 30 => println(11)\n      case _ => println(12)\n    }\n  }\n}", "positive_code": [{"source_code": "import scala.math._\nimport scala.collection.immutable.Range\nimport scala.io.Source\n\nobject a8 {\n  def main(args: Array[String]): Unit = {\n    val a = Array.iterate(4,366)(a=>(a + 1)%7).map(_+1)\n    val b = Array(31,29,31,30,31,30,31,31,30,31,30,31).map(a=>(1 to a ).toArray)\n    val line = Source.stdin.getLines().toArray.head.split(' ')\n    val x = line(0).toInt\n    println(line(2) match {\n      case  \"week\" => a.count(_ == x)\n      case \"month\" => b.map(_.count(_ == x)).sum\n    })\n    //a.foreach(println)\n  }\n\n}\n"}, {"source_code": "object A611 {\n  @inline def read = scala.io.StdIn.readLine\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val t1 = tokenizeLine\n    val input = Array.fill(3)(t1.nextToken)\n    if(input.contains(\"week\")) {\n      val day = input(0).toInt\n      if(Array(1,2,3,4,7).contains(day))\n        println(\"52\")\n      else\n        println(\"53\")\n    } else {\n      val day = input(0).toInt\n      if(day <= 29) {\n        println(\"12\")\n      } else if (day == 30) {\n        println(\"11\")\n      } else {\n        println(\"7\")\n      }\n    }\n  }\n}"}, {"source_code": "import scala.collection._\n\nobject A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val ss = readLine.split(\" \")\n\n  val n = ss(0).toInt\n  if (ss(2) == \"week\") {\n    val w = Seq(0, 52, 52, 52, 52, 53, 53, 52)\n    println(w(n))\n  } else {\n    val x = if (n <= 29) 12 \n    else if (n <= 30) 11\n    else 7\n    println(x)\n  }\n}\n"}, {"source_code": "\n/**\n * @author pvasilyev\n * @since 05 May 2016\n */\nobject A611 extends App {\n\n  val Array(x, y, z) = scala.io.StdIn.readLine().split(\" \")\n  val n = x.toInt\n  var answer = 0\n  if (\"month\".equals(z)) {\n    if (n < 30) {\n      answer = 12\n    } else if (n == 30) {\n      answer = 11\n    } else {\n      answer = 7\n    }\n  } else {\n    if (n == 5 || n == 6) {\n      answer = 53\n    } else {\n      answer = 52\n    }\n  }\n\n  println(answer)\n\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject Main{\n  def main (args: Array[String]){\n    val sc = new Scanner(System.in)\n    val n = sc.nextInt()\n    val of = sc.next()\n    val span = sc.next()\n\n    if(span == \"week\"){\n      if(n == 7)\n        println(52)\n      else if(n >= 5)\n        println(53)\n      else\n        println(52)\n    }\n    else if(span == \"month\"){\n      if(n <= 29)\n        println(12)\n      else if(n == 30)\n        println(11)\n      else  // n == 31\n        println(7)\n    }\n  }\n}\n"}], "negative_code": [{"source_code": "import scala.math._\nimport scala.collection.immutable.Range\nimport scala.io.Source\n\nobject a8 {\n  def main(args: Array[String]): Unit = {\n    val a = Array.iterate(4,365)(a=>(a + 1)%7).map(_+1)\n    val b = Array(31,28,31,30,31,30,31,31,30,31,30,31).map(a=>(1 to a ).toArray)\n    val line = Source.stdin.getLines().toArray.head.split(' ')\n    val x = line(0).toInt\n    println(line(2) match {\n      case  \"week\" => a.count(_ == x)\n      case \"month\" => b.map(_.count(_ == x)).sum\n    })\n    //b.foreach(println)\n  }\n\n}\n"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val Array(day, of, period) = in.next().split(' ')\n  val d = day.toInt\n  if (period == \"week\") {\n    d match {\n      case 6 => println(53)\n      case 5 => println(53)\n      case _ => println(52)\n    }\n  } else {\n    d match {\n      case 31 => println(7)\n      case 30 => println(11)\n      case 29 => println(11)\n      case _ => println(12)\n    }\n  }\n}"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val Array(day, of, period) = in.next().split(' ')\n  val d = day.toInt\n  if (period == \"week\") {\n    d match {\n      case 7 => println(53)\n      case 6 => println(53)\n      case _ => println(52)\n    }\n  } else {\n    d match {\n      case 31 => println(7)\n      case 30 => println(11)\n      case 29 => println(11)\n      case _ => println(12)\n    }\n  }\n}"}, {"source_code": "import java.util.Scanner\n\nobject Main{\n  def main (args: Array[String]){\n    val sc = new Scanner(System.in)\n    val n = sc.nextInt()\n    val of = sc.next()\n    val span = sc.next()\n\n    if(span == \"week\"){\n      if(n >= 5)\n        println(53)\n      else\n        println(52)\n    }\n    else if(span == \"month\"){\n      if(n <= 29)\n        println(12)\n      else if(n == 30)\n        println(11)\n      else  // n == 31\n        println(7)\n    }\n  }\n}\n"}], "src_uid": "9b8543c1ae3666e6c163d268fdbeef6b"}
{"source_code": "import scala.io.StdIn._\nobject B extends App{\n  val Array(n,m) = readLine().split(\" \").map(_.toLong)\n  if (2*m-1 >= n){\n    println(Math.max(m-1,1))\n  }else{\n    println(Math.min(n,m+1))\n  }\n}\n", "positive_code": [{"source_code": "\nimport scala.io.StdIn.readLine\nimport scala.io.StdIn.readInt\n\n\nobject SimpleGame {\n  \n   def readInts() : Array[Int] =\n     readLine.split(' ').map(_.toInt)\n   \n   def readTuple() : (Int,Int) = {\n     val line = readInts\n     (line(0),line(1))\n   }\n   def readTriple() : (Int,Int,Int) = {\n     val line = readInts\n     (line(0),line(1),line(2))\n   }\n     \n  \n   def main(args: Array[String]) {\n     val (n,m) = readTuple()\n     if (m <= n/2) println(Math.min(m+1,n)) else println(Math.max(m-1,1))\n   }\n  \n}"}, {"source_code": "object B570 {\n\n  import IO._\n\n  def main(args: Array[String]): Unit = {\n    val Array(n, m) = readInts(2)\n    var maxAndrew = 0\n    var res = n-m+1\n    Array(m+1, m-1).foreach{\n      case a if a > 0 && a <= n =>\n        var andrew = 0\n        if(a == m+1) {\n          andrew = n - m - 1\n        } else {\n          andrew = m-1\n        }\n        if(andrew > maxAndrew) {\n          maxAndrew = andrew\n          res = a\n        }\n      case _ =>\n    }\n    println(res)\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "import java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject B {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  /**\n   * Segment tree for any commutative function\n   * @param values Array of Int\n   * @param commutative function like min, max, sum\n   * @param zero zero value - e.g. 0 for sum, Inf for min, max\n   */\n  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {\n    private val SIZE = 1e5.toInt\n    private val n = values.length\n    val t = new Array[Int](2 * n)\n    Array.copy(values, 0, t, n, n)\n\n    // build segment tree\n    def build = {\n      for (i <- n - 1 until 0 by -1) {\n        t(i) = commutative(t(2 * i), t(2 * i + 1))\n      }\n    }\n\n    // change value at position p to x\n    // TODO beatify\n    def modify(p: Int, x: Int) = {\n      var pos = p + n\n      t(pos) = x\n      while (pos > 1) {\n        t(pos / 2) = commutative(t(pos), t(pos ^ 1))\n        pos /= 2\n      }\n    }\n\n    // TODO implement me!\n    def modify(p: Int, left: Int, right: Int) = ???\n\n    def query(p: Int) = ???\n\n    // sum [l, r)\n    // min l = 0\n    // max r = n\n    // TODO beatify\n    def query(left: Int, right: Int): Int = {\n      var res = zero\n      var r = right + n\n      var l = left + n\n      while (l < r) {\n        if (l % 2 == 1) {\n          res = commutative(res, t(l))\n          l += 1\n        }\n        if (r % 2 == 1) {\n          r -= 1\n          res = commutative(res, t(r))\n        }\n        l /= 2\n        r /= 2\n      }\n      res\n    }\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val m = nextInt\n    if (n == 1) {\n      out.println(1)\n      return 0\n    }\n    val abs = n - m\n    if (abs > m) {\n      out.println(m + 1)\n    } else if (abs < m){\n      out.println(m - 1)\n    } else {\n      out.println(m + 1)\n    }\n    return 0\n  }\n}\n"}, {"source_code": "import io.StdIn._\nimport scala.collection.mutable\nimport scala.collection.mutable._\n\nobject Solution {\n\n  def main(args: Array[String]) {\n    val Array(n, m) = readLine().split(\" \").map(_.toInt)\n\n    println (if (m <= n/2) Math.min(n,m+1) else Math.max(1,m-1))\n  }\n}\n"}, {"source_code": "import annotation.tailrec, collection.mutable, util._, control.Breaks._, math.Ordering.Implicits._\nimport CodeForcesApp._\nobject _570B extends CodeForcesApp[Int]({scanner => import scanner._\n  val (n, m) = (nextInt, nextInt)\n  (n, m) match {\n    case (1, _) => 1\n    case (_, 1) => 2\n    case (_, `n`) => n-1\n    case _  => m + (if (m <= n / 2) 1 else -1)\n  }\n})\nimport java.util.Scanner\nabstract class CodeForcesApp[A](solver: Scanner => A) {\n  final def apply(problem: String): String = apply(new Scanner(problem))\n  final def apply(scanner: Scanner): String = format(solver(scanner))\n  def format(result: A): String = result.toString\n  final def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))\n}\nobject CodeForcesApp {\n  import scala.collection.mutable.{Map => Dict}\n  final val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  final def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  final val modulus: Int = 1000000007\n  final val eps: Double = 1e-9\n  final def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None\n  final def repeat[A](n: Int)(f: => A): Seq[A] = 1 to n map {_ => f}\n  final def newCounter[A]: Dict[A, Int] = Dict.empty[A, Int] withDefaultValue 0\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject SomeTest extends App {\n  val Array(n, m) = readLine().split(\" \").map(_.toLong)\n\n  if (n == 1) println(1)\n  else if (n - m > m - 1) {\n    println(m + 1)\n  } else {\n    println(m - 1)\n  }\n}"}], "negative_code": [{"source_code": "import scala.io.StdIn._\nobject B extends App{\n  val Array(n,m) = readLine().split(\" \").map(_.toInt)\n  if (2*m-1 >= n){\n    println(m-1)\n  }else{\n    println(m+1)\n  }\n}\n"}, {"source_code": "import scala.io.StdIn._\nobject B extends App{\n  val Array(n,m) = readLine().split(\" \").map(_.toLong)\n  if (2*m-1 >= n){\n    println(m-1)\n  }else{\n    println(m+1)\n  }\n}\n"}, {"source_code": "import scala.io.StdIn._\nobject B extends App{\n  val Array(n,m) = readLine().split(\" \").map(_.toLong)\n  if (2*m-1 >= n){\n    println(Math.max(m-1,0))\n  }else{\n    println(Math.min(n,m+1))\n  }\n}\n"}, {"source_code": "import scala.io.StdIn._\nobject B extends App{\n  val Array(n,m) = readLine().split(\" \").map(_.toInt)\n  if (2*m-1 <= n){\n    println(m+1)\n  }else{\n    println(m-1)\n  }\n}\n"}, {"source_code": "object B570 {\n\n  import IO._\n\n  def main(args: Array[String]): Unit = {\n    val Array(n, m) = readInts(2)\n    var maxAndrew = 0\n    var res = 0\n    Array(m+1, m-1).foreach{\n      case a if a > 1 && a <= n =>\n        var andrew = 0\n        if(a == m+1) {\n          andrew = n - (m+1)\n        } else {\n          andrew = m-1\n        }\n        if(andrew > maxAndrew) {\n          maxAndrew = andrew\n          res = a\n        }\n      case _ =>\n    }\n    println(res)\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "object B570 {\n\n  import IO._\n\n  def main(args: Array[String]): Unit = {\n    val Array(n, m) = readInts(2)\n    var maxAndrew = 0\n    var res = 1\n    Array(m+1, m-1).foreach{\n      case a if a > 0 && a <= n =>\n        var andrew = 0\n        if(a == m+1) {\n          andrew = n - m\n        } else {\n          andrew = a\n        }\n        if(andrew > maxAndrew) {\n          maxAndrew = andrew\n          res = a\n        }\n      case _ =>\n    }\n    println(res)\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "object B570 {\n\n  import IO._\n\n  def main(args: Array[String]): Unit = {\n    val Array(n, m) = readInts(2)\n    var maxAndrew = 0\n    var res = 1\n    Array(m+1, m-1).foreach{\n      case a if a > 1 && a <= n =>\n        var andrew = 0\n        if(a == m+1) {\n          andrew = n - (m+1)\n        } else {\n          andrew = m-1\n        }\n        if(andrew > maxAndrew) {\n          maxAndrew = andrew\n          res = a\n        }\n      case _ =>\n    }\n    println(res)\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "import java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject B {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  /**\n   * Segment tree for any commutative function\n   * @param values Array of Int\n   * @param commutative function like min, max, sum\n   * @param zero zero value - e.g. 0 for sum, Inf for min, max\n   */\n  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {\n    private val SIZE = 1e5.toInt\n    private val n = values.length\n    val t = new Array[Int](2 * n)\n    Array.copy(values, 0, t, n, n)\n\n    // build segment tree\n    def build = {\n      for (i <- n - 1 until 0 by -1) {\n        t(i) = commutative(t(2 * i), t(2 * i + 1))\n      }\n    }\n\n    // change value at position p to x\n    // TODO beatify\n    def modify(p: Int, x: Int) = {\n      var pos = p + n\n      t(pos) = x\n      while (pos > 1) {\n        t(pos / 2) = commutative(t(pos), t(pos ^ 1))\n        pos /= 2\n      }\n    }\n\n    // TODO implement me!\n    def modify(p: Int, left: Int, right: Int) = ???\n\n    def query(p: Int) = ???\n\n    // sum [l, r)\n    // min l = 0\n    // max r = n\n    // TODO beatify\n    def query(left: Int, right: Int): Int = {\n      var res = zero\n      var r = right + n\n      var l = left + n\n      while (l < r) {\n        if (l % 2 == 1) {\n          res = commutative(res, t(l))\n          l += 1\n        }\n        if (r % 2 == 1) {\n          r -= 1\n          res = commutative(res, t(r))\n        }\n        l /= 2\n        r /= 2\n      }\n      res\n    }\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val m = nextInt\n    if (n == 1) {\n      out.println(1)\n      return 0\n    }\n    val abs: Int = Math.abs(n - m)\n    if (abs > m) {\n      out.println(m + 1)\n    } else if (abs < m){\n      out.println(m - 1)\n    } else {\n      out.println(m - 1)\n    }\n    return 0\n  }\n}\n"}, {"source_code": "import java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject B {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  /**\n   * Segment tree for any commutative function\n   * @param values Array of Int\n   * @param commutative function like min, max, sum\n   * @param zero zero value - e.g. 0 for sum, Inf for min, max\n   */\n  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {\n    private val SIZE = 1e5.toInt\n    private val n = values.length\n    val t = new Array[Int](2 * n)\n    Array.copy(values, 0, t, n, n)\n\n    // build segment tree\n    def build = {\n      for (i <- n - 1 until 0 by -1) {\n        t(i) = commutative(t(2 * i), t(2 * i + 1))\n      }\n    }\n\n    // change value at position p to x\n    // TODO beatify\n    def modify(p: Int, x: Int) = {\n      var pos = p + n\n      t(pos) = x\n      while (pos > 1) {\n        t(pos / 2) = commutative(t(pos), t(pos ^ 1))\n        pos /= 2\n      }\n    }\n\n    // TODO implement me!\n    def modify(p: Int, left: Int, right: Int) = ???\n\n    def query(p: Int) = ???\n\n    // sum [l, r)\n    // min l = 0\n    // max r = n\n    // TODO beatify\n    def query(left: Int, right: Int): Int = {\n      var res = zero\n      var r = right + n\n      var l = left + n\n      while (l < r) {\n        if (l % 2 == 1) {\n          res = commutative(res, t(l))\n          l += 1\n        }\n        if (r % 2 == 1) {\n          r -= 1\n          res = commutative(res, t(r))\n        }\n        l /= 2\n        r /= 2\n      }\n      res\n    }\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val m = nextInt\n    if (n == 1) {\n      out.println(1)\n      return 0\n    }\n    val mid = n / 2 + n % 2\n    if (m > mid) {\n      out.println(mid)\n    } else if (m < mid) {\n      out.println(m + 1)\n    } else {\n      out.println(m - 1)\n    }\n    return 0\n  }\n}\n"}, {"source_code": "import io.StdIn._\nimport scala.collection.mutable\nimport scala.collection.mutable._\n\nobject Solution {\n\n  def main(args: Array[String]) {\n    val Array(n, m) = readLine().split(\" \").map(_.toInt)\n\n    println (if (m < (n+1)/2) m+1 else m-1)\n  }\n}\n"}, {"source_code": "import io.StdIn._\nimport scala.collection.mutable\nimport scala.collection.mutable._\n\nobject Solution {\n\n  def main(args: Array[String]) {\n    val Array(n, m) = readLine().split(\" \").map(_.toInt)\n\n    println (if (m <= n/2) m+1 else m-1)\n  }\n}\n"}, {"source_code": "import annotation.tailrec, collection.mutable, util._, control.Breaks._, math.Ordering.Implicits._\nimport CodeForcesApp._\nobject _570B extends CodeForcesApp[Int]({scanner => import scanner._\n  val (n, m) = (nextInt, nextInt)\n  if (m < n/2) {\n    m+1\n  } else if (m > n/2) {\n    m-1\n  } else {\n    if (n%2 == 1) m+1 else m-1\n  }\n})\nimport java.util.Scanner\nabstract class CodeForcesApp[A](solver: Scanner => A) {\n  final def apply(problem: String): String = apply(new Scanner(problem))\n  final def apply(scanner: Scanner): String = format(solver(scanner))\n  def format(result: A): String = result.toString\n  final def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))\n}\nobject CodeForcesApp {\n  import scala.collection.mutable.{Map => Dict}\n  final val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  final def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  final val modulus: Int = 1000000007\n  final val eps: Double = 1e-9\n  final def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None\n  final def repeat[A](n: Int)(f: => A): Seq[A] = 1 to n map {_ => f}\n  final def newCounter[A]: Dict[A, Int] = Dict.empty[A, Int] withDefaultValue 0\n}\n"}, {"source_code": "import annotation.tailrec, collection.mutable, util._, control.Breaks._, math.Ordering.Implicits._\nimport CodeForcesApp._\nobject _570B extends CodeForcesApp[Int]({scanner => import scanner._\n  val (n, m) = (nextInt, nextInt)\n  (n, m) match {\n    case (1, _) => 1\n    case (2, 1) => 2\n    case (2, 2) => 1\n    case (3, 1) => 2\n    case (3, 2) => 1\n    case (3, 3) => 1\n    case _ if m <= n/2 => m+1\n    case _ if m > n/2 => m-1\n  }\n})\nimport java.util.Scanner\nabstract class CodeForcesApp[A](solver: Scanner => A) {\n  final def apply(problem: String): String = apply(new Scanner(problem))\n  final def apply(scanner: Scanner): String = format(solver(scanner))\n  def format(result: A): String = result.toString\n  final def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))\n}\nobject CodeForcesApp {\n  import scala.collection.mutable.{Map => Dict}\n  final val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  final def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  final val modulus: Int = 1000000007\n  final val eps: Double = 1e-9\n  final def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None\n  final def repeat[A](n: Int)(f: => A): Seq[A] = 1 to n map {_ => f}\n  final def newCounter[A]: Dict[A, Int] = Dict.empty[A, Int] withDefaultValue 0\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject B extends App {\n  val Array(n, m) = readLine().split(\" \").map(_.toLong)\n  val Half = Math.ceil(n / 2.0).toLong\n\n  if (m >= Half) {\n    println(m - 1)\n  } else {\n    println(m + 1)\n  }\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject B extends App {\n  val Array(n, m) = readLine().split(\" \").map(_.toLong)\n  val Half = Math.ceil(n / 2.0)\n\n  if (m >= Half) {\n    println(m - 1)\n  } else if (m < Half) {\n    println(m + 1)\n  }\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject B extends App {\n  val Array(n, m) = readLine().split(\" \").map(_.toLong)\n  val Half = Math.ceil(n / 2.0)\n\n  if (n == 1) println(1)\n  else if (m >= Half) {\n    println(m - 1)\n  } else if (m < Half) {\n    println(m + 1)\n  }\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject B extends App {\n  val Array(n, m) = readLine().split(\" \").map(_.toLong)\n  val Half = Math.ceil(n / 2.0).toInt\n\n  if (m >= Half) {\n    println(m - 1)\n  } else {\n    println(m + 1)\n  }\n}\n"}, {"source_code": "\nimport scala.io.StdIn.readLine\nimport scala.io.StdIn.readInt\n\n\nobject SimpleGame {\n  \n   def readInts() : Array[Int] =\n     readLine.split(' ').map(_.toInt)\n   \n   def readTuple() : (Int,Int) = {\n     val line = readInts\n     (line(0),line(1))\n   }\n   def readTriple() : (Int,Int,Int) = {\n     val line = readInts\n     (line(0),line(1),line(2))\n   }\n     \n  \n   def main(args: Array[String]) {\n     val (n,m) = readTuple()\n     if (m <= n/2) println(m+1) else println(m-1)\n   }\n  \n}"}], "src_uid": "f6a80c0f474cae1e201032e1df10e9f7"}
{"source_code": "\nimport java.util._\nimport java.io._\nimport java.util\nimport scala.annotation.tailrec\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n  var ans = 0\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val m = nextInt\n    val a = nextInt\n    val b = nextInt\n    var min = Int.MaxValue\n    for (i <- 0 to n / m + 1) {\n      var temp = i * b\n      val x: Int = n - (i * m)\n      if ( x > 0) {\n        temp += x * a\n      }\n      min = Math.min(min, temp)\n    }\n    out.println(min)\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n", "positive_code": [{"source_code": "\n\nobject CheapTravel {\n\tdef main (args: Array[String]) {\n\t\t//Parsing the input\n\t\tval scanner = new java.util.Scanner(System.in);\n\t\tval n = scanner.nextInt();\n\t\tval m = scanner.nextInt();\n\t\tval a = scanner.nextInt();\n\t\tval b = scanner.nextInt();\n\t\t// Check whether it is cheaper to buy m-rides tickets\n\t\tif (a*m >= b) {\n\t\t  val lastTicket = if ((n%m * a) < b) n%m*a else b\n\t\t\tprintln(n / m * b + lastTicket)\n\t\t}\n\t\telse\n\t\t\tprintln(n * a)\n\t}\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]) = {\n    val cin = new java.util.Scanner(System.in)\n    val n = cin.nextInt()\n    val m = cin.nextInt()\n    val a = cin.nextInt()\n    val b = cin.nextInt()\n    println(Math.min(Math.min(n * a, (n / m) * b + (n % m) * a), ((n + m - 1) / m) * b))\n  }\n}\n"}, {"source_code": "//package xubiker.archive\n  \nimport java.util.Scanner\n\nobject Task_466A extends App {\n\n  val sc = new Scanner(System.in)\n\n  val n = sc.nextInt()\n  val m = sc.nextInt()\n  val a = sc.nextInt()\n  val b = sc.nextInt()\n\n  sc.close()\n\n  val price1 = (Math.ceil(n.toDouble / m) * b).toInt\n  val price2 = a * n\n  val price3 = (n / m) * b + (n % m) * a\n\n  val price = price1.min(price2.min(price3))\n  println(price)\n\n}\n"}, {"source_code": "\nimport scala.io.StdIn.readLine\nimport scala.io.StdIn.readInt\n\n\nobject CheapTravel {\n  \n   def readInts() : Array[Int] =\n     readLine.split(' ').map(_.toInt)\n   \n   def readLongs() : Array[Long] = \n      readLine.split(' ').map(_.toLong)\n   \n   def readTuple() : (Int,Int) = {\n     val line = readInts\n     (line(0),line(1))\n   }\n   def readTupleLong() : (Long,Long) = {\n     val line = readLongs\n     (line(0),line(1))\n   }\n   \n   def readTriple() : (Int,Int,Int) = {\n     val line = readInts\n     (line(0),line(1),line(2))\n   }\n   def readQuad() : (Int,Int,Int,Int) = {\n     val line = readInts\n     (line(0),line(1),line(2),line(3))\n   }\n   \n   \n                 \n   def main(args: Array[String]) {\n     val (n,m,a,b) = readQuad()\n     val pricePerRide = b.toDouble/m\n     if (pricePerRide >= a) println(a*n) // always by single tickets\n     else {       \n       val priceRem = if ( (n%m)*a <= b) (n%m)*a else b\n       println( (n/m)*b + priceRem)\n     }\n   }\n  \n}"}, {"source_code": "object Main extends App {\n  val in = readLine\n  val Array(n, m, a, b) = in.split(\" \").map(_.toInt)\n  if (m * a <= b)\n    println(a * n)\n  else \n    println((n / m) * b + (if (n % m > 0) Math.min(b, n % m * a) else 0))\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject Main2 extends App {\n  val Array(ridesNumber, subscriptionRidesNumber, ridePrice, subscriptionPrice) = readLine().split(\" \").map(_.toInt)\n  val ans = if (subscriptionRidesNumber * ridePrice > subscriptionPrice) {\n    val priceWithGreedySubscriptions = (ridesNumber/subscriptionRidesNumber) * subscriptionPrice\n    val remainingRides = ridesNumber%subscriptionRidesNumber\n    if (remainingRides * ridePrice < subscriptionPrice) {\n      priceWithGreedySubscriptions + remainingRides * ridePrice\n    } else {\n      priceWithGreedySubscriptions + subscriptionPrice\n    }\n  } else {\n    ridesNumber * ridePrice\n  }\n  println(ans)\n}\n"}, {"source_code": "import scala.util.Sorting\nimport scala.io.StdIn\n\nobject App {\n\n\n  def main(args: Array[String]) {\n\n    val Array(n,m,a,b) = StdIn.readLine().split(\" \").map(_.toInt)\n\n\n\n    var ans = 10000000;\n    for(i <- 0 to 1000) {\n      ans = math.min(ans, b * i + math.max(n - m * i,0) * a)\n    }\n\n    println(ans)\n\n\n  }\n\n\n}\n"}, {"source_code": "object Main extends App {\n  val in = readLine\n  val Array(n, m, a, b) = in.split(\" \").map(_.toInt)\n  if (m * a <= b)\n    println(a * n)\n  else \n    println((n / m) * b + (if (n % m > 0) Math.min(b, n % m * a) else 0))\n}"}, {"source_code": "object Main {\n   def main(args: Array[String]): Unit = {\nval Array(n,m,a,b) = scala.io.StdIn.readLine().split(' ').map(_.toInt)\nprintln(scala.math.min(n/m*b+scala.math.min(n%m*a, b), n*a))\n      }\n    }"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val Array(n, m, a, b) = in.next().split(\" \").map(_.toInt)\n  if (m * a <= b)\n    println(a * n)\n  else {\n    println((n / m) * b + (if (n % m > 0) Math.min(b, n % m * a) else 0))\n  }\n\n}\n"}, {"source_code": "import scala.collection.JavaConversions._\n\n\nobject Codeforces466A {\n    def main(args: Array[String]) {\n        val Array(n, m, a, b) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n        if (b.toFloat/m > a) {\n            println(n*a)\n        }\n        else {\n            val x = n / m\n            val y = n % m\n            if (y > 0) {\n                if (y*a < b)\n                    println(x*b + y*a)\n                else\n                    println(x*b + b)\n            }\n            else\n                println(x*b)\n        }\n    }\n}"}, {"source_code": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn._\nimport scala.util.Sorting._\nimport scala.math._\nimport scala.collection._\nimport java.util._\n\nobject HelloWorld {\n  def main(args: Array[String]): Unit = {\n    val Array(n, m, a, b) = readLine.split(\" \").map(_.toInt)\n\n    var ans = Int.MaxValue\n    for(i <- 0 to n){\n      var by_one = i\n      var by_one_price = by_one * a\n\n      var remained_tickets = n - i\n      if(remained_tickets >= 0){\n        var by_m = (remained_tickets + (m - 1)) / m\n        var by_m_price = by_m * b\n\n        ans = Array(ans, by_one_price + by_m_price).min\n      }\n    }\n\n    println(ans)\n  }\n}"}, {"source_code": "object A466 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val Array(n, m, a, b) = readInts(4)\n\n    var res = n * a\n    res = math.min(res, b*(if(n%m == 0) n/m else n/m + 1) )\n    res = math.min(res, if(n%m == 0) b*(n/m) else b*(n/m) + a*(n%m))\n    println(res)\n  }\n}"}], "negative_code": [{"source_code": "object Main {\n   def main(args: Array[String]): Unit = {\nval Array(n,m,a,b) = scala.io.StdIn.readLine().split(' ').map(_.toInt)\nprintln(n/m*b+n%m*a)\n      }\n    }\n"}, {"source_code": "import scala.io.StdIn\n\nobject Task466A {\n\tdef main(args: Array[String]) {\n\t\tval nmab = StdIn.readLine().split(\" \").map(_.toInt)\n\t\tif (nmab(3).toDouble / nmab(1) < nmab(2))\n\t\t\tprintln(nmab(0) / nmab(1) * nmab(3) + Math.min(nmab(2), nmab(3)))\n\t\telse println(nmab(0) * nmab(2))\n\t}\n}\n"}, {"source_code": "import scala.io.StdIn\n\nobject Task466A {\n\tdef main(args: Array[String]) {\n\t\tval nmab = StdIn.readLine().split(\" \").map(_.toInt)\n\t\tif (nmab(3).toDouble / nmab(1) < nmab(2))\n\t\t\tprintln(nmab(0) / nmab(1) * nmab(3) + nmab(0) % nmab(1) * Math.min(nmab(2), nmab(3)))\n\t\telse println(nmab(0) * nmab(2))\n\t}\n}\n"}, {"source_code": "import scala.io.StdIn\n\nobject Task466A {\n\tdef main(args: Array[String]) {\n\t\tval nmab = StdIn.readLine().split(\" \").map(_.toInt)\n\t\tprintln(if (nmab(3).toDouble / nmab(1) < nmab(2))\n\t\t\tif (nmab(0).toDouble / nmab(1) < 1) nmab(3)\n\t\t\telse nmab(0) / nmab(1) * nmab(3) + nmab(0) % nmab(1) * Math.min(nmab(2), nmab(3))\n\t\telse nmab(0) * nmab(2))\n\t}\n}\n"}, {"source_code": "import scala.collection.JavaConversions._\n\n\nobject Codeforces468A {\n    def main(args: Array[String]) {\n        val Array(n, m, a, b) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n        if (m.toFloat/b > a) {\n            println(n*a)\n        }\n        else {\n            println((n/m)*b + (n%m)*a)\n        }\n    }\n}"}, {"source_code": "import scala.collection.JavaConversions._\n\n\nobject Codeforces466A {\n    def main(args: Array[String]) {\n        val Array(n, m, a, b) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n        if (m.toFloat/b > a) {\n            println(n*a)\n        }\n        else {\n            val x = n / m\n            val y = n % m\n            if (y*a < b)\n                println((n/m)*b + (n%m)*a)\n            else\n                println((n/m)*b + b)\n        }\n    }\n}"}, {"source_code": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn._\nimport scala.util.Sorting._\nimport scala.math._\nimport scala.collection._\nimport java.util._\n\nobject HelloWorld {\n  def main(args: Array[String]): Unit = {\n    val Array(n, m, a, b) = readLine.split(\" \").map(_.toInt)\n\n    var ans = Int.MaxValue\n    for(i <- 0 to n){\n      var by_one = i\n      var by_one_price = by_one * a\n\n      var remained_tickets = n - i\n      if(remained_tickets > 0){\n        var by_m = (remained_tickets + (m - 1)) / m\n        var by_m_price = by_m * b\n\n        ans = Array(ans, by_one_price + by_m_price).min\n      }\n    }\n\n    println(ans)\n  }\n}"}, {"source_code": "import java.util._\nimport java.io._\nimport java.util\nimport scala.annotation.tailrec\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n  var ans = 0\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val m = nextInt\n    val a = nextInt\n    val b = nextInt\n    var min = Int.MaxValue\n    for (i <- 0 to n / m) {\n      min = Math.min(min, i * b + (n - (i * m)) * a)\n    }\n    out.println(min)\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n"}, {"source_code": "\nimport java.util._\nimport java.io._\nimport java.util\nimport scala.annotation.tailrec\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n  var ans = 0\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    val m = nextInt\n    val a = nextInt\n    val b = nextInt\n    out.println(Math.min(n * a, (n / m) * b + (n % m) * a))\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n"}, {"source_code": "\n\nobject CheapTravel {\n\tdef main (args: Array[String]) {\n\t\t//Parsing the input\n\t\tval scanner = new java.util.Scanner(System.in);\n\t\tval n = scanner.nextInt();\n\t\tval m = scanner.nextInt();\n\t\tval a = scanner.nextInt();\n\t\tval b = scanner.nextInt();\n\t\t// Check whether it is cheaper to buy m-rides tickets\n\t\tif (a*m >= b) \n\t\t\tprintln(n / m * b + n%m * a)\n\t\t\telse\n\t\t\t\tprintln(n * a)\n\t}\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject Main2 extends App {\n  val Array(ridesNumber, subscriptionRidesNumber, ridePrice, subscriptionPrice) = readLine().split(\" \").map(_.toInt)\n  val ans = if (subscriptionRidesNumber * ridePrice > subscriptionPrice) {\n    val subscriptionsPrice = (ridesNumber/subscriptionRidesNumber) * subscriptionPrice\n    val remainingRides = (ridesNumber%subscriptionRidesNumber)\n    if (remainingRides * ridePrice < subscriptionsPrice) {\n      subscriptionsPrice + remainingRides * ridePrice\n    } else {\n      subscriptionsPrice + subscriptionPrice\n    }\n  } else {\n    ridesNumber * ridePrice\n  }\n  println(ans)\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject Main2 extends App {\n  val Array(ridesNumber, subscriptionRidesNumber, ridePrice, subscriptionPrice) = readLine().split(\" \").map(_.toInt)\n  val ans = if (subscriptionRidesNumber * ridePrice > subscriptionPrice) {\n    (ridesNumber/subscriptionRidesNumber) * subscriptionPrice + (ridesNumber%subscriptionRidesNumber) * ridePrice\n  } else {\n    ridesNumber * ridePrice\n  }\n  println(ans)\n}\n"}, {"source_code": "import scala.util.Sorting\nimport scala.io.StdIn\n\nobject App {\n\n\n  def main(args: Array[String]) {\n\n    val Array(n,m,a,b) = StdIn.readLine().split(\" \").map(_.toInt)\n\n\n\n    var ans = 10000;\n    for(i <- 0 to 1000) {\n      ans = math.min(ans, b * i + math.max(n - m * i,0) * a)\n    }\n\n    println(ans)\n\n\n  }\n\n\n}\n"}], "src_uid": "faa343ad6028c5a069857a38fa19bb24"}
{"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val data = in.next().split(' ').map(_.toLong)\n  var (a, b) = if (data.head % data.last == 0) (data.head /data.last, 1l) else (data.head, data.last)\n  var r = 0l\n  while (b > 0) {\n    r += a / b\n    val newB = a % b\n    a = b\n    b = newB\n  }\n  println(r)\n}", "positive_code": [{"source_code": "object C extends App {\n\n  def readString = Console.readLine\n  def tokenizeLine = new java.util.StringTokenizer(readString)\n  def readLongs(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toLong) }\n  \n  def cnt(a: Long, b: Long): Long = {\n    if (a == 1L) b\n    else if (a > b) a / b + cnt(a % b, b)\n    else cnt(b, a)\n  }\n\n  val Array(a, b) = readLongs(2)\n\n  println(cnt(a, b))\n}"}, {"source_code": "import scala.collection._\n\nobject C extends App {\n\n  def readString = Console.readLine\n  def tokenizeLine = new java.util.StringTokenizer(readString)\n  def readInts(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toInt) }\n  def readLongs(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toLong) }\n  def readBigs(n: Int) = { val t = tokenizeLine; Array.fill(n)(BigInt(t.nextToken)) }\n  \n  def cnt(a: Long, b: Long): Long = {\n    //println(a, b)\n    if (a == 0L || b == 0L) 0L\n    else if (a == 1L) b\n    else if (b == a) 1L\n    else if (b == 1L) a\n    else if (a > b) a / b + cnt(a % b, b)\n    else b / a + cnt(b % a, a)\n  }\n\n  val Array(a, b) = readLongs(2)\n\n  println(cnt(a, b))\n}"}, {"source_code": "object C344 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val Array(a, b) = readLongs(2)\n    println(rec(a, b))\n  }\n  def rec(a: Long, b: Long): Long = {\n    if(a == 1 || b == 1) {\n      a+b-1\n    } else {\n      if (a > b) {\n        (a / b) + rec(b, a%b)\n      } else {\n        rec(b, a)\n      }\n    }\n  }\n}"}], "negative_code": [{"source_code": "import scala.collection._\n\nobject C extends App {\n\n  def readString = Console.readLine\n  def tokenizeLine = new java.util.StringTokenizer(readString)\n  def readInts(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toInt) }\n  def readLongs(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toLong) }\n  def readBigs(n: Int) = { val t = tokenizeLine; Array.fill(n)(BigInt(t.nextToken)) }\n  \n  def cnt(a: Long, b: Long): Long = {\n    //println(a, b)\n    if (a == 0L || b == 0L) 0L\n    //else if (a == 1L) b\n    else if (b == a) 1L\n    else if (b == 1L) a\n    else if (a > b) (a - b) + cnt(a % b, b)\n    else (b - a) + cnt(b % a, a)\n  }\n\n  val Array(a, b) = readLongs(2)\n\n  println(cnt(a, b))\n}"}, {"source_code": "import scala.collection._\n\nobject C extends App {\n\n  def readString = Console.readLine\n  def tokenizeLine = new java.util.StringTokenizer(readString)\n  def readInts(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toInt) }\n  def readLongs(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toLong) }\n  def readBigs(n: Int) = { val t = tokenizeLine; Array.fill(n)(BigInt(t.nextToken)) }\n  \n  def cnt(a: Long, b: Long): Long = {\n    //println(a, b)\n    if (a == 0L || b == 0L) 0L\n    else if (a == 1L) b\n    else if (b == a) 1L\n    else if (b == 1L) a\n    else if (a > b) (a - b) + cnt(a % b, b)\n    else (b - a) + cnt(b % a, a)\n  }\n\n  val Array(a, b) = readLongs(2)\n\n  println(cnt(a, b))\n}"}, {"source_code": "import scala.collection._\n\nobject C extends App {\n\n  def readString = Console.readLine\n  def tokenizeLine = new java.util.StringTokenizer(readString)\n  def readInts(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toInt) }\n  def readLongs(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toLong) }\n  def readBigs(n: Int) = { val t = tokenizeLine; Array.fill(n)(BigInt(t.nextToken)) }\n  \n  def cnt(a: Long, b: Long): Long = {\n    //println(a, b)\n    if (a == 0L || b == 0L) 0L\n    else if (a == 1L) b\n    else if (b == a) 1L\n    else if (a > b) (a - b) + cnt(a % b, b)\n    else (b - a) + cnt(b % a, a)\n  }\n\n  val Array(a, b) = readLongs(2)\n\n  println(cnt(a, b))\n}"}, {"source_code": "import scala.collection._\n\nobject C extends App {\n\n  def readString = Console.readLine\n  def tokenizeLine = new java.util.StringTokenizer(readString)\n  def readInts(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toInt) }\n  def readLongs(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toLong) }\n  def readBigs(n: Int) = { val t = tokenizeLine; Array.fill(n)(BigInt(t.nextToken)) }\n  \n  def cnt(a: Long, b: Long): Long = {\n    //println(a, b)\n    /*if (a == 1L) b\n    else*/ if (b == 1L) 1L\n    else if (a > b) (a - b) + cnt(a % b, b)\n    else (b - a) + cnt(b % a, a)\n  }\n\n  val Array(a, b) = readLongs(2)\n\n  println(cnt(a, b))\n}"}, {"source_code": "import scala.collection._\n\nobject C extends App {\n\n  def readString = Console.readLine\n  def tokenizeLine = new java.util.StringTokenizer(readString)\n  def readInts(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toInt) }\n  def readLongs(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toLong) }\n  def readBigs(n: Int) = { val t = tokenizeLine; Array.fill(n)(BigInt(t.nextToken)) }\n  \n  def cnt(a: Long, b: Long): Long = {\n    //println(a, b)\n    if (a == 1L) b\n    else if (b == 1L) 1L\n    else if (a > b) (a - b) + cnt(a % b, b)\n    else cnt(b, a)\n  }\n\n  val Array(a, b) = readLongs(2)\n\n  println(cnt(a, b))\n}"}], "src_uid": "792efb147f3668a84c866048361970f8"}
{"source_code": "import java.util.Scanner\n\nobject A extends App {\n    val sc = new java.util.Scanner(System.in)\n    val n, x, y = sc.nextInt()\n    println(math.max(0, (n*y+99)/100-x))\n}\n\n", "positive_code": [{"source_code": "import annotation.tailrec\nimport java.io._\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readInt = reader.readLine().toInt\n\n  val Array(n, x, y) = readInts\n  def ceil(a: Int, b: Int) = a / b + (if(a % b == 0) 0 else 1)\n//  def ans = ceil(n * y - 100 * x, 100) max 0\n  def ans = (0.01 * n * y - 0.000001 - x).ceil.toInt max 0\n\n\n  def main(args: Array[String]) {\n    println(ans)\n  }\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val nxy = readLine().split(\" \").map(_.toInt)\n    val n = nxy(0)\n    val x = nxy(1)\n    val y = nxy(2)\n    println((((n * y + 99) / 100) - x).max(0))\n  }\n}"}, {"source_code": "object Solver {\n  def main(args: Array[String]) {\n    var input = Console.readLine.split(\" \").map(x => x.toInt)\n    var n = input(0); var x = input(1); var y = input(2);\n\n    var required = Math.ceil(n * y / 100.0).toInt\n    var clones = if (required > x) required - x else 0\n    println(clones)\n  }\n}\n"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val Array(n, x, y) = in.next().split(\" \").map(_.toInt)\n  println(Range(0, 1000 * 1000 + 1).find(i => (i + x) * 100 / n >= y).get)\n}"}, {"source_code": "import scala.math\nobject Main\n{\n\tdef up(a:Double):Int = \n\t{\n\t\tif(a.floor == a)\n\t\t\treturn a.floor.toInt\n\t\treturn (a.floor.toInt + 1)\n\t}\n\n\tdef main(args:Array[String])\n\t{\n\t\tval rd = readLine.split(\" \").map(i => i.toInt);\n\t\tval n = rd(0)\n\t\tval x = rd(1)\n\t\tval y = rd(2)\n\t\t\n\t\tval cl = up((n / 100.0) * y - x)\n\t\tif (cl < 0)\n\t\t\tprintln(0)\n\t\telse \n\t\t\tprintln(cl)\n\t}\n}"}, {"source_code": "import java.util.Scanner\n\nobject A {\n    def main(args: Array[String]) {\n        val sc = new java.util.Scanner(System.in)\n        val n, x, y = sc.nextInt()\n        println(math.max(0, (n*y+99)/100-x))\n    }\n}\n\n"}, {"source_code": "import java.util.Scanner\nobject A {\n    def main(args: Array[String]) {\n        val sc = new java.util.Scanner(System.in)\n        val n, x, y = sc.nextInt()\n        val s = n * y - x * 100\n        if (s <= 0) println(0)\n        else if(s % 100 == 0) println(s / 100)\n        else println((s + 100) / 100)\n    }\n}\n\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P168A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val N, X, Y = sc.nextInt\n\n  val p = math.ceil(N * Y / 100.0).toInt - X\n\n  out.println(if (p < 0) 0 else p)\n  out.close\n}\n"}], "negative_code": [{"source_code": "import java.util.Scanner\nobject A {\n    def main(args: Array[String]) {\n        val sc = new java.util.Scanner(System.in)\n        val n, x, y = sc.nextInt()\n        if ((n * y - x * 100) <= 0) println(0)\n        else println(((n * y - x * 100) / 100).ceil)\n    }\n}\n\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P168A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val N, X, Y = sc.nextInt\n\n  val answer = math.ceil(N * Y / 100.0).toInt - X\n\n  out.println(answer)\n  out.close\n}\n"}, {"source_code": "import annotation.tailrec\nimport java.io._\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readInt = reader.readLine().toInt\n\n  val Array(n, x, y) = readInts\n  def ceil(a: Int, b: Int) = a / b + (if(a % b == 0) 0 else 1)\n//  def ans = ceil(n * y - 100 * x, 100) max 0\n  def ans = (0.01 * n * y - 0.1 - x).ceil.toInt max 0\n\n\n  def main(args: Array[String]) {\n    println(ans)\n  }\n}\n"}, {"source_code": "import annotation.tailrec\nimport java.io._\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readInt = reader.readLine().toInt\n\n  val Array(n, x, y) = readInts\n  def ceil(a: Int, b: Int) = a / b + (if(a % b == 0) 0 else 1)\n//  def ans = ceil(n * y - 100 * x, 100) max 0\n  def ans = (0.01 * n * y - x).ceil.toInt max 0\n\n\n  def main(args: Array[String]) {\n    println(ans)\n  }\n}\n"}, {"source_code": "import annotation.tailrec\nimport java.io._\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readInt = reader.readLine().toInt\n\n  val Array(n, x, y) = readInts\n  def ceil(a: Int, b: Int) = a / b + (if(a % b == 0) 0 else 1)\n//  def ans = ceil(n * y - 100 * x, 100) max 0\n  def ans = (1.0 * n * y - x).ceil.toInt max 0\n\n\n  def main(args: Array[String]) {\n    println(ans)\n  }\n}\n"}, {"source_code": "import annotation.tailrec\nimport java.io._\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readInt = reader.readLine().toInt\n\n  val Array(n, x, y) = readInts\n  def ceil(a: Int, b: Int) = a / b + (if(a % b == 0) 0 else 1)\n  def ans = ceil(n * y - 100 * x, 100) max 0\n\n\n  def main(args: Array[String]) {\n    println(ans)\n  }\n}\n"}], "src_uid": "7038d7b31e1900588da8b61b325e4299"}
{"source_code": "/**\n  * Created by moiseev on 21.04.2017.\n  */\nobject Task2 extends App {\n\n  import java.util.{Scanner}\n\n  val in = new Scanner(System.in)\n\n  val X = in.next\n  val Y = in.next\n\n  def middleChar( charLeft: Char, charRes: Char ): (Boolean,Char) = {\n    if ( charLeft < charRes ) (false,' ')\n    else  {\n      // a - 92 z - 122\n      // charLeft - between 92 and 122\n      // result should be between charLeft and 122 inclusive\n      (\n        true,if ( charLeft == charRes ) {\n        val randRandge: Int = 122 - charLeft\n        (charLeft.toInt + (if (randRandge > 0)scala.util.Random.nextInt(randRandge) else 0) ).toChar\n      }\n      else charRes\n      )\n    }\n  }\n\n  def findSecondString( strLeft:String, strRes: String ): (Boolean, String) = {\n    if ( strLeft.size == 0 ) (true,\"\") // Finishing the recursion\n    else if (strLeft.size != strRes.size )\n      (false,\"\") // Strings are of different size - false definetly\n    else {\n      val (res, ch) = middleChar(strLeft.head, strRes.head)\n\n      if (!res)\n        (false, \"\") // Some i chars says they are not from our F()\n      else {\n        val (recRes, strRec) = findSecondString(strLeft.tail, strRes.tail)\n\n        if (!recRes)\n          (false, \"\") // Just to recursevly inform about failure\n        else (true, ch + strRec)\n      }\n    }\n  }\n\n  val (resBool,resStr) = findSecondString(X,Y)\n  if (resBool) {\n    println(resStr)\n  } else {\n    println(-1)\n  }\n}\n", "positive_code": [{"source_code": "object _801B extends CodeForcesApp {\n  import Utils._, annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._\n\n  override def apply(io: IO) = {import io.{read, readAll, write, writeAll, writeLine}\n    val x, z = read[String]\n\n    val ans = Try{x.zip(z).map({case (a, b) => b.ensuring(b <= a)})}\n\n    write(ans.map(_.mkString).getOrElse(\"-1\"))\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\nobject Utils {\n  import scala.collection.mutable, mutable.{Map => Dict}\n  implicit class GenericExtensions[A](val a: A) extends AnyVal {\n    def in(set: collection.Set[A]): Boolean = set(a)\n    def some: Option[A] = Some(a)\n    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a\n  }\n  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {\n    def onlyElement: A = assuming(t.size == 1)(t.head)\n    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)\n    def duplicates(implicit b: C of A): C[A] = {\n      val elems = mutable.Set.empty[A]\n      (t collect {case i if !elems.add(i) => i}).to[C]\n    }\n    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}\n    def maxWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.max)\n    def minWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.min)\n    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]\n    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap\n    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)\n    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}\n    def toMutableMultiSet: Dict[A, Int] = {\n      val c = map[A] to 0\n      t.foreach(i => c(i) += 1)\n      c\n    }\n    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0\n    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)\n  }\n  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)\n  }\n  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)\n  }\n  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {\n    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t\n  }\n  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {\n    def key = p._1\n    def value = p._2\n  }\n  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {\n    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)\n    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])\n    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]\n  }\n  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {\n    def lastKeyOption: Option[K] = m.lastOption.map(_.key)\n    def firstKeyOption: Option[K] = m.headOption.map(_.key)\n    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap\n    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}\n    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m\n    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\n  }\n  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {\n    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)\n    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)\n    private def removeNode(kv: (K, V)): (K, V) = {\n      m -= kv.key\n      kv\n    }\n  }\n  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {\n    def notContains(x: A): Boolean = !(s contains x)\n    def toMutable = mutable.Set.empty[A] ++ s\n  }\n  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {\n    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}\n    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)\n    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)\n    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}\n    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)\n  }\n  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {\n    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero\n    def toEnglish = if(x) \"YES\" else \"NO\"\n  }\n  implicit class IntExtensions(val x: Int) extends AnyVal {\n    import java.lang.{Integer => JInt}\n    def withHighestOneBit: Int = JInt.highestOneBit(x)\n    def withLowestOneBit: Int = JInt.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)\n    def bitCount: Int = JInt.bitCount(x)\n    def setLowestBits(n: Int): Int = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Int = x & left(n, ~0)\n    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Int = x | left(i)\n    def clearBit(i: Int): Int = x & ~left(i)\n    def toggleBit(i: Int): Int = x ^ left(i)\n    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1\n    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)\n    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)\n  }\n  implicit class LongExtensions(val x: Long) extends AnyVal {\n    import java.lang.{Long => JLong}\n    def withHighestOneBitSet: Long = JLong.highestOneBit(x)\n    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)\n    def bitCount: Int = JLong.bitCount(x)\n    def setLowestBits(n: Int): Long = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Long = x & left(n, ~0L)\n    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Long = x | left(i)\n    def clearBit(i: Int): Long = x & ~left(i)\n    def toggleBit(i: Int): Long = x ^ left(i)\n    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1\n    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)\n  }\n  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {\n    import Numeric.Implicits._\n    def **(i: Int): A = if (i == 0) n.one else {\n      val h = x ** (i/2)\n      if (i%2 == 0) h * h else h * h * x\n    }\n    def distance(y: A) = (x - y).abs()\n    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)\n    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf \"Greg\" whenNegative Int.MaxValue\n  }\n  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {\n    import scala.collection.immutable.NumericRange, Integral.Implicits._\n    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x\n    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)\n    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)\n  }\n  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))\n  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)\n  def asc[A](implicit order: Ordering[A]): Ordering[A] = order\n  def map[K] = new {\n    def to[V](default: => V): Dict[K, V] = using(_ => default)\n    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {\n      override def apply(key: K) = getOrElseUpdate(key, f(key))\n    }\n  }\n  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]\n  def memoize[A, B](f: A => B): A ==> B = map[A] using f\n  implicit class FuzzyDouble(val x: Double) extends AnyVal {\n    def  >~(y: Double) = x > y + eps\n    def >=~(y: Double) = x >= y + eps\n    def  ~<(y: Double) = y >=~ x\n    def ~=<(y: Double) = y >~ x\n    def  ~=(y: Double) = (x distance y) <= eps\n  }\n  def toPolygon(points: Traversable[(Int, Int)]): java.awt.Polygon = {\n    val (xs, ys) = points.unzip\n    new java.awt.Polygon(xs.toArray, ys.toArray, points.size)\n  }\n  def toShape(points: Traversable[(Double, Double)]): java.awt.geom.GeneralPath = {\n    val shape = new java.awt.geom.GeneralPath()\n    points.headOption foreach {case (x, y) => shape.moveTo(x, y)}\n    points.tail foreach {case (x, y) => shape.lineTo(x, y)}\n    shape.closePath()\n    shape\n  }\n  def until(until: Int): Range = 0 until until\n  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}\n  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}\n  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None\n  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)\n  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]\n  type ==>[A, B] = collection.Map[A, B]\n  val mod: Int = (1e9 + 7).toInt\n  val eps: Double = 1e-9\n}\n/***********************************[Scala I/O]*********************************************/\nimport Utils._, java.io._, java.util.StringTokenizer\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    when(tokenizers.nonEmpty)(tokenizers.head)\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  def readAll[A: IO.Read]: (Int, Vector[A]) = {\n    val data = read[Vector[A]]\n    (data.length, data)\n  }\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any): this.type = {\n    printer.print(obj)\n    this\n  }\n  def writeLine(): this.type = {\n    printer.println()\n    this\n  }\n  def writeLine(obj: Any): this.type = {\n    printer.println(obj)\n    this\n  }\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n  def query[A: IO.Read](question: Any): A = writeLine(question).read\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                       : Read[String]       = new Read(_.next())\n    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)\n    implicit val int                                          : Read[Int]          = string.map(_.toInt)\n    implicit val long                                         : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                       : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                      : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n"}], "negative_code": [], "src_uid": "ce0cb995e18501f73e34c76713aec182"}
{"source_code": "import scala.io.StdIn\n\nobject Main {\n  def main(args: Array[String]): Unit = {\n    StdIn.readLine()\n    val a = StdIn.readLine().split(\" \")\n    val b = StdIn.readLine().split(\" \")\n    val c = a.filter(item => b.contains(item))\n    c.foreach(item => print(item + \" \"))\n  }\n}", "positive_code": [{"source_code": "import scala.collection.mutable._\nimport scala.io.StdIn\n\nobject Main {\n    def main(arg: Array[String]) {\n        var z = readLine().split(\" \")\n        var n = z(0).toInt\n        var m = z(1).toInt\n\n        \n\n        var x = readLine.split(\" \").map(_.toInt).toArray\n        var y = readLine.split(\" \").map(_.toInt).toArray\n        \n\n        for(ele <- x){\n            if(y contains ele) {\n                print(ele + \" \")\n            }\n        }\n    }\n}"}, {"source_code": "/**\n  * @author ShankarShastri\n  *         Algorithm: ProblemA (http://codeforces.com/contest/994/problem/A)\n  */\n\nimport scala.io.StdIn._\nimport scala.annotation.tailrec\n\nobject ProblemA {\n  def main(args: Array[String]): Unit = {\n    readLine\n    val list = readLine.split(\" \").map(_.toInt).toList\n    val keys = readLine.split(\" \").map(_.toInt).toList\n    val res = keys.map(x => (x, list.indexOf(x))).filter(_._2 != -1).sortBy(_._2).map(_._1)\n    println(res.mkString(\" \"))\n  }\n}\n"}], "negative_code": [], "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72"}
{"source_code": "import scala.io.StdIn\n\n/** A. Mr. Kitayuta's Gift\n  * http://codeforces.com/contest/505/problem/A\n  * @author Yuichiroh Matsubayashi\n  *         Created on 15/01/19.\n  */\nobject P505A extends App {\n  val letters = StdIn.readLine().toList\n  val size = letters.size\n\n  def solution = {\n    def valid(size: Int, short: List[Char], long: List[Char], skipped: Int = -1, char: String = \"\"): (Int, String) = {\n      if (long == Nil) (skipped, char)\n      else if (short == Nil) (size - 1, long.mkString)\n      else if (short.head == long.head) valid(size, short.tail, long.tail, skipped, char)\n      else if (skipped < 0) valid(size, short, long.tail, size - long.size, long.head.toString)\n      else (-1, \"\")\n    }\n\n    if (size % 2 == 0) {\n      val (pre, post) = letters.splitAt(size / 2)\n      if (pre == post) pre.mkString + post.head.toString + post.mkString\n      else {\n        val (skippedPre, cPre) = valid(pre.size, pre.reverse.tail, post)\n        if (skippedPre >= 0) {\n          val (ppre, ppost) = pre.splitAt(pre.size - skippedPre-1)\n          ppre.mkString + cPre + ppost.mkString + post.mkString\n        }\n        else {\n          val (skippedPost, cPost) = valid(post.size, post.tail, pre.reverse)\n          if (skippedPost >= 0) {\n            val (ppre, ppost) = post.splitAt(skippedPost+1)\n            pre.mkString + ppre.mkString + cPost + ppost.mkString\n          }\n          else \"NA\"\n        }\n      }\n    }\n    else {\n      val (pre, b) = letters.splitAt(size / 2)\n      val (mid, post) = (b.head, b.tail)\n\n      if (pre == post.reverse) pre.mkString + mid + mid + post.mkString\n      else {\n        val (skippedPre, cPre) = valid(pre.size + 1, pre.reverse, mid :: post)\n        if (skippedPre >= 0) {\n          val (ppre, ppost) = pre.splitAt(pre.size - skippedPre)\n          ppre.mkString + cPre + ppost.mkString + mid + post.mkString\n        }\n        else {\n          val (skippedPost, cPost) = valid(post.size + 1, post, mid :: pre.reverse)\n          if (skippedPost >= 0) {\n            val (ppre, ppost) = post.splitAt(skippedPost)\n            pre.mkString + mid + ppre.mkString + cPost + ppost.mkString\n          }\n          else \"NA\"\n        }\n      }\n    }\n  }\n\n  println(solution)\n}", "positive_code": [{"source_code": "import scala.io.StdIn\n\n/** A. Mr. Kitayuta's Gift\n  * http://codeforces.com/contest/505/problem/A\n  * @author Yuichiroh Matsubayashi\n  *         Created on 15/01/19.\n  */\nobject P505A extends App {\n  val letters = StdIn.readLine().toList\n  val size = letters.size\n\n  def solution = {\n    def valid(size: Int, short: List[Char], long: List[Char], skipped: Int = -1, char: String = \"\"): (Int, String) = {\n      if (long == Nil) (skipped, char)\n      else if (short == Nil) {\n        if (skipped < 0) (size - 1, long.mkString)\n        else {\n          new NoSuchElementException\n          (size, \"\")\n        }\n      }\n      else if (short.head == long.head) valid(size, short.tail, long.tail, skipped, char)\n      else if (skipped < 0) valid(size, short, long.tail, size - long.size, long.head.toString)\n      else (-1, \"\")\n    }\n\n    if (size % 2 == 0) {\n      val (pre, post) = letters.splitAt(size / 2)\n      if (pre == post) pre.mkString + post.head.toString + post.mkString\n      else {\n        val (skippedPre, cPre) = valid(pre.size, pre.reverse.tail, post)\n        if (skippedPre >= 0) {\n          val (ppre, ppost) = pre.splitAt(pre.size - skippedPre-1)\n          ppre.mkString + cPre + ppost.mkString + post.mkString\n        }\n        else {\n          val (skippedPost, cPost) = valid(post.size, post.tail, pre.reverse)\n          if (skippedPost >= 0) {\n            val (ppre, ppost) = post.splitAt(skippedPost+1)\n            pre.mkString + ppre.mkString + cPost + ppost.mkString\n          }\n          else \"NA\"\n        }\n      }\n    }\n    else {\n      val (a, b) = letters.splitAt(size / 2)\n      val (pre, mid, post) = (a.toList, b.head, b.tail)\n\n      if (pre == post.reverse) pre.mkString + mid + mid + post.mkString\n      else {\n\n        val (skippedPre, cPre) = valid(pre.size + 1, pre.reverse, mid :: post)\n        if (skippedPre >= 0) {\n          val (ppre, ppost) = pre.splitAt(pre.size - skippedPre)\n          ppre.mkString + cPre + ppost.mkString + mid + post.mkString\n        }\n        else {\n          val (skippedPost, cPost) = valid(post.size + 1, post, mid :: pre.reverse)\n          if (skippedPost >= 0) {\n            val (ppre, ppost) = post.splitAt(skippedPost)\n            pre.mkString + mid + ppre.mkString + cPost + ppost.mkString\n          }\n          else \"NA\"\n        }\n      }\n    }\n  }\n\n  println(solution)\n}\n"}, {"source_code": "object A505 {\n\n  import IO._\n  import collection.{mutable => cu}\n  def isPalin(str: String): Boolean = {\n    (0 until str.length/2).forall(i => str(i) == str(str.length-i-1))\n  }\n  def main(args: Array[String]): Unit = {\n    var str = read\n    val n = str.length\n    var break = false\n    for(i <- 0 to n if !break) {\n      for(j <- 'a' to 'z' if !break) {\n        val (f, s) = str.splitAt(i)\n        if(isPalin(f+j+s)) {\n          str = f + j + s\n          break = true\n        }\n      }\n    }\n    if(!break) {\n      out.println(\"NA\")\n    } else {\n      out.println(str)\n    }\n    out.close()\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(\"src/input\")))\n    val out = new java.io.PrintWriter(System.out)\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "\n/**\n * @author pvasilyev\n * @since 01 Aug 2016\n */\nobject A505 extends App {\n\n  def palindrome(stringToCheck: String): Boolean = {\n    for (i <- 0 until stringToCheck.length / 2 + 1) {\n      if (stringToCheck.charAt(i) != stringToCheck.charAt(stringToCheck.length() - 1 - i)) {\n        return false\n      }\n    }\n    true\n  }\n\n  def solve() = {\n    var pal: String = null\n    val s: String = scala.io.StdIn.readLine()\n    for (c <- 0 until 26 ) {\n      val ch: Char = ('a'.toInt + c).toChar\n      for (i <- 0 until s.length) {\n        val stringToCheck = s.substring(0, i) + ch + s.substring(i)\n        if (palindrome(stringToCheck)) {\n          pal = stringToCheck\n        }\n      }\n      if (palindrome(s + ch)) {\n        pal = s + ch\n      }\n    }\n    if (pal != null) {\n      println(pal)\n    } else {\n      println(\"NA\")\n    }\n  }\n\n  solve()\n\n}\n"}, {"source_code": "\nobject Main {\n  def main(args: Array[String]) {\n    val s:String=io.StdIn.readLine()\n    println(solve(s))\n  }\n    def solve(s:String):String = {\n      if (s.length==1)\n        return s+s\n      if (isPal(s))\n        if (s.length%2==0) insert(s,'a',s.length/2) else insert(s,s(s.length/2),s.length/2)\n      else {\n        var i=0\n        while (i<s.length/2){\n          if (s(i)==s(s.length-i-1))\n            i+=1\n          else {\n            var r=insert(s,s(s.length-i-1),i)\n            if (isPal(r))\n              return r\n            r = insert(s,s(i),s.length-i)\n            if (isPal(r))\n              return r\n            i+=1\n          }\n        }\n        \"NA\"\n      }\n    }\n    def insert(s:String, c:Char, p:Int) = {\n      s.take(p)+c+s.takeRight(s.length-p)\n    }\n    def isPal(s:String) = {\n      s==s.reverse\n    }\n\n}"}, {"source_code": "\n\nimport java.io.InputStream\nimport java.io.PrintStream\nimport java.util.Scanner\n\nobject A_Mr_Kitayutas_Gift {\n\n  def main(args: Array[String]) {\n    parseSolveAndPrint(System.in, System.out)\n  }\n\n  def parseSolveAndPrint(in: InputStream, out: PrintStream): Unit = {\n    val scanner = new Scanner(in)\n    val str = scanner.next()\n\n    def findInsertionPoints(str : String, l : Int, h: Int, acc : Seq[(Int, Char)] = Nil) : Seq[(Int, Char)] = {\n      (l, h) match {\n        case (l, h) if l > h => acc\n        case (l, h) => {\n          if (str.charAt(l) == str.charAt(h))\n            findInsertionPoints(str, l + 1, h - 1, acc)\n          else {\n            val loResult = findInsertionPoints(str, l, h - 1, acc :+ (l, str.charAt(h)))\n            val hiResult = findInsertionPoints(str, l + 1, h, acc :+ (h + 1, str.charAt(l)))\n\n            if (loResult.size < hiResult.size)\n              loResult\n            else\n              hiResult\n          }\n        }\n      }\n    }\n\n    val insertionPoints = findInsertionPoints(str, 0, str.length - 1)\n\n    if (insertionPoints.size == 1) {\n      val point = insertionPoints.head\n      val newStr = str.substring(0, point._1) + point._2 + str.substring(point._1)\n      out.println(newStr)\n    } else if (insertionPoints.size == 0) {\n      if (str.size % 2 == 0) {\n        val newStr = str.substring(0, str.size / 2) + 'a' + str.substring(str.size / 2)\n        out.println(newStr)\n      } else {\n        val newStr = str.substring(0, str.size / 2) + str.charAt(str.size / 2) + str.charAt(str.size / 2) + str.substring(str.size / 2 + 1)\n        out.println(newStr)\n      }\n    } else {\n      out.println(\"NA\")\n    }\n  }\n}\n"}, {"source_code": "import scala.io.StdIn\n\nobject Main {\n\n  val chars = 'a' to 'z'\n\n  def main(args: Array[String]): Unit = {\n    val s = StdIn.readLine()\n    for (c <- chars) {\n      for (pos <- Range(0, s.length + 1)) {\n        val splitted = s.splitAt(pos)\n        val newS = splitted._1 + c + splitted._2\n        if(newS == newS.reverse) {\n          println(newS)\n          return\n        }\n      }\n    }\n    println(\"NA\")\n    return\n  }\n}"}, {"source_code": "object Main extends App {\n  val word = readLine\n  def morph(s: String): Option[Char] = {\n    val d = s.size / 2\n    val dir = s take d\n    val back = s.reverse take d\n    (dir zip back).foldLeft[Option[Char]](Some('*'))({\n      case (None, _) => None\n      case (_, ('*', c2)) => Some(c2)\n      case (_, (c1, '*')) => Some(c1)\n      case (acc, (c1, c2)) if c1==c2 => acc\n      case _ => None\n    })\n  }\n\n  (word.inits.toList.zip(word.tails.toList.reverse)).map({\n    case (start, end) => {\n      val v = List(start, \"*\", end).mkString\n      (v, morph(v))\n    }\n  }).filter({ case (_, None) => false; case _ => true }).headOption match {\n    case None => println(\"NA\")\n    case Some((v, Some(r))) => println(v.replace(\"*\", if(r == '*') \"a\" else r.toString))\n  }\n}"}, {"source_code": "import scala.io.StdIn._\n\nobject Main extends App {\n  val s = readLine\n  val n = s.length\n\n  def ans: String = {\n    var mp = 0\n    while (mp < n && s(mp) == s(n - 1 - mp)) {\n      mp += 1\n    }\n\n    val anyChar = \"a\"\n    val noAns = \"NA\"\n\n    def getForEven: String = {\n      def getLeft: Option[Int] = {\n        var mid = n / 2 - 1\n        var i = 1\n        while (mid - i >= 0 && s(mid - i) == s(mid + i)) {\n          i += 1\n        }\n        mid -= i - 1\n\n        (0 to n / 2 - 1).find(i => i <= mp && i >= mid)\n      }\n\n      def getRight: Option[Int] = {\n        var mid = n / 2\n        var i = 1\n        while (mid + i < n && s(mid - i) == s(mid + i)) {\n          i += 1\n        }\n        mid += i - 1\n\n        (n / 2 + 1 to n).find(i => n - i <= mp && i - 1 <= mid)\n      }\n\n      val fromLeft = getLeft\n      if (fromLeft.isDefined) {\n        val pos = fromLeft.get\n        return s.substring(0, pos) + s(n - 1 - pos) + s.substring(pos)\n      }\n\n      val fromRight = getRight\n      if (fromRight.isDefined) {\n        val pos = fromRight.get\n        return s.substring(0, pos) + s(n - pos) + s.substring(pos)\n      }\n\n      if (mp >= n / 2)\n        s.substring(0, n / 2) + anyChar + s.substring(n / 2)\n      else\n        noAns\n    }\n\n    def getForOdd: String = {\n      def getLeft: Option[Int] = {\n        var mid = n / 2 - 1\n        if (s(mid) != s(mid + 1)) {\n          return Option.empty\n        }\n\n        var i = 1\n        while (mid - i >= 0 && s(mid - i) == s(mid + 1 + i)) {\n          i += 1\n        }\n        mid -= i - 1\n\n        (0 to n / 2 - 1).find(i => i <= mp && i >= mid)\n      }\n\n      def getRight: Option[Int] = {\n        var mid = n / 2 + 1\n        if (s(mid - 1) != s(mid)) {\n          return Option.empty\n        }\n\n        var i = 1\n        while (mid + i < n && s(mid - 1 - i) == s(mid + i)) {\n          i += 1\n        }\n        mid += i - 1\n\n        (n / 2 + 2 to n).find(i => n - i <= mp && i - 1 <= mid)\n      }\n\n      val fromLeft = getLeft\n      if (fromLeft.isDefined) {\n        val pos = fromLeft.get\n        return s.substring(0, pos) + s(n - 1 - pos) + s.substring(pos)\n      }\n\n      val fromRight = getRight\n      if (fromRight.isDefined) {\n        val pos = fromRight.get\n        return s.substring(0, pos) + s(n - pos) + s.substring(pos)\n      }\n\n      if (mp >= n / 2)\n        s.substring(0, n / 2) + s(n / 2) + s.substring(n / 2)\n      else\n        noAns\n    }\n\n    if (n == 1)\n      s * 2\n    else if (n % 2 == 0)\n      getForEven\n    else\n      getForOdd\n  }\n\n  println(ans)\n}\n"}], "negative_code": [{"source_code": "import scala.io.StdIn\n\n/** A. Mr. Kitayuta's Gift\n  * http://codeforces.com/contest/505/problem/A\n  * @author Yuichiroh Matsubayashi\n  *         Created on 15/01/19.\n  */\nobject P505A extends App {\n  val letters = StdIn.readLine().toList\n  val size = letters.size\n\n//  println(letters, size)\n\n  def valid(s1: List[Char], s2: List[Char], skippedA: Int = -1, skippedB: Int = -1, skippedLetter: Char = ' '): String = {\n//    println(s1, s2, skippedLetter)\n    if (s1 == Nil || s2 == Nil) {\n//      println(skippedA, skippedB)\n      if (skippedA >= 0) {\n        val (pre, post) = letters.splitAt(size - skippedA)\n        pre.mkString + skippedLetter + post.mkString\n      }\n      else if (skippedB >= 0) {\n        val (pre, post) = letters.splitAt(skippedB)\n        pre.mkString + skippedLetter + post.mkString\n      }\n      else if (size % 2 == 0) {\n        val (pre, post) = letters.splitAt(size / 2)\n        pre.mkString + \"a\" + post.mkString\n      }\n      else {\n        val (pre, post) = letters.splitAt(size / 2)\n        pre.mkString + post.head + post.mkString\n      }\n    }\n    else if (s1.head == s2.head) valid(s1.tail, s2.tail, skippedA, skippedB, skippedLetter)\n    else {\n      val a = if (skippedA < 0) valid(s1.tail, s2, skippedA = size / 2 - s1.size, skippedB, s1.head) else \"NA\"\n      if (a != \"NA\") a\n      else if (skippedB < 0) valid(s1, s2.tail, skippedA, skippedB = size / 2 - s2.size, s2.head)\n      else \"NA\"\n    }\n  }\n\n  def solution = valid(letters.slice(0, size / 2), letters.reverse.slice(0, size / 2))\n\n  println(solution)\n}\n"}, {"source_code": "\n\nimport scala.io.StdIn\n\n/** A. Mr. Kitayuta's Gift\n  * http://codeforces.com/contest/505/problem/A\n  * @author Yuichiroh Matsubayashi\n  *         Created on 15/01/19.\n  */\nobject P505A extends App {\n  val letters = StdIn.readLine().toList\n  val size = letters.size\n\n  def solution = {\n    if (size % 2 == 0) {\n      val (pre, post) = letters.splitAt(size / 2)\n      if (pre.toList == post.reverse) pre.mkString + post.head.toString + post.mkString\n      else {\n        if (pre.toList == pre.head :: post.tail.reverse) (letters.head :: letters.reverse).reverse.mkString\n        else if ((post.last :: pre).reverse.tail == post.toList) (post.last :: letters).mkString\n        else \"NA\"\n      }\n    }\n    else {\n      val (a, b) = letters.splitAt(size / 2)\n      val (pre, mid, post) = (a.toList, b.head, b.tail)\n\n      if (pre == post.reverse) pre.mkString + mid + mid + post.mkString\n      else {\n        def valid(size: Int, short: List[Char], long: List[Char], skipped: Int = -1, char: String = \"\"): (Int, String) = {\n          if (long == Nil) (skipped, char)\n          else if (short == Nil) {\n            if (skipped < 0) (size - 1, long.mkString)\n            else {\n              new NoSuchElementException\n              (size, \"\")\n            }\n          }\n          else if (short.head == long.head) valid(size, short.tail, long.tail, skipped, char)\n          else if (skipped < 0) valid(size, short, long.tail, size - long.size, long.head.toString)\n          else (-1, \"\")\n        }\n\n        val (skippedPre, cPre) = valid(pre.size + 1, pre.reverse, mid :: post)\n        if (skippedPre >= 0) {\n          val (ppre, ppost) = pre.splitAt(pre.size - skippedPre)\n          ppre.mkString + cPre + ppost.mkString + mid + post.mkString\n        }\n        else {\n          val (skippedPost, cPost) = valid(post.size + 1, post, mid :: pre.reverse)\n          if (skippedPost >= 0) {\n            val (ppre, ppost) = post.splitAt(skippedPost)\n            pre.mkString + mid + ppre.mkString + cPost + ppost.mkString\n          }\n          else \"NA\"\n        }\n      }\n    }\n  }\n\n  println(solution)\n}\n"}, {"source_code": "\nimport scala.io.StdIn\n\n/** A. Mr. Kitayuta's Gift\n  * http://codeforces.com/contest/505/problem/A\n  * @author Yuichiroh Matsubayashi\n  *         Created on 15/01/19.\n  */\nobject P505A extends App {\n  val letters = StdIn.readLine().toList\n  val size = letters.size\n\n  println(letters, size)\n\n  def valid(s1: List[Char], s2: List[Char], size: Int, skippedA: Int = -1, skippedB: Int = -1, skippedLetter: Char = ' '): String = {\n    println(s1, s2, size, skippedA, skippedB, skippedLetter)\n    if (s1 == Nil || s2 == Nil) {\n      println(skippedA, skippedB)\n      if (skippedA >= 0) {\n        val (pre, post) = letters.splitAt(size - skippedA)\n        pre.mkString + skippedLetter + post.mkString\n      }\n      else if (skippedB >= 0) {\n        val (pre, post) = letters.splitAt(skippedB)\n        pre.mkString + skippedLetter + post.mkString\n      }\n      else if (size % 2 == 0) {\n        val (pre, post) = letters.splitAt(size / 2)\n        pre.mkString + \"a\" + post.mkString\n      }\n      else {\n        val (pre, post) = letters.splitAt(size / 2)\n        pre.mkString + post.head + post.mkString\n      }\n    }\n    else if (s1.head == s2.head) valid(s1.tail, s2.tail, size, skippedA, skippedB, skippedLetter)\n    else {\n      val a = if (skippedA < 0) valid(s1.tail, s2, size, size - s1.size, skippedB, s1.head) else \"NA\"\n      if (a != \"NA\") a\n      else if (skippedA < 0 && skippedB < 0) valid(s1, s2.tail, size, skippedA, size - s2.size, s2.head)\n      else \"NA\"\n    }\n  }\n\n  def solution = valid(letters.slice(0, (size / 2.0).ceil.toInt), letters.reverse.slice(0, (size / 2.0).ceil.toInt), (size / 2.0).ceil.toInt)\n\n  println(solution)\n}\n"}, {"source_code": "\n\nimport scala.io.StdIn\n\n/** A. Mr. Kitayuta's Gift\n  * http://codeforces.com/contest/505/problem/A\n  * @author Yuichiroh Matsubayashi\n  *         Created on 15/01/19.\n  */\nobject P505A extends App {\n  val letters = StdIn.readLine().toList\n  val size = letters.size\n\n  def solution = {\n    if (size % 2 == 0) {\n      val (pre, post) = letters.splitAt(size / 2)\n      if (pre.toList == post.reverse) pre + post.head.toString + post\n      else {\n        if (pre.toList == pre.head :: post.tail.reverse) (letters.head :: letters.reverse).reverse.mkString\n        else if ((post.last :: pre).reverse.tail == post.toList) (post.last :: letters).mkString\n        else \"NA\"\n      }\n    }\n    else {\n      val (a, b) = letters.splitAt(size / 2)\n      val (pre, mid, post) = (a.toList, b.head, b.tail)\n\n      if (pre == post.reverse) pre.mkString + mid + mid + post.mkString\n      else {\n        def valid(size: Int, short: List[Char], long: List[Char], skipped: Int = -1, char: String = \"\"): (Int, String) = {\n          if (long == Nil) (skipped, char)\n          else if (short == Nil) {\n            if (skipped < 0) (size - 1, long.mkString)\n            else {\n              new NoSuchElementException\n              (size, \"\")\n            }\n          }\n          else if (short.head == long.head) valid(size, short.tail, long.tail, skipped, char)\n          else if (skipped < 0) valid(size, short, long.tail, size - long.size, long.head.toString)\n          else (-1, \"\")\n        }\n\n        val (skippedPre, cPre) = valid(pre.size + 1, pre.reverse, mid :: post)\n        if (skippedPre >= 0) {\n          val (ppre, ppost) = pre.splitAt(pre.size - skippedPre)\n          ppre.mkString + cPre + ppost.mkString + mid + post.mkString\n        }\n        else {\n          val (skippedPost, cPost) = valid(post.size + 1, post, mid :: pre.reverse)\n          if (skippedPost >= 0) {\n            val (ppre, ppost) = post.splitAt(skippedPost)\n            pre.mkString + mid + ppre.mkString + cPost + ppost.mkString\n          }\n          else \"NA\"\n        }\n      }\n    }\n  }\n\n  println(solution)\n}\n"}, {"source_code": "\nobject Main {\n  def main(args: Array[String]) {\n    val s:String=io.StdIn.readLine()\n    println(solve(s))\n  }\n    def solve(s:String):String = {\n      if (isPal(s))\n        if (s.length%2==0) insert(s,'a',s.length/2) else \"NA\"\n      else {\n        var i=0\n        while (i<s.length/2){\n          if (s(i)==s(s.length-i-1))\n            i+=1\n          else {\n            var r=insert(s,s(s.length-i-1),i)\n            if (isPal(r))\n              return r\n            r = insert(s,s(i),s.length-i)\n            if (isPal(r))\n              return r\n            i+=1\n          }\n        }\n        \"NA\"\n      }\n    }\n    def insert(s:String, c:Char, p:Int) = {\n      s.take(p)+c+s.takeRight(s.length-p)\n    }\n    def isPal(s:String) = {\n      s==s.reverse\n    }\n\n}"}, {"source_code": "\nobject Main {\n  def main(args: Array[String]) {\n    val s:String=io.StdIn.readLine()\n    println(solve(s))\n  }\n    def solve(s:String):String = {\n      if (s.length==1)\n        return s+s\n      if (isPal(s))\n        if (s.length%2==0) insert(s,'a',s.length/2) else \"NA\"\n      else {\n        var i=0\n        while (i<s.length/2){\n          if (s(i)==s(s.length-i-1))\n            i+=1\n          else {\n            var r=insert(s,s(s.length-i-1),i)\n            if (isPal(r))\n              return r\n            r = insert(s,s(i),s.length-i)\n            if (isPal(r))\n              return r\n            i+=1\n          }\n        }\n        \"NA\"\n      }\n    }\n    def insert(s:String, c:Char, p:Int) = {\n      s.take(p)+c+s.takeRight(s.length-p)\n    }\n    def isPal(s:String) = {\n      s==s.reverse\n    }\n\n}"}, {"source_code": "\n\nimport java.io.InputStream\nimport java.io.PrintStream\nimport java.util.Scanner\n\nobject A_Mr_Kitayutas_Gift {\n\n  def main(args: Array[String]) {\n    parseSolveAndPrint(System.in, System.out)\n  }\n\n  def parseSolveAndPrint(in: InputStream, out: PrintStream): Unit = {\n    val scanner = new Scanner(in)\n    val str = scanner.next()\n\n    def findInsertionPoints(str : String, l : Int, h: Int, acc : Seq[(Int, Char)] = Nil) : Seq[(Int, Char)] = {\n      (l, h) match {\n        case (l, h) if l > h => acc\n        case (l, h) => {\n          if (str.charAt(l) == str.charAt(h))\n            findInsertionPoints(str, l + 1, h - 1, acc)\n          else {\n            val loResult = findInsertionPoints(str, l, h - 1, acc :+ (l, str.charAt(h)))\n            val hiResult = findInsertionPoints(str, l + 1, h, acc :+ (h + 1, str.charAt(l)))\n\n            if (loResult.size < hiResult.size)\n              loResult\n            else\n              hiResult\n          }\n        }\n      }\n    }\n\n    val insertionPoints = findInsertionPoints(str, 0, str.length - 1)\n\n    if (insertionPoints.size == 1) {\n      val point = insertionPoints.head\n      val newStr = str.substring(0, point._1) + point._2 + str.substring(point._1)\n      out.println(newStr)\n    } else if (insertionPoints.size == 0) {\n      if (str.size % 2 == 0) {\n        val newStr = str.substring(0, str.size / 2) + 'a' + str.substring(str.size / 2)\n        out.println(newStr)\n      } else if (str.size == 1) {\n        out.println(str + str)\n      } else {\n        out.println(\"NA\")\n      }\n    } else {\n      out.println(\"NA\")\n    }\n  }\n}\n"}, {"source_code": "\n\nimport java.io.InputStream\nimport java.io.PrintStream\nimport java.util.Scanner\n\nobject A_Mr_Kitayutas_Gift {\n\n  def main(args: Array[String]) {\n    parseSolveAndPrint(System.in, System.out)\n  }\n\n  def parseSolveAndPrint(in: InputStream, out: PrintStream): Unit = {\n    val scanner = new Scanner(in)\n    val str = scanner.next()\n\n    def findInsertionPoints(str : String, l : Int, h: Int, acc : Seq[(Int, Char)] = Nil) : Seq[(Int, Char)] = {\n      (l, h) match {\n        case (l, h) if l > h => acc\n        case (l, h) => {\n          if (str.charAt(l) == str.charAt(h))\n            findInsertionPoints(str, l + 1, h - 1, acc)\n          else {\n            val loResult = findInsertionPoints(str, l, h - 1, acc :+ (l, str.charAt(h)))\n            val hiResult = findInsertionPoints(str, l + 1, h, acc :+ (h + 1, str.charAt(l)))\n\n            if (loResult.size < hiResult.size)\n              loResult\n            else\n              hiResult\n          }\n        }\n      }\n    }\n\n    val insertionPoints = findInsertionPoints(str, 0, str.length - 1)\n\n    if (insertionPoints.size == 1) {\n      val point = insertionPoints.head\n      val newStr = str.substring(0, point._1) + point._2 + str.substring(point._1)\n      out.println(newStr)\n    } else if (insertionPoints.size == 0) {\n      if (str.size % 2 == 0) {\n        val newStr = str.substring(0, str.size / 2) + 'a' + str.substring(str.size / 2)\n        out.println(newStr)\n      } else {\n        out.println(\"NA\")\n      }\n    } else {\n      out.println(\"NA\")\n    }\n  }\n}\n"}, {"source_code": "\n\nimport java.io.InputStream\nimport java.io.PrintStream\nimport java.util.Scanner\n\nobject A_Mr_Kitayutas_Gift {\n\n  def main(args: Array[String]) {\n    parseSolveAndPrint(System.in, System.out)\n  }\n\n  def parseSolveAndPrint(in: InputStream, out: PrintStream): Unit = {\n    val scanner = new Scanner(in)\n    val str = scanner.next()\n\n    def findInsertionPoints(str : String, l : Int, h: Int, acc : Seq[(Int, Char)] = Nil) : Seq[(Int, Char)] = {\n      (l, h) match {\n        case (l, h) if l > h => acc\n        case (l, h) => {\n          if (str.charAt(l) == str.charAt(h))\n            findInsertionPoints(str, l + 1, h - 1, acc)\n          else {\n            val loResult = findInsertionPoints(str, l, h - 1, acc :+ (l, str.charAt(h)))\n            val hiResult = findInsertionPoints(str, l + 1, h, acc :+ (h + 1, str.charAt(l)))\n\n            if (loResult.size < hiResult.size)\n              loResult\n            else\n              hiResult\n          }\n        }\n      }\n    }\n\n    val insertionPoints = findInsertionPoints(str, 0, str.length - 1)\n\n    if (insertionPoints.size == 1) {\n      val point = insertionPoints.head\n      val newStr = str.substring(0, point._1) + point._2 + str.substring(point._1)\n      out.println(newStr)\n    } else if (insertionPoints.size == 0) {\n      if (str.size % 2 == 0) {\n        val newStr = str.substring(0, str.size / 2) + 'a' + str.substring(str.size / 2)\n        out.println(newStr)\n      } else {\n        out.println(\"NA\")\n      }\n    } else {\n      out.println(\"NA\")\n    }\n\n    println(insertionPoints.toString())\n  }\n}\n"}], "src_uid": "24e8aaa7e3e1776adf342ffa1baad06b"}
{"source_code": "object A {\n  val mod = 1000000009L\n\n  def main(args: Array[String]) {\n    val (n, m) = {\n      val sp = readLine.split(\" \")\n      (sp(0).toInt, sp(1).toInt)\n    }\n\n    if (m < 60 && (1L << m) - n < 0) {\n      println(0)\n      return\n    }\n\n    val m2 = (1 to m).foldLeft(1L) { (v: Long, i) =>\n      v * 2 % mod\n    }\n\n    val ans = (1 to n).foldLeft(1L) { (v: Long, i) =>\n      v * (m2 - i + mod) % mod\n    }\n    println(ans)\n  }\n}", "positive_code": [{"source_code": "import java.util._\n\nobject Main extends App {\n  val sc = new Scanner(System.in)\n  val mod = 1000000009L\n\n  val n, m = sc.nextInt()\n\n  def power(x: Long, p: Long, res: Long = 1L): Long =\n    if (p == 0) res else power(x, p - 1, res * x % mod)\n\n  def solve(p: Long, n: Long, res: Long = 1L): Long =\n    if (n == 0) res else solve(p - 1, n - 1, res * p % mod)\n\n  println(solve(power(2, m) - 1, n))\n}\n"}], "negative_code": [], "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8"}
{"source_code": "/**\n  * Created by mettu.r on 20/08/17.\n  */\nobject Demo extends App {\n  override def main(args: Array[String]): Unit = {\n    var a = readLine().split(\" \").map(x => x.toInt);\n    var n = a(0);\n    var k = a(1);\n    var s = readLine();\n    var map = scala.collection.mutable.Map[Char,Int]();\n    s.foreach(x => {\n      map.put(x , map.getOrElse(x,0) + 1 );\n    });\n    var ans = true;\n    map.foreach( x => if( x._2 > k ) ans = false );\n    if( ans )\n      printf(\"Yes\\n\");\n    else\n      printf(\"No\\n\");\n  }\n}", "positive_code": [{"source_code": "import java.util.Scanner\n\nobject Try1 {\n  def main(args: Array[String]) {\n    val in = new Scanner(System.in)\n    var len, m, k, n, j, i: Int = 0\n    var a = new Array[Int](26)\n    n = in.nextInt()\n    m = in.nextInt()\n    k=0\n    var line = in.nextLine()\n    line = in.nextLine()\n    for (i <- 0 to 25) a(i)=0\n    for (i <- 0 until  n)\n      a(line(i)-'a')+=1\n//    len = line.length()\n    for (i <- 0 to 25)\n      if (a(i)>m) k=1\n    if (k==0) println(\"YES\")\n    else println(\"NO\")\n  }\n}"}], "negative_code": [{"source_code": "import java.util.Scanner\n\nobject Try1 {\n  def main(args: Array[String]) {\n    val in = new Scanner(System.in)\n    var len, w, ans, m, x, c, k, n, j, i: Int = 0\n    var a = new Array[Int](26)\n    n = in.nextInt()\n    m = in.nextInt()\n    k=0\n    var line = in.nextLine()\n    line = in.nextLine()\n    for (i <- 0 to 25) a(i)=0\n    for (i <- 0 until  n)\n      a(line(i)-'a')+=1\n//    len = line.length()\n    if (n<m+m) x = n/2\n    else x=m\n    i=0\n    while (i<m)\n      {\n        j=0\n        while (j<26 && a(j)==0) j+=1\n        if (j<26) {\n          a(j)-=1\n          j+=1\n          while (j<26 && a(j)==0) j+=1\n          if (j<26) {\n            a(j)-=1\n            k+=1\n          }\n        }\n        i+=1\n      }\n    if (k==m) println(\"YES\")\n    else println(\"NO\")\n  }\n}"}, {"source_code": "import java.util.Scanner\n\nobject Try1 {\n  def main(args: Array[String]) {\n    val in = new Scanner(System.in)\n    var len, w, ans, m, x, c, k, n, j, i: Int = 0\n    var a = new Array[Int](26)\n    n = in.nextInt()\n    m = in.nextInt()\n    k=1\n    var line = in.nextLine()\n    line = in.nextLine()\n    for (i <- 0 to 25) a(i)=0\n    for (i <- 0 until  n)\n      a(line(i)-'a')+=1\n//    len = line.length()\n    for (i <- 0 to 25)\n      if (a(i)>m) k=1\n    if (k==0) println(\"YES\")\n    else println(\"NO\")\n  }\n}"}, {"source_code": "import java.util.Scanner\n\nobject Try1 {\n  def main(args: Array[String]) {\n    val in = new Scanner(System.in)\n    var len, w, ans, m, x, c, k, n, j, i: Int = 0\n    var a = new Array[Int](26)\n    n = in.nextInt()\n    m = in.nextInt()\n    k=0\n    var line = in.nextLine()\n    line = in.nextLine()\n    for (i <- 0 to 25) a(i)=0\n    for (i <- 0 until  n)\n      a(line(i)-'a')+=1\n//    len = line.length()\n    if (n<m+m) x = n/2\n    else x=m\n    i=0\n    while (i<x)\n      {\n        j=0\n        while (j<26 && a(j)==0) j+=1\n        if (j<26) {\n          a(j)-=1\n          j+=1\n          while (j<26 && a(j)==0) j+=1\n          if (j<26) {\n            a(j)-=1\n            k+=1\n          }\n        }\n        i+=1\n      }\n    if (k==x) println(\"YES\")\n    else println(\"NO\")\n  }\n}"}], "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be"}
{"source_code": "object _1178C extends CodeForcesApp {\n  import annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._, Math._\n\n  override def apply(io: IO): io.type = {\n    val w, h = io.read[Int]\n    val ans = BigInt(2).modPow(w+h, 998244353)\n    io.write(ans)\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\n/***********************************[Scala I/O]*********************************************/\nimport java.io._, java.util.StringTokenizer\nimport scala.collection.generic.CanBuild\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    tokenizers.headOption\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: CanBuild[A, C[A]]): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  def readAll[A: IO.Read]: (Int, Vector[A]) = {\n    val data = read[Vector[A]]\n    (data.length, data)\n  }\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any): this.type = {\n    printer.print(obj)\n    this\n  }\n  def writeLine(): this.type = {\n    printer.println()\n    this\n  }\n  def writeLine(obj: Any): this.type = {\n    printer.println(obj)\n    this\n  }\n  def writeLines(obj: Traversable[Any]): this.type = writeAll(obj, separator = \"\\n\")\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n  def query[A: IO.Read](question: Any): A = writeLine(question).read\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: CanBuild[A, C[A]]) : Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                                   : Read[String]       = new Read(_.next())\n    implicit val int                                                      : Read[Int]          = string.map(_.toInt)\n    implicit val long                                                     : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                                   : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                                   : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                               : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                                 : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                                  : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n", "positive_code": [{"source_code": "object C extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(w, h) = readInts(2)\n  val MOD = BigInt(998244353L)\n\n  val res = BigInt(2).modPow(w + h, MOD)\n\n  println(res)\n}\n"}], "negative_code": [], "src_uid": "8b2a9ae21740c89079a6011a30cd6aee"}
{"source_code": "import java.util.ArrayList\nimport java.util.StringTokenizer\n//import scala.reflect.io.File\nimport java.io.BufferedReader\nimport java.io.BufferedInputStream\nimport java.io.InputStreamReader\nimport java.io.ByteArrayInputStream\nimport java.io.InputStream\n\nobject C_441 {   var br = createBufferedReader(); var debugV = false \n    \n    //COMMENT ME !\n//    runTest(Test.sa1)\n//    debugV = true\n//    file = File(\"C:\\\\temp\\\\google cj\\\\2014q\\\\c-small.res\")\n  \n  def main(args: Array[String]): Unit = {\n    //---------------------------- parameters reading\n    val n = readLine.int\n    \n    //---------------------------- parameters reading :end\n    \n    var continue = true\n    var variants = List[Int]()\n    var x = n\n    val maxDif = n.toString().length() * 9\n    while (continue) {\n      val sum = sumDig(x) + x\n      continue = x > 0 && x + maxDif >= n\n      if (sum == n) variants ::= x\n      x -= 1\n    }\n    \n    def sumDig(x: Int) = {\n      x.toString.map(c => (c+\"\").toInt).sum\n    }\n    \n    val res = if (variants.size > 0) {\n      variants.size + \"\\n\" + variants.sorted.mkString(\" \")\n    } else {\n      \"0\"\n    }\n  \n    outLn(res)\n    finish\n  }\n  \n  \n  //============================ service code ======================\n\n//  var file:File = null\n  val resultStr = new StringBuilder\n  def outLn(str:String) = resultStr.append(str).append(\"\\n\")\n  def outLn(number:Integer) = resultStr.append(number+\"\").append(\"\\n\")\n  def finish() {\n//    if (file == null || !devEnv) {\n      println(resultStr.toString())\n//    } else {\n//      file.writeAll(resultStr.toString())\n//    }\n  }\n  \n  def readLine() = new Line  \n  class Line {\n    val fullLine = br.readLine()\n    val tok = new StringTokenizer(fullLine, \" \")\n    def int = tok.nextToken().toInt\n    def long = tok.nextToken().toLong\n    def double = tok.nextToken().toDouble\n    def string = tok.nextToken()\n  }\n  \n  def createBufferedReader(inst:InputStream = System.in): BufferedReader = {\n    val bis = if (inst == null) new BufferedInputStream(System.in) else new BufferedInputStream(inst);\n    new BufferedReader(new InputStreamReader(bis));\n  }\n  \n  def runTest(str:String) = if (devEnv) { \n    br = createBufferedReader(new ByteArrayInputStream(str.trim.getBytes(\"ISO-8859-1\")))\n  }\n  \n  def debug(x: => String) = if (debugV && devEnv) println(x) // nullary function\n  \n  lazy val devEnv = this.getClass.getCanonicalName.contains(\".\")\n  \n//============================================================================================\nobject Test {\n  \nval sa1 = \"\"\"\n21\n\"\"\"\n\nval sa2 = \"\"\"\n20\n\"\"\"\n\nval sa3 = \"\"\"\n100 \n\"\"\"\n}\n\n}\n\n", "positive_code": [{"source_code": "import scala.collection.mutable.ListBuffer\n\nobject test {\n  def digits(a: Int): Int =\n    if (a == 0) 0\n    else 1 + digits(a/10)\n  def sumDigits(a: Int): Int =\n    if (a == 0) 0\n    else (a % 10) + sumDigits(a/10)\n  def main(args: Array[String]) {\n    val a = scala.io.StdIn.readInt\n    var l = ListBuffer[Int]()\n    for(x <- math.max(a-9*digits(a)-5, 0) to a) {\n      if(sumDigits(x)+x == a) l += x\n    }\n    println(l.length)\n    for(x <- l) {\n      println(x)\n    }\n  }\n}"}], "negative_code": [{"source_code": "import java.util.ArrayList\nimport java.util.StringTokenizer\n//import scala.reflect.io.File\nimport java.io.BufferedReader\nimport java.io.BufferedInputStream\nimport java.io.InputStreamReader\nimport java.io.ByteArrayInputStream\nimport java.io.InputStream\n\nobject C_441 {   var br = createBufferedReader(); var debugV = false \n    \n    //COMMENT ME !\n//    runTest(Test.sa1)\n//    debugV = true\n//    file = File(\"C:\\\\temp\\\\google cj\\\\2014q\\\\c-small.res\")\n  \n  def main(args: Array[String]): Unit = {\n    //---------------------------- parameters reading\n    val n = readLine.int\n    \n    var continue = true\n    var variants = List[Int]()\n    var x = n\n    while (continue) {\n      val sum = sumDig(x) + x\n      continue = sum > n\n      if (sum == n) variants ::= x\n      x -= 1\n    }\n    \n    def sumDig(x: Int) = {\n      x.toString.map(c => (c+\"\").toInt).sum\n    }\n    \n//    val max = groups.values.reduce((a,b) => if (a.size > b.size) a else b) \n//    debug(\"max = \" + max.mkString(\" \"))\n    \n    //---------------------------- parameters reading :end\n    \n    val res = if (variants.size > 0) {\n      variants.size + \"\\n\" + variants.sorted.mkString(\" \")\n    } else {\n      \"0\"\n    }\n  \n    outLn(res)\n    finish\n  }\n  \n  \n  //============================ service code ======================\n\n//  var file:File = null\n  val resultStr = new StringBuilder\n  def outLn(str:String) = resultStr.append(str).append(\"\\n\")\n  def outLn(number:Integer) = resultStr.append(number+\"\").append(\"\\n\")\n  def finish() {\n//    if (file == null || !devEnv) {\n      println(resultStr.toString())\n//    } else {\n//      file.writeAll(resultStr.toString())\n//    }\n  }\n  \n  def readLine() = new Line  \n  class Line {\n    val fullLine = br.readLine()\n    val tok = new StringTokenizer(fullLine, \" \")\n    def int = tok.nextToken().toInt\n    def long = tok.nextToken().toLong\n    def double = tok.nextToken().toDouble\n    def string = tok.nextToken()\n  }\n  \n  def createBufferedReader(inst:InputStream = System.in): BufferedReader = {\n    val bis = if (inst == null) new BufferedInputStream(System.in) else new BufferedInputStream(inst);\n    new BufferedReader(new InputStreamReader(bis));\n  }\n  \n  def runTest(str:String) = if (devEnv) { \n    br = createBufferedReader(new ByteArrayInputStream(str.trim.getBytes(\"ISO-8859-1\")))\n  }\n  \n  def debug(x: => String) = if (debugV && devEnv) println(x) // nullary function\n  \n  lazy val devEnv = this.getClass.getCanonicalName.contains(\".\")\n  \n//============================================================================================\nobject Test {\n  \nval sa1 = \"\"\"\n21\n\"\"\"\n\nval sa2 = \"\"\"\n20\n\"\"\"\n\nval sa3 = \"\"\"\n100 \n\"\"\"\n}\n\n}\n\n"}], "src_uid": "ae20ae2a16273a0d379932d6e973f878"}
{"source_code": "object Main {\n  val primes: Stream[Int] = 2 #:: 3 #:: \n    Stream.from(5, 2).filter(i => primes.takeWhile(_ < Math.sqrt(i)).forall(i % _ != 0))\n\n  def split(n: Int): List[Int] = {\n    primes.takeWhile(_ <= Math.sqrt(n)).find(n % _ == 0) match {\n      case Some(div) => div :: split(n / div)\n      case None => List(n)\n    }\n  }\n\n  def main(args: Array[String]) {\n    val n = readInt()\n    val divs = split(n)\n    if (n == 1) println(\"1\")\n    else println(divs.scanLeft(1)(_ * _).reverse.mkString(\" \"))\n  }\n}", "positive_code": [{"source_code": "import scala.collection.mutable.ListBuffer\nobject P58B extends App {\n\n  val n = readLine.toInt\n  val cache = new Array[List[Int]](n)\n  cache(0) = List(1)\n\n  def f(n: Int): List[Int] = {\n    if (cache(n - 1) != null) cache(n - 1)\n    else {\n      var factors = ListBuffer[Int](1)\n      for (e <- 2 to math.sqrt(n).toInt) if (n % e == 0) factors ++= Set(e, n / e)\n      cache(n - 1) = List(n) ++ factors.map(f(_)).maxBy(_.size)\n      cache(n - 1)\n    }\n  }\n\n  for (e <- f(n)) print(e+\" \")\n}"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val n = in.next().toInt\n  val res = (2 to n).foldLeft(List(1)) {\n    case(list, el) if n % el == 0 && el % list.head == 0 => el :: list\n    case(list, el) => list\n  }\n\n  println(res.mkString(\" \"))\n}"}], "negative_code": [{"source_code": "import scala.collection.mutable.ListBuffer\nobject P58B extends App {\n\n  val n = readLine.toInt\n  var factors = ListBuffer[Int]()\n  for (e <- 2 to math.sqrt(n).toInt) if (n % e == 0) factors ++= Set(e, n / e)\n\n  val evens = factors.filter(_ % 2 == 0)\n  val odds = factors.filter(_ % 2 == 1)\n  factors = List(evens, odds).maxBy(_.size) + n + 1\n\n  for (e <- factors.toSet.toList.sortWith(_ > _)) print(e+\" \")\n\n}"}, {"source_code": "import scala.collection.mutable.ListBuffer\nobject P58B extends App {\n\n  val n = readLine.toInt\n  var factors = ListBuffer[Int]()\n  for (e <- 2 to math.sqrt(n).toInt) if (n % e == 0) factors ++= Set(e, n / e)\n\n  val evens = factors.filter(_ % 2 == 0)\n  val odds = factors.filter(_ % 2 == 1)\n  factors = List(evens, odds).maxBy(_.size) + n + 1\n\n  for (e <- factors.toList.sortWith(_ > _)) print(e+\" \")\n\n}"}, {"source_code": "object Main {\n  val primes: Stream[Int] = 2 #:: 3 #:: \n    Stream.from(5, 2).filter(i => primes.takeWhile(_ < Math.sqrt(i)).forall(i % _ != 0))\n\n  def split(n: Int): List[Int] = {\n    primes.takeWhile(_ <= Math.sqrt(n)).find(n % _ == 0) match {\n      case Some(div) => div :: split(n / div)\n      case None => List(n)\n    }\n  }\n\n  def main(args: Array[String]) {\n    val n = readInt()\n    val divs = split(n)\n    println(divs.scanLeft(1)(_ * _).reverse.mkString(\" \"))\n  }\n}"}], "src_uid": "2fc946bb72f56b6d86eabfaf60f9fa63"}
{"source_code": "object main {\nimport scala.io.StdIn._\nimport scala.collection.mutable.{HashMap,HashSet}\n\ndef gcd(a: Long, b: Long): Long = {\n\tif (a == 0) b else gcd(b % a, a)\n}\n\n\ndef main(args: Array[String]) {\n\n\nval input = readLine.trim.split(\" +\")\nval left = input(0).toLong\nval right = input(1).toLong\nval coprimes = HashMap[Long, HashSet[Long]]()\nfor (x <- left to right) {\n\tval temp = HashSet[Long]()\n\tfor (y <- left to right) {\n\t\tif (x != y && gcd(x,y) == 1) temp += y\n\t}\n\tcoprimes += x -> temp\n}\ndef findIt: (Long, Long, Long) = {\n\tfor (a <- coprimes.keys) {\n\t\tfor (b <- coprimes(a)) {\n\t\t\tif (b > a) {\n\t\t\t\tfor (c <- coprimes(b)) {\n\t\t\t\t\tif (c > a && c > b && !coprimes(a).contains(c)) return (a,b,c)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn null\n}\nval res = findIt\nprintln(if (res != null) { res._1 + \" \"  + res._2 + \" \" + res._3 } else -1)\n\n\n\n\n}\n\n}", "positive_code": [{"source_code": "object Solution extends App {\n  def simple(a: Long, b: Long): Boolean = {\n    if (b == 0) a == 1\n    else simple(b, a % b)\n  }\n\n  val in = scala.io.Source.stdin.getLines()\n  val Array(a, b) = in.next().split(\" \").map(_.toLong)\n  val options = (a to b - 2).flatMap(a1 => (a1 + 1 to b - 1).flatMap(b1 => (b1 + 1 to b).map(c1 => (a1, b1, c1))))\n  println(options.find{\n    case(a, b, c) => simple(a, b) && simple(b, c) && !simple(a, c)\n  }.map(t => s\"${t._1} ${t._2} ${t._3}\").getOrElse(\"-1\"))\n\n\n}"}, {"source_code": "object A483 {\n\n  import IO._\n  def gcd(a: Long, b: Long): Long = {\n    if(b == 0) a else gcd(b, a%b)\n  }\n  def main(args: Array[String]): Unit = {\n    val Array(l, r) = readLongs(2)\n    var break = false\n    for(a <- l to r-2; b <- a+1 to r-1; c <- b+1 to r if !break) {\n      if(gcd(a, b) == 1 && gcd(b, c) == 1 && gcd(a, c) != 1) {\n        println(s\"$a $b $c\")\n        break = true\n      }\n    }\n    if(!break) {\n      println(\"-1\")\n    }\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "  /**\n   * Created by SchmAn4 on 26.10.2014.\n   */\n  object Counterexample {\n    def main(s: Array[String]): Unit = {\n      val start = System.currentTimeMillis\n      val scanner = new java.util.Scanner(System.in)\n      val x = scanner.nextLong()\n      val y = scanner.nextLong()\n      val list = (x to y)\n\n/*\n      val triples = for(x <- list; y <- list; z <- list) yield (x,y,z)\n      println(triples.filter {\n        case (x, y, z) => x < y && y < z && x != y && y != z && x != z && ggT(x, y) == 1 && ggT(y, z) == 1 && ggT(x, z) != 1\n      })\n      */\n      // 380ms\n\n\n      /*\n      val seven = (for (\n        x <- list; y <- list; z <- list\n        if x < y && y < z && x != y && y != z && x != z && ggT(x, y) == 1 && ggT(y, z) == 1 && ggT(x, z) != 1\n      ) yield (x,y,z)).headOption\n      // 340ms\n*/\n      val iter = (for {\n        x <- list.toIterator; y <- list.toIterator; z <- list.toIterator\n        if x < y && y < z && x != y && y != z && x != z && ggT(x, y) == 1 && ggT(y, z) == 1 && ggT(x, z) != 1\n      } yield (x,y,z))\n\n      if (iter.hasNext) {\n        val triple = iter.next\n        println(triple._1+\" \"+triple._2+\" \"+triple._3)\n      } else\n        println(-1)\n      // 300ms\n\n//      println((System.currentTimeMillis-start)+\"ms\")\n    }\n\n    /*\n    def perform(a: Long, b: Long): String = (a,b) match {\n      //case (p,q) if ggT(p,q) == 1 => \"-1\"\n      case (p,q) => perform2(p,q,p+1,p+1)\n    }\n\n    def perform2(a: Long, b: Long, c: Long, d: Long): String = (a,b,c,d) match {\n      case (a,b,c,d) if b >= c && ggT(a,c) == 1 => perform3(a,b,c,d+1) //a+\" \"+c+\" \"+b\n      case (_,b,c,d) if b <= c => \"-1\"\n      case (a,b,c,d) => perform2(a,b,c+1,d+1)\n    }\n\n    def perform3(a: Long, b: Long, c: Long, d: Long): String = (a,b,c,d) match {\n      case (a,b,c,d) if b >= d && ggT(c,d) == 1 && ggT(a,d) != 1 => a+\" \"+c+\" \"+d\n      case (_,b,c,d) if b <= d => \"-1\"\n      case (a,b,c,d) => perform2(a,b,c,d+1)\n    }\n    */\n\n    def ggT(a: Long, b: Long): Long = (a,b) match {\n      case (_,0) => a\n      case (p,q) if p == q => a\n      case (p,q) => ggT(b,a%b)\n    }\n\n    /*\n    Input\n    900000000000000009 900000000000000029\n    Output\n    900000000000000009 900000000000000010 900000000000000029\n    Answer\n    900000000000000009 900000000000000010 900000000000000021\n    */\n\n\n  }\n"}, {"source_code": "import java.util.StringTokenizer\n\nobject _483A extends App {\n  var token = new StringTokenizer(\"\")\n\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n\n  val l = next.toLong\n  val r = next.toLong\n\n  def gcd(a: Long, b: Long): Long = if (b == 0) a else gcd(b, a % b)\n  val ans = for {\n    a <- l to r\n    b <- a + 1 to r\n    c <- b +1 to r\n    if (gcd(a, b) == 1 && gcd(b, c) == 1 && gcd(a, c) > 1)\n  } yield (a, b, c)\n\n  if (ans.size == 0) println(-1)\n  else println(ans.head._1 + \" \" + ans.head._2 + \" \" + ans.head._3)\n}\n"}], "negative_code": [{"source_code": "  /**\n   * Created by SchmAn4 on 26.10.2014.\n   */\n  object Counterexample {\n    def main(s: Array[String]): Unit = {\n      val scanner = new java.util.Scanner(System.in)\n      val x = scanner.nextLong()\n      val y = scanner.nextLong()\n      println(perform(x,y))\n    }\n\n    def perform(a: Long, b: Long): String = (a,b) match {\n      //case (p,q) if ggT(p,q) == 1 => \"-1\"\n      case (p,q) => perform2(p,q,p+1)\n    }\n\n    def perform2(a: Long, b: Long, c: Long): String = (a,b,c) match {\n      case (_,b,c) if b == c => \"-1\"\n      case (a,b,c) if ggT(a,c) == 1 && ggT(b,c) == 1 => a+\" \"+c+\" \"+b\n      case (a,b,c) => perform2(a,b,c+1)\n    }\n\n    def ggT(a: Long, b: Long): Long = (a,b) match {\n      case (_,0) => a\n      case (p,q) if p == q => a\n      case (p,q) => ggT(b,a%b)\n    }\n\n\n  }\n"}, {"source_code": "  /**\n   * Created by SchmAn4 on 26.10.2014.\n   */\n  object Counterexample {\n    def main(s: Array[String]): Unit = {\n      val scanner = new java.util.Scanner(System.in)\n      val x = scanner.nextLong()\n      val y = scanner.nextLong()\n      println(perform(x,y))\n    }\n\n    def perform(a: Long, b: Long): String = (a,b) match {\n      case (p,q) if ggT(p,q) == 1 => \"-1\"\n      case (p,q) => perform2(p,q,p+1)\n    }\n\n    def perform2(a: Long, b: Long, c: Long): String = (a,b,c) match {\n      case (_,b,c) if b == c => \"-1\"\n      case (a,b,c) if ggT(a,c) == 1 && ggT(b,c) == 1 => a+\" \"+c+\" \"+b\n      case (a,b,c) => perform2(a,b,c+1)\n    }\n\n    def ggT(a: Long, b: Long): Long = (a,b) match {\n      case (_,0) => a\n      case (p,q) if p == q => a\n      case (p,q) => ggT(b,a%b)\n    }\n\n\n  }\n"}, {"source_code": "  /**\n   * Created by SchmAn4 on 26.10.2014.\n   */\n  object Counterexample {\n    def main(s: Array[String]): Unit = {\n      val scanner = new java.util.Scanner(System.in)\n      val x = scanner.nextLong()\n      val y = scanner.nextLong()\n      println(perform(x,y))\n    }\n\n    def perform(a: Long, b: Long): String = (a,b) match {\n      //case (p,q) if ggT(p,q) == 1 => \"-1\"\n      case (p,q) => perform2(p,q,p+1,p+1)\n    }\n\n    def perform2(a: Long, b: Long, c: Long, d: Long): String = (a,b,c,d) match {\n      case (a,b,c,d) if ggT(a,c) == 1 => perform3(a,b,c,d+1) //a+\" \"+c+\" \"+b\n      case (_,b,c,d) if b <= c => \"-1\"\n      case (a,b,c,d) => perform2(a,b,c+1,d+1)\n    }\n\n    def perform3(a: Long, b: Long, c: Long, d: Long): String = (a,b,c,d) match {\n      case (a,b,c,d) if ggT(c,d) == 1 && ggT(a,d) != 1 => a+\" \"+c+\" \"+d\n      case (_,b,c,d) if b <= d => \"-1\"\n      case (a,b,c,d) => perform2(a,b,c,d+1)\n    }\n\n    def ggT(a: Long, b: Long): Long = (a,b) match {\n      case (_,0) => a\n      case (p,q) if p == q => a\n      case (p,q) => ggT(b,a%b)\n    }\n\n    /*\n    Input\n    900000000000000009 900000000000000029\n    Output\n    900000000000000009 900000000000000010 900000000000000029\n    Answer\n    900000000000000009 900000000000000010 900000000000000021\n    */\n\n\n  }\n"}, {"source_code": "  /**\n   * Created by SchmAn4 on 26.10.2014.\n   */\n  object Counterexample {\n    def main(s: Array[String]): Unit = {\n      val scanner = new java.util.Scanner(System.in)\n      val x = scanner.nextLong()\n      val y = scanner.nextLong()\n      println(perform(x,y))\n    }\n\n    def perform(a: Long, b: Long): String = (a,b) match {\n      //case (p,q) if ggT(p,q) == 1 => \"-1\"\n      case (p,q) => perform2(p,q,p+1,p+1)\n    }\n\n    def perform2(a: Long, b: Long, c: Long, d: Long): String = (a,b,c,d) match {\n      case (a,b,c,d) if b >= c && ggT(a,c) == 1 => perform3(a,b,c,d+1) //a+\" \"+c+\" \"+b\n      case (_,b,c,d) if b <= c => \"-1\"\n      case (a,b,c,d) => perform2(a,b,c+1,d+1)\n    }\n\n    def perform3(a: Long, b: Long, c: Long, d: Long): String = (a,b,c,d) match {\n      case (a,b,c,d) if b >= d && ggT(c,d) == 1 && ggT(a,d) != 1 => a+\" \"+c+\" \"+d\n      case (_,b,c,d) if b <= d => \"-1\"\n      case (a,b,c,d) => perform2(a,b,c,d+1)\n    }\n\n    def ggT(a: Long, b: Long): Long = (a,b) match {\n      case (_,0) => a\n      case (p,q) if p == q => a\n      case (p,q) => ggT(b,a%b)\n    }\n\n    /*\n    Input\n    900000000000000009 900000000000000029\n    Output\n    900000000000000009 900000000000000010 900000000000000029\n    Answer\n    900000000000000009 900000000000000010 900000000000000021\n    */\n\n\n  }\n"}, {"source_code": "  /**\n   * Created by SchmAn4 on 26.10.2014.\n   */\n  object Counterexample {\n    def main(s: Array[String]): Unit = {\n      val scanner = new java.util.Scanner(System.in)\n      val x = scanner.nextLong()\n      val y = scanner.nextLong()\n      println(perform(x,y))\n    }\n\n    def perform(a: Long, b: Long): String = (a,b) match {\n      //case (p,q) if ggT(p,q) == 1 => \"-1\"\n      case (p,q) => perform2(p,q,p+1,p+1)\n    }\n\n    def perform2(a: Long, b: Long, c: Long, d: Long): String = (a,b,c,d) match {\n      case (a,b,c,d) if ggT(a,c) == 1 => perform3(a,b,c,d+1) //a+\" \"+c+\" \"+b\n      case (_,b,c,d) if b == c => \"-1\"\n      case (a,b,c,d) => perform2(a,b,c+1,d+1)\n    }\n\n    def perform3(a: Long, b: Long, c: Long, d: Long): String = (a,b,c,d) match {\n      case (a,b,c,d) if ggT(c,d) == 1 && ggT(a,d) != 1 => a+\" \"+c+\" \"+d\n      case (_,b,c,d) if b == d => \"-1\"\n      case (a,b,c,d) => perform2(a,b,c,d+1)\n    }\n\n    def ggT(a: Long, b: Long): Long = (a,b) match {\n      case (_,0) => a\n      case (p,q) if p == q => a\n      case (p,q) => ggT(b,a%b)\n    }\n\n    /*\n    Input\n    900000000000000009 900000000000000029\n    Output\n    900000000000000009 900000000000000010 900000000000000029\n    Answer\n    900000000000000009 900000000000000010 900000000000000021\n    */\n\n\n  }\n"}], "src_uid": "6c1ad1cc1fbecff69be37b1709a5236d"}
{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val Array(hpy, atky, defy) = in.next().split(\" \").map(_.toLong)\n  val Array(hpm, atkm, defm) = in.next().split(\" \").map(_.toLong)\n  val Array(hpcost, atkcost, defcost) = in.next().split(\" \").map(_.toLong)\n  var atkmin = if (atky > defm) atky else defm + 1\n  var cost = -1l\n  (atkmin to (hpm + defm)).foreach { atk =>\n    if (cost == -1l || (atk - atky) * atkcost < cost)\n      if (atkm > defy)\n        (defy to atkm).foreach { defend =>\n          if (cost == -1l || ((atk - atky) * atkcost + (defend - defy) * defcost < cost)) {\n            val win = hpm / (atk - defm) + (if (hpm % (atk - defm) > 0) 1 else 0)\n            val damage = win * (atkm - defend)\n            val hp = if (damage >= hpy) damage - hpy + 1 else 0\n            if (cost == -1l || ((atk - atky) * atkcost + (defend - defy) * defcost + hp * hpcost < cost))\n              cost = (atk - atky) * atkcost + (defend - defy) * defcost + hp * hpcost\n          }\n        }\n      else {\n        cost = (atk - atky) * atkcost\n      }\n  }\n  if (cost == -1l)\n    println(0)\n  else\n    println(cost)\n\n\n}", "positive_code": [{"source_code": "import scala.collection._\n\nobject A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(hy, ay, dy) = readLongs(3)\n  val Array(hm, am, dm) = readLongs(3)\n  val Array(ch, ca, cd) = readLongs(3)\n\n  var min = Long.MaxValue\n\n  for (a <- 0 to 1000) {\n    for (d <- 0 to 100) {\n\n      def can(h: Long) = {\n        //(hy + h) * (ay + a - dm) > hm * (am - dy - d)\n        val x = (ay + a - dm)\n        if (am - dy - d <= 0 && x > 0) true\n        else {\n          if (x <= 0) false\n          else {\n            val steps = (hm + x - 1) / x\n            if ((am - dy - d) * steps < hy + h) true\n            else false\n          }\n        }\n      }\n\n      @annotation.tailrec\n      def binSearch(low: Long, hi: Long): Long = {\n        if (hi < low) low\n        else {\n          val mid = (low + hi) >>> 1\n          if (can(mid)) binSearch(low, mid - 1)\n          else binSearch(mid + 1, hi)\n        }\n      }\n\n      val h = binSearch(0, 100000000L)\n      \n      //if (d == 0 && a == 0) println(h)\n      \n      val cost = a * ca + d * cd + h * ch \n      \n      min = Math.min(min, cost)\n    }\n  }\n\n  println(min)\n}"}], "negative_code": [{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val Array(hpy, atky, defy) = in.next().split(\" \").map(_.toLong)\n  val Array(hpm, atkm, defm) = in.next().split(\" \").map(_.toLong)\n  val Array(hpcost, atkcost, defcost) = in.next().split(\" \").map(_.toLong)\n  var atkmin = if (atky > defm) atky else defm + 1\n  var cost = -1l\n  (atkmin to (hpm + defm)).foreach { atk =>\n    if (cost == -1l || (atk - atky) * atkcost < cost)\n      if (atkm > defm)\n        (defy to atkm).foreach { defend =>\n          println(\"andhere\")\n          if (cost == -1l || ((atk - atky) * atkcost + (defend - defy) * defcost < cost)) {\n            val win = hpm / (atk - defm) + (if (hpm % (atk - defm) > 0) 1 else 0)\n            val damage = win * (atkm - defend)\n            val hp = if (damage >= hpy) damage - hpy + 1 else 0\n            if (cost == -1l || ((atk - atky) * atkcost + (defend - defy) * defcost + hp * hpcost < cost))\n              cost = (atk - atky) * atkcost + (defend - defy) * defcost + hp * hpcost\n          }\n        }\n      else cost = (atk - atky) * atkcost\n  }\n  if (cost == -1l)\n    println(0)\n  else\n    println(cost)\n\n\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val Array(hpy, atky, defy) = in.next().split(\" \").map(_.toLong)\n  val Array(hpm, atkm, defm) = in.next().split(\" \").map(_.toLong)\n  val Array(hpcost, atkcost, defcost) = in.next().split(\" \").map(_.toLong)\n  var atkmin = if (atky > defm) atky else defm + 1\n  var cost = -1l\n  (atkmin to (hpm + defm)).foreach { atk =>\n    if (cost == -1l || (atk - atky) * atkcost < cost)\n      if (atkm > defm)\n        (defy to atkm).foreach { defend =>\n          if (cost == -1l || ((atk - atky) * atkcost + (defend - defy) * defcost < cost)) {\n            val win = hpm / (atk - defm) + (if (hpm % (atk - defm) > 0) 1 else 0)\n            val damage = win * (atkm - defend)\n            val hp = if (damage >= hpy) damage - hpy + 1 else 0\n            if (cost == -1l || ((atk - atky) * atkcost + (defend - defy) * defcost + hp * hpcost < cost))\n              cost = (atk - atky) * atkcost + (defend - defy) * defcost + hp * hpcost\n          }\n        }\n      else cost = (atk - atky) * atkcost\n  }\n  if (cost == -1l)\n    println(0)\n  else\n    println(cost)\n\n\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val Array(hpy, atky, defy) = in.next().split(\" \").map(_.toLong)\n  val Array(hpm, atkm, defm) = in.next().split(\" \").map(_.toLong)\n  val Array(hpcost, atkcost, defcost) = in.next().split(\" \").map(_.toLong)\n  var atkmin = if (atky > defm) atky else defm + 1\n  var cost = -1l\n  (atkmin to (hpm + defm)).foreach { atk =>\n    if (cost == -1l || (atk - atky) * atkcost < cost)\n      (defy to atkm).foreach { defend =>\n        if (cost == -1l || ((atk - atky) * atkcost + (defend - defy) * defcost < cost)) {\n          val win = hpm / (atk - defm) + (if (hpm % (atk - defm) > 0) 1 else 0)\n          val damage = win * (atkm - defend)\n          val hp = if (damage >= hpy) damage - hpy + 1 else 0\n          if (cost == -1l || ((atk - atky) * atkcost + (defend - defy) * defcost + hp * hpcost < cost))\n            cost = (atk - atky) * atkcost + (defend - defy) * defcost + hp * hpcost\n        }\n      }\n  }\n  if (cost == -1l)\n    println(0)\n  else\n    println(cost)\n\n\n}"}, {"source_code": "import scala.collection._\n\nobject A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(hy, ay, dy) = readLongs(3)\n  val Array(hm, am, dm) = readLongs(3)\n  val Array(ch, ca, cd) = readLongs(3)\n\n  var min = Long.MaxValue\n\n  for (a <- 0 to 100) {\n    for (d <- 0 to 100) {\n\n      def can(h: Long) = {\n        (hy + h) * (ay + a - dm) > hm * (am - dy - d)\n      }\n\n      @annotation.tailrec\n      def binSearch(low: Long, hi: Long): Long = {\n        if (hi < low) low\n        else {\n          val mid = (low + hi) >>> 1\n          if (can(mid)) binSearch(low, mid - 1)\n          else binSearch(mid + 1, hi)\n        }\n      }\n\n      val h = binSearch(0, 100000000L)\n      \n      val cost = a * ca + d * cd + h * ch \n      \n      min = Math.min(min, cost)\n    }\n  }\n\n  println(min)\n}"}, {"source_code": "import scala.collection._\n\nobject A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(hy, ay, dy) = readLongs(3)\n  val Array(hm, am, dm) = readLongs(3)\n  val Array(ch, ca, cd) = readLongs(3)\n\n  var min = Long.MaxValue\n\n  for (a <- 0 to 1000) {\n    for (d <- 0 to 100) {\n\n      def can(h: Long) = {\n        //(hy + h) * (ay + a - dm) > hm * (am - dy - d)\n        if (am - dy - d <= 0) true\n        else {\n          val x = (ay + a - dm)\n          if (x <= 0) false\n          else {\n            val steps = (hm + x - 1) / x\n            if ((am - dy - d) * steps < hy + h) true\n            else false\n          }\n        }\n      }\n\n      @annotation.tailrec\n      def binSearch(low: Long, hi: Long): Long = {\n        if (hi < low) low\n        else {\n          val mid = (low + hi) >>> 1\n          if (can(mid)) binSearch(low, mid - 1)\n          else binSearch(mid + 1, hi)\n        }\n      }\n\n      val h = binSearch(0, 100000000L)\n      \n      //if (d == 0 && a == 0) println(h)\n      \n      val cost = a * ca + d * cd + h * ch \n      \n      min = Math.min(min, cost)\n    }\n  }\n\n  println(min)\n}"}, {"source_code": "import scala.collection._\n\nobject A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(hy, ay, dy) = readLongs(3)\n  val Array(hm, am, dm) = readLongs(3)\n  val Array(ch, ca, cd) = readLongs(3)\n\n  var min = Long.MaxValue\n\n  for (a <- 0 to 100) {\n    for (d <- 0 to 100) {\n\n      def can(h: Long) = {\n        //(hy + h) * (ay + a - dm) > hm * (am - dy - d)\n        if (am - dy - d <= 0) true\n        else {\n          val x = (ay + a - dm)\n          if (x <= 0) false\n          else {\n            val steps = (hm + x - 1) / x\n            if ((am - dy - d) * steps < hy + h) true\n            else false\n          }\n        }\n      }\n\n      @annotation.tailrec\n      def binSearch(low: Long, hi: Long): Long = {\n        if (hi < low) low\n        else {\n          val mid = (low + hi) >>> 1\n          if (can(mid)) binSearch(low, mid - 1)\n          else binSearch(mid + 1, hi)\n        }\n      }\n\n      val h = binSearch(0, 100000000L)\n      \n      //if (d == 0 && a == 0) println(h)\n      \n      val cost = a * ca + d * cd + h * ch \n      \n      min = Math.min(min, cost)\n    }\n  }\n\n  println(min)\n}"}, {"source_code": "import scala.collection._\n\nobject A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(hy, ay, dy) = readLongs(3)\n  val Array(hm, am, dm) = readLongs(3)\n  val Array(ch, ca, cd) = readLongs(3)\n\n  var min = Long.MaxValue\n\n  for (a <- 0 to 1000) {\n    for (d <- 0 to 100) {\n\n      def can(h: Long) = {\n        //(hy + h) * (ay + a - dm) > hm * (am - dy - d)\n        if (am - dy - d <= 0) true\n        else {\n          val x = (ay + a - dm)\n          if (x <= 0) false\n          else {\n            (hy + h) * (ay + a - dm) > hm * (am - dy - d)\n            /*val steps = (hm + x) * 1f / x\n            if ((am - dy - d) * steps < hy + h) true\n            else false*/\n          }\n        }\n      }\n\n      @annotation.tailrec\n      def binSearch(low: Long, hi: Long): Long = {\n        if (hi < low) low\n        else {\n          val mid = (low + hi) >>> 1\n          if (can(mid)) binSearch(low, mid - 1)\n          else binSearch(mid + 1, hi)\n        }\n      }\n\n      val h = binSearch(0, 100000000L)\n      \n      //if (d == 0 && a == 0) println(h)\n      \n      val cost = a * ca + d * cd + h * ch \n      \n      min = Math.min(min, cost)\n    }\n  }\n\n  println(min)\n}"}, {"source_code": "import scala.collection._\n\nobject A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(hy, ay, dy) = readLongs(3)\n  val Array(hm, am, dm) = readLongs(3)\n  val Array(ch, ca, cd) = readLongs(3)\n\n  var min = Long.MaxValue\n\n  for (a <- 0 to 1000) {\n    for (d <- 0 to 100) {\n\n      def can(h: Long) = {\n        //(hy + h) * (ay + a - dm) > hm * (am - dy - d)\n        if (am - dy - d <= 0) true\n        else {\n          val x = (ay + a - dm)\n          if (x <= 0) false\n          else {\n            val steps = 1d * hm / x\n            if ((am - dy - d) * steps < hy + h) true\n            else false\n          }\n        }\n      }\n\n      @annotation.tailrec\n      def binSearch(low: Long, hi: Long): Long = {\n        if (hi < low) low\n        else {\n          val mid = (low + hi) >>> 1\n          if (can(mid)) binSearch(low, mid - 1)\n          else binSearch(mid + 1, hi)\n        }\n      }\n\n      val h = binSearch(0, 100000000L)\n      \n      //if (d == 0 && a == 0) println(h)\n      \n      val cost = a * ca + d * cd + h * ch \n      \n      min = Math.min(min, cost)\n    }\n  }\n\n  println(min)\n}"}], "src_uid": "bf8a133154745e64a547de6f31ddc884"}
{"source_code": "\nimport java.io._\nimport java.util.StringTokenizer\n\nobject D {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  def checkPrime(n: Int): Boolean = {\n    if (n == 1)\n      return false\n    var ind = 2\n    var flag = false\n    while (!flag && ind <= Math.sqrt(n).toInt) {\n      if (n % ind == 0) {\n        flag = true\n      }\n      ind += 1\n    }\n    !flag\n  }\n\n  def solve: Int = {\n    val n = nextInt\n    var ind = 2\n    var flag = false\n    if (n == 4) {\n      out.println(2)\n      out.println(\"2 2\")\n      return 0\n    }\n    while (!flag && ind <= Math.sqrt(n).toInt) {\n      if (n % ind == 0) {\n        flag = true\n      }\n      ind += 1\n    }\n    if (flag) {\n      if (checkPrime(n - 3)) {\n        out.println(2)\n        out.println(\"3 \" + (n - 3))\n        return 0\n      }\n      out.println(3)\n      out.print(\"3 \")\n      for (i <- 2 to 1e6.toInt) {\n        if (checkPrime(i) && checkPrime(n - i - 3) && n - i - 3 > 0) {\n          out.println(i + \" \" + (n - i - 3))\n          return 0\n        }\n      }\n    } else {\n      out.println(1)\n      out.println(n)\n    }\n    return 0\n  }\n}\n", "positive_code": [{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val n1 = in.next().toInt\n  val first = 3\n  val n = n1 - first\n\n  def isPrime(n: Int) =\n    if (n == 1) false\n    else if (n == 2) true\n    else if (n % 2 == 0) false\n    else !(3 to Math.sqrt(n).toInt + 1 by 2).exists(i => n % i == 0)\n\n\n  if (n == 0) {\n    println(1)\n    println(3)\n  } else if (isPrime(n)) {\n    println(2)\n    println(\"3 \" + n)\n  } else {\n    val second = (2 until n).find(i => isPrime(i) && isPrime(n - i)).get\n    println(3)\n    println(s\"3 $second ${n - second}\")\n  }\n}"}, {"source_code": "/**\n * @author netman\n */\n\n\nimport java.io._\nimport scala._\nimport scala.Array._\nimport java.util.ArrayList\nimport scala.collection.mutable._\nimport java.util.StringTokenizer\n\n\nobject HelloWorld {\n\n  class InputReader(reader: BufferedReader) {\n    \n    var tokenizer: StringTokenizer = null;\n    \n    def this(stream: InputStream) = {\n      this(new BufferedReader(new InputStreamReader(stream), (1 << 20)));\n    }\n    \n    def this(f: File) = {\n      this(new BufferedReader(new FileReader(f), (1 << 20)));\n    }\n    \n    def next(): String = {\n      while (tokenizer == null || !tokenizer.hasMoreTokens()) {\n        tokenizer = new StringTokenizer(reader.readLine());\n      }\n      return tokenizer.nextToken();\n    }\n    \n    def nextInt(): Int = next().toInt\n  \n    def nextDouble(): Double = next().toDouble\n    \n    def close() = reader.close();\n  }\n  \n  class OutputWriter(writer: PrintWriter) {\n    def this(stream: OutputStream) {\n      this(new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream))));\n    }\n    \n    def this(f: File) = {\n      this(new PrintWriter(new BufferedWriter(new FileWriter(f))));\n    }\n    \n    def print(x: Any) = writer.print(x);\n    \n    def println(x: Any) = writer.println(x);\n    \n    def close() = writer.close();\n  }\n  \n  \n  val in = new InputReader(System.in)\n  val out = new OutputWriter(System.out)\n  \n  def sieve = {\n    val MAX_P = 2000\n    var _isPrime = Array.fill[Boolean](MAX_P)(true)\n    _isPrime(1) = false\n    for (i <- 2 until MAX_P) {\n      if (_isPrime(i)) {\n        for (j <- i + i until MAX_P by i) {\n          _isPrime(j) = false\n        }\n      }\n    }\n    \n    var primes = ArrayBuffer.empty[Int]\n    \n    primes += 0\n    \n    for (i <- 1 until MAX_P) {\n      if (_isPrime(i)) primes += i\n    }\n    \n    primes\n  }\n  \n  def isPrime(x: Int): Boolean = {\n    if (x == 0) return true\n    if (x == 1) return false\n    val sqrtX = math.ceil(math.sqrt(x)).toInt\n    for (i <- 2 to sqrtX) {\n      if (x % i == 0) return false\n    }\n    return true\n  }\n  \n  def main(args: Array[String]): Unit = {  \n    val primes = sieve\n    \n    val x = in.nextInt\n    \n    var i = 0\n    while (primes(i) <= 1000 && primes(i) <= x) {\n      var j = 0\n      while (primes(j) <= 1000 && primes(i) + primes(j) <= x) {\n        if (isPrime(x - primes(i) - primes(j))) {\n          var res = ArrayBuffer.empty[Int]\n          res += primes(i)\n          res += primes(j)\n          res += x - primes(i) - primes(j)\n          \n          while (res.indexOf(0) != -1) res.remove(res.indexOf(0))\n          \n          out.println(res.length)\n          for (x <- res) {\n            out.print(x + \" \")\n          }\n          out.println(\"\")\n          \n          out.close\n          \n          return\n        }\n        j += 1\n      }\n      i += 1\n    }\n    \n    out.close\n  }\n}"}], "negative_code": [{"source_code": "import scala.collection.mutable\n\nobject Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val n1 = in.next().toInt\n  val first = 3\n  val n = n1 - first\n\n  def isPrime(n: Int) =\n    if (n == 1) false\n    else if (n == 2) true\n    else !(3 to Math.sqrt(n).toInt + 1 by 2).exists(i => n % i == 0)\n\n\n  if (n == 0) {\n    println(1)\n    println(3)\n  } else {\n    val set = mutable.Set(2)\n    val notPrime = Array.ofDim[Boolean](n + 1)\n    notPrime(1) = true\n    notPrime(0) = true\n\n    (4 to n by 2).foreach { i => notPrime(i) = true }\n    (3 to n by 2).foreach { i =>\n      if (!notPrime(i)) {\n        set += i\n        (2 * i to n by i).foreach { j => notPrime(j) = true }\n      }\n    }\n\n    if (set.contains(n)) {\n      println(2)\n      println(\"3 \" + n)\n    } else {\n      val second = set.find(i => isPrime(i) && isPrime(n - i)).get\n      println(3)\n      println(s\"3 $second ${n - second}\")\n    }\n  }\n}"}], "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3"}
{"source_code": "object _946B extends CodeForcesApp {\n  import Utils._, annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._, Math._\n\n  override def apply(io: IO): io.type = {\n    var a, b = io.read[Long]\n\n    while(a > 0 && b > 0 && (a >= 2*b || b >= 2*a)) {\n      if (a >= 2*b) {\n        val ka = (a - 2*b)/(2*b) max 1L\n        a -= ka*(2*b)\n      } else {\n        val kb = (b - 2*a)/(2*a) max 1L\n        b -= kb*(2*a)\n      }\n    }\n\n    io.writeAll(Seq(a, b))\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\nobject Utils {\n  import scala.collection.mutable, mutable.{Map => Dict}\n  type Point = java.awt.geom.Point2D.Double\n  implicit class GenericExtensions[A](val a: A) extends AnyVal {\n    def in(set: collection.Set[A]): Boolean = set(a)\n    def some: Option[A] = Some(a)\n    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a\n  }\n  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {\n    def onlyElement: A = assuming(t.size == 1)(t.head)\n    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)\n    def duplicates(implicit b: C of A): C[A] = {\n      val elems = mutable.Set.empty[A]\n      (t collect {case i if !elems.add(i) => i}).to[C]\n    }\n    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}\n    def maxWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.max)\n    def minWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.min)\n    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]\n    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap\n    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)\n    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}\n    def toMutableMultiSet: Dict[A, Int] = {\n      val c = map[A] to 0\n      t.foreach(i => c(i) += 1)\n      c\n    }\n    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0\n    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)\n  }\n  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {\n    def sort(from: Int = 0, until: Int = a.length)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)\n  }\n  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {\n    def sort(from: Int = 0, until: Int = a.length)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)\n  }\n  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {\n    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t\n  }\n  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {\n    def key = p._1\n    def value = p._2\n    def toSeq(implicit ev: B =:= A): Seq[A] = Seq(p._1, ev(p._2))\n  }\n  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {\n    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)\n    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C]).withDefaultValue(b().result())\n    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]\n  }\n  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {\n    def lastKeyOption: Option[K] = m.lastOption.map(_.key)\n    def firstKeyOption: Option[K] = m.headOption.map(_.key)\n    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap\n    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}\n    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m\n    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\n  }\n  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {\n    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)\n    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)\n    private def removeNode(kv: (K, V)): (K, V) = {\n      m -= kv.key\n      kv\n    }\n  }\n  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {\n    def notContains(x: A): Boolean = !(s contains x)\n    def toMutable = mutable.Set.empty[A] ++ s\n  }\n  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {\n    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}\n    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)\n    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)\n    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}\n    //def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)\n  }\n  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {\n    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero\n    def toEnglish = if(x) \"Yes\" else \"No\"\n  }\n  implicit class IntExtensions(val x: Int) extends AnyVal {\n    import java.lang.{Integer => JInt}\n    def withHighestOneBit: Int = JInt.highestOneBit(x)\n    def withLowestOneBit: Int = JInt.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)\n    def bitCount: Int = JInt.bitCount(x)\n    def setLowestBits(n: Int): Int = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Int = x & left(n, ~0)\n    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Int = x | left(i)\n    def clearBit(i: Int): Int = x & ~left(i)\n    def toggleBit(i: Int): Int = x ^ left(i)\n    def getBit(i: Int): Int = (x >> i) & 1\n    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)\n    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)\n  }\n  implicit class LongExtensions(val x: Long) extends AnyVal {\n    import java.lang.{Long => JLong}\n    def withHighestOneBitSet: Long = JLong.highestOneBit(x)\n    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)\n    def bitCount: Int = JLong.bitCount(x)\n    def setLowestBits(n: Int): Long = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Long = x & left(n, ~0L)\n    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Long = x | left(i)\n    def clearBit(i: Int): Long = x & ~left(i)\n    def toggleBit(i: Int): Long = x ^ left(i)\n    def getBit(i: Int): Long = (x >> i) & 1\n    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)\n  }\n  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {\n    import Numeric.Implicits._\n    def **(i: Int): A = if (i == 0) n.one else {\n      val h = x ** (i/2)\n      if (i%2 == 0) h * h else h * h * x\n    }\n    def distance(y: A) = (x - y).abs()\n    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)\n    def whenNegative(f: => A): A = nonNegative.getOrElse(f)   //e.g. students.indexOf(\"Greg\").whenNegative(Int.MaxValue)\n  }\n  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {\n    import scala.collection.immutable.NumericRange, Integral.Implicits._\n    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x\n    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)\n    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)\n  }\n  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new Point(n.toDouble(p._1), n.toDouble(p._2))\n  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)\n  def asc[A](implicit order: Ordering[A]): Ordering[A] = order\n  def map[K] = new {\n    def to[V](default: => V): Dict[K, V] = using(_ => default)\n    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {\n      override def apply(key: K) = getOrElseUpdate(key, f(key))\n    }\n  }\n  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]\n  def memoize[A, B](f: A => B): A ==> B = map[A] using f\n  implicit class FuzzyDouble(val x: Double) extends AnyVal {\n    def  >~(y: Double) = x > y + eps\n    def >=~(y: Double) = x >= y + eps\n    def  ~<(y: Double) = y >=~ x\n    def ~=<(y: Double) = y >~ x\n    def  ~=(y: Double) = (x distance y) <= eps\n  }\n  def toPolygon(points: Traversable[(Int, Int)]): java.awt.Polygon = {\n    val (xs, ys) = points.unzip\n    new java.awt.Polygon(xs.toArray, ys.toArray, points.size)\n  }\n  def toShape(points: Traversable[(Double, Double)]): java.awt.geom.GeneralPath = {\n    val shape = new java.awt.geom.GeneralPath()\n    points.headOption foreach {case (x, y) => shape.moveTo(x, y)}\n    points.tail foreach {case (x, y) => shape.lineTo(x, y)}\n    shape.closePath()\n    shape\n  }\n  def isPrime(n: Int): Boolean = BigInt(n).isProbablePrime(31)\n  def until(until: Int): Range = 0 until until\n  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}\n  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}\n  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None\n  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)\n  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]\n  type ==>[A, B] = collection.Map[A, B]\n  val mod: Int = (1e9 + 7).toInt\n  val eps: Double = 1e-9\n}\n/***********************************[Scala I/O]*********************************************/\nimport Utils._, java.io._, java.util.StringTokenizer\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    when(tokenizers.nonEmpty)(tokenizers.head)\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  def readAll[A: IO.Read]: (Int, Vector[A]) = {\n    val data = read[Vector[A]]\n    (data.length, data)\n  }\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any): this.type = {\n    printer.print(obj)\n    this\n  }\n  def writeLine(): this.type = {\n    printer.println()\n    this\n  }\n  def writeLine(obj: Any): this.type = {\n    printer.println(obj)\n    this\n  }\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n  def query[A: IO.Read](question: Any): A = writeLine(question).read\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                       : Read[String]       = new Read(_.next())\n    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)\n    implicit val int                                          : Read[Int]          = string.map(_.toInt)\n    implicit val long                                         : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                       : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                      : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n", "positive_code": [{"source_code": "object B extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n\n  var Array(a, b) = readLongs(2)\n\n  var changed = true\n  while (a != 0 && b != 0 && changed) {\n    if (a >= 2 * b) {\n      var bb = b\n      while (2 * bb <= a) bb *= 2\n      a -= bb\n    } else if (b >= 2 * a) {\n      var aa = a\n      while (2 * aa <= b) aa *= 2\n      b -= aa\n    } else changed = false\n  }\n\n  println(s\"$a $b\")\n}\n"}, {"source_code": "object B extends App {\n  val Array(n, m) = scala.io.StdIn.readLine().split(\" \").map(_.toLong)\n\n  def weird(a: Long, b: Long): (Long, Long) =\n    if (a == 0 || b == 0) (a, b)\n    else {\n      val ra = a % (2 * b)\n      if (ra != a) weird(ra, b)\n      else {\n        val rb = b % (2 * a)\n        if (rb != b) weird(a, rb)\n        else (a, b)\n      }\n    }\n\n  val (a, b) = weird(n, m)\n  println(a + \" \" + b)\n}\n"}, {"source_code": "object BWeirdSubtractionProcess extends App {\n  val Array(n, m) = scala.io.StdIn.readLine().split(\" \").map(_.toLong)\n\n  def weird(a: Long, b: Long): (Long, Long) =\n    if (a == 0 || b == 0) (a, b)\n    else {\n      val _b = 2 * b\n      if (a >= _b) weird(a % _b, b)\n      else {\n        val _a = 2 * a\n        if (b >= _a) weird(a, b % _a)\n        else (a, b)\n      }\n    }\n\n  val (a, b) = weird(n, m)\n  println(a + \" \" + b)\n}\n"}], "negative_code": [{"source_code": "object B extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  var Array(a, b) = readLongs(2)\n\n  var changed = true\n  while (a * b != 0 && changed) {\n    if (a >= 2 * b) {\n      changed = true\n      var bb = b\n      while (2 * bb <= a) bb *= 2\n      a -= bb\n    } else if (b >= 2 * a) {\n      changed = true\n      var aa = a\n      while (2 * aa <= b) aa *= 2\n      b -= aa\n    } else changed = false\n  }\n\n  println(s\"$a $b\")\n}\n"}], "src_uid": "1f505e430eb930ea2b495ab531274114"}
{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val n = in.next().toInt\n  val sum = in.next().split(\" \").map(_.toInt).sum\n  println((1 to 5).count(i => (i + sum - 1) % (n + 1) != 0))\n}", "positive_code": [{"source_code": "object CF272A {\n    def main(argv: Array[String]) {\n        val n = readInt\n        val str = readLine.split(\" \")\n        def readSum(i: Int, acc: Int): Int = {\n            if (i == n) acc\n            else readSum(i + 1, acc + str(i).toInt)\n        }\n        val sum = readSum(0, 0)\n        def findAns(i: Int, acc: Int): Int = {\n            if (i == 6) acc\n            else {\n                if ((sum + i) % (n + 1) != 1) findAns(i + 1, acc + 1)\n                else findAns(i + 1, acc)\n            }\n        }\n        println(findAns(1, 0))\n    }\n}"}, {"source_code": "import java.util.StringTokenizer\n\nobject _272A extends App {\n  var token = new StringTokenizer(\"\")\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n  val n = next.toInt\n  val sum = (1 to n).map(i => next.toInt).sum\n  val cb = (1 to 5).filter(i => (i + sum) % (n + 1) != 1)\n  println(cb.size)\n}\n"}, {"source_code": "object A272 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def solve(arr: Array[Int], fing: Int): Boolean = {\n    (arr.sum + fing)%(arr.length+1) != 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    val in = readInts(n)\n    out.println((1 to 5).count(fing => solve(in, fing)))\n    out.close()\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(\"src/input\")))\n    val out = new java.io.PrintWriter(System.out)\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P272A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val N = sc.nextInt\n  val fs = List.fill(N)(sc.nextInt).sum\n\n  val answer: Int = {\n    for {\n      i <- 1 to 5\n      if ((fs + i - 1) % (N + 1) > 0)\n    }\n    yield 1\n  }.sum\n\n  out.println(answer)\n  out.close\n}\n"}, {"source_code": "import java.util._\n\nobject Main {\n    def main(args: Array[String]) {\n        val in = new Scanner(System.in)\n        val n = in.nextInt\n        var s = 0\n        for (i <- 0 to n - 1) {\n            s += in.nextInt\n        }\n        \n        var cnt = 0\n        for (i <- 1 to 5) {\n           if ((s + i) % (n + 1) != 1) {\n               cnt += 1\n           }\n        }\n        println(cnt)\n    }\n}"}, {"source_code": "object Fuck {\n  def main(args: Array[String]) {\n    var n = readInt()+1\n    var a = readLine().split(\" \").toList map (_.toInt) sum;\n    println(Range(1,6) count (x => (x+a) % n != 1))\n  }\n}\n"}, {"source_code": "import annotation.tailrec\nimport java.io._\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readInt = reader.readLine().toInt\n\n  val n = readInt\n  val fingers = readInts.sum\n  def ans = (1 to 5).count(x => (x + fingers) % (n + 1) != 1)\n\n  def main(args: Array[String]) {\n    println(ans)\n  }\n}\n"}, {"source_code": "object A\n{\n    def main(args: Array[String])\n    {\n        val n = readLine.toInt\n        val fingers= readLine.split(\" \").map(_.toInt).sum\n        println((1 to 5) map(_+fingers) filter(_%(n+1)!=1) length)\n    }\n}"}, {"source_code": "object A\n{\n    def main(args: Array[String])\n    {\n        val n = readLine.toInt\n        val fingers= readLine.split(\" \").map(_.toInt).sum\n        println((1 to 5) filter{x=>(x+fingers)%(n+1)!=1} length)\n    }\n}\n"}, {"source_code": "import java.util._\n\nobject Main {\n    def main(args: Array[String]) {\n        val in = new Scanner(System.in)\n        val n = in.nextInt\n        var s = 0\n        for (i <- 0 to n - 1) {\n            s += in.nextInt\n        }\n        \n        var cnt = 0\n        for (i <- 1 to 5) {\n           if ((s + i) % (n + 1) != 1) {\n               cnt += 1\n           }\n        }\n        println(cnt)\n    }\n}"}, {"source_code": "import collection.mutable.Map\nimport collection.mutable.ArrayBuffer\n\nobject test6 extends App {\n    val n=readInt\n    val total=readLine.split(\" \").map(_.toInt).sum\n    \n    val ans=(for(i<-1 to 5) yield {\n        if((total+i)%(n+1)==1) 0 else 1 \n    }) sum\n    \n    println(ans)\n}   \n\n\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val n = readInt\n    val sum = readLine().split(\" \").map(_.toInt).sum\n    val r = (1 to 5).foldLeft(0) { (acc, i) => \n      if ((sum + i) % (n + 1) == 1) acc\n      else acc + 1\n    }\n    println(r)\n  }\n}"}], "negative_code": [{"source_code": "object A272 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def solve(arr: Array[Int], fing: Int): Boolean = {\n    (arr.sum + fing)%(arr.length+1) != 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    val in = readInts(n)\n    var break = false\n    for(fing <- 2 to 5 if !break) {\n      if(solve(in, fing)) {\n        out.println(fing)\n        break = true\n      }\n    }\n    out.close()\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(\"src/input\")))\n    val out = new java.io.PrintWriter(System.out)\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "object A272 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def solve(arr: Array[Int], fing: Int): Boolean = {\n    (arr.sum + fing)%(arr.length+1) == 0\n  }\n\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    val in = readInts(n)\n    var break = false\n    for(fing <- 1 to 5 if !break) {\n      if(solve(in, fing)) {\n        out.println(fing)\n        break = true\n      }\n    }\n    out.close()\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(\"src/input\")))\n    val out = new java.io.PrintWriter(System.out)\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "object A272 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def solve(arr: Array[Int], fing: Int): Boolean = {\n    (arr.sum + fing)%(arr.length+1) == 0\n  }\n\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    val in = readInts(n)\n    var break = false\n    for(fing <- 2 to 5 if !break) {\n      if(solve(in, fing)) {\n        out.println(fing)\n        break = true\n      }\n    }\n    out.close()\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(\"src/input\")))\n    val out = new java.io.PrintWriter(System.out)\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}], "src_uid": "ff6b3fd358c758324c19a26283ab96a4"}
{"source_code": "object Solution extends App {\n  val Array(n, m) = readLine().split(\" \").map(_.toInt)\n  println(Range(0, 1000).flatMap(i => Range(0, 1000).map(t => (i, t))).count{\n    case(a, b) => a * a + b == n && a + b * b == m\n  })\n\n}", "positive_code": [{"source_code": "object Round131A2 {\n\n  def main(args: Array[String]): Unit = {\n    val Array(n, m) = readLine().split(\" \").map(_.toInt)\n    var res = 0\n    for (a <- 0 to 1000)\n      for (b <- 0 to 1000)\n        if (a * a + b == n && a + b * b == m)\n          res = res + 1\n    println(res)\n  }\n\n}"}, {"source_code": "import java.util.StringTokenizer\n\nobject _214A extends App {\n  var token = new StringTokenizer(\"\")\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n  val n = next.toInt\n  val m = next.toInt\n  val ans = for {\n    a <- 0 to m\n    val b = n - a * a\n    if (b >= 0 && a + b * b == m)\n  } yield 1\n  println(ans.sum)\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P214A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n  val N, M = sc.nextInt\n\n  val answer = {\n    for {\n      i <- 0 until 32\n      j <- 0 until 32\n      if i * i + j == N && i + j * j == M\n    } yield 1\n  }.sum\n\n  out.println(answer)\n  out.close\n}\n"}, {"source_code": "import java.io._\nimport scala.annotation.tailrec\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInt = reader.readLine().toInt\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n\n  val Array(n, m) = readInts\n  def sqr(x: Int) = x * x\n  def ans = (0 to n).filter(n - sqr(_) >= 0).count(a => a + sqr(n - sqr(a)) == m)\n\n  def main(a: Array[String]) {\n    println(ans)\n  }\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val mn = readLine().split(\" \").map(_.toInt)\n    val m = mn(0)\n    val n = mn(1)\n    var count = 0\n    val s = for {\n      a <- 0 to (Math.sqrt(m).toInt + 1)\n      b <- 0 to (Math.sqrt(n).toInt + 1) \n      if a * a + b == m && a + b * b == n\n    } yield (1)\n    println(s.size)\n  }\n}"}, {"source_code": "object A{\n  def main(args: Array[String]){\n\n    val (n,m)={\n      val sp=readLine.split(\" \")\n      (sp(0).toInt, sp(1).toInt)\n    }\n    \n    println(\n      0 to 1000 count{a=>\n        val b= n-a*a\n        b>=0 && a+b*b==m\n      }\n    )\n  }\n}\n"}, {"source_code": "import scala.io.StdIn\n\nobject Main {\n  def main(args: Array[String]): Unit = {\n    val Array(n, m) = StdIn.readLine().split(\" \").map(_.toInt)\n    println(f(n, m))\n  }\n\n  def f(n: Int, m: Int): Int = {\n    var r = 0\n    for {\n      a <- 0 to 100\n      b <- 0 to 100\n      if a * a + b == n && a + b * b == m\n    } yield {\n      r += 1\n    }\n    r\n  }\n}\n"}], "negative_code": [{"source_code": "object Round131A2 {\n\n  def main(args: Array[String]): Unit = {\n    val Array(n, m) = readLine().split(\" \").map(_.toInt)\n    var res = 0\n    for (a <- 1 to 1000)\n      for (b <- 1 to 1000)\n        if (a * a + b == n && a + b * b == m)\n          res = res + 1\n    println(res)\n  }\n\n}"}, {"source_code": "object Solution extends App {\n  val Array(n, m) = readLine().split(\" \").map(_.toInt)\n  println(Range(0, 1000).flatMap(i => Range(0, i).map(t => (i, t))).count{\n    case(a, b) => a * a + b == n && a + b * b == m\n  })\n\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P214A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val N, M = sc.nextInt\n\n  out.println(List(N, M).mkString(\" \"))\n\n  val answer = {\n    for {\n      a <- 0 to math.sqrt(N).floor.toInt\n      b = math.sqrt(M - a).floor.toInt\n      if a + b * b == M && a * a + b == N\n    } yield 1\n  }.size\n\n  out.println(answer)\n  out.close\n}\n"}, {"source_code": "object A{\n  def main(args: Array[String]){\n\n    val (n,m)={\n      val sp=readLine.split(\" \")\n      (sp(0).toInt, sp(1).toInt)\n    }\n    \n    println(\n      0 to 1000 count{a=>\n        val b= n-a*a\n        a+b*b==m\n      }\n    )\n  }\n}\n"}], "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd"}
{"source_code": "import scala.util.matching.Regex\n\nobject A extends App {\n  def ms2s(ms: (Int, Int)) = { ms._1*60 + ms._2 }\n  def s2ms(s: Int) = { (s/60, s%60) }\n  def str2ms(s: String): (Int, Int) = {\n    val p: Regex = \"\"\"([0-9][0-9]):([0-9][0-9])\"\"\".r\n    val m: Regex.Match = p.findFirstMatchIn(s).get\n    return (m.group(1).toInt, m.group(2).toInt)\n  }\n  \n  var ta, tb = ms2s(str2ms(readLine()))\n  val ans = s2ms(ta+(if (ta < tb) 24*60 else 0) - tb)\n  println(\"%02d:%02d\".format(ans._1, ans._2))\n}\n", "positive_code": [{"source_code": "\nobject ThreeEightSevenA {\n\n\tdef main(args: Array[String]): Unit = {\n\t\tvar to=readLine.split(':').map(_.toInt)\n\t\tvar from=readLine.split(':').map(_.toInt)\n\t\t\n\t\tif(to(0)==from(0) && to(1)==from(1)){\n\t\t\tprintln(\"00:00\")\n\t\t\treturn\n\t\t}\n\t\t\n\t\tif(to(0)==0 && to(1)==0){\n\t\t\tto(0)=24\n\t\t}\n\t\t\n\t\t\n\t\tvar h=to(0)-from(0)\n\t\tvar min=to(1)-from(1)\n\t\t\n\t\tif(min<0)\n\t\t{\n\t\t\th=h-1\n\t\t\tmin+=60\n\t\t}\n\t\tif(h<0){\n\t\t\th+=24\n\t\t}\n\t\tif(h<10)\n\t\t\tprint(\"0\"+h)\n\t\telse\n\t\t\tprint(h)\n\t\t\n\t\tprint(\":\")\n\t\t\n\t\tif(min<10)\n\t\t\tprintln(\"0\"+min)\n\t\telse\n\t\t\tprintln(min)\n\t\t\n\t}\n}"}, {"source_code": "import java.util.StringTokenizer\n\nobject _387A extends App {\n  var token = new StringTokenizer(\"\")\n\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n\n  val cb = next.split(\":\").map(s => s.toInt)\n  val wb = next.split(\":\").map(s => s.toInt)\n\n  var h = cb(0)\n  var m = cb(1)\n  val h1 = wb(0)\n  val m1 = wb(1)\n\n  if (h < h1 || h == h1 && m < m1) h += 24\n\n  if (m < m1) {\n    m += 60\n    h -= 1\n  }\n\n  println(\"%02d:%02d\".format(h - h1, m - m1))\n}\n"}, {"source_code": "object Solution extends App {\n\n  val in = scala.io.Source.stdin.getLines()\n  val k = in.next()\n  val t = in.next()\n  var hourNow = k.take(2).toInt\n  var minutesNow = k.drop(3).toInt\n  val hours = t.take(2).toInt\n  val minutes = t.drop(3).toInt\n  if (minutesNow < minutes) {\n    minutesNow += 60\n    hourNow -= 1\n  }\n  if (hourNow < hours)\n    hourNow += 24\n  hourNow -= hours\n  minutesNow -= minutes\n  println(f\"$hourNow%02d:$minutesNow%02d\")\n\n\n}"}, {"source_code": "import java.util.Scanner\n\nobject P387A {\n    class Time(timeString: String) {\n        val splitTime = timeString.split(\":\")\n        val hour = splitTime(0).toInt\n        val minute = splitTime(1).toInt\n        val totalMinute = hour * 60 + minute\n        def -(that: Time): Time = {\n            val t = (this.totalMinute - that.totalMinute + 60 * 24) % (60 * 24)\n            new Time(t / 60 + \":\" + t % 60)\n        }\n        override def toString =\n            \"0\" * (2 - hour.toString.length) + hour + \":\" + \"0\" * (2 - minute.toString.length) + minute\n    }\n\n    def main(args: Array[String]) {\n        val scanner = new Scanner(System.in)\n        val wakeUpTime = new Time(scanner.next())\n        val sleepTime = new Time(scanner.next())\n        val bedInTime = wakeUpTime - sleepTime\n        println(bedInTime)\n    }\n}\n"}, {"source_code": "object A387 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def main(args: Array[String]): Unit = {\n    val curr = read.split(\":\").map(_.toInt)\n    val time = read.split(\":\").map(_.toInt)\n\n    val start = Array(((if(curr(1)-time(1) < 0) -1 else 0) + 24+curr(0)-time(0))%24, (60+curr(1)-time(1))%60)\n\n    out.println(s\"${\"%02d\".format(start(0))}:${\"%02d\".format(start(1))}\")\n    out.close()\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(\"src/input\")))\n    val out = new java.io.PrintWriter(System.out)\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P387A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n  \n  object Clock {\n    def apply(m: Int): String = {\n      val hour = m / 60\n      val min  = m % 60\n      f\"$hour%02d:$min%02d\"\n    }\n\n    def unapply(s: String): Option[Int] = {\n      val parts = s split \":\"\n      if (parts.length == 2) Some(parts(0).toInt * 60 + parts(1).toInt)\n      else None\n    }\n  }\n\n  def solve(): String = {\n    val Clock(t0) = sc.nextLine\n    val Clock(t1) = sc.nextLine\n    if (t0 >= t1) Clock(t0 - t1)\n    else Clock(t0 - t1 + 1440)\n  }\n\n  out.println(solve)\n  out.close\n}\n"}, {"source_code": "import java.util.Scanner\n\n/**\n * Created by Kuang.Ru on 14-10-10.\n */\nobject A387 {\n  def main(args: Array[String]) {\n    val sc = new Scanner(System.in)\n    val s, t = sc.next()\n    var st = s.split(\":\").map(_.toInt)\n    val tt = t.split(\":\").map(_.toInt)\n    var goBedMin = st(1) - tt(1)\n\n    if (goBedMin < 0) {\n      st(0) -= 1\n      goBedMin = 60 + goBedMin\n    }\n\n    var goBedHour = st(0) - tt(0)\n\n    if (goBedHour < 0) {\n      goBedHour = 24 + goBedHour\n    }\n\n    printf(\"%02d:%02d\", goBedHour, goBedMin)\n  }\n}\n"}, {"source_code": "import scala.util.matching.Regex\n\nobject A extends App {\n  def ms2s(ms: (Int, Int)) = { ms._1*60 + ms._2 }\n  def s2ms(s: Int) = { (s/60, s%60) }\n  def str2ms(s: String): (Int, Int) = {\n    val p: Regex = \"\"\"([0-9][0-9]):([0-9][0-9])\"\"\".r\n    val m: Regex.Match = p.findFirstMatchIn(s).get\n    return (m.group(1).toInt, m.group(2).toInt)\n  }\n  \n  val a = readLine()\n  val b = readLine()\n  \n  var ta = ms2s(str2ms(a))\n  val tb = ms2s(str2ms(b))\n  \n  if (ta < tb) ta += 24*60\n  val ans = s2ms(ta - tb)\n  println(\"%02d:%02d\".format(ans._1, ans._2))\n}\n"}], "negative_code": [{"source_code": "\nobject ThreeEightSevenA {\n\n\tdef main(args: Array[String]): Unit = {\n\t\tvar to=readLine.split(':').map(_.toInt)\n\t\tvar from=readLine.split(':').map(_.toInt)\n\t\tif(to(0)==from(0) && to(1)==from(1)){\n\t\t\tprintln(\"00:00\")\n\t\t\treturn\n\t\t}\n\t\tif(to(0)==0 && to(1)==0){\n\t\t\tto(0)=24\n\t\t}\n\t\tvar h=to(0)-from(0)\n\t\tvar min=to(1)-from(1)\n\t\t\n\t\tif(min<0)\n\t\t{\n\t\t\th=h-1\n\t\t\tmin=min+60\n\t\t}\n\t\t\n\t\tif(h<10)\n\t\t\tprint(\"0\"+h)\n\t\telse\n\t\t\tprint(h)\n\t\tprint(\":\")\n\t\tif(min<10)\n\t\t\tprintln(\"0\"+min)\n\t\telse\n\t\t\tprintln(min)\n\t\t\n\t}\n}"}, {"source_code": "\nobject ThreeEightSevenA {\n\n\tdef main(args: Array[String]): Unit = {\n\t\tvar to=readLine.split(':').map(_.toInt)\n\t\tvar from=readLine.split(':').map(_.toInt)\n\t\tif(to(0)==0 && to(1)==0){\n\t\t\tto(0)=24\n\t\t}\n\t\tvar h=to(0)-from(0)\n\t\tvar min=to(1)-from(1)\n\t\tif(min<0)\n\t\t{\n\t\t\th=h-1\n\t\t\tmin=min+60\n\t\t}\n\t\tif(h<10)\n\t\t\tprint(\"0\"+h)\n\t\telse\n\t\t\tprint(h)\n\t\tprint(\":\")\n\t\tif(min<10)\n\t\t\tprintln(\"0\"+min)\n\t\telse\n\t\t\tprintln(min)\n\t}\n\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P387A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n  \n  object Clock {\n    def apply(m: Int): String = {\n      val hour = m / 60\n      val min  = m % 60\n      f\"$hour%02d:$min%02d\"\n    }\n\n    def unapply(s: String): Option[Int] = {\n      val parts = s split \":\"\n      if (parts.length == 2) Some(parts(0).toInt * 60 + parts(1).toInt)\n      else None\n    }\n  }\n\n  def solve(): String = {\n    val Clock(t0) = sc.nextLine\n    val Clock(t1) = sc.nextLine\n    if (t0 > t1) Clock(t0 - t1)\n    else Clock(t0 - t1 + 1440)\n  }\n\n  out.println(solve)\n  out.close\n}\n"}], "src_uid": "595c4a628c261104c8eedad767e85775"}
{"source_code": "import scala.io._\nimport scala.collection.mutable._\nimport java.util.StringTokenizer\n\nobject HelloWorld {\n\n  def main(args: Array[String]): Unit = {\n    var s = readLine;\n    var result = \"\";\n    var ind = 0;\n    while (ind < s.length) {\n      if (s.startsWith(\".\", ind)) {\n        result += \"0\";\n        ind += 1;\n      } else if (s.startsWith(\"-.\", ind)) {\n        result += \"1\";\n        ind += 2;\n      } else if (s.startsWith(\"--\", ind)) {\n        result += \"2\";\n        ind += 2;\n      }\n    }\n    println(result);\n  }\n\n}", "positive_code": [{"source_code": "object P032B extends App {\n  def f(a: List[Char]):Unit = a match {\n    case '.'::tail => print(0); f(tail)\n    case '-'::'.'::tail => print(1); f(tail)\n    case '-'::'-'::tail => print(2); f(tail)\n    case Nil =>\n  }\n  f(readLine.toList)\n}\n\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val text = in.next().foldLeft(None: Option[Char], List.empty[Int]) {\n    case((None, list), '.') => (None, 0 :: list)\n    case((None, list), '-') => (Some('-'), list)\n    case((Some('-'), list), '-') => (None, 2 :: list)\n    case((Some('-'), list), '.') => (None, 1 :: list)\n  }\n\n  println(text._2.reverse.mkString)\n\n}\n\n\n"}, {"source_code": "object BBorze extends App {\n  import scala.io.StdIn._\n\n  val ans = readLine()\n    .foldLeft((List.empty[Int], \"\")) {\n      case ((codes, code), part) =>\n        code + part match {\n          case \".\"  => (0 :: codes, \"\")\n          case \"-.\" => (1 :: codes, \"\")\n          case \"--\" => (2 :: codes, \"\")\n          case _    => (codes, part.toString)\n        }\n    }\n    ._1\n    .reverse\n\n  println(ans.mkString(\"\"))\n}\n"}, {"source_code": "object BBorze extends App {\n  import scala.io.StdIn._\n\n  val ans = readLine().replace(\"--\", \"2\").replace(\"-.\", \"1\").replace(\".\", \"0\")\n\n  println(ans.mkString(\"\"))\n}\n"}, {"source_code": "import scala.io._\nimport scala.collection.mutable._\nimport java.util.StringTokenizer\n\nobject HelloWorld {\n\n  def main(args: Array[String]): Unit = {\n    var s = readLine;\n    var result = \"\";\n    while (s.length > 0) {\n      if (s.startsWith(\".\")) {\n        result += \"0\";\n        s = s.replaceFirst(\".\", \"\");\n      } else if (s.startsWith(\"-.\")) {\n        result += \"1\";\n        s = s.replaceFirst(\"-.\", \"\");\n      } else if (s.startsWith(\"--\")) {\n        result += \"2\";\n        s = s.replaceFirst(\"--\", \"\");\n      }\n    }\n    println(result);\n  }\n\n}"}], "negative_code": [], "src_uid": "46b5a1cd1bd2985f2752662b7dbb1869"}
{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val data = (1 to 4).map(_ => in.next().map{t => if (t == '#') 1 else 0}).toArray\n  val r = (1 to 3).map(i =>\n    (1 to 3).map{\n      j =>\n        val sum = data(i)(j) + data(i - 1)(j) + data(i)(j - 1) + data(i - 1)(j - 1)\n        Math.max(sum, 4 - sum)\n    }.max\n  ).max\n  if (r < 3)\n    println(\"NO\")\n  else\n    println(\"YES\")\n}", "positive_code": [{"source_code": "object IQ {\n  \n  def main (args : Array[String]){\n    var a = new Array[String](4)\n    for (i <- 0 to 3)\n      a(i) = readLine\n     for (i <- 1 to 3; j <- 1 to 3){\n         var ans = 0\n         if (a(i).charAt(j)=='.')ans +=1\n         if (a(i-1).charAt(j-1)=='.')ans +=1\n         if (a(i).charAt(j-1)=='.')ans +=1\n         if (a(i-1).charAt(j)=='.')ans +=1\n         if (ans!=2){\n        \t println(\"YES\");return\n        \t }\n         }\n     println(\"NO\") \n  }\n\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P287A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  type Grid = Array[Array[Char]]\n  val grid: Grid = Array.fill(4)(sc.nextLine.toArray)\n \n  def solve(): String = {\n    def test(i: Int, j: Int): Boolean = {\n      val cells = List(List(i, j), List(i + 1, j), List(i, j + 1), List(i + 1, j + 1))\n      cells.count {\n        case List(x, y) => grid(x)(y) == '#'\n      } != 2\n    }\n\n    if ((for (i <- 0 until 3; j <- 0 until 3) yield test(i, j)).exists(_ == true)) \"YES\"\n    else \"NO\"\n  }\n\n  out.println(solve)\n  out.close\n}\n"}, {"source_code": "\nobject A {\n  def R = readLine().split(\" \") map(_.toInt)\n\n  def main(args: Array[String]) {\n    var a = Array.ofDim[Boolean](4,4)\n    def check(b:Boolean):Boolean = {\n      for (x <- 0 until 3; y <- 0 until 3 if (a(x)(y) == b &&a(x+1)(y) ==b &&a(x)(y+1) == b &&a(x+1)(y+1) == b)) return true;\n      return false;\n    }\n    for (i <- 0 until 4)\n      a(i) = readLine().toCharArray() map(x => if (x == '#') true else false)\n\n    if (check(true) || check(false)) {\n      println(\"YES\")\n      return;\n    }\n    for (b <- List(false, true); i <- 0 until 4; j <- 0 until 4 if (a(i)(j) != b)) {\n      a(i)(j) = b;\n      if (check(b)) {\n        println(\"YES\")\n        return;\n      }\n      a(i)(j) = !b;\n    }\n    println(\"NO\")\n    \n  }\n\n}"}, {"source_code": "import annotation.tailrec\nimport java.io._\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readInt = reader.readLine().toInt\n\n  val board = for(_ <- 1 to 4) yield reader.readLine().map {\n    case '.' => 0\n    case _ => 1\n  }\n  def ans = (for(i <- 0 to 2) yield (for(j <- 0 to 2) yield {\n    val sum = board(i)(j) + board(i + 1)(j) + board(i)(j + 1) + board(i + 1)(j + 1)\n    sum != 2\n  }).contains(true)).contains(true)\n  def yesNoAns = Map(true -> \"YES\", false -> \"NO\")\n\n  def main(args: Array[String]) {\n    println(yesNoAns(ans))\n  }\n}\n"}, {"source_code": "object A\n{\n\tdef main(args: Array[String]) {\n\t\tval sz = 4\n\t\tval maze = Array.ofDim[Int](sz, sz)\n\t\tfor (i <- 0 until sz) {\n\t\t\tmaze(i) = readLine.split(\"\").tail.map( x => if(x == \"#\") 1 else 0 )\n\t\t}\n\t\tval result = (for (i <- 0 until sz - 1; j <- 0 until sz - 1) yield(i, j)).map( pos => {\n\t\t\t\t\t\t\tval (x, y) = pos\n\t\t\t\t\t\t\tval ss = maze(x)(y) + maze(x+1)(y) + maze(x)(y+1) + maze(x+1)(y+1)\n\t\t\t\t\t\t\tif(ss >= 3 || ss<=1) true else false\n\t\t\t\t\t\t}) reduceLeft(_ || _)\n\t\tprintln(if(result) \"YES\" else \"NO\")\n\t}\n}\n\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val al = new Array[String](4)\n    al(0) = readLine()\n    al(1) = readLine()\n    al(2) = readLine()\n    al(3) = readLine()\n    \n    val sqs = for {\n      i <- 0 to 2\n      j <- 0 to 2\n    } yield(Seq(al(i)(j), al(i)(j + 1), al(i + 1)(j), al(i + 1)(j + 1)))\n    if (sqs.count{ s => \n      val bl = s.count(_ == '#')\n      bl <= 1 || bl >= 3\n    } >= 1) println(\"YES\")\n    else println(\"NO\")\n  }\n}"}, {"source_code": "object CFContest176Div2A {\n  def main(args: Array[String]){\n    var inp = new Array[Array[Char]](4);\n    inp = inp.map(_ => readLine().toCharArray())\n    var result = false;\n    var i =0; var j = 0;\n    for(i <- 0 to 2; j <- 0 to 2){\n      var b=0;\n      for(k<- 0 to 1; l<- 0 to 1){\n        if(inp(i+k)(j+l) == '#') b+=1;\n        \n      }\n      result = result || (b<=1 || b>=3)\n    }\n    if(result) println(\"YES\") else println(\"NO\")\n    \n  }\n}"}], "negative_code": [{"source_code": "object CFContest176Div2A {\n  def main(args: Array[String]){\n    var inp = new Array[Array[Char]](4);\n    inp = inp.map(_ => readLine().toCharArray())\n    var result = false;\n    var i =0; var j = 0;\n    for(i <- 0 to 2; j <- 0 to 2){\n      var b=0;\n      for(k<- 0 to 1; l<- 0 to 1){\n        if(inp(i+k)(j+l) == '#') b+=1;\n        \n      }\n      result = result || (b==1 || b==3)\n    }\n    if(result) println(\"YES\") else println(\"NO\")\n    \n  }\n}"}, {"source_code": "object IQ {\n  \n  def main (args : Array[String]){\n    var a = new Array[String](4)\n    for (i <- 0 until 4)\n      a(i) = readLine\n     var ans = 0\n     for (i <- 1 to 3; j <- 1 to 3){\n         if (a(i).charAt(j)=='.')ans +=1\n         if (a(i-1).charAt(j-1)=='.')ans +=1\n         if (a(i-1).charAt(j+1)=='.')ans +=1\n         if (a(i+1).charAt(j-1)=='.')ans +=1\n         if (ans!=2){\n        \t println(\"YES\");return}\n         }\n     println(\"No\") \n  }\n\n}"}, {"source_code": "object IQ {\n  \n  def main (args : Array[String]){\n    var a = new Array[String](4)\n    for (i <- 0 until 4)\n      a(i) = readLine\n     var ans = 0\n     for (i <- 0 to 1)\n       for (j <- 0 to 1)\n         if (a(i).charAt(j)=='.')ans +=1\n     if (ans==3 || ans==1){\n       println(\"YES\");return}\n     ans = 0\n     for (i <- 2 to 3)\n       for (j <- 0 to 1)\n         if (a(i).charAt(j)=='.')ans +=1\n      if (ans==3 || ans==1){\n       println(\"YES\");return}\n     ans = 0\n     for (i <- 2 to 3)\n       for (j <- 2 to 3)\n         if (a(i).charAt(j)=='.')ans +=1\n      if (ans==3 || ans==1){\n       println(\"YES\");return}\n     ans = 0\n     for (i <- 0 to 1)\n       for (j <- 2 to 3)\n         if (a(i).charAt(j)=='.')ans +=1\n      if (ans==3 || ans==1){\n       println(\"YES\");return}\n     println(\"NO\")    \n    \n  }\n\n}"}, {"source_code": "\nobject A {\n  def R = readLine().split(\" \") map(_.toInt)\n\n  def main(args: Array[String]) {\n    var a = Array.ofDim[Boolean](4,4)\n    def check:Boolean = {\n      for (x <- 0 until 3; y <- 0 until 3 if (a(x)(y)&&a(x+1)(y)&&a(x)(y+1)&&a(x+1)(y+1))) return true;\n      return false;\n    }\n    for (i <- 0 until 4)\n      a(i) = readLine().toCharArray() map(x => if (x == '#') true else false)\n\n    for (i <- 0 until 4; j <- 0 until 4 if (!a(i)(j))) {\n      a(i)(j) = true;\n      if (check) {\n        println(\"YES\")\n        return;\n      }\n      a(i)(j) = false;\n    }\n    println(\"NO\")\n    \n  }\n\n}"}, {"source_code": "\nobject A {\n  def R = readLine().split(\" \") map(_.toInt)\n\n  def main(args: Array[String]) {\n    var a = Array.ofDim[Boolean](4,4)\n    def check(b:Boolean):Boolean = {\n      for (x <- 0 until 3; y <- 0 until 3 if (a(x)(y) == b &&a(x+1)(y) ==b &&a(x)(y+1) == b &&a(x+1)(y+1) == b)) return true;\n      return false;\n    }\n    for (i <- 0 until 4)\n      a(i) = readLine().toCharArray() map(x => if (x == '#') true else false)\n\n    \n    for (b <- List(false, true); i <- 0 until 4; j <- 0 until 4 if (a(i)(j) != b)) {\n      a(i)(j) = b;\n      if (check(b)) {\n        println(\"YES\")\n        return;\n      }\n      a(i)(j) = !b;\n    }\n    println(\"NO\")\n    \n  }\n\n}"}, {"source_code": "object CFContest176Div2A {\n  def main(args: Array[String]){\n    var inp = new Array[Array[Char]](4);\n    inp = inp.map(_ => readLine().toCharArray())\n    var result = false;\n    var i =0; var j = 0;\n    for(i <- 0 to 2; j <- 0 to 2){\n      var b=0;\n      for(k<- 0 to 1; l<- 0 to 1){\n        if(inp(i+k)(j+l) == '#') b+=1;\n        \n      }\n      result = result || (b<1 || b>3)\n    }\n    if(result) println(\"YES\") else println(\"NO\")\n    \n  }\n}"}], "src_uid": "01b145e798bbdf0ca2ecc383676d79f3"}
{"source_code": "//package codeforces.contest1091\n\nobject NewYearAndTheChristmasOrnament {\n  def main(args: Array[String]): Unit = {\n    val Array(y, b, r) = io.StdIn.readLine.split(\" \").map(_.toInt)\n    println(sumOfMaxPossibleIncrementalSequence(y, b, r))\n  }\n\n  def sumOfMaxPossibleIncrementalSequence(y: Int, b: Int, r: Int): Int = {\n    if (!requiresFix(y, b) && !requiresFix(b, r)) y + b + r\n    else {\n      if (requiresFix(b, r)) {\n        val f = fix(b, r)\n        sumOfMaxPossibleIncrementalSequence(y, f._1, f._2)\n      } else {\n        val f = fix(y, b)\n        sumOfMaxPossibleIncrementalSequence(f._1, f._2, r)\n      }\n    }\n  }\n\n  def requiresFix(x: Int, y: Int): Boolean = x + 1 != y\n\n  def fix(x: Int, y: Int): (Int, Int) = {\n    if (x < y) (x, x + 1)\n    else (y - 1, y)\n  }\n}\n", "positive_code": [{"source_code": "import scala.io.StdIn\n\nobject A1091 {\n  def main(args: Array[String]): Unit = {\n    val Array (y_, b_, r_) = StdIn.readLine().split(' ').map{_.toInt}\n    println(\n      (for { y <-  y_ to 1 by -1\n             b <-  b_  to 2 by -1\n             r <-  r_ to 3 by -1\n             if r == b+1 && b == y+1 }\n        yield y+b+r).take(1).head\n    )\n  }\n}\n"}, {"source_code": "import scala.io.StdIn\n\nobject NewYearAndTheChristmasOrnament extends App {\n\n  val line = StdIn.readLine().split(\" \").map(_.toInt)\n\n  val (y, b, r) = (line(0), line(1), line(2))\n\n  val resY = Iterator\n    .iterate(y)(_ - 1)\n    .takeWhile(_ >= 1)\n    .find(y1 => {\n      val b1 = y1 + 1\n      val r1 = b1 + 1\n\n      b1 <= b && r1 <= r\n    })\n    .get\n\n  println(resY + resY + 1 + resY + 2)\n}\n"}, {"source_code": "object A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(y, b, r) = readInts(3)\n\n  val y2 = y min (b - 1) min (r - 2)\n  val b2 = y2 + 1\n  val r2 = b2 + 1\n\n  println(y2 + b2 + r2)\n\n  Console.flush\n}\n"}], "negative_code": [], "src_uid": "03ac8efe10de17590e1ae151a7bae1a5"}
{"source_code": "import scala.annotation.tailrec\nimport scala.io.StdIn.readLine\nimport scala.math.ceil\n\nobject Main extends App {\n  def read(): List[Int] = readLine().split(' ').map(_.toInt).toList\n  @tailrec def f(marks: List[Int], need: Int, ans: Int = 0): Int = {\n    if (need > 0) marks match {\n      case _ :: Nil => ans + 1\n      case x :: xs => f(xs, need - 5 + x, ans + 1)\n    } else ans\n  }\n  val List(n) = read()\n  val marks = read().sorted\n  val need = ceil(n * 4.5).toInt - marks.sum\n  println(f(marks, need))\n}\n", "positive_code": [{"source_code": "import math._\nobject Main extends App {\n    val n = readInt\n    val m = ceil(4.5 * n).toInt\n    val array = readLine.split(\" \").map(_.toInt).sorted\n    val dif = m - array.sum\n    if (dif <= 0) println(0)\n    else {\n        val a_2 = array.count(_ == 2)\n        if (dif <= a_2 * 3) {\n            println(ceil(dif / 3.0).toInt)\n        } else {\n            val r = dif - 3 * a_2\n            val a_3 = array.count(_ == 3)\n            if (r <= a_3 * 2) {\n                println(ceil(r / 2.0).toInt + a_2)\n            } else {\n                println(dif - 2 * a_2 - a_3)\n            }\n        }\n    }\n}"}, {"source_code": "import scala.annotation.tailrec\nimport scala.io.StdIn.readLine\n\nobject Task2 extends App {\n  val n = readLine().split(' ').map(_.toInt).head\n\n  val marks = readLine().split(' ').map(_.toInt).toList.sorted\n\n  @tailrec\n  def sol(n: Int, marks: List[Int], index: Int = 0, res: Int = 0): Int =\n    if (marks.sum.toDouble / n >= 4.5) res else sol(n, marks.updated(index, 5), index + 1, res + 1)\n\n  println(sol(n, marks))\n\n}"}, {"source_code": "object Main{\n  def main(arr: Array[String]): Unit ={\n    val n = readInt()\n    val a = readLine.split(\" \").map(_.toInt).map(_ * 10)\n\n    val totReq = n * 45\n\n    val as = a.sorted\n    var ctot = as.sum\n    var changes = 0\n    var i = 0\n    while(totReq > ctot && i < n){\n      ctot += (50 - as(i))\n      changes += 1\n      i += 1\n    }\n\n    println(changes)\n  }\n}"}], "negative_code": [{"source_code": "import math._\nobject Main extends App {\n    val n = readInt\n    val m = 5 * n - n / 2\n    val array = readLine.split(\" \").map(_.toInt).sorted\n    val dif = m - array.sum\n    if (dif <= 0) println(0)\n    else {\n        val a_3 = array.count(_ == 3)\n        if (dif <= a_3 * 2){\n            println(ceil(dif / 2))\n        } else {\n            println(dif - a_3)\n        }\n    }\n}"}, {"source_code": "import math._\nobject Main extends App {\n    val n = readInt\n    val m = 5 * n - n / 2\n    val array = readLine.split(\" \").map(_.toInt).sorted\n    val dif = m - array.sum\n    if (dif <= 0) println(0)\n    else {\n        val a_3 = array.count(_ == 3)\n        if (dif <= a_3 * 2){\n            println(ceil(dif / 2).toInt)\n        } else {\n            println(dif - a_3)\n        }\n    }\n}"}, {"source_code": "import math._\nobject Main extends App {\n    val n = readInt\n    val m = ceil(4.5 * n).toInt\n    val array = readLine.split(\" \").map(_.toInt).sorted\n    val dif = m - array.sum\n    if (dif <= 0) println(0)\n    else {\n        val a_3 = array.count(_ == 3)\n        if (dif <= a_3 * 2){\n            println(ceil(dif / 2).toInt)\n        } else {\n            println(dif - a_3)\n        }\n    }\n}"}, {"source_code": "import math._\nobject Main extends App {\n    val n = readInt\n    val m = ceil(4.5 * n).toInt\n    val array = readLine.split(\" \").map(_.toInt).sorted\n    val dif = m - array.sum\n    if (dif <= 0) println(0)\n    else {\n        val a_3 = array.count(_ == 3)\n        if (dif <= a_3 * 2){\n            println(ceil(dif / 2.0).toInt)\n        } else {\n            println(dif - a_3)\n        }\n    }\n}"}, {"source_code": "import math._\nobject Main extends App {\n    val n = readInt\n    val m = 5 * n - n / 2\n    val array = readLine.split(\" \").map(_.toInt).sorted\n    val dif = m - array.sum\n    if (dif <= 0) println(0)\n    else {\n        val a_3 = array.count(_ == 3)\n        if (dif <= a_3 * 2){\n            println(dif / 2)\n        } else {\n            println(dif - a_3)\n        }\n    }\n}"}], "src_uid": "715608282b27a0a25b66f08574a6d5bd"}
{"source_code": "import scala.collection._\n\nobject C extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(n) = readInts(1)\n  var ls, rs = Array.ofDim[Int](n)\n\n  for (i <- 0 until n) {\n    val Array(l, r) = readInts(2)\n    ls(i) = l\n    rs(i) = r\n  }\n\n  var ev1, ev2 = 0d\n\n  def probWin(x: Int, l: Int, r: Int): Double = {\n    if (x < l) 0d\n    else if (x > r) 1d\n    else (x - l + 0d) / (r - l + 1d)\n  }\n\n  def probLose(x: Int, l: Int, r: Int): Double = {\n    if (x < l) 1d\n    else if (x > r) 0d\n    else (r - x + 0d) / (r - l + 1d)\n  }\n\n  def probEq(x: Int, l: Int, r: Int): Double = {\n    if (x < l) 0d\n    else if (x > r) 0d\n    else 1d / (r - l + 1d)\n  }\n\n  val maxMask = (1 << (n - 2)) - 1\n\n  for (p1 <- 0 until n) {\n    for (p2 <- 0 until n) if (p2 != p1) {\n      var sumProb1 = 0d\n      var sumProb2 = 0d\n      for (x2 <- ls(p2) to rs(p2)) {\n        for (mask <- 0 to maxMask) {\n          var prob = 1d\n          var i = 1\n          var eqCnt = 2\n          for (px <- 0 until n) if (px != p2 && px != p1) {\n            if ((mask & i) == 0) prob *= probWin(x2, ls(px), rs(px))\n            else {\n              prob *= probEq(x2, ls(px), rs(px))\n              eqCnt += 1\n            }\n            i *= 2\n          }\n         // println(p1, p2, x2, mask, prob, probLose(x2, ls(p1), rs(p1)), probEq(x2, ls(p1), rs(p1)))\n          sumProb1 += x2 * prob * probLose(x2, ls(p1), rs(p1)) / (eqCnt - 1d)\n          sumProb2 += x2 * prob * probEq(x2, ls(p1), rs(p1)) / (eqCnt - 1d) / eqCnt\n          //sumProb2 += x2 * 0.5d * prob * probEq(x2, ls(p1), rs(p1))\n        }\n      }\n      ev1 += sumProb1 / (rs(p2) - ls(p2) + 1d)\n      ev2 += sumProb2 / (rs(p2) - ls(p2) + 1d)\n    }\n  }\n  //println(ev1, ev2)\n  println(ev1 + ev2)\n}\n", "positive_code": [{"source_code": "import java.util.StringTokenizer\n\nobject _513C extends App {\n  var token = new StringTokenizer(\"\")\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n\n  val n = next.toInt\n  val l = Array.fill(n)(0)\n  val r = Array.fill(n)(0)\n  for (i <- 0 until n) {\n    l(i) = next.toInt\n    r(i) = next.toInt\n  }\n  val mask = (1 to n).toArray\n  val denominator = (l zip r).map(p => 1.0 * (p._2 - p._1 + 1)).reduce(_ * _)\n\n  def calc(l: Int, r: Int, ll: Int, rr: Int): Double = {\n    val lll = l max ll\n    val rrr = r min rr\n    if (lll <= rrr) rrr - lll + 1 else 0\n  }\n\n  var second = 1\n  var numerator = 0.0\n  def dfs(t: Int) {\n    if (t >= n) {\n      val sorted = mask.sorted\n      if (sorted(n - 2) == 0) {\n        var tmp = 1.0\n        for (i <- 0 until n) {\n          if (mask(i) == 1) tmp *= calc(l(i), r(i), second + 1, Int.MaxValue)\n          else if (mask(i) == 0) tmp *= calc(l(i), r(i), second, second)\n          else tmp *= calc(l(i), r(i), 0, second - 1)\n        }\n        numerator += second * tmp\n      }\n    } else {\n      for (i <- -1 to 1) {\n        mask(t) = i; dfs(t + 1)\n      }\n    }\n  }\n  while (second <= 10000) {\n    dfs(0)\n    second += 1\n  }\n  println(\"%.10f\".format(numerator / denominator))\n}\n"}, {"source_code": "import java.io.FileInputStream\nimport java.util.Scanner\nimport scala.collection.mutable\n\nobject Solution {\n  def main(args: Array[String]) {\n    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)\n    val n = sc.nextInt\n\n    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))\n    //val start = System.nanoTime()\n    println(new Auction(n, arr).expectationOfSecond())\n    //val end = System.nanoTime()\n    //println(\"Time = \" + (end - start) / 1000000L)\n  }\n}\n\nclass Auction(n: Int, r: Array[(Int, Int)]) {\n  def low(i: Int): Int = r(i)._1\n  def hi(i: Int): Int = r(i)._2\n  def length(i: Int): Int = r(i)._2 - r(i)._1 + 1\n\n  val ZERO = BigInt(0)\n  val ONE = BigInt(0)\n  def gcd(a: BigInt, b: BigInt): BigInt = if (b == ZERO) a else gcd(b, a % b)\n\n  def simplify(a: BigInt, b: BigInt): (BigInt, BigInt) = {\n    val g = gcd(a, b)\n    if (g == ONE) (a, b) else (a / g, b / g)\n  }\n\n  def expectationOfSecond(): Double = {\n    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)\n    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)\n    val map = new mutable.OpenHashMap[BigInt, BigInt](200000)\n    //val summands =\n      for {\n        second <- secondFrom to secondTo\n        si <- 0 until n if low(si) <= second && second <= hi(si)\n        fi <- 0 until n if fi != si && (if (fi < si) second + 1 else second) <= hi(fi)\n        if (0 until n).filter(i => i != si && i != fi).forall(i => low(i) <= (if (i < si) second + 1 else second))\n      } {\n        val a0: BigInt = second * (hi(fi) - math.max(if (fi < si) second + 1 else second, low(fi)) + 1)\n        val b0: BigInt = length(si) * length(fi)\n        val is = (0 until n).filter(i => i != si && i != fi && hi(i) > (if (i < si) second else second - 1))\n        val a = is.map(i => (if (i < si) second else second - 1) - low(i) + 1).foldLeft(a0)(_ * _)\n        val b = is.map(i => length(i)).foldLeft(b0)(_ * _)\n        val x = simplify(a, b)\n        map += (x._2 -> (map.getOrElse(x._2, ZERO) + x._1))\n      }\n      val grouped = map.toIterator.map(p => simplify(p._2, p._1))\n//    val grouped = summands.foldLeft(Map[BigInt, BigInt]())((m, x) => m + (x._2 -> (m.getOrElse(x._2, ZERO) + x._1))).\n//      toList.map(p => simplify(p._2, p._1))\n\n    //println(  summands.foldLeft(Map[BigInt, BigInt]()) ( (m, x) => m + (x._2 -> (m.getOrElse(x._2, ZERO) + x._1)) )  )\n\n    //val grouped = summands.groupBy(_._2).mapValues(_.map(_._1).sum).toList.map(p=>simplify(p._2,p._1))\n    //val grouped = summands.agroupBy(_._2).map(p => (p._1,p._2.map(_._1).sum)).map(p=>simplify(p._2,p._1))\n    grouped.map(p => BigDecimal(p._1) / BigDecimal(p._2)).sum.toDouble\n  }\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.FileInputStream\n\nobject DoubleSolution {\n\n  def main(args: Array[String]) {\n    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)\n    val n = sc.nextInt\n    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))\n    //val start = System.nanoTime()\n    println(new DoubleAuction(n, arr).expectationOfSecond())\n    //val end = System.nanoTime()\n    //println(\"Time = \" + (end - start) / 1000000L)\n  }\n}\n\nclass DoubleAuction(n: Int, r: Array[(Int, Int)]) {\n  def low(i: Int): Int = r(i)._1\n  def hi(i: Int): Int = r(i)._2\n  def length(i: Int): Int = r(i)._2 - r(i)._1 + 1\n\n  val ZERO = BigInt(0)\n  val ONE = BigInt(0)\n  def gcd(a: BigInt, b: BigInt): BigInt = if (b == ZERO) a else gcd(b, a % b)\n\n  def simplify(a: BigInt, b: BigInt): (BigInt, BigInt) = {\n    val g = gcd(a, b)\n    if (g == ONE) (a, b) else (a / g, b / g)\n  }\n\n  def expectationOfSecond(): Double = {\n    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)\n    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)\n    var value = 0.0\n    var second = secondFrom\n    while (second<=secondTo) {\n      var si = 0\n      while (si < n) {\n        if (low(si) <= second && second <= hi(si)) {\n          var fi = 0\n          while (fi<n) {\n            if (fi != si && (if (fi < si) second + 1 else second) <= hi(fi)) {\n              var exists = true\n              var k = 0\n              while (exists && k < n) {\n                if (k != si && k != fi) {\n                  if (!(low(k) <= (if (k < si) second + 1 else second))) exists = false\n                }\n                k += 1\n              }\n              if (exists) {\n                var a0 = second * (hi(fi) - math.max(if (fi < si) second + 1 else second, low(fi)) + 1) / length(si).toDouble / length(fi)\n                var i = 0\n                while (i < n) {\n                  if (i != si && i != fi && hi(i) > (if (i < si) second else second - 1)) {\n                    a0 *= ((if (i < si) second else second - 1) - low(i) + 1)\n                    a0 /= length(i)\n                  }\n                  i += 1\n                }\n                value = value + a0\n              }\n            }\n            fi += 1\n          }\n        }\n        si += 1\n      }\n      second += 1\n    }\n    value\n  }\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.FileInputStream\n\nobject DoubleSolution {\n\n  def main(args: Array[String]) {\n    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)\n    val n = sc.nextInt\n    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))\n    println(new DoubleAuction(n, arr).expectationOfSecond())\n  }\n}\n\nclass DoubleAuction(n: Int, r: Array[(Int, Int)]) {\n  def low(i: Int): Int = r(i)._1\n  def hi(i: Int): Int = r(i)._2\n  def length(i: Int): Int = r(i)._2 - r(i)._1 + 1\n\n  val ZERO = BigInt(0)\n  val ONE = BigInt(0)\n  def gcd(a: BigInt, b: BigInt): BigInt = if (b == ZERO) a else gcd(b, a % b)\n\n  def simplify(a: BigInt, b: BigInt): (BigInt, BigInt) = {\n    val g = gcd(a, b)\n    if (g == ONE) (a, b) else (a / g, b / g)\n  }\n\n  def expectationOfSecond(): Double = {\n    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)\n    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)\n    //val summands =\n    (for {\n      second <- secondFrom to secondTo\n      si <- 0 until n if low(si) <= second && second <= hi(si)\n      fi <- 0 until n if fi != si && (if (fi < si) second + 1 else second) <= hi(fi)\n      if (0 until n).filter(i => i != si && i != fi).forall(i => low(i) <= (if (i < si) second + 1 else second))\n\n    } yield {\n      val a0: Double = second * (hi(fi) - math.max(if (fi < si) second + 1 else second, low(fi)) + 1) / length(si).toDouble / length(fi)\n      (0 until n).filter(i => i != si && i != fi && hi(i) > (if (i < si) second else second - 1)).\n        foldLeft(a0) ((p, i) => p * ((if (i < si) second else second - 1) - low(i) + 1) / length(i))\n    }).sum\n  }\n}"}], "negative_code": [{"source_code": "import java.util.StringTokenizer\n\nobject _513C extends App {\n  var token = new StringTokenizer(\"\")\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n\n  val n = next.toInt\n  val l = Array.fill(n)(0)\n  val r = Array.fill(n)(0)\n  for (i <- 0 until n) {\n    l(i) = next.toInt\n    r(i) = next.toInt\n  }\n  val mask = (1 to n).toArray\n  val denominator = (l zip r).map(p => 1.0 * (p._2 - p._1 + 1)).reduce(_ * _)\n\n  def calc(l: Int, r: Int, ll: Int, rr: Int): Double = {\n    val lll = l max ll\n    val rrr = r min rr\n    if (lll <= rrr) rrr - lll + 1 else 0\n  }\n\n  val numerators = for (second <- 1 to 50) yield {\n    def dfs(t: Int): Double =\n      if (t >= n) {\n        val sorted = mask.sorted\n        if (sorted(n - 2) == 0) {\n          val cand = for (i <- 0 until n) yield {\n            if (mask(i) == 1) calc(l(i), r(i), second + 1, Int.MaxValue)\n            else if (mask(i) == 0) calc(l(i), r(i), second, second)\n            else calc(l(i), r(i), 0, second - 1)\n          }\n          cand.reduce(_ * _) * second\n        } else 0\n      } else {\n        val hehe = for (i <- -1 to 1) yield { mask(t) = i; dfs(t + 1) }\n        hehe.sum\n      }\n    dfs(0)\n  }\n  val numerator = numerators.sum\n  println(\"%.10f\".format(numerator / denominator))\n}\n"}, {"source_code": "import scala.collection._\n\nobject C extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(n) = readInts(1)\n  var ls, rs = Array.ofDim[Int](n)\n\n  for (i <- 0 until n) {\n    val Array(l, r) = readInts(2)\n    ls(i) = l\n    rs(i) = r\n  }\n\n  var ev1, ev2 = 0d\n\n  def probWin(x: Int, l: Int, r: Int): Double = {\n    if (x < l) 0d\n    else if (x > r) 1d\n    else (x - l + 0d) / (r - l + 1d)\n  }\n\n  def probLose(x: Int, l: Int, r: Int): Double = {\n    if (x < l) 1d\n    else if (x > r) 0d\n    else (r - x + 0d) / (r - l + 1d)\n  }\n\n  def probEq(x: Int, l: Int, r: Int): Double = {\n    if (x < l) 0d\n    else if (x > r) 0d\n    else 1d / (r - l + 1d)\n  }\n\n  val maxMask = (1 << (n - 2)) - 1\n\n  for (p1 <- 0 until n) {\n    for (p2 <- 0 until n) if (p2 != p1) {\n      var sumProb1 = 0d\n      var sumProb2 = 0d\n      for (x2 <- ls(p2) to rs(p2)) {\n        for (mask <- 0 to maxMask) {\n          var prob = 1d\n          var i = 1\n          var eqCnt = 2\n          for (px <- 0 until n) if (px != p2 && px != p1) {\n            if ((mask & i) == 0) prob *= probWin(x2, ls(px), rs(px))\n            else {\n              prob *= probEq(x2, ls(px), rs(px))\n              eqCnt += 1\n            }\n            i *= 2\n          }\n         // println(p1, p2, x2, mask, prob, probLose(x2, ls(p1), rs(p1)), probEq(x2, ls(p1), rs(p1)))\n          sumProb1 += x2 * prob * probLose(x2, ls(p1), rs(p1)) / (eqCnt - 1d)\n          sumProb2 += x2 * prob * probEq(x2, ls(p1), rs(p1)) / (eqCnt - 1d) / eqCnt\n          //sumProb2 += x2 * 0.5d * prob * probEq(x2, ls(p1), rs(p1))\n        }\n      }\n      ev1 += sumProb1 / (rs(p2) - ls(p2) + 1d)\n      ev2 += sumProb2 / (rs(p2) - ls(p2) + 1d)\n    }\n  }\n  println(ev1, ev2)\n  println(ev1 + ev2)\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.FileInputStream\n\nobject DoubleSolution {\n\n  def main(args: Array[String]) {\n    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)\n    val n = sc.nextInt\n    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))\n    println(new DoubleAuction(n, arr).expectationOfSecond())\n  }\n}\n\nclass DoubleAuction(n: Int, r: Array[(Int, Int)]) {\n  def low(i: Int): Int = r(i)._1\n  def hi(i: Int): Int = r(i)._2\n  def length(i: Int): Int = r(i)._2 - r(i)._1 + 1\n\n  val ZERO = BigInt(0)\n  val ONE = BigInt(0)\n  def gcd(a: BigInt, b: BigInt): BigInt = if (b == ZERO) a else gcd(b, a % b)\n\n  def simplify(a: BigInt, b: BigInt): (BigInt, BigInt) = {\n    val g = gcd(a, b)\n    if (g == ONE) (a, b) else (a / g, b / g)\n  }\n\n  def expectationOfSecond(): Double = {\n    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)\n    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)\n    var value = 0.0\n    var second = secondFrom\n    while (second<=secondTo) {\n      var si = 0\n      while (si < n) {\n        if (low(si) <= second && second <= hi(si)) {\n          var fi = 0\n          while (fi < n) {\n            if (fi != si && (if (fi < si) second + 1 else second) <= hi(fi)) {\n              var v = second * (hi(fi) - math.max(if (fi < si) second + 1 else second, low(fi)) + 1) / length(si).toDouble / length(fi)\n              var i = 0\n              while (i < n) {\n                if (i != si && i != fi && hi(i) > (if (i < si) second else second - 1)) {\n                  v *= ((if (i < si) second else second - 1) - low(i) + 1) / length(i).toDouble\n                }\n                i += 1\n              }\n              value += v\n            }\n            fi += 1\n          }\n        }\n        si += 1\n      }\n      second += 1\n    }\n    value\n  }\n}\n"}, {"source_code": "import Fraction._\nimport java.io.FileInputStream\nimport java.util.Scanner\n\nobject Solution {\n  def main(args: Array[String]) {\n    // assert(new Auction(3, Array((4, 7), (8, 10), (5, 5))).expectationOfSecond().toDouble == 5.75)\n    // assert(new Auction(3, Array((2,5), (3,4), (1,6))).expectationOfSecond().toDouble == 3.5)\n    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)\n    val n = sc.nextInt\n    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))\n    val expectation = new Auction(3, arr).expectationOfSecond().toDouble\n    println(expectation)\n  }\n}\n\nclass Fraction(val a:Long, val b:Long) {\n  def toDouble: Double = if (a == 0) 0.0 else a.toDouble / b\n\n  def *(that: Fraction): Fraction = mul(this, that)\n\n  override def toString: String =\n    if (a == 0) \"0\"\n    else if (b == 1) a.toString\n    else a + \"/\" + b\n}\n\nobject Fraction {\n  val ZERO = new Fraction(0L, 1L)\n  val ONE = new Fraction(1L, 1L)\n  def gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\n  def fract(a: Long, b: Long): Fraction =\n    if (a == 0L) ZERO\n    else if (a == b) ONE\n    else {\n      val d = gcd(a, b)\n      new Fraction(a / d, b / d)\n    }\n\n  def mul(x: Fraction, y: Fraction): Fraction =\n    if (x == ZERO || y == ZERO) ZERO\n    else if (x == ONE) y\n    else if (y == ONE) x\n    else fract(x.a * y.a, x.b * y.b)\n\n  def mul(x: Long, y: Fraction): Fraction =\n    if (x == 0 || y == ZERO) ZERO\n    else if (x == 1) y\n    else if (y == ONE) new Fraction(x, 1L)\n    else fract(x * y.a, y.b)\n\n  def sum(x: Fraction, y: Fraction): Fraction =\n    if (x == ZERO) y\n    else if (y == ZERO) x\n    else if (x.b == y.b) fract(x.a + y.a, x.b)\n    else fract(x.a * y.b + y.a * x.b, x.b * y.b)\n}\n\nclass Auction(n: Int, r: Array[(Int, Int)]) {\n  @inline def low(i: Int): Int = r(i)._1\n  @inline def hi(i: Int): Int = r(i)._2\n  @inline def length(i: Int): Int = r(i)._2 - r(i)._1 + 1\n\n  def pFirst(firstFrom: Int, excluded: Int): Fraction = {\n    @inline def from(i: Int) = if (i < excluded) firstFrom + 1 else firstFrom\n    @inline def till(i: Int) = if (i < excluded) firstFrom else firstFrom - 1\n    val fs = (0 until n).filter(i => i != excluded && from(i) <= hi(i))\n    if (fs.isEmpty) ZERO\n    else\n      fs.map(f =>\n        (0 until n).filter(i => i != excluded && i != f).\n          map(i => if (hi(i) <= till(i)) ONE\n                   else if (till(i) < low(i)) ZERO\n                   else fract(till(i) - low(i) + 1, length(i))).\n          foldLeft(fract(hi(f) - math.max(from(f), low(f)) + 1, length(f)))(mul)\n      ).reduce(sum)\n  }\n\n  def expectationOfSecond(): Fraction = {\n    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)\n    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)\n    (for {\n      second <- secondFrom to secondTo\n      i <- 0 until n if low(i) <= second && second <= hi(i)\n    } yield fract(second, length(i)) * pFirst(second, i)) reduce sum\n  }\n\n}\n\n"}, {"source_code": "import java.io.FileInputStream\nimport java.util.Scanner\n\nobject Solution {\n  def main(args: Array[String]) {\n    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)\n    val n = sc.nextInt\n    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))\n    println(new Auction(n, arr).expectationOfSecond())\n  }\n}\nclass Auction(n: Int, r: Array[(Int, Int)]) {\n  def low(i: Int): Int = r(i)._1\n  def hi(i: Int): Int = r(i)._2\n  def length(i: Int): Int = r(i)._2 - r(i)._1 + 1\n\n  val ZERO = BigInt(0)\n  val ONE = BigInt(0)\n  def gcd(a: BigInt, b: BigInt): BigInt = if (b == ZERO) a else gcd(b, a % b)\n\n  def simplify(a: BigInt, b: BigInt): (BigInt, BigInt) = {\n    val g = gcd(a, b)\n    if (g == ONE) (a, b) else (a / g, b / g)\n  }\n\n  def expectationOfSecond(): Double = {\n    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)\n    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)\n    val summands =\n      for {\n        second <- secondFrom to secondTo\n        si <- 0 until n if low(si) <= second && second <= hi(si)\n        fi <- 0 until n if fi != si && (if (fi < si) second + 1 else second) <= hi(fi)\n        if (0 until n).filter(i => i != si && i != fi).forall(i => low(i) <= (if (i < si) second + 1 else second))\n      } yield {\n        val a0: BigInt = second * (hi(fi) - math.max(if (fi < si) second + 1 else second, low(fi)) + 1)\n        val b0: BigInt = length(si) * length(fi)\n        val is = (0 until n).filter(i => i != si && i != fi && hi(i) > (if (i < si) second else second - 1))\n        val a = is.map(i => (if (i < si) second else second - 1) - low(i) + 1).foldLeft(a0)(_ * _)\n        val b = is.map(i => length(i)).foldLeft(b0)(_ * _)\n        simplify(a, b)\n      }\n    //val optimized = summands\n    val grouped = summands.groupBy(_._2).mapValues(_.map(_._1).sum).map(p => simplify(p._2, p._1))\n    grouped.map(p => BigDecimal(p._1) / BigDecimal(p._2)).sum.toDouble\n  }\n}\n"}, {"source_code": "import Fraction._\nimport java.io.FileInputStream\nimport java.util.Scanner\n\nobject Solution {\n  def main(args: Array[String]) {\n    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)\n    val n = sc.nextInt\n    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))\n    val expectation = new Auction(n, arr).expectationOfSecond().toDouble\n    println(expectation)\n  }\n}\n\nclass Fraction(val a:Long, val b:Long) {\n  def toDouble: Double = if (a == 0) 0.0 else a.toDouble / b\n\n  def *(that: Fraction): Fraction = mul(this, that)\n\n  override def toString: String =\n    if (a == 0) \"0\"\n    else if (b == 1) a.toString\n    else a + \"/\" + b\n}\n\nobject Fraction {\n  val ZERO = new Fraction(0L, 1L)\n  val ONE = new Fraction(1L, 1L)\n  def gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\n  def fract(a: Long, b: Long): Fraction =\n    if (a == 0L) ZERO\n    else if (a == b) ONE\n    else {\n      val d = gcd(a, b)\n      new Fraction(a / d, b / d)\n    }\n\n  def mul(x: Fraction, y: Fraction): Fraction =\n    if (x == ZERO || y == ZERO) ZERO\n    else if (x == ONE) y\n    else if (y == ONE) x\n    else fract(x.a * y.a, x.b * y.b)\n\n  def mul(x: Long, y: Fraction): Fraction =\n    if (x == 0 || y == ZERO) ZERO\n    else if (x == 1) y\n    else if (y == ONE) new Fraction(x, 1L)\n    else fract(x * y.a, y.b)\n\n  def sum(x: Fraction, y: Fraction): Fraction =\n    if (x == ZERO) y\n    else if (y == ZERO) x\n    else if (x.b == y.b) fract(x.a + y.a, x.b)\n    else fract(x.a * y.b + y.a * x.b, x.b * y.b)\n}\n\nclass Auction(n: Int, r: Array[(Int, Int)]) {\n  @inline def low(i: Int): Int = r(i)._1\n  @inline def hi(i: Int): Int = r(i)._2\n  @inline def length(i: Int): Int = r(i)._2 - r(i)._1 + 1\n\n  def pFirst(firstFrom: Int, excluded: Int): Fraction = {\n    @inline def from(i: Int) = if (i < excluded) firstFrom + 1 else firstFrom\n    @inline def till(i: Int) = if (i < excluded) firstFrom else firstFrom - 1\n    val fs = (0 until n).filter(i => i != excluded && from(i) <= hi(i))\n    if (fs.isEmpty) ZERO\n    else\n      fs.map(f =>\n        (0 until n).filter(i => i != excluded && i != f).\n          map(i => if (hi(i) <= till(i)) ONE\n                   else if (till(i) < low(i)) ZERO\n                   else fract(till(i) - low(i) + 1, length(i))).\n          foldLeft(fract(hi(f) - math.max(from(f), low(f)) + 1, length(f)))(mul)\n      ).reduce(sum)\n  }\n\n  def expectationOfSecond(): Fraction = {\n    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)\n    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)\n    (for {\n      second <- secondFrom to secondTo\n      i <- 0 until n if low(i) <= second && second <= hi(i)\n    } yield fract(second, length(i)) * pFirst(second, i)) reduce sum\n  }\n\n}\n\n"}, {"source_code": "import Fraction._\nimport java.io.FileInputStream\nimport java.util.Scanner\n\nobject Solution {\n  def main(args: Array[String]) {\n    // assert(new Auction(3, Array((4, 7), (8, 10), (5, 5))).expectationOfSecond().toDouble == 5.75)\n    // assert(new Auction(3, Array((2,5), (3,4), (1,6))).expectationOfSecond().toDouble == 3.5)\n    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)\n    val n = sc.nextInt\n    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))\n    val start = System.nanoTime()\n    val expectation = new Auction(n, arr).expectationOfSecond().toDouble\n    val end = System.nanoTime()\n    println(expectation)\n    println(\"Time = \" + (end - start) / 1000000L)\n  }\n}\n\nclass Fraction(val a:Long, val b:Long) {\n  def toDouble: Double = if (a == 0) 0.0 else a.toDouble / b\n\n  def *(that: Fraction): Fraction = mul(this, that)\n\n  override def toString: String =\n    if (a == 0) \"0\"\n    else if (b == 1) a.toString\n    else a + \"/\" + b\n}\n\nobject Fraction {\n  val ZERO = new Fraction(0L, 1L)\n  val ONE = new Fraction(1L, 1L)\n  def gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\n  def fract(a: Long, b: Long): Fraction =\n    if (a == 0L) ZERO\n    else if (a == b) ONE\n    else {\n      val d = gcd(a, b)\n      new Fraction(a / d, b / d)\n    }\n\n//  def mul(x: Fraction, y: Fraction): Fraction =\n//    if (x == ZERO || y == ZERO) ZERO\n//    else if (x == ONE) y\n//    else if (y == ONE) x\n//    else {\n//      val gcd1 = gcd(x.a, y.b)\n//      val gcd2 = gcd(x.b, y.a)\n//      fract((x.a / gcd1) * (y.a / gcd2), (x.b / gcd2) * (y.b / gcd1))\n//      if (x.a * y.a < x.a || x.a * y.a < y.a) println(x.a, y.a, x.a * y.a)\n//      fract( x.a * y.a, x.b * y.b)\n//    }\n\n  def mul(x: Fraction, y: Fraction): Fraction = mulUnsafe(reduce(x), reduce(y))\n  def mulUnsafe(x: Fraction, y: Fraction): Fraction =\n    if (x == ZERO || y == ZERO) ZERO\n    else if (x == ONE) y\n    else if (y == ONE) x\n    else {\n      val gcd1 = gcd(x.a, y.b)\n      val gcd2 = gcd(x.b, y.a)\n      fract((x.a / gcd1) * (y.a / gcd2), (x.b / gcd2) * (y.b / gcd1))\n      if (x.a * y.a < x.a || x.a * y.a < y.a) println(x.a, y.a, x.a * y.a)\n      fract( x.a * y.a, x.b * y.b)\n    }\n\n\n  def mul(x: Long, y: Fraction): Fraction =\n    if (x == 0 || y == ZERO) ZERO\n    else if (x == 1) y\n    else if (y == ONE) new Fraction(x, 1L)\n    else fract(x * y.a, y.b)\n\n//  def sum(x: Fraction, y: Fraction): Fraction =\n//    if (x == ZERO) y\n//    else if (y == ZERO) x\n//    else if (x.b == y.b) fract(x.a + y.a, x.b)\n//    else {\n//      val g = gcd(x.b, y.b)\n//      if (g == 1) fract(x.a * y.b + y.a * x.b, x.b * y.b)\n//      else fract(x.a * (y.b / g) + y.a * (x.b / g), x.b / g * y.b)\n//    }\n\n  def sumUnsafe(x: Fraction, y: Fraction): Fraction =\n    if (x == ZERO) y\n    else if (y == ZERO) x\n    else if (x.b == y.b) fract(x.a + y.a, x.b)\n    else {\n      val g = gcd(x.b, y.b)\n      if (g == 1) fract(x.a * y.b + y.a * x.b, x.b * y.b)\n      else fract(x.a * (y.b / g) + y.a * (x.b / g), x.b / g * y.b)\n    }\n\n  def sum(x: Fraction, y: Fraction): Fraction = sumUnsafe(reduce(x),reduce(y))\n\n  val MAX: Long = Integer.MAX_VALUE\n  def reduce(x: Fraction): Fraction =\n    if (x.a < MAX && x.b < MAX) x\n    else {\n      var a = x.a\n      var b = x.b\n      while (a > MAX || b > MAX) {\n        a >>= 1\n        b >>= 1\n      }\n      fract(a, b)\n    }\n}\n\n//class BigFraction(val a:BigInt, val b:BigInt) {\n//\n//}\n//\n//object BigFraction {\n//  def sum(x: BigFraction, y: Fraction): BigFraction = {\n//\n//  }\n//}\n\nclass Auction(n: Int, r: Array[(Int, Int)]) {\n  @inline def low(i: Int): Int = r(i)._1\n  @inline def hi(i: Int): Int = r(i)._2\n  @inline def length(i: Int): Int = r(i)._2 - r(i)._1 + 1\n\n  def pFirst(firstFrom: Int, excluded: Int): Fraction = {\n    @inline def from(i: Int) = if (i < excluded) firstFrom + 1 else firstFrom\n    @inline def till(i: Int) = if (i < excluded) firstFrom else firstFrom - 1\n    val fs = (0 until n).filter(i => i != excluded && from(i) <= hi(i))\n    if (fs.isEmpty) ZERO\n    else\n      fs.map(f =>\n        (0 until n).filter(i => i != excluded && i != f).\n          map(i => if (hi(i) <= till(i)) ONE\n                   else if (till(i) < low(i)) ZERO\n                   else fract(till(i) - low(i) + 1, length(i))).\n          foldLeft(fract(hi(f) - math.max(from(f), low(f)) + 1, length(f)))(mul)\n      ).reduce(sum)\n  }\n\n  def expectationOfSecond(): Fraction = {\n    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)\n    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)\n    val summands =\n      for {\n        second <- secondFrom to secondTo\n        i <- 0 until n if low(i) <= second && second <= hi(i)\n      } yield fract(second, length(i)) * pFirst(second, i)\n    val optimized = summands.groupBy(_.b).mapValues(_.map(_.a).sum).map(p => fract(p._2, p._1))\n    optimized.reduce(sum)\n  }\n\n}\n"}, {"source_code": "import Fraction._\nimport java.io.FileInputStream\nimport java.util.Scanner\n\nobject Solution {\n  def main(args: Array[String]) {\n    // assert(new Auction(3, Array((4, 7), (8, 10), (5, 5))).expectationOfSecond().toDouble == 5.75)\n    // assert(new Auction(3, Array((2,5), (3,4), (1,6))).expectationOfSecond().toDouble == 3.5)\n    val sc = new Scanner(if (args.length > 0) new FileInputStream(args(0)) else System.in)\n    val n = sc.nextInt\n    val arr = Array.tabulate(n)(_ => (sc.nextInt(), sc.nextInt()))\n//    val start = System.nanoTime()\n    val expectation = new Auction(n, arr).expectationOfSecond().toDouble\n//    val end = System.nanoTime()\n    println(expectation)\n//    println(\"Time = \" + (end - start) / 1000000L)\n  }\n}\n\nclass Fraction(val a:Long, val b:Long) {\n  def toDouble: Double = if (a == 0) 0.0 else a.toDouble / b\n\n  def *(that: Fraction): Fraction = mul(this, that)\n\n  override def toString: String =\n    if (a == 0) \"0\"\n    else if (b == 1) a.toString\n    else a + \"/\" + b\n}\n\nobject Fraction {\n  val ZERO = new Fraction(0L, 1L)\n  val ONE = new Fraction(1L, 1L)\n  def gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)\n  def fract(a: Long, b: Long): Fraction =\n    if (a == 0L) ZERO\n    else if (a == b) ONE\n    else {\n      val d = gcd(a, b)\n      new Fraction(a / d, b / d)\n    }\n\n//  def mul(x: Fraction, y: Fraction): Fraction =\n//    if (x == ZERO || y == ZERO) ZERO\n//    else if (x == ONE) y\n//    else if (y == ONE) x\n//    else {\n//      val gcd1 = gcd(x.a, y.b)\n//      val gcd2 = gcd(x.b, y.a)\n//      fract((x.a / gcd1) * (y.a / gcd2), (x.b / gcd2) * (y.b / gcd1))\n//      if (x.a * y.a < x.a || x.a * y.a < y.a) println(x.a, y.a, x.a * y.a)\n//      fract( x.a * y.a, x.b * y.b)\n//    }\n\n  def mul(x: Fraction, y: Fraction): Fraction = mulUnsafe(reduce(x), reduce(y))\n  def mulUnsafe(x: Fraction, y: Fraction): Fraction =\n    if (x == ZERO || y == ZERO) ZERO\n    else if (x == ONE) y\n    else if (y == ONE) x\n    else {\n      //val gcd1 = gcd(x.a, y.b)\n      //val gcd2 = gcd(x.b, y.a)\n      // fract((x.a / gcd1) * (y.a / gcd2), (x.b / gcd2) * (y.b / gcd1))\n      // if (x.a * y.a < x.a || x.a * y.a < y.a) println(x.a, y.a, x.a * y.a)\n      fract( x.a * y.a, x.b * y.b)\n    }\n\n\n  def mul(x: Long, y: Fraction): Fraction =\n    if (x == 0 || y == ZERO) ZERO\n    else if (x == 1) y\n    else if (y == ONE) new Fraction(x, 1L)\n    else fract(x * y.a, y.b)\n\n//  def sum(x: Fraction, y: Fraction): Fraction =\n//    if (x == ZERO) y\n//    else if (y == ZERO) x\n//    else if (x.b == y.b) fract(x.a + y.a, x.b)\n//    else {\n//      val g = gcd(x.b, y.b)\n//      if (g == 1) fract(x.a * y.b + y.a * x.b, x.b * y.b)\n//      else fract(x.a * (y.b / g) + y.a * (x.b / g), x.b / g * y.b)\n//    }\n\n  def sumUnsafe(x: Fraction, y: Fraction): Fraction =\n    if (x == ZERO) y\n    else if (y == ZERO) x\n    else if (x.b == y.b) fract(x.a + y.a, x.b)\n    else {\n      val g = gcd(x.b, y.b)\n      if (g == 1) fract(x.a * y.b + y.a * x.b, x.b * y.b)\n      else fract(x.a * (y.b / g) + y.a * (x.b / g), x.b / g * y.b)\n    }\n\n  def sum(x: Fraction, y: Fraction): Fraction = sumUnsafe(reduce(x),reduce(y))\n\n  val MAX: Long = Integer.MAX_VALUE\n  def reduce(x: Fraction): Fraction =\n    if (x.a < MAX && x.b < MAX) x\n    else {\n      var a = x.a\n      var b = x.b\n      while (a > MAX || b > MAX) {\n        a >>= 1\n        b >>= 1\n      }\n      fract(a, b)\n    }\n}\n\n//class BigFraction(val a:BigInt, val b:BigInt) {\n//\n//}\n//\n//object BigFraction {\n//  def sum(x: BigFraction, y: Fraction): BigFraction = {\n//\n//  }\n//}\n\nclass Auction(n: Int, r: Array[(Int, Int)]) {\n  @inline def low(i: Int): Int = r(i)._1\n  @inline def hi(i: Int): Int = r(i)._2\n  @inline def length(i: Int): Int = r(i)._2 - r(i)._1 + 1\n\n  def pFirst(firstFrom: Int, excluded: Int): Fraction = {\n    @inline def from(i: Int) = if (i < excluded) firstFrom + 1 else firstFrom\n    @inline def till(i: Int) = if (i < excluded) firstFrom else firstFrom - 1\n    val fs = (0 until n).filter(i => i != excluded && from(i) <= hi(i))\n    if (fs.isEmpty) ZERO\n    else\n      fs.map(f =>\n        (0 until n).filter(i => i != excluded && i != f).\n          map(i => if (hi(i) <= till(i)) ONE\n                   else if (till(i) < low(i)) ZERO\n                   else fract(till(i) - low(i) + 1, length(i))).\n          foldLeft(fract(hi(f) - math.max(from(f), low(f)) + 1, length(f)))(mul)\n      ).reduce(sum)\n  }\n\n  def expectationOfSecond(): Fraction = {\n    val secondFrom = (0 until n).map(low).sortWith(_ > _)(1)\n    val secondTo = (0 until n).map(hi).sortWith(_ > _)(1)\n    val summands =\n      for {\n        second <- secondFrom to secondTo\n        i <- 0 until n if low(i) <= second && second <= hi(i)\n      } yield fract(second, length(i)) * pFirst(second, i)\n    val optimized = summands.groupBy(_.b).mapValues(_.map(_.a).sum).map(p => fract(p._2, p._1))\n    optimized.reduce(sum)\n  }\n\n}\n\n"}], "src_uid": "5258ce738eb268b9750cfef309d265ef"}
{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val d = (1 to 8).map(_ => in.next())\n  if (d.forall(t => t == \"WBWBWBWB\" || t == \"BWBWBWBW\"))\n    println(\"YES\")\n  else\n    println(\"NO\")\n}", "positive_code": [{"source_code": "object Main{\n\n    def different(a: String, b: String, pos: Int = 0): Boolean = {\n        if (pos >= a.length) true else{\n            if (a(pos) == b(pos)) false else different(a, b, pos+1)\n        }\n    }                                         //> different: (a: String, b: String, pos: Int)Boolean\n    \n    def validPair(a: String, b: String, remainTry: Int = 0): Boolean = {\n        if (remainTry == a.length) false else{\n            if (different(a, b)) true else{\n                val nextA = a.substring(1) + a(0)\n                validPair(nextA, b, remainTry+1)\n            }\n        }\n    }                                         //> validPair: (a: String, b: String, remainTry: Int)Boolean\n    \n    def alterChar(s: String, pos: Int = 1): Boolean = {\n        if (pos == s.length) true else{\n            if (s(pos) == s(pos-1)) false else alterChar(s, pos+1)\n        }\n    }                                         //> alterChar: (s: String, pos: Int)Boolean\n    \n    def validRow(s: String, remainTry: Int = 0): Boolean = {\n        if (remainTry == s.length) false else{\n            if (alterChar(s)) true else{\n                val nextS = s.substring(1) + s(0)\n                validRow(nextS, remainTry + 1)\n            }\n        }\n    }                                         //> validRow: (s: String, remainTry: Int)Boolean\n    \n    def validBoard(board: Array[String])={\n        var ret = true\n        if (!validRow(board(0))) ret = false\n        for (i <- 1 until board.length){\n            if (!validPair(board(i-1), board(i))) ret = false\n        }\n        ret\n    }                                         //> validBoard: (board: Array[String])Boolean\n\n    def main(args: Array[String]) = {\n        val board = new Array[String](8)\n        for (i <- 0 until 8){\n            board(i) = readLine()\n        }\n        if (validBoard(board)) println(\"YES\") else println(\"NO\")\n        \n    }                                         //> main: (args: Array[String])Unit\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P259A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val B = List.fill(8)(sc.nextLine)\n  \n  def solve(): String = if (B forall (s => s == \"WBWBWBWB\" || s == \"BWBWBWBW\")) \"YES\"\n                        else \"NO\"\n\n  out.println(solve)\n  out.close\n}\n"}, {"source_code": "import java.io._\nimport java.util.Locale\nimport scala.annotation.tailrec\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInt = reader.readLine().toInt\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readLongs = reader.readLine().split(\" \").map(_.toLong)\n\n  val bw = \"(BW)*\"\n  val wb = \"(WB)*\"\n  val ans = (for(_ <- 1 to 8) yield reader.readLine()).forall(s => s.matches(bw) || s.matches(wb))\n  val yesNoAns = Map(true -> \"YES\", false -> \"NO\")\n\n  def main(a: Array[String]) {\n    println(yesNoAns(ans))\n  }\n}\n"}, {"source_code": "object Main {\n  def correct(row: String): Boolean = {\n    val sum = row.zipWithIndex.map{ t => \n      if (t._1 == 'W') 1 << t._2\n      else 0\n    }.sum\n    if (sum == 0x55 || sum == 0xAA) true\n    else false\n  }\n\n  def main(args: Array[String]) {\n    val cor = (1 to 8).map(_ => readLine()).map(correct(_)).foldLeft(true)(_ & _)\n    if (cor) println(\"YES\")\n    else println(\"NO\")\n  }\n}"}, {"source_code": "object B{\n  def main(args: Array[String]){\n\n    val s1=\"WBWBWBWB\"\n    val s2=\"BWBWBWBW\"\n    (1 to 8).foreach{i=>\n      val str=readLine\n      if(str!=s1 && str!=s2){\n        println(\"NO\")\n        return\n      }\n    }\n    println(\"YES\")\n  }\n}"}, {"source_code": "object Ches {\n     def main(args:Array[String]):Unit={\n       var list=List[String]()\n       for(i<-0 until 8){\n          list=list:+readLine()\n       }\n       if(solve(list)) println(\"YES\")\n       else println(\"NO\")\n     }\n  def solve(list:List[String]):Boolean={\n    def isNormal(str:String):Boolean={\n      def strIter(str:String, c:Char):Boolean={\n        if(str.length==0) true\n        else if(c==str.head) false\n        else strIter(str.tail, str.head)\n      }\n      strIter(str, str.last)\n    }\n    if(list.length==0) true\n    else if(!isNormal(list.head)) false\n    else solve(list.tail)\n  }\n}\n"}], "negative_code": [{"source_code": "object Main{\n\n    def different(a: String, b: String, pos: Int = 0): Boolean = {\n        if (pos >= a.length) true else{\n            if (a(pos) == b(pos)) false else different(a, b, pos+1)\n        }\n    }                                         //> different: (a: String, b: String, pos: Int)Boolean\n    \n    def validPair(a: String, b: String, remainTry: Int = 0): Boolean = {\n        if (remainTry == a.length) false else{\n            if (different(a, b)) true else{\n                val nextA = a.substring(1) + a(0)\n                validPair(nextA, b, remainTry+1)\n            }\n        }\n    }                                         //> validPair: (a: String, b: String, remainTry: Int)Boolean\n    \n    def validBoard(board: Array[String])={\n        var ret = true\n        for (i <- 1 until board.length){\n            if (!validPair(board(i-1), board(i))) ret = false\n        }\n        ret\n    }                                         //> validBoard: (board: Array[String])Boolean\n\n    def main(args: Array[String]) = {\n        val board = new Array[String](8)\n        for (i <- 0 until 8){\n            board(i) = readLine()\n        }\n        if (validBoard(board)) println(\"YES\") else println(\"NO\")\n        \n    }                                         //> main: (args: Array[String])Unit\n}"}], "src_uid": "ca65e023be092b2ce25599f52acc1a67"}
{"source_code": "\n\nobject Main {\n\n  import java.io.{PrintWriter, _}\n  import java.util._\n\n\n  def main(args: Array[String]): Unit = {\n    val inputStream = System.in\n    val outputStream = System.out\n    val in = new InputReader(inputStream)\n    val out = new PrintWriter(outputStream)\n    val solver = new Task\n    solver.solve(1, in, out)\n    out.close()\n  }\n\n  def ?(item: Boolean, first: Any, second: Any): Any = if (item) first else second\n\n  class Task {\n    def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {\n      var arr = new Array[Int](3)\n      arr(0) = in.nextInt\n      arr(1) = in.nextInt\n      arr(2) = in.nextInt\n      arr = arr.sorted\n      val d = in.nextInt\n      val a = math.max(arr(1) + d - arr(2), 0)\n      val b = math.min(arr(1) - d - arr(0), 0)\n      out.println(a - b)\n    }\n\n  }\n\n\n  class InputReader(val stream: InputStream) extends AutoCloseable {\n    //reader = new BufferedReader(new FileReader(stream), 32768);\n    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n    private var tokenizer = new StringTokenizer(\"\")\n\n\n    def next: String = {\n      while ( {\n        tokenizer == null || !tokenizer.hasMoreTokens\n      }) try\n        tokenizer = new StringTokenizer(reader.readLine)\n      catch {\n        case e: IOException =>\n          throw new RuntimeException(e)\n      }\n      tokenizer.nextToken\n    }\n\n    def nextLine: String = {\n      try\n        return reader.readLine\n      catch {\n        case e: IOException =>\n          e.printStackTrace()\n      }\n      \"\"\n    }\n\n    def nextInt: Int = next.toInt\n\n    def nextLong: Long = next.toLong\n\n    override def close(): Unit = {\n    }\n  }\n\n}\n", "positive_code": [{"source_code": "object Main {\n  import java.io.{BufferedReader, InputStream, InputStreamReader}\n  import java.util.StringTokenizer\n  import scala.reflect.ClassTag\n\n  def main(args: Array[String]): Unit = {\n    val out = new java.io.PrintWriter(System.out)\n    new Main(out, new InputReader(System.in)).solve()\n    out.flush()\n  }\n\n  private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n  def DEBUG(f: => Unit): Unit = {\n    if (!oj){ f }\n  }\n  def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) \"1\" else \"0\").mkString) }\n  def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(\" \")) }\n  def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(\" \")) }\n  def debugDim(m: Array[Array[Int]]): Unit = if (!oj){\n    REP(m.length) { i =>\n      debug(m(i))\n    }\n  }\n  def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){\n    REP(m(0).length) { j =>\n      REP(m.length) { i =>\n        System.err.print(m(i)(j))\n        System.err.print(\" \")\n      }\n      System.err.println()\n    }\n  }\n  def debug(s: => String): Unit = DEBUG {\n    System.err.println(s)\n  }\n  def debugL(num: => Long): Unit = DEBUG {\n    System.err.println(num)\n  }\n\n  class InputReader(val stream: InputStream) {\n    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n    private var tokenizer: StringTokenizer = _\n\n    def next(): String = {\n      while (tokenizer == null || !tokenizer.hasMoreTokens)\n        tokenizer = new StringTokenizer(reader.readLine)\n      tokenizer.nextToken\n    }\n\n    def nextInt(): Int = Integer.parseInt(next())\n    def nextLong(): Long = java.lang.Long.parseLong(next())\n    def nextChar(): Char = next().charAt(0)\n\n    def ni(): Int = nextInt()\n    def nl(): Long = nextLong()\n    def nc(): Char = nextChar()\n    def ns(): String = next()\n    def ns(n: Int): Array[Char] = ns().toCharArray\n    def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n    def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n      val A1, A2 = Array.ofDim[Int](n)\n      REP(n) { i =>\n        A1(i) = ni() + offset\n        A2(i) = ni() + offset\n      }\n      (A1, A2)\n    }\n    def nm(n: Int, m: Int): Array[Array[Int]] = {\n      val A = Array.ofDim[Int](n, m)\n      REP(n) { i =>\n        REP(m) { j =>\n          A(i)(j) = ni()\n        }\n      }\n      A\n    }\n    def nal(n: Int): Array[Long] = map(n)(_ => nl())\n    def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n  }\n\n  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = offset\n    val N = n + offset\n    while(i < N) { f(i); i += 1 }\n  }\n  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = n - 1 + offset\n    while(i >= offset) { f(i); i -= 1 }\n  }\n  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n    REP(to - from + 1, from) { i =>\n      f(i)\n    }\n  }\n  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n    val res = Array.ofDim[A](n)\n    REP(n)(i => res(i) = f(i + offset))\n    res\n  }\n\n  def sumL(as: Array[Int]): Long = {\n    var s = 0L\n    REP(as.length)(i => s += as(i))\n    s\n  }\n  def cumSum(as: Array[Int]): Array[Long] = {\n    val cum = Array.ofDim[Long](as.length + 1)\n    REP(as.length) { i =>\n      cum(i + 1) = cum(i) + as(i)\n    }\n    cum\n  }\n}\n\nclass Main(out: java.io.PrintWriter, sc: Main.InputReader) {\n  import sc._\n  import Main._\n  import java.util.Arrays.sort\n\n  import scala.collection.mutable\n  import math.{abs, max, min}\n  import mutable.ArrayBuffer\n\n  // toIntとか+7とかするならvalにしろ\n  @inline private def MOD = 1000000007\n\n  def solve(): Unit = {\n    val A, B, C, D = ni()\n    val V = Array(A, B, C)\n    sort(V)\n    val ans = max(0, D - (V(1) - V(0))) + max(0, D - (V(2) - V(1)))\n    out.println(ans)\n  }\n}"}, {"source_code": "object _1185A extends CodeForcesApp {\n  import annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._, Math._\n\n  override def apply(io: IO): io.type = {\n    val Seq(a, b, c) = io.read[Seq, Int](3).sorted\n    val d = io.read[Int]\n    val ans = ((d - b + a) max 0) + ((d - c + b) max 0)\n    io.write(ans)\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\n/***********************************[Scala I/O]*********************************************/\nimport java.io._, java.util.StringTokenizer\nimport scala.collection.generic.CanBuild\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    tokenizers.headOption\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: CanBuild[A, C[A]]): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  def readAll[A: IO.Read]: (Int, Vector[A]) = {\n    val data = read[Vector[A]]\n    (data.length, data)\n  }\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any): this.type = {\n    printer.print(obj)\n    this\n  }\n  def writeLine(): this.type = {\n    printer.println()\n    this\n  }\n  def writeLine(obj: Any): this.type = {\n    printer.println(obj)\n    this\n  }\n  def writeLines(obj: Traversable[Any]): this.type = writeAll(obj, separator = \"\\n\")\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n  def query[A: IO.Read](question: Any): A = writeLine(question).read\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: CanBuild[A, C[A]]) : Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                                   : Read[String]       = new Read(_.next())\n    implicit val int                                                      : Read[Int]          = string.map(_.toInt)\n    implicit val long                                                     : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                                   : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                                   : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                               : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                                 : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                                  : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n"}], "negative_code": [{"source_code": "\n\nobject Main {\n\n  import java.io.{PrintWriter, _}\n  import java.util._\n\n\n  def main(args: Array[String]): Unit = {\n    val inputStream = System.in\n    val outputStream = System.out\n    val in = new InputReader(inputStream)\n    val out = new PrintWriter(outputStream)\n    val solver = new Task\n    solver.solve(1, in, out)\n    out.close()\n  }\n\n  def ?(item: Boolean, first: Any, second: Any): Any = if (item) first else second\n\n  class Task {\n    def solve(testNumber: Int, in: InputReader, out: PrintWriter): Unit = {\n      var arr = new Array[Int](3)\n      arr(0) = in.nextInt\n      arr(1) = in.nextInt\n      arr(2) = in.nextInt\n      arr = arr.sorted\n      val d = in.nextInt\n      val a = math.max(arr(1) + d - arr(2), 0)\n      val b = math.max(math.abs(arr(1) - d - arr(0)), 0)\n      out.println(a + b)\n    }\n\n  }\n\n\n  class InputReader(val stream: InputStream) extends AutoCloseable {\n    //reader = new BufferedReader(new FileReader(stream), 32768);\n    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n    private var tokenizer = new StringTokenizer(\"\")\n\n\n    def next: String = {\n      while ( {\n        tokenizer == null || !tokenizer.hasMoreTokens\n      }) try\n        tokenizer = new StringTokenizer(reader.readLine)\n      catch {\n        case e: IOException =>\n          throw new RuntimeException(e)\n      }\n      tokenizer.nextToken\n    }\n\n    def nextLine: String = {\n      try\n        return reader.readLine\n      catch {\n        case e: IOException =>\n          e.printStackTrace()\n      }\n      \"\"\n    }\n\n    def nextInt: Int = next.toInt\n\n    def nextLong: Long = next.toLong\n\n    override def close(): Unit = {\n    }\n  }\n\n}\n"}], "src_uid": "47c07e46517dbc937e2e779ec0d74eb3"}
{"source_code": "import scala.io.Source\n\nobject Cf177a1 extends App {\n  val a = Source.stdin.getLines.drop(1).map(_.split(\" \").map(_.toInt)).toArray\n  var rez = 0\n  val n = a.length\n  for (i <- 0 until n) {\n    for (j <- 0 until n) {\n      if (i == j || i == n - j - 1 || i == n / 2 || j == n / 2) rez = rez + a(i)(j)\n    }\n  }\n  println(rez)\n}", "positive_code": [{"source_code": "import scala.io.Source\n\nobject Cf177a1 extends App {\n  val a = Source.stdin.getLines.drop(1).map(_.split(\" \").map(_.toInt)).toArray\n  var rez = 0\n  val n = a.length\n  for (i <- 0 until n) {\n    for (j <- 0 until n) {\n      if (i == j || i == n - j - 1 || i == n / 2 || j == n / 2) rez = rez + a(i)(j)\n    }\n  }\n  println(rez)\n}"}], "negative_code": [], "src_uid": "5ebfad36e56d30c58945c5800139b880"}
{"source_code": "object _1178A extends CodeForcesApp {\n  import annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._, Math._\n\n  override def apply(io: IO): io.type = {\n    val votes = io.read[Vector[Int]]\n    val majority = 0 +: votes.indicesWhere(v => 2*v <= votes.head)\n    val ans = if (2*majority.map(votes).sum > votes.sum) {\n      majority\n    } else {\n      Nil\n    }\n    io.writeLine(ans.length).writeAll(ans.map(_ +  1))\n  }\n\n  implicit class IterableExtensions[A, C[A] <: Seq[A]](s: C[A]) {\n    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\n/***********************************[Scala I/O]*********************************************/\nimport java.io._, java.util.StringTokenizer\nimport scala.collection.generic.CanBuild\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    tokenizers.headOption\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: CanBuild[A, C[A]]): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  def readAll[A: IO.Read]: (Int, Vector[A]) = {\n    val data = read[Vector[A]]\n    (data.length, data)\n  }\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any): this.type = {\n    printer.print(obj)\n    this\n  }\n  def writeLine(): this.type = {\n    printer.println()\n    this\n  }\n  def writeLine(obj: Any): this.type = {\n    printer.println(obj)\n    this\n  }\n  def writeLines(obj: Traversable[Any]): this.type = writeAll(obj, separator = \"\\n\")\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n  def query[A: IO.Read](question: Any): A = writeLine(question).read\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: CanBuild[A, C[A]]) : Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                                   : Read[String]       = new Read(_.next())\n    implicit val int                                                      : Read[Int]          = string.map(_.toInt)\n    implicit val long                                                     : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                                   : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                                   : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                               : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                                 : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                                  : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n", "positive_code": [{"source_code": "object A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(n) = readInts(1)\n  val as = readInts(n).zipWithIndex\n  val a0 = as(0)._1\n\n  val cs = as.filter(_._1 * 2 <= a0)\n\n  val sum = a0 + cs.map(_._1).sum\n\n  if (sum * 2 > as.map(_._1).sum) {\n    println(cs.size + 1)\n    println((1 +: cs.map(_._2 + 1)).mkString(\" \"))\n  } else {\n    println(0)\n  }\n\n  Console.flush\n}\n"}], "negative_code": [{"source_code": "object _1178A extends CodeForcesApp {\n  import annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._, Math._\n\n  override def apply(io: IO): io.type = {\n    val votes = io.read[Vector[Int]]\n    val majority = 0 +: votes.indicesWhere(v => 2*v <= votes.head)\n    val ans = if (2*majority.map(votes).sum >= votes.sum) {\n      majority\n    } else {\n      Nil\n    }\n    io.writeLine(ans.length).writeAll(ans.map(_ +  1))\n  }\n\n  implicit class IterableExtensions[A, C[A] <: Seq[A]](s: C[A]) {\n    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\n/***********************************[Scala I/O]*********************************************/\nimport java.io._, java.util.StringTokenizer\nimport scala.collection.generic.CanBuild\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    tokenizers.headOption\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: CanBuild[A, C[A]]): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  def readAll[A: IO.Read]: (Int, Vector[A]) = {\n    val data = read[Vector[A]]\n    (data.length, data)\n  }\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any): this.type = {\n    printer.print(obj)\n    this\n  }\n  def writeLine(): this.type = {\n    printer.println()\n    this\n  }\n  def writeLine(obj: Any): this.type = {\n    printer.println(obj)\n    this\n  }\n  def writeLines(obj: Traversable[Any]): this.type = writeAll(obj, separator = \"\\n\")\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n  def query[A: IO.Read](question: Any): A = writeLine(question).read\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: CanBuild[A, C[A]]) : Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                                   : Read[String]       = new Read(_.next())\n    implicit val int                                                      : Read[Int]          = string.map(_.toInt)\n    implicit val long                                                     : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                                   : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                                   : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                               : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                                 : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                                  : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n"}], "src_uid": "0a71fdaaf08c18396324ad762b7379d7"}
{"source_code": "object Main {\n  def main(args: Array[String]) {\n    val n = readInt()\n    println(3 * n / 2)\n  }\n}", "positive_code": [{"source_code": "import java.util.Scanner\nobject GAGA {\n    def main(args: Array[String]) {\n      val scanner = new Scanner(System.in)\n      val n = scanner.nextInt()\n      println(n/2*3);\n    }\n}"}, {"source_code": "import java.util.StringTokenizer\n\nobject _84A extends App {\n  var token = new StringTokenizer(\"\")\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n  val n = next.toInt\n  println(n / 2 * 3)\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  println(3 * in.next().toInt / 2)\n}"}, {"source_code": "import scala.math\nobject Main\n{\n\tdef main(args:Array[String])\n\t{\n\t\tprintln(readInt / 2 * 3)\n\t}\n}"}, {"source_code": "object A84 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    println(3*(n/2))\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P84A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val N = sc.nextInt\n\n  val answer = 2 * N - (N / 2)\n\n  out.println(answer)\n  out.close\n}\n"}, {"source_code": "import java.io._\nimport java.util.Locale\nimport scala.annotation.tailrec\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInt = reader.readLine().toInt\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readLongs = reader.readLine().split(\" \").map(_.toLong)\n\n  def ans = readInt / 2 * 3\n\n  def main(a: Array[String]) {\n    println(ans)\n  }\n}\n"}], "negative_code": [], "src_uid": "031e53952e76cff8fdc0988bb0d3239c"}
{"source_code": "import scala.io.StdIn._\n\nobject _361A extends App {\n  readInt\n  val s = readLine.toCharArray.map(_.asDigit).toSet\n  val unique =\n    List(\n      Set(1, 4, 7, 0),\n      Set(1, 2, 3),\n      Set(3, 6, 9, 0),\n      Set(7, 0, 9))\n  val ans = unique.forall(x => x.intersect(s).nonEmpty)\n  println(if (ans) \"YES\" else \"NO\")\n}", "positive_code": [{"source_code": "import scala.io.StdIn._ \nimport scala.util.control._\n\nobject cf689A {\n    def main (args: Array[String]) {\n        val n = readInt();\n        val s = readLine();\n\n        if (judge(s, up) || judge(s, down) || judge(s, left) || judge(s, right)) {\n            println(\"NO\");\n        } else {\n            println(\"YES\");\n        }\n    }\n\n    def judge (s:String, f: Char => Boolean) : Boolean = {\n        var res:Boolean = true;\n        for (i <- 0 until s.length()) {\n            if (f(s(i)) == false) {\n                res = false\n            }\n        }\n        return res;\n    }\n\n    def up (c:Char) : Boolean = {\n        if (c == '0' || c > '3') return true;\n        else return false;\n    }\n\n\n    def down (c:Char) : Boolean = {\n        if (c == '8' || (c < '7' && c > '0')) return true;\n        else return false;\n    }\n\n    def left (c:Char) : Boolean = {\n        if ((c - '0') % 3 == 1 || c == '0') return false;\n        else return true;\n    }\n\n    def right (c:Char) : Boolean = {\n        if ((c - '0') % 3 == 0 || c == '0') return false;\n        else return true;\n    }\n}"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val n = in.next().toInt\n  val line = in.next()\n  val up = Set('1', '2', '3')\n  val down = Set('7', '0', '9')\n  val right = Set('3', '6', '9', '0')\n  val left = Set('1', '4', '7', '0')\n  List(left, right, down, up).exists(set => line.forall(i => !set.contains(i))) match {\n    case false => println(\"YES\")\n    case true => println(\"NO\")\n  }\n}\n"}, {"source_code": "import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._\n\nobject _689A extends CodeForcesApp {\n\n  val moves = Map(\n    1 -> \"DR\",\n    2 -> \"DLR\",\n    3 -> \"DL\",\n    4 -> \"UDR\",\n    5 -> \"UDLR\",\n    6 -> \"UDL\",\n    7 -> \"UR\",\n    8 -> \"UDLR\",\n    9 -> \"UL\",\n    0 -> \"U\"\n  ).mapValues(_.toSet)\n\n  override def apply(io: IO) = {import io.{read, write}\n    val (_, d) = read[(Int, String)]\n    val ans = \"UDLR\" find {c => d.forall(i => moves(i - '0').contains(c))}\n    write(ans.isEmpty.toYesNo)\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\nobject Utils {\n  import scala.collection.mutable, mutable.{Map => Dict}\n  implicit class GenericExtensions[A](val a: A) extends AnyVal {\n    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a\n  }\n  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {\n    def onlyElement: A = t.head.ensuring(t.size == 1)\n    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)\n    def duplicates(implicit b: C of A): C[A] = {\n      val elems = mutable.Set.empty[A]\n      (t collect {case i if !elems.add(i) => i}).to[C]\n    }\n    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}\n    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]\n    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap\n    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)\n    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}\n    def toMutableMultiSet: Dict[A, Int] = {\n      val c = map[A] to 0\n      t.foreach(i => c(i) += 1)\n      c\n    }\n    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0\n  }\n  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)\n  }\n  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)\n  }\n  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {\n    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t\n  }\n  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {\n    def key = p._1\n    def value = p._2\n  }\n  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {\n    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)\n    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])\n    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]\n  }\n  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {\n    def lastKeyOption: Option[K] = m.lastOption.map(_.key)\n    def firstKeyOption: Option[K] = m.headOption.map(_.key)\n    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap\n    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}\n    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m\n  }\n  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {\n    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)\n    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)\n    private def removeNode(kv: (K, V)): (K, V) = {\n      m -= kv.key\n      kv\n    }\n  }\n  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {\n    def notContains(x: A): Boolean = !(s contains x)\n    def toMutable = mutable.Set.empty[A] ++ s\n  }\n  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {\n    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)\n    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)\n    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}\n    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f) findWithIndex c\n  }\n  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {\n    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero\n    def toYesNo = if(x) \"YES\" else \"NO\"\n  }\n  implicit class IntExtensions(val x: Int) extends AnyVal {\n    def bitCount: Int = java.lang.Integer.bitCount(x)\n  }\n  implicit class LongExtensions(val x: Long) extends AnyVal {\n    def bitCount: Int = java.lang.Long.bitCount(x)\n  }\n  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {\n    import Numeric.Implicits._\n    def **(i: Int): A = if (i == 0) n.one else {\n      val h = x ** (i/2)\n      if (i%2 == 0) h * h else h * h * x\n    }\n    def distance(y: A) = (x - y).abs()\n    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)\n    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf \"Greg\" whenNegative Int.MaxValue\n  }\n  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {\n    import scala.collection.immutable.NumericRange, Integral.Implicits._\n    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x\n    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(n.min(x, y), n.max(x, y), n.one)\n    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)\n  }\n  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))\n  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)\n  def asc[A](implicit order: Ordering[A]): Ordering[A] = order\n  def map[K] = new {\n    def to[V](default: => V): Dict[K, V] = using(_ => default)\n    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {\n      override def apply(key: K) = getOrElseUpdate(key, f(key))\n    }\n  }\n  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]\n  def memoize[A, B](f: A => B): A ==> B = map[A] using f\n  implicit class FuzzyDouble(val x: Double) extends AnyVal {\n    def  >~(y: Double) = x > y + eps\n    def >=~(y: Double) = x >= y + eps\n    def  ~<(y: Double) = y >=~ x\n    def ~=<(y: Double) = y >~ x\n    def  ~=(y: Double) = (x distance y) <= eps\n  }\n  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None\n  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)\n  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]\n  type ==>[A, B] = collection.Map[A, B]\n  val mod: Int = (1e9 + 7).toInt\n  val eps: Double = 1e-9\n}\n/***********************************[Scala I/O]*********************************************/\nimport Utils._, java.io._, java.util.StringTokenizer\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    when(tokenizers.nonEmpty)(tokenizers.head)\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any, more: Any*): this.type = {\n    printer.print(obj)\n    more foreach {i =>\n      printer.print(' ')\n      printer.print(i)\n    }\n    this\n  }\n  def writeLine(obj: Any*): this.type = {\n    if (obj.isEmpty) printer.println() else obj foreach printer.println\n    this\n  }\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                       : Read[String]       = new Read(_.next())\n    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)\n    implicit val int                                          : Read[Int]          = string.map(_.toInt)\n    implicit val long                                         : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                       : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                      : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n"}, {"source_code": "import java.util.Scanner\n\nobject Main{\n  def ctoi(c: Char) = c.toInt - '0'.toInt\n\n  def main (args: Array[String]){\n    val sc = new Scanner(System.in)\n    val n = sc.nextInt()\n    sc.nextLine()\n    val s = sc.nextLine()\n\n    val dp = new Array[Boolean](10)\n\n    val key = Array((1, 3),\n      (0,0), (1,0), (2,0),\n      (0,1), (1,1), (2,1),\n      (0,2), (1,2), (2,2)\n    )\n\n    var xl = 9\n    var xr = -1\n    var yl = 9\n    var yr = -1\n\n    for(i <- 0 until n){\n      val now = ctoi(s(i))\n      dp(now) = true\n      val (nx, ny) = key(now)\n\n      xl = Math.min(xl, nx)\n      xr = Math.max(xr, nx)\n      yl = Math.min(yl, ny)\n      yr = Math.max(yr, ny)\n    }\n\n    val xz = xr - xl + 1\n    val yz = yr - yl + 1\n\n    val yes = \"YES\"\n    val no = \"NO\"\n\n    if(yz == 4)\n      println(yes)\n    else if(xz == 3 && yz == 3){\n      if(dp(0) || (dp(8) && !dp(7) && !dp(9)))\n        println(no)\n      else\n        println(yes)\n    }\n    else\n      println(no)\n  }\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject A extends App {\n  readInt()\n  val M = readLine().toCharArray.map(_.asDigit)\n\n  def delta(a: Int, b: Int): (Int, Int) = {\n    val (y1, x1) = pos(a)\n    val (y2, x2) = pos(b)\n    (y2 - y1, x2 - x1)\n  }\n\n  def pos(a: Int) = {\n    if (List(1, 2, 3).contains(a)) (0, a - 1)\n    else if (List(4, 5, 6).contains(a)) (1, a % 4)\n    else if (List(7, 8, 9).contains(a)) (2, a % 7)\n    else (3, 1)\n  }\n\n  var prev = M.head\n  val Deltas = M.tail.map { curr =>\n    val d = delta(prev, curr)\n    prev = curr\n    d\n  }\n\n  def canMoveFromThisPoint(startY: Int, startX: Int): Boolean = {\n    var y = startY\n    var x = startX\n\n    Deltas.foreach { case (dy, dx) =>\n      y += dy\n      x += dx\n\n      if (y < 0 || x < 0 || y > 3 || x >= 3) return false\n      else if (y == 3 && x != 1) return false\n    }\n\n    true\n  }\n\n  def existDifferentPath: Boolean = {\n    val (startY, startX) = pos(M.head)\n    for {\n      y <- 0 to 3\n      x <- 0 to 2\n    } {\n      val isIllegal = (y == 3 && x != 1) || (y == startY && x == startX)\n      if (!isIllegal && canMoveFromThisPoint(y, x)) return true\n    }\n\n    false\n  }\n\n  val unique = !existDifferentPath\n  println(if (unique) \"YES\" else \"NO\")\n}\n"}, {"source_code": "object main\n{\n\tdef main(args : Array[String] )\n\t{\n\t\tvar n = Console.readLine.toInt;\n\t\tvar str = Console.readLine;\n\n\t\tvar pos = Array(Array(4,2),Array(1,1),Array(1,2),Array(1,3),Array(2,1),Array(2,2),Array(2,3),Array(3,1),Array(3,2),Array(3,3));\n\n\t\tvar cnt = 0;\n\t\tvar a = 0;\n\t\tfor (a <- 0 to 9 )\n\t\t{\n\t\t\tvar nowx = pos(a)(0);\n\t\t\tvar nowy = pos(a)(1);\n\t\t\tvar able = true;\n\t\t\tvar b = 0;\n\t\t\tfor (b <- 0 to n-2)\n\t\t\t{\n\t\t\t\tvar dx = pos(str.charAt(b+1)-'0')(0)-pos(str.charAt(b)-'0')(0);\n\t\t\t\tvar dy = pos(str.charAt(b+1)-'0')(1)-pos(str.charAt(b)-'0')(1);\n\t\t\t\tnowx += dx;\n\t\t\t\tnowy += dy;\n\t\t\t\tif (nowx < 1 || nowy < 1 || nowy>3) able=false;\n\t\t\t\tif (nowx>3 && (nowx!=4 || nowy!=2)) able=false;\n\t\t\t}\n\t\t\tif (able) cnt+=1;\n\t\t}\n\t\tif (cnt==1) println(\"YES\");\n\t\telse println(\"NO\");\n}\n}"}], "negative_code": [{"source_code": "import scala.io.StdIn._ \nimport scala.util.control._\n\nobject cf689A {\n    def main (args: Array[String]) {\n        val n = readInt();\n        val s = readLine();\n\n        if (judge(s, up) || judge(s, down) || judge(s, left) || judge(s, right)) {\n            println(\"NO\");\n        } else {\n            println(\"YES\");\n        }\n    }\n\n    def judge (s:String, f: Char => Boolean) : Boolean = {\n        var res:Boolean = true;\n        for (i <- 0 until s.length()) {\n            if (f(s(i)) == false) {\n                res = false\n            }\n        }\n        return res;\n    }\n\n    def up (c:Char) : Boolean = {\n        if (c == '0' || c > '3') return true;\n        else return false;\n    }\n\n\n    def down (c:Char) : Boolean = {\n        if (c == '8' || c < '7') return true;\n        else return false;\n    }\n\n    def left (c:Char) : Boolean = {\n        if ((c - '0') % 3 == 1 || c == '0') return false;\n        else return true;\n    }\n\n    def right (c:Char) : Boolean = {\n        if ((c - '0') % 3 == 0 || c == '0') return false;\n        else return true;\n    }\n}"}, {"source_code": "import scala.io.StdIn._ \nimport scala.util.control._\n\nobject cf689A {\n    def main (args: Array[String]) {\n        val n = readInt();\n        val s = readLine();\n\n        if (judge(s, up) || judge(s, down) || judge(s, left) || judge(s, right)) {\n            println(\"NO\");\n        } else {\n            println(\"YES\");\n        }\n    }\n\n    def judge (s:String, f: Char => Boolean) : Boolean = {\n        var res:Boolean = true;\n        for (i <- 0 until s.length()) {\n            if (f(s(i)) == false) {\n                res = false\n            }\n        }\n        return res;\n    }\n\n    def up (c:Char) : Boolean = {\n        if (c == '0' || c > '3') return true;\n        else return false;\n    }\n\n\n    def down (c:Char) : Boolean = {\n        if (c == '8' || c < '7') return true;\n        else return false;\n    }\n\n    def left (c:Char) : Boolean = {\n        if ((c - '0') % 3 == 1) return true;\n        else return false;\n    }\n\n    def right (c:Char) : Boolean = {\n        if ((c - '0') % 3 == 0 && c != '0') return true;\n        else return false;\n    }\n}"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val n = in.next().toInt\n  val line = in.next()\n  val up = Set('1', '2', '3')\n  val down = Set('7', '0', '9')\n  val right = Set('3', '6', '9', '0')\n  val left = Set('1', '4', '7', '0')\n  List(left, up, down, up).exists(set => line.forall(i => !set.contains(i))) match {\n    case false => println(\"YES\")\n    case true => println(\"NO\")\n  }\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject Main{\n  def ctoi(c: Char) = c.toInt - '0'.toInt\n\n  def main (args: Array[String]){\n    val sc = new Scanner(System.in)\n    val n = sc.nextInt()\n    sc.nextLine()\n    val s = sc.nextLine()\n\n    val key = Array((1, 3),\n      (0,0), (1,0), (2,0),\n      (0,1), (1,1), (2,1),\n      (0,2), (1,2), (2,2)\n    )\n\n    var xl = 9\n    var xr = -1\n    var yl = 9\n    var yr = -1\n\n    for(i <- 0 until n){\n      val (nx, ny) = key(ctoi(s(i)))\n      xl = Math.min(xl, nx)\n      xr = Math.max(xr, nx)\n      yl = Math.min(yl, ny)\n      yr = Math.max(yr, ny)\n    }\n\n    val xz = xr - xl + 1\n    val yz = yr - yl + 1\n\n    val yes = \"YES\"\n    val no = \"NO\"\n\n    if(yz == 4)\n      println(yes)\n    else if(xz == 3 && yz == 3)\n      println(yes)\n    else\n      println(no)\n  }\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject A extends App {\n  readInt()\n  val M = readLine().toCharArray.map(_.asDigit)\n\n  def delta(a: Int, b: Int): (Int, Int) = {\n    val (y1, x1) = pos(a)\n    val (y2, x2) = pos(b)\n    (y2 - y1, x2 - x1)\n  }\n\n  def pos(a: Int) = {\n    if (List(1, 2, 3).contains(a)) (0, a - 1)\n    else if (List(4, 5, 6).contains(a)) (1, a % 4)\n    else if (List(7, 8, 9).contains(a)) (2, a % 7)\n    else (3, 1)\n  }\n\n  var prev = M.head\n  val Deltas = M.tail.map { curr =>\n    val d = delta(prev, curr)\n    prev = curr\n    d\n  }\n\n  def canMoveFromThisPoint(startY: Int, startX: Int): Boolean = {\n    var y = startY\n    var x = startX\n\n    Deltas.foreach { case (dy, dx) =>\n      y += dy\n      x += dx\n\n      if (y < 0 || x < 0 || y > 3 || x >= 3) return false\n      else if (y == 3 && x != 1) return false\n    }\n\n    true\n  }\n\n  def existDifferentPath: Boolean = {\n    val (startY, startX) = pos(M.head)\n    for {\n      y <- 0 to 3\n      x <- 0 to 2\n      if y != startY && x != startX\n    } {\n      if (canMoveFromThisPoint(y, x)) return true\n    }\n\n    false\n  }\n\n  val unique = !existDifferentPath\n  println(if (unique) \"YES\" else \"NO\")\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject A extends App {\n  readInt()\n  val M = readLine().toCharArray.map(_.asDigit)\n\n  def delta(a: Int, b: Int): (Int, Int) = {\n    val (y1, x1) = pos(a)\n    val (y2, x2) = pos(b)\n    (y2 - y1, x2 - x1)\n  }\n\n  def pos(a: Int) = {\n    if (List(1, 2, 3).contains(a)) (0, a - 1)\n    else if (List(4, 5, 6).contains(a)) (1, a % 4)\n    else if (List(7, 8, 9).contains(a)) (2, a % 7)\n    else (3, 1)\n  }\n\n  var prev = M.head\n  val Deltas = M.tail.map { curr =>\n    val d = delta(prev, curr)\n    prev = curr\n    d\n  }\n\n  def canMoveFromThisPoint(startY: Int, startX: Int): Boolean = {\n    var y = startY\n    var x = startX\n\n    Deltas.foreach { case (dy, dx) =>\n      y += dy\n      x += dx\n\n      if (y < 0 || x < 0 || y > 3 || x >= 3) return false\n      else if (y == 3 && x != 1) return false\n    }\n\n    true\n  }\n\n  def existDifferentPath: Boolean = {\n    val (startY, startX) = pos(M.head)\n    for {\n      y <- 0 to 3\n      x <- 0 to 2\n      if y != startY && x != startX\n    } {\n      val isIllegal = y == 3 && x != 1\n      if (!isIllegal && canMoveFromThisPoint(y, x)) return true\n    }\n\n    false\n  }\n\n  val unique = !existDifferentPath\n  println(if (unique) \"YES\" else \"NO\")\n}\n"}, {"source_code": "object main\n{\n\tdef main(args : Array[String] )\n\t{\n\t\tvar n = Console.readLine.toInt;\n\t\tvar str = Console.readLine;\n\n\t\tvar a = 0;\n\n\t\tvar minx = 3;\n\t\tvar miny = 3;\n\t\tvar maxx = 1;\n\t\tvar maxy = 1;\n\n\t\tfor ( a <- 0 to n-1 )\n\t\t{\n\t\t\tif (str.charAt(a)<='3') \n\t\t\t{\n\t\t\t\tminx=1;\n\t\t\t}\n\t\t\tif (str.charAt(a)<='6' && minx==3)\n\t\t\t{\n\t\t\t\tminx=2;\n\t\t\t}\n\t\t\tif (str.charAt(a)>='7')\n\t\t\t{\n\t\t\t\tmaxx=3;\n\t\t\t}\n\t\t\tif (str.charAt(a)>='4' && maxx==1)\n\t\t\t{\n\t\t\t\tmaxx=2;\n\t\t\t}\n\t\t\tif (str.charAt(a)=='1' || str.charAt(a)=='4' || str.charAt(a)=='7')\n\t\t\t{\n\t\t\t\tminy=1;\n\t\t\t}\n\t\t\tif ((str.charAt(a)=='2' || str.charAt(a)=='5' || str.charAt(a)=='8'))\n\t\t\t{\n\t\t\t\tif (miny==3) \n\t\t\t\t{\n\t\t\t\t\tminy=2;\n\t\t\t\t}\n\t\t\t\tif (maxy==1)\n\t\t\t\t{\n\t\t\t\t\tmaxy=2;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (str.charAt(a)=='3' || str.charAt(a)=='6' || str.charAt(a)=='9')\n\t\t\t{\n\t\t\t\tmaxy=3;\n\t\t\t}\n\t\t}\n\t\tif (minx==1 && maxx==3 && miny==1 && maxy==3)\n\t\t{\n\t\t\tprintln(\"YES\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintln(\"NO\");\n\t\t}\n\t}\n}"}, {"source_code": "object main\n{\n\tdef main(args : Array[String] )\n\t{\n\t\tvar n = Console.readLine.toInt;\n\t\tvar str = Console.readLine;\n\n\t\tvar a = 0;\n\n\t\tvar minx = 3;\n\t\tvar miny = 3;\n\t\tvar maxx = 1;\n\t\tvar maxy = 1;\n\n\t\tfor ( a <- 0 to n-1 )\n\t\t{\n\t\t\tif (str.charAt(a)<='3') \n\t\t\t{\n\t\t\t\tminx=1;\n\t\t\t}\n\t\t\tif (str.charAt(a)<='6' && minx==3)\n\t\t\t{\n\t\t\t\tminx=2;\n\t\t\t}\n\t\t\tif (str.charAt(a)>='7')\n\t\t\t{\n\t\t\t\tmaxx=3;\n\t\t\t}\n\t\t\tif (str.charAt(a)>='4' && maxx==1)\n\t\t\t{\n\t\t\t\tmaxx=2;\n\t\t\t}\n\t\t\tif (str.charAt(a)=='1' || str.charAt(a)=='4' || str.charAt(a)=='7')\n\t\t\t{\n\t\t\t\tminy=1;\n\t\t\t}\n\t\t\tif ((str.charAt(a)=='2' || str.charAt(a)=='5' || str.charAt(a)=='8'))\n\t\t\t{\n\t\t\t\tif (miny==3) \n\t\t\t\t{\n\t\t\t\t\tminy=2;\n\t\t\t\t}\n\t\t\t\tif (maxy==1)\n\t\t\t\t{\n\t\t\t\t\tmaxy=2;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (str.charAt(a)=='3' || str.charAt(a)=='6' || str.charAt(a)=='9')\n\t\t\t{\n\t\t\t\tmaxx=3;\n\t\t\t}\n\t\t}\n\t\tif (minx==1 && maxx==3 && miny==1 && maxy==3)\n\t\t{\n\t\t\tprintln(\"YES\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintln(\"NO\");\n\t\t}\n\t}\n}"}], "src_uid": "d0f5174bb0bcca5a486db327b492bf33"}
{"source_code": "//package codeforces.contest1213\n\nobject EqualizingByDivision {\n\n  def main(args: Array[String]): Unit = {\n    val Array(_, k) = io.StdIn.readLine().split(\" \").map(_.toInt)\n    val elements = io.StdIn.readLine().split(\" \").map(_.toInt)\n\n    val maxElement = elements.max\n\n    val frequency = Array.ofDim[Int](maxElement + 1, 20) // frequency with steps\n\n    for (e <- elements) {\n      var temp = e\n      var i = 0\n      while (temp > 0) {\n        frequency(temp)(i) += 1\n\n        i += 1\n        temp = temp / 2\n      }\n    }\n\n    println {\n      (1 to maxElement).foldLeft(Int.MaxValue) {\n        case (acc, e) =>\n          val (steps, count) = frequency(e).indices\n            .foldLeft((0, 0)) {\n              case ((steps, count), i) =>\n                val c = frequency(e)(i)\n                if (c != 0 && count < k)\n                  if (count + c <= k) (steps + i * c, count + c)\n                  else (steps + i * (k - count), k)\n                else\n                  (steps, count)\n            }\n\n          if (count == k) acc min steps else acc\n      }\n    }\n  }\n}\n", "positive_code": [{"source_code": "//package codeforces.contest1213\n\nobject EqualizingByDivision {\n\n  def main(args: Array[String]): Unit = {\n    val Array(_, k) = io.StdIn.readLine().split(\" \").map(_.toInt)\n    val elements = io.StdIn.readLine().split(\" \").map(_.toInt)\n\n    val maxElement = elements.max\n\n    val frequency = Array.ofDim[Int](maxElement + 1, 20) // frequency with steps\n\n    for (e <- elements) {\n      var temp = e\n      var i = 0\n      while (temp > 0) {\n        frequency(temp)(i) += 1\n\n        i += 1\n        temp = temp / 2\n      }\n    }\n\n    println {\n      (1 to maxElement).foldLeft(Int.MaxValue) {\n        case (acc, e) =>\n          val (steps, count) = frequency(e).indices\n            .foldLeft((0, 0)) {\n              case ((steps, count), i) =>\n                val c = frequency(e)(i)\n                if (c != 0 && count < k)\n                  if (count + c <= k) (steps + i * c, count + c)\n                  else (steps + i * (k - count), k)\n                else\n                  (steps, count)\n            }\n\n          if (count == k) acc min steps else acc\n      }\n    }\n  }\n}\n"}], "negative_code": [{"source_code": "//package codeforces.contest1213\n\nobject EqualizingByDivision {\n\n  def main(args: Array[String]): Unit = {\n    val Array(_, k) = io.StdIn.readLine().split(\" \").map(_.toInt)\n    val elements = io.StdIn.readLine().split(\" \").map(_.toInt)\n\n    val maxElement = elements.max\n\n    val frequency = Array.ofDim[Int](maxElement + 1, 20) // frequency with steps\n\n    for (e <- elements) {\n      var temp = e\n      var i = 0\n      while (temp > 0) {\n        frequency(temp)(i) += 1\n\n        i += 1\n        temp = temp / 2\n      }\n    }\n\n    println {\n      (1 to maxElement).foldLeft(Int.MaxValue) {\n        case (acc, e) =>\n          val (steps, count) = frequency(e).indices\n            .foldLeft((0, 0)) {\n              case ((steps, count), i) =>\n                val c = frequency(e)(i)\n                if (c != 0 && count < k)\n                  if (count + c <= k) (steps + i * c, count + c)\n                  else (steps + i * (count + c - k), k)\n                else\n                  (steps, count)\n            }\n\n          if (count == k) acc min steps else acc\n      }\n    }\n  }\n}\n"}], "src_uid": "ed1a2ae733121af6486568e528fe2d84"}
{"source_code": "object A extends App {\n  def l(n: Int): Int = n * (n + 1) / 2\n\n  val a = scala.io.StdIn.readInt()\n  val b = scala.io.StdIn.readInt()\n  val n = (a - b).abs\n  val m = n / 2\n\n  val t = if (n == 1) 1\n  else if (n % 2 == 0) 2 * l(m)\n  else 2 * l(m) + (m + 1)\n\n  println(t)\n}\n", "positive_code": [{"source_code": "import scala.io._\nimport scala.math._\n\nobject a7 {\n  def main(args: Array[String]): Unit = {\n    def apsum(n:Int) = n*(n+1)/2\n    val pos = Source.stdin.getLines().toArray.map(_.toInt)\n    val (a,b)=(pos(0), pos(1))\n    val diff = abs(a-b)\n    println(apsum(diff/2)+apsum(diff-diff/2))\n  }\n}\n"}], "negative_code": [], "src_uid": "d3f2c6886ed104d7baba8dd7b70058da"}
{"source_code": "//2.12.5 | JDoodle.Com & 2.12 | CodeForces.Com\nimport scala.io.Source\n\nobject Solution {\n    def main(args: Array[String]) {\n        val input = Source.stdin.getLines()\n        \n        val Array(grown_ups, children) = input.next().split(' ').map(_.toInt)\n        \n        if (grown_ups < 1 & children > 0)\n            print(\"Impossible\")\n        else\n            print(math.max(grown_ups, children) + \" \" + {if (children > 0) grown_ups + children - 1 else grown_ups})\n    }\n}", "positive_code": [{"source_code": "object Solution {\n  def main(args: Array[String]) {\n    val tokens = readLine().split(\" \").map(_.toInt)\n    val grownups = tokens(0)\n    val kids = tokens(1)\n    if (grownups == 0 && kids > 0) {\n      println(\"Impossible\")\n    } else {\n      printf(\"%d %d\\n\",\n             grownups + (0 max (kids-grownups)),\n             grownups + (0 max (kids-1)))\n    }\n  }\n}\n"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val Array(n, m) = in.next().split(' ').map(_.toInt)\n  println((n, m) match {\n    case(x, 0) => s\"$x $x\"\n    case(0, x) => \"Impossible\"\n    case(y, x) if y >= x => s\"$y ${y + x - 1}\"\n    case(y, x) => s\"$x ${y + x - 1}\"\n  })\n\n}"}, {"source_code": "//http://rextester.com scala 2.11.7\nimport scala.io.Source\nobject Rextester extends App{\n    val a=Source.stdin.getLines();val Array(b,c)=a.next().split(' ').map(_.toInt)\n    if(b<1&c>0)print(\"Impossible\")\n    else{\n        var d=b+c-1\n        if(c==0)d=b\n        print(math.max(b,c)+\" \"+d)\n    }\n}"}, {"source_code": "import scala.io.Source;object a{def main(args:Array[String]){val z=Source.stdin.getLines();val Array(a,b)=z.next().split(' ').map(_.toInt);if(a<1&b>0)print(\"Impossible\")else print(math.max(a,b)+\" \"+{if(b>0)a+b-1 else a})}}"}, {"source_code": "//rextester.com:2.11.7--codeforces.com:2.11.8\nimport scala.io.Source\nobject Rextester extends App{\n    val z=Source.stdin.getLines();val Array(a,b)=z.next().split(' ').map(_.toInt)\n    if(a<1&b>0)print(\"Impossible\")\n    else print(math.max(a,b)+\" \"+{if(b>0)a+b-1 else a})\n}"}, {"source_code": "//rextester.com:2.11.7--codeforces.com:2.11.8\nimport scala.io.Source\nobject a extends App{\n    val z=Source.stdin.getLines();val Array(a,b)=z.next().split(' ').map(_.toInt)\n    if(a<1&b>0)print(\"Impossible\")\n    else print(math.max(a,b)+\" \"+{if(b>0)a+b-1 else a})\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport java.util.Arrays.binarySearch\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.collection.mutable.ArrayBuffer\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\n\nobject P190A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val N, M = sc.nextInt\n\n  val res = (N, M) match {\n      case (0, 0) => \"0 0\"\n      case (0, _) => \"Impossible\"\n      case (x, 0) => List(x, x).mkString(\" \")\n      case (x, y) => List(x max y, x + y - 1).mkString(\" \")\n  }\n\n  out.println(res)\n  out.close\n}\n\n\n\n\n\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val Array(n, m) = readLine().split(\" \").map(_.toInt)\n    val min = n + (m - n).max(0)\n    val max = n + (m - 1).max(0)\n    if (n == 0 && m == 0) println(\"0 0\")\n    else if (n == 0) println(\"Impossible\")\n    else println(min + \" \" + max)\n  }\n}"}], "negative_code": [{"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val Array(n, m) = in.next().split(' ').map(_.toInt)\n  println((n, m) match {\n    case(0, x) => \"Impossible\"\n    case(x, 0) => s\"$x $x\"\n    case(y, x) if y >= x => s\"$y ${y + x - 1}\"\n    case(y, x) => s\"$x ${y + x - 1}\"\n  })\n\n}"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val Array(n, m) = in.next().split(' ').map(_.toInt)\n  println((n, m) match {\n    case(0, x) => \"Impossible\"\n    case(y, x) if y >= x => s\"$y ${y + x - 1}\"\n    case(y, x) => s\"$x ${y + x - 1}\"\n  })\n\n}"}, {"source_code": "//http://rextester.com scala 2.11.7\nimport scala.io.Source\nobject Rextester extends App{\n    val in=Source.stdin.getLines();val Array(a,b)=in.next().split(' ').map(_.toInt)\n    if(a>0&b>=0){\n        var c=a+b-1\n        if(b==0)c=a\n        print(math.max(a,b)+\" \"+c)\n    }\n    else print(\"Impossible\")\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport java.util.Arrays.binarySearch\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.collection.mutable.ArrayBuffer\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\n\nobject P190A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val N, M = sc.nextInt\n\n  val res = (N, M) match {\n      case (0, _) => \"Impossible\"\n      case (x, 0) => List(x, x).mkString(\" \")\n      case (x, y) => List(x max y, x + y - 1).mkString(\" \")\n  }\n\n  out.println(res)\n  out.close\n}\n\n\n\n\n\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val Array(n, m) = readLine().split(\" \").map(_.toInt)\n    val min = n + (m - n).max(0)\n    val max = n + (m - 1).max(0)\n    if (n == 0) println(\"Impossible\")\n    else println(min + \" \" + max)\n  }\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val Array(n, m) = readLine().split(\" \").map(_.toInt)\n    val min = n + (m - n).max(0)\n    val max = n + m - 1\n    if (n == 0) println(\"Impossible\")\n    else println(min + \" \" + max)\n  }\n}"}], "src_uid": "1e865eda33afe09302bda9077d613763"}
{"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val data = (1 to 8).map(_ => in.next())\n  val lines = data.count(_.forall(_ == 'B'))\n  val rows = data.find(_.exists(_ == 'W')).map(_.count(_ == 'B')).getOrElse(0)\n  println(lines + rows)\n}\n", "positive_code": [{"source_code": "object P7A {\n    def main(args : Array[String]) {\n        val a = Array.fill(8){readLine}\n        val af = a filter {_ != \"BBBBBBBB\"}\n        val c = 0 until 8 count {n => af exists {_(n) == 'B'}}\n        println(8 - af.size + c)\n    }\n}"}, {"source_code": "import java.util.Scanner\n\nobject A7Chess extends App {\n\n  val scanner = new Scanner(System.in)\n\n  val in = Array.ofDim[Cell](8, 8)\n\n  var result = 0\n\n  for (x <- 0 until 8) yield {\n    val str = scanner.next()\n    in(x) = str.map({\n      case 'W' => Cell(color = false)\n      case 'B' => Cell(color = true)\n    }).toArray\n  }\n\n  (0 until 8) foreach(i => solve(in(_)(i)))\n  (0 until 8) foreach(i => solve(in(i)(_)))\n\n  println(result)\n\n  def solve(function: (Int) => Cell): Unit = {\n    if (paintedWithBlack(function)) {\n      visit(function)\n      result += 1\n    }\n  }\n\n  def visit(function: (Int) => Cell): Unit = {\n    (0 until 8).foreach(function(_).visited = true)\n  }\n\n  def paintedWithBlack(function: (Int) => Cell): Boolean = {\n    (0 until 8).forall(function(_).color) && (0 until 8).exists(!function(_).visited)\n  }\n\n  case class Cell(color: Boolean, var visited: Boolean = false)\n\n}\n"}, {"source_code": "object A7 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def main(args: Array[String]): Unit = {\n    val in = Array.fill(8)(read.toCharArray)\n    val res = {\n      (0 until 8).map{j => (0 until 8).map(i=>in(i)(j))}.count(_.forall(_ == 'B')) +\n      in.count(_.forall(_ == 'B'))\n    }\n    if(res == 16)\n      println(\"8\")\n    else\n      println(res)\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "object P7A {\n    def main(args : Array[String]) {\n        val a = Array.fill(8){readLine}\n        val af = a filter {_ != \"BBBBBBBB\"}\n        val c = 0 until 8 count {n => af exists {_(n) == 'B'}}\n        println(8 - af.size + c)\n    }\n}"}, {"source_code": "object P7A {\n    def main(args : Array[String]) {\n        val a = Array.fill(8){readLine}\n        val af = a filter {_ != \"BBBBBBBB\"}\n        val c = 0 until 8 count {n => af exists {_(n) == 'B'}}\n        println(8 - af.size + c)\n    }\n}\n"}, {"source_code": "object P7A {\n    def main(args : Array[String]) {\n        val a = Array.fill(8){readLine} filter {_ != \"BBBBBBBB\"}\n        val c = 0 until 8 count {n => a exists {_(n) == 'B'}}\n        println(8 - a.size + c)\n    }\n}\n"}], "negative_code": [{"source_code": "object P7A {\n    def main(args : Array[String]) {\n        val a = Array.fill(8){readLine}\n        val af = a filter {_ != \"BBBBBBBB\"}\n        val c = 0 until 8 count {n => af exists {_(n) == 'W'}}\n        println(8 - af.size + c)\n    }\n}"}, {"source_code": "object P7A {\n    def main(args : Array[String]) {\n        val a = Array.fill(8){readLine}\n        val af = a filter {_ != \"BBBBBBBB\"}\n        val c = 0 until 8 count {\n            n : Int => af forall {_(n) == 'B'}\n        }\n        println(8 - af.size + c)\n    }\n}\n"}, {"source_code": "object P7A {\n    def main(args : Array[String]) {\n        val a = Array.fill(8){readLine}\n        val af = a filter {_ != \"BBBBBBBB\"}\n        val c = 0 until 8 count {n => af exists {_(n) == 'W'}}\n        println(8 - af.size + c)\n    }\n}\n"}], "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0"}
{"source_code": "import java.util.Scanner\n\nobject UnusualSequencesJudgeSolution {\n  val MOD: Long = 1000000007\n\n  def main(args: Array[String]): Unit = {\n    val sc = new Scanner(System.in)\n    val (x, y) = (sc.nextInt, sc.nextInt)\n\n    def count(L: Int): Long = {\n      if (L <= 2) 1\n      else {\n        def pow(b: Long, p: Long): Long = {\n          if (p == 0) 1L\n          else if (p % 2 == 0) {\n            val result = pow(b, p / 2);\n            (result * result) % MOD\n          }\n          else (b * pow(b, p - 1)) % MOD\n        }\n        def divisors(x: Int): List[Int] = {\n          def divisorsRec(d: Int): List[Int] = {\n            if (1L * d * d > x) List.empty\n            else if (x % d == 0) {\n              if (d * d == x) d :: divisorsRec(d + 1)\n              else d :: x / d :: divisorsRec(d + 1)\n            }\n            else divisorsRec(d + 1)\n          }\n          divisorsRec(1)\n        }\n\n        val DP = collection.mutable.Map[Int, Long]()\n        def D(l: Int): Long = {\n          if (DP.contains(l)) DP(l)\n          else {\n            val result = (pow(2, l - 1) - divisors(l).filter(_ != l).map(d => D(d)).foldLeft(0L)((x, sum) => (x + sum) % MOD) + MOD) % MOD\n            DP.update(l, result)\n            result\n          }\n        }\n\n        D(L)\n      }\n    }\n    def solve(): Long = {\n      if (y % x != 0) 0\n      else {\n        count(y / x)\n      }\n    }\n    println(solve())\n  }\n}\n", "positive_code": [{"source_code": "import java.util.Scanner\n\nobject UnusualSequencesJudgeSolution {\n  class Lazy[A](x: => A) {\n    lazy val value = x\n    override def toString(): String = value.toString()\n  }\n\n  object Lazy {\n    def apply[A](x: => A) = new Lazy(x)\n    implicit def fromLazy[A](z: Lazy[A]): A = z.value\n    implicit def toLazy[A](x: => A): Lazy[A] = Lazy(x)\n  }\n  def memoize[I, O](f: I => O): I => O = new collection.mutable.HashMap[I, O]() {\n    override def apply(key: I) = getOrElseUpdate(key, f(key))\n  }\n\n  val MOD: Long = 1000000007\n\n  def main(args: Array[String]): Unit = {\n    val sc = new Scanner(System.in)\n    val (x, y) = (sc.nextInt, sc.nextInt)\n\n    def count(L: Int): Long = {\n      if (L <= 2) 1\n      else {\n        def pow(b: Long, p: Long): Long = {\n          if (p == 0) 1L\n          else if (p % 2 == 0) {\n            val result = pow(b, p / 2);\n            (result * result) % MOD\n          }\n          else (b * pow(b, p - 1)) % MOD\n        }\n        def divisors(x: Int): List[Int] = {\n          def divisorsRec(d: Int): List[Int] = {\n            if (1L * d * d > x) List.empty\n            else if (x % d == 0) {\n              if (d * d == x) d :: divisorsRec(d + 1)\n              else d :: x / d :: divisorsRec(d + 1)\n            }\n            else divisorsRec(d + 1)\n          }\n          divisorsRec(1)\n        }\n\n        lazy val D: Int => Long = memoize (l => (pow(2, l - 1) - divisors(l).filter(_ != l).map(d => D(d)).foldLeft(0L)((x, sum) => (x + sum) % MOD) + MOD) % MOD)\n\n        D(L)\n      }\n    }\n    def solve(): Long = {\n      if (y % x != 0) 0\n      else {\n        count(y / x)\n      }\n    }\n    println(solve())\n  }\n}\n"}, {"source_code": "object Main extends App {\n\n  import scala.io.StdIn\n  val MOD: Integer = 1000000007\n\n  val Array(x, y) = StdIn.readLine().split(\" \").map(_.toInt)\n  var mem = collection.mutable.Map[Integer, Integer]()\n\n  if (y % x > 0) {\n    println(0)\n  }\n  else {\n    println(f(y/x))\n  }\n\n\n\n  def f(n: Integer): Integer = {\n\n    if (n == 1) return 1\n\n    if (mem contains(n))\n      return mem(n)\n\n    var res = pow2(n-1)\n\n    for (d <- 2 to Math.round(Math.sqrt(1*n)).toInt)\n      if (n % d == 0) {\n        res = ((res - f(n / d))%MOD+MOD)%MOD\n        if (d != n / d) res = ((res - f(d))%MOD+MOD)%MOD\n      }\n    res -= 1\n    mem += n -> (res%MOD+MOD)%MOD\n    mem(n)\n  }\n\n  def pow2(x: Integer): Integer = {\n    x%2 match {\n      case 0 if x > 0 => {\n        val res = pow2(x/2)%MOD\n        ((1l*res*res)%MOD).toInt\n      }\n      case 0 if x == 0 => 1\n      case _ => {\n        (2 * pow2(x-1) % MOD) % MOD\n      }\n    }\n  }\n\n}\n"}], "negative_code": [{"source_code": "object Main extends App {\n\n  import scala.io.StdIn\n  val MOD: Integer = 1000000007\n\n  val Array(x, y) = StdIn.readLine().split(\" \").map(_.toInt)\n  var mem = collection.mutable.Map[Integer, Integer]()\n\n  if (y % x > 0) {\n    println(0)\n  }\n  else {\n    println(f(y/x))\n  }\n\n\n\n  def f(n: Integer): Integer = {\n\n    if (mem contains(n))\n      return mem(n)\n\n    var res = pow2(n-1)\n\n    for (d <- 2 to Math.round(Math.sqrt(1*n)).toInt)\n      if (n % d == 0) {\n        res = ((res - f(n / d))%MOD+MOD)%MOD\n        if (d != n / d) res = ((res - f(d))%MOD+MOD)%MOD\n      }\n    res -= 1\n    mem += n -> (res%MOD+MOD)%MOD\n    mem(n)\n  }\n\n  def pow2(x: Integer): Integer = {\n    x%2 match {\n      case 0 if x > 0 => {\n        val res = pow2(x/2)%MOD\n        ((1l*res*res)%MOD).toInt\n      }\n      case 0 if x == 0 => 1\n      case _ => {\n        (2 * pow2(x-1) % MOD) % MOD\n      }\n    }\n  }\n\n}\n"}, {"source_code": "\nimport java.util.Scanner\n\n\nobject UnusualSequences {\n  val MOD: Long = 1000000007\n\n  class Matrix (val M: Array[Array[Long]]) {\n    val R = M.size\n    val C = M(0).size\n    def *(other: Matrix): Matrix = {\n      val result = Array.tabulate(R, other.C)((r, c) => 0.until(C).map(x => M(r)(x) * other.M(x)(c)).sum)\n      new Matrix(result)\n    }\n    def power(pow: Long): Matrix = {\n      if (pow == 0) Matrix.getIdentity(R, C)\n      else if (pow % 2 != 0) this * power(pow - 1)\n      else {\n        val result = power(pow / 2)\n        result * result\n      }\n    }\n  }\n  object Matrix {\n    def apply(M: Array[Array[Long]]) = new Matrix(M)\n    def getIdentity(r: Int, c: Int) = {\n      new Matrix(Array.tabulate(r, c)((i, j) => if (i == j) 1 else 0))\n    }\n  }\n\n  def main(args: Array[String]): Unit = {\n    val sc = new Scanner(System.in)\n    val (x, y) = (sc.nextInt, sc.nextInt)\n\n    def count(L: Int): Long = {\n      if (L <= 2) 1\n      else {\n        val base = Matrix(Array(Array(1), Array(0), Array(1)))\n        val matrix = Matrix(Array(Array(0, 1, 1), Array(1, 1, 0), Array(0, 0, 2)))\n\n        val result = matrix.power(L - 1) * base\n        result.M(0)(0)\n      }\n    }\n    def solve(): Long = {\n      if (y % x != 0) 0\n      else {\n        count(y / x)\n      }\n    }\n    println(solve())\n  }\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject UnusualSequencesJudgeSolution {\n  val MOD: Long = 1000000007\n\n  def main(args: Array[String]): Unit = {\n    val sc = new Scanner(System.in)\n    val (x, y) = (sc.nextInt, sc.nextInt)\n\n    def count(L: Int): Long = {\n      if (L <= 2) 1\n      else {\n        def pow(b: Long, p: Long): Long = {\n          if (p == 0) 1\n          else if (p % 2 == 0) {\n            val result = pow(b, p / 2);\n            (result * result) % MOD\n          }\n          else (b * pow(b, p - 1)) % MOD\n        }\n        def divisors(x: Int): List[Int] = {\n          def divisorsRec(d: Int): List[Int] = {\n            if (1L * d * d > x) List.empty\n            else if (x % d == 0) {\n              if (d * d == x) d :: divisorsRec(d + 1)\n              else d :: x / d :: divisorsRec(d + 1)\n            }\n            else divisorsRec(d + 1)\n          }\n          divisorsRec(1)\n        }\n\n        val DP = collection.mutable.Map[Int, Long]()\n        def D(l: Int): Long = {\n          if (DP.contains(l)) DP(l)\n          else {\n            val result = pow(2, l - 1) - divisors(l).filter(_ != l).map(d => D(d)).foldLeft(0L)((x, sum) => (x + sum) % MOD)\n            DP.update(l, result)\n            result\n          }\n        }\n\n        D(L)\n      }\n    }\n    def solve(): Long = {\n      if (y % x != 0) 0\n      else {\n        count(y / x)\n      }\n    }\n    println(solve())\n  }\n}\n"}], "src_uid": "de7731ce03735b962ee033613192f7bc"}
{"source_code": "import scala.io.StdIn._\r\nimport scala.util.control.Breaks._\r\n\r\nobject Main {\r\n  def main(args: Array[String]): Unit = {\r\n      val t: Int = readInt()\r\n      for (_ <- 1 to t) {\r\n          var curr_door: Int = readInt()\r\n          val A: Array[Int] = readLine().split(\" \").map(_.toInt)\r\n          var a: Boolean = true\r\n          breakable {for (_ <- 1 to 3) {\r\n              if (curr_door == 0) {\r\n                  a = false\r\n                  break\r\n              }\r\n              curr_door = A(curr_door-1)\r\n          }}\r\n          if (a) println(\"YES\") else println(\"NO\")\r\n      }\r\n    }\r\n}", "positive_code": [{"source_code": "\r\n\r\nobject prob2 {\r\n  def main(args: Array[String]) = {\r\n    new Resolver3(Console.in, Console.out).run()\r\n  }\r\n}\r\n\r\nclass Resolver3(input: java.io.BufferedReader, output: java.io.PrintStream) {\r\n\r\n  import java.util.StringTokenizer\r\n  import scala.collection.mutable\r\n  import scala.collection.mutable._\r\n  import scala.math.{abs,pow,min,max}\r\n  import scala.collection.mutable.ListBuffer\r\n\r\n  def run() {\r\n    var tokenizer = new StringTokenizer(input.readLine())\r\n    val q = tokenizer.nextToken().toInt\r\n    for (sss <- 0 until q) {\r\n      tokenizer = new StringTokenizer(input.readLine())\r\n      val n = tokenizer.nextToken().toInt\r\n      val A = new Array[Int](3)\r\n      tokenizer = new StringTokenizer(input.readLine())\r\n      A(0) = tokenizer.nextToken().toInt\r\n      A(1) = tokenizer.nextToken().toInt\r\n      A(2) = tokenizer.nextToken().toInt\r\n      var t = false\r\n      val a = A(n-1)\r\n      if (a != 0) {\r\n        val b = A(a-1)\r\n        if (b!=0) {\r\n          t = true\r\n        }\r\n      }\r\n      if (t) {\r\n        println(\"YES\")\r\n      }\r\n      else {\r\n        println(\"NO\")\r\n      }\r\n    }\r\n  }\r\n}"}], "negative_code": [], "src_uid": "5cd113a30bbbb93d8620a483d4da0349"}
{"source_code": "import java.io._\nimport java.util\nimport java.util.StringTokenizer\n\n\nobject Solution {\n  // VM options: -Xmx1024m -Xss1024m\n  private val inputFilename = \"input.txt\"\n  private val outputFilename = \"output.txt\"\n\n  def main(args: Array[String]): Unit = {\n    new Solution(args.contains(\"DEBUG_MODE\")).run(args)\n  }\n}\n\ncase class Solution(isDebug: Boolean) {\n  def solve(): Unit = {\n    var l = nextInt\n    var r = nextInt\n    var a = nextInt\n    val addL = Math.max(0, Math.min(r - l, a))\n    l += addL\n    a -= addL\n    val addR = Math.max(0, Math.min(l - r, a))\n    r += addR\n    a -= addR\n    l += a / 2\n    r += a / 2\n    println(s\"${Math.min(l, r) * 2}\")\n  }\n\n  def run(args: Array[String]): Unit = {\n    if (isDebug) {\n      in = new BufferedReader(new InputStreamReader(new FileInputStream(Solution.inputFilename)))\n      //      in = new BufferedReader(new InputStreamReader(System.in))\n    } else {\n      in = new BufferedReader(new InputStreamReader(System.in))\n    }\n    out = new PrintWriter(System.out)\n    //    out = new PrintWriter(outputFilename)\n\n    //    val t = nextInt\n    val t = 1\n    (0 until t).foreach { i =>\n      //      out.print(s\"Case #${i + 1}: \")\n      solve()\n    }\n    in.close()\n    out.flush()\n    out.close()\n  }\n\n  private var in: BufferedReader = _\n  private var line: StringTokenizer = _\n  private var out: PrintWriter = _\n\n  private[this] def println(s: String = \"\"): Unit = out.println(s)\n\n  private[this] def nextIntArray(n: Int) = (0 until n).map(_ => nextInt).toArray\n\n  private[this] def nextLongArray(n: Int) = (0 until n).map(_ => nextLong).toArray\n\n  private[this] def nextInt = nextToken.toInt\n\n  private[this] def nextLong = nextToken.toLong\n\n  private[this] def nextDouble = nextToken.toDouble\n\n  private[this] def nextToken = {\n    while (line == null || !line.hasMoreTokens) {\n      line = new StringTokenizer(in.readLine)\n    }\n    line.nextToken\n  }\n}", "positive_code": [{"source_code": "object aTask1 {\n  import scala.io.StdIn.{readLine, readInt}\n  def main(args: Array[String]):Unit = {\n    val l::r::a::Nil = readLine.split(\" \").map(_.toInt).toList\n    val p1 = math.min(l,r)\n    val p2 = math.min(math.abs(l - r), a)\n    val p3 = if (a - p2 >0) (a-p2)/2 else 0\n    println((p1+p2+p3) * 2)\n  }\n}"}, {"source_code": "object Solution {\n  def main(args: Array[String]) {\n    val sc = new java.util.Scanner(System.in)\n    val l, r, a = sc.nextInt\n    val u = a.min((r - l).abs)\n    \n    println(2 * (l.min(r) + u + (a - u)/2))\n  }\n}"}, {"source_code": "object A extends App {\n  val Array(l, r, a) = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n  val d = (l max r) - (l min r)\n  val t = a min d\n  val s = (l min r) + t + (0 max (a - t)) / 2\n\n  println(2 * s)\n}\n"}], "negative_code": [], "src_uid": "e8148140e61baffd0878376ac5f3857c"}
{"source_code": "import java.util.Scanner\n\nobject Main {\n\n  def sqr(x: Long) = x * x\n\n  def powmod(x: Long, n: Long, p: Long): Long = {\n    if (n == 1) x\n    else if (n % 2 == 1) (powmod(x, n - 1, p) * x) % p\n    else sqr(powmod(x, n / 2, p)) % p\n  }\n\n  def C(n: Int, k: Int) = {\n    var res = BigInt(1)\n    for (i <- n - k + 1 to n) {\n      res = res * i\n    }\n    for (i <- 1 to k.toInt) {\n      res = res / i\n    }\n    res\n  }\n\n  def fact(n: Int) = {\n    var res = BigInt(1)\n    for (i <- 1 to n) {\n      res = res * i\n    }\n    res\n  }\n\n  def gcd(a: Long, b: Long): Long = if (b == 0) a else gcd(b, a % b)\n\n  def lcm(a: Long, b: Long) = a / gcd(a, b) * b\n\n  def main(args: Array[String]): Unit = {\n    val in = new Scanner(System.in)\n\n    val s = in.nextLine()\n\n    val t = \"\" + s(0) + s(2) + s(4) + s(3) + s(1)\n\n    val x = BigInt(t)\n    val y = (x * x * x * x * x).toString()\n\n    println(y.substring(y.length() - 5))\n  }\n}\n", "positive_code": [{"source_code": "import scala.io.StdIn\n\nobject CrackingTheCode {\n\n  def main(args: Array[String]) {\n    val MOD = 100000\n    val n = StdIn.readLong()\n    val res = Array(n / 10000, (n / 100) % 10, n % 10, (n / 10) % 10, (n / 1000) % 10)\n    val k = res(0) * 10000 + res(1) * 1000 + res(2) * 100 + res(3) * 10 + res(4)\n    def pow(n : Int) : Long = {\n      if (n == 0) 1\n      else (k * pow(n - 1)) % MOD\n    }\n    println(\"%05d\".format(pow(5)))\n  }\n\n}\n"}], "negative_code": [{"source_code": "import scala.io.StdIn\n\nobject CrackingTheCode {\n\n  def main(args: Array[String]) {\n    val MOD = 100000\n    val n = StdIn.readLong()\n    val res = Array(n / 10000, (n / 100) % 10, n % 10, (n / 10) % 10, (n / 1000) % 10)\n    val k = res(0) * 10000 + res(1) * 1000 + res(2) * 100 + res(3) * 10 + res(4)\n    def pow(n : Int) : Long = {\n      if (n == 0) 1\n      else (k * pow(n - 1)) % MOD\n    }\n    println(pow(5))\n  }\n\n}\n"}], "src_uid": "51b1c216948663fff721c28d131bf18f"}
{"source_code": "import java.io._\nimport java.util.Locale\nimport scala.annotation.tailrec\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInt = reader.readLine().toInt\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readLongs = reader.readLine().split(\" \").map(_.toLong)\n  def readLine = reader.readLine\n\n  def calc(str: String): Double = {\n    if(str.length == 0) 0\n    else {\n      val ch = str.head\n      Math.ceil(0.2 * str.takeWhile(_ == ch).length) + calc(str.dropWhile(_ == ch))\n    }\n  }\n  def ans = calc(readLine)\n\n  def main(a: Array[String]) {\n    println(ans.round)\n  }\n}\n", "positive_code": [{"source_code": "import scala.collection.mutable.ArrayBuffer\n\nobject Flask {\n  def main(args: Array[String]): Unit = {\n    var s = readLine\n    var total = 0\n    var symbol = s(0); var count = 1\n    \n    (1 until s.size).foreach(i => {\n        if (s(i) == symbol && count < 5) count += 1\n        else { count = 1; symbol = s(i); total += 1 }\n    })\n    println(total + 1)\n  }\n}\n"}, {"source_code": "object main {\n    def main(args: Array[String]) = {\n        val str = readLine()\n        \n        var last:Char = str apply 0\n        var n = 0\n        var res = 0\n        \n        \n        str foreach ((x:Char) => {\n            if (last == x) {\n                if (n == 5) {\n                    n = 1\n                    res += 1\n                } else {\n                    n += 1\n                }\n            } else {\n                if (n != 0) {\n                    res += 1\n                } \n                n = 1\n                last = x\n              \n            }\n        })\n        \n        println(res + 1)\n    }\n}"}, {"source_code": "object P137A extends App {\n  \n  println(readLine.foldLeft((0,0,'x'))((t,c) => if (t._3 != c) (t._1+1,1,c) else (if(t._2 == 5) (t._1+1,1,c) else (t._1,t._2+1,c))) _1)\n\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val str = in.next()\n  val res = str.tail.foldLeft((0, 1, str.head)) {\n    case ((count, soFar, prev), el) if soFar == 5 => (count + 1, 1, el)\n    case ((count, soFar, prev), el) if el == prev => (count, soFar + 1, el)\n    case ((count, soFar, prev), el) => (count + 1, 1, el)\n  }\n  println(res._1 + (if (res._2 != 0) 1 else 0))\n}"}, {"source_code": "object A137 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def main(args: Array[String]): Unit = {\n    val str = read\n    var res = 0\n    var curr = 1\n    for(i <- 1 to str.length) {\n      if(i == str.length || str(i) != str(i-1)) {\n        res += (curr+4)/5\n        curr = 1\n      } else {\n        curr += 1\n      }\n    }\n    out.println(res)\n    out.close()\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(\"src/input\")))\n    val out = new java.io.PrintWriter(System.out)\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P137A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n  val CP = sc.nextLine.toList\n\n  def solve(): Int = {\n\n    @tailrec\n    def loop(n: Int, carry: List[Char], wall: List[Char]): Int = (carry, wall) match {\n        case (_, Nil) => n\n        case (Nil, y :: ys) => loop(n, y :: Nil, ys)\n        case (xs, ys) if xs.size == 5     => loop(n + 1, Nil, ys)\n        case (x :: xs, y :: ys) if x == y => loop(n, y :: x :: xs, ys)\n        case (x :: xs, y :: ys) if x != y => loop(n + 1, y :: Nil, ys)\n      }\n\n    loop(0, Nil, CP) + 1\n  }\n\n  out.println(solve)\n  out.close\n}\n"}, {"source_code": "object A137 {\n\tdef main(args: Array[String]) {\n\t\tval s: String = readLine\n\t\tvar res: Int = 0\n\t\tvar curc: Char = '?'\n\t\tvar curval: Int = 5\n\t\tfor (c <- s)\n\t\t\tif (c == curc && curval < 5)\n\t\t\t\tcurval += 1\n\t\t\telse {\n\t\t\t\tres += 1\n\t\t\t\tcurval = 1\n\t\t\t\tcurc = c\n\t\t\t}\n\t\tprintln(res)\n\t}\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]) = {\n    val s = readLine()\n    \n    var cur = ' '\n    var inHands = 0\n    var count = 0\n    s.foreach{ c => \n      if (c != cur) {\n        inHands = 0\n        count += 1\n        cur = c\n      } else if (inHands == 5) {\n        count += 1\n        inHands = 0\n      }\n      inHands += 1\n    }\n    println(count)\n  }\n}"}], "negative_code": [{"source_code": "object main {\n\tdef main(args: Array[String]) = {\n\t\tval str = readLine()\n\t\t\n\t\tvar last:Char = str apply 0\n\t\tvar n = 0\n\t\tvar res = 1\n\t\t\n\t\t\n\t\tstr foreach ((x:Char) => {\n\t\t\tif (last == x) {\n\t\t\t\tif (n == 5) {\n\t\t\t\t\tn = 0\n\t\t\t\t\tres += 1\n\t\t\t\t} else {\n\t\t\t\t\tn += 1\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (n != 0) {\n\t\t\t\t\tres += 1\n\t\t\t\t}\n\t\t\t\tn += 1\n\t\t\t\tlast = x\n\t\t\t  \n\t\t\t}\n\t\t})\n\t\t\n\t\tprintln(res)\n\t}\n}"}, {"source_code": "object main {\n    def main(args: Array[String]) = {\n        val str = readLine()\n        \n        var last:Char = str apply 0\n        var n = 0\n        var res = 0\n        \n        \n        str foreach ((x:Char) => {\n            if (last == x) {\n                if (n == 5) {\n                    n = 1\n                    res += 1\n                } else {\n                    n += 1\n                }\n            } else {\n                if (n != 0) {\n                    res += 1\n                }\n                n += 1\n                last = x\n              \n            }\n        })\n        \n        println(res + 1)\n    }\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val str = in.next()\n  val res = str.tail.foldLeft((0, 0, str.head)) {\n    case ((count, soFar, prev), el) if soFar == 5 => (count + 1, 1, el)\n    case ((count, soFar, prev), el) if el == prev => (count, 1, el)\n    case ((count, soFar, prev), el) => (count + 1, 1, el)\n  }\n  println(res._1 + (if (res._2 != 0) 1 else 0))\n}"}], "src_uid": "5257f6b50f5a610a17c35a47b3a0da11"}
{"source_code": "import java.io.FileReader\nimport java.util.Comparator\n\nimport collection.Searching._\nimport scala.collection.mutable\n\nobject Solution {\n  //Console.setIn(new FileReader(new java.io.File(\"input\")))\n  //Console.setOut(new PrintStream(new java.io.File(\"output\")))\n  var caseNo = 1\n  val magicMod = 1000000007\n\n  def doCase() : Unit = {\n    val Array(n) = readIntLine()\n    val widths = readIntLine()\n\n    val sum = Array.ofDim[Int](widths.length, widths.length + 1)\n\n    for (i <- widths.indices) {\n      for (j <- i + 1 to widths.length) {\n        sum(i)(j) = sum(i)(j - 1) + widths(j - 1)\n      }\n    }\n\n    val minDiff = widths.indices.map{\n      i =>\n        (i + 1 to widths.length).map{\n          j =>\n            Math.abs(180 - sum(i)(j)) * 2\n        }.min\n    }.min\n\n    println(minDiff)\n  }\n\n\n  def main(args: Array[String]) {\n    var tests = 1\n    for (test <- 0 until tests) {\n      doCase()\n      caseNo += 1\n    }\n  }\n\n  def readIntLine(): Array[Int] = {\n    readLine().split(\" \").map(_.toInt)\n  }\n\n  def readLongLine(): Array[Long] = {\n    readLine().split(\" \").map(_.toLong)\n  }\n\n  def readBigIntLine(): Array[BigInt] = {\n    readLine().split(\" \").map(BigInt.apply)\n  }\n}", "positive_code": [{"source_code": "object A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(n) = readInts(1)\n  val as = readInts(n)\n\n  var min = 360\n\n  for {\n    i <- 0 until n\n    j <- i to n\n  } {\n    val s1 = as.view(i, j).sum\n    val s2 = 360 - s1\n    val d = Math.abs(s1 - s2)\n    if (d < min) min = d\n  }\n\n  println(min)\n}\n"}, {"source_code": "object A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n\n  val Array(n) = readInts(1)\n  val as = readInts(n)\n\n  var min = 360\n  var s1 = 0\n  var l, r = 0\n\n  def check(s1: Int) = {\n    val s2 = 360 - s1\n    val d = Math.abs(s1 - s2)\n    if (d < min) min = d\n  }\n\n  while (r < n) {\n    while (s1 < 180 && r < n) {\n      s1 += as(r)\n      r += 1\n      check(s1)\n    }\n    while (s1 >= 180) {\n      s1 -= as(l)\n      l += 1\n      check(s1)\n    }\n  }\n\n  println(min)\n}\n"}, {"source_code": "\nimport java.util.Scanner\nimport scala.language.implicitConversions\n\nobject PizzaSeparation {\n\n  class Lazy[A](x: => A) {\n    lazy val value = x\n    override def toString(): String = value.toString()\n  }\n\n  object Lazy {\n    def apply[A](x: => A) = new Lazy(x)\n    implicit def fromLazy[A](z: Lazy[A]): A = z.value\n    implicit def toLazy[A](x: => A): Lazy[A] = Lazy(x)\n  }\n\n  def main(args: Array[String]): Unit = {\n    val sc = new Scanner(System.in)\n\n    val N = sc.nextInt()\n    val A = for (i <- 0.until(N)) yield sc.nextInt()\n\n    def bestPrefix(xs: List[Int], s: Int): Int = xs match {\n      case Nil => 360\n      case x :: rest => val ns = s + x; Math.min(Math.abs(360 - 2 * ns), bestPrefix(rest, ns))\n    }\n\n    def solve(xs: List[Int]): Int = xs match {\n      case Nil => 360\n      case x :: rest => Math.min(bestPrefix(xs, 0), solve(rest))\n    }\n\n    println(solve(A.toList))\n  }\n}"}], "negative_code": [{"source_code": "object A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n\n  val Array(n) = readInts(1)\n  val as = readInts(n)\n\n  var min = 360\n  var s1 = 0\n  var l, r = 0\n\n  def check(s1: Int) = {\n    val s2 = 360 - s1\n    val d = Math.abs(s1 - s2)\n    if (d < min) min = d\n  }\n\n  while (r < n) {\n    while (s1 < 180 && r < n) {\n      s1 += as(r)\n      r += 1\n    }\n    check(s1)\n    while (s1 >= 180) {\n      s1 -= as(l)\n      l += 1\n    }\n    check(s1)\n  }\n\n  println(min)\n}\n"}], "src_uid": "1b6a6aff81911865356ec7cbf6883e82"}
{"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n\n  def isGood(str: String) = {\n    str.length >= 1 && str.length <= 16 && str.forall(ch => (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_')\n  }\n\n  if (line.split(\"@\", -1) match {\n    case Array(first, second) if isGood(first) =>\n      second.split(\"/\", -1) match {\n        case Array(hostname, resource) =>\n          hostname.split(\"\\\\.\", -1).forall(isGood) && isGood(resource) && hostname.length <= 32\n        case Array(hostname) =>\n          hostname.split(\"\\\\.\", -1).forall(isGood)\n        case _ => false\n      }\n    case _ => false\n  })\n    println(\"YES\")\n  else\n    println(\"NO\")\n}\n", "positive_code": [{"source_code": "import java.util._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val user = next\n    if (user.split(\"@\").length != 2 ||  user.endsWith(\"@\")) {\n      out.println(\"NO\")\n      return 1\n    }\n    val name = user.split(\"@\")(0)\n    if (name.length <= 0 || name.length > 16) {\n      out.println(\"NO\")\n      return 1\n    }\n    val part2 = user.split(\"@\")(1)\n    val allow = \"QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_\".toCharArray\n    if (name.filter(x => !allow.contains(x)).length > 0) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"/\")(0).length <= 0 || part2.split(\"/\")(0).length > 32) {\n      out.println(\"NO\")\n      return 1\n    }\n\n    val hosts = part2.split(\"/\")(0).split(\"\\\\.\")\n    if (part2.split(\"/\")(0).startsWith(\".\") || part2.split(\"/\")(0).endsWith(\".\")) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"/\")(0).contains(\".\") && hosts.length == 0) {\n      out.println(\"NO\")\n      return 1\n    }\n    for (i <- 0 until hosts.length) {\n      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n      if (hosts(i).length <= 0 || hosts(i).length > 16) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n\n    if (part2.split(\"/\").length > 1) {\n      val res = part2.split(\"/\")(1)\n      if (res.filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n    if (user.endsWith(\"/\")) {\n      out.println(\"NO\")\n      return 1\n    }\n    out.println(\"YES\")\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}"}], "negative_code": [{"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n\n  def isGood(str: String) = {\n    str.length >= 1 && str.length <= 16 && str.forall(ch => (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_')\n  }\n\n  if (line.split('@') match {\n    case Array(first, second) if isGood(first) =>\n      second.split(\"/\", -1) match {\n        case Array(hostname, resource) =>\n          hostname.split(\"\\\\.\", -1).forall(isGood) && isGood(resource) && hostname.length <= 32\n        case Array(hostname) =>\n          hostname.split(\"\\\\.\", -1).forall(isGood)\n        case _ => false\n      }\n    case _ => false\n  })\n    println(\"YES\")\n  else\n    println(\"NO\")\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n\n  def isGood(str: String) = {\n    str.length >= 1 && str.length <= 16 && str.forall(ch => (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_')\n  }\n\n  if (line.split('@') match {\n    case Array(first, second) if isGood(first) =>\n      second.split('/') match {\n        case Array(hostname, resource) =>\n          hostname.split('.').forall(isGood) && isGood(resource) && hostname.length <= 32\n        case Array(hostname) =>\n          hostname.split('.').forall(isGood)\n        case _ => false\n      }\n    case _ => false\n  })\n    println(\"YES\")\n  else\n    println(\"NO\")\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n\n  def isGood(str: String) = {\n    str.length >= 1 && str.length <= 16 && str.forall(ch => (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_')\n  }\n\n  if (line.split('@') match {\n    case Array(first, second) if isGood(first) =>\n      second.split('/') match {\n        case Array(hostname, resource) =>\n          hostname.split(\"\\\\.\", -1).forall(isGood) && isGood(resource) && hostname.length <= 32\n        case Array(hostname) =>\n          hostname.split(\"\\\\.\", -1).forall(isGood)\n        case _ => false\n      }\n    case _ => false\n  })\n    println(\"YES\")\n  else\n    println(\"NO\")\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n\n  def isGood(str: String) = {\n    str.length >= 1 && str.length <= 16 && str.forall(ch => (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_')\n  }\n\n  if (line.split('@') match {\n    case Array(first, second) =>\n      second.split('/') match {\n        case Array(hostname, resource) =>\n          hostname.split('.').forall(isGood) && isGood(resource) && hostname.length <= 32\n        case Array(hostname) =>\n          hostname.split('.').forall(isGood)\n        case _ => false\n      }\n    case _ => false\n  })\n    println(\"YES\")\n  else\n    println(\"NO\")\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n\n  def isGood(str: String) = {\n    str.length >= 1 && str.length <= 16 && str.forall(ch => (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '_')\n  }\n\n  if (line.split('@') match {\n    case Array(first, second) =>\n      second.split('/') match {\n        case Array(hostname, resource) =>\n          hostname.split('.').forall(isGood) && isGood(resource) && hostname.length <= 32\n        case Array(hostname) =>\n          println(\"HERE\")\n          hostname.split('.').forall(isGood)\n        case _ => false\n      }\n    case _ => false\n  })\n    println(\"YES\")\n  else\n    println(\"NO\")\n}\n"}, {"source_code": "import java.util._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val user = next\n    if (user.split(\"@\").length != 2) {\n      out.println(\"NO\")\n      return 1\n    }\n\n    val name = user.split(\"@\")(0)\n    if (name.length <= 0 || name.length > 16) {\n      out.println(\"NO\")\n      return 1\n    }\n    val part2 = user.split(\"@\")(1)\n    val allow = \"abcdefghijklmnopqrstuvwxyz1234567890_\".toCharArray\n    if (name.filter(x => !allow.contains(x)).length > 0) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"\\\\\\\\\")(0).length <= 0 || part2.split(\"\\\\\\\\\")(0).length > 32) {\n      out.println(\"NO\")\n      return 1\n    }\n\n    val hosts = part2.split(\"\\\\\\\\\")(0).split(\".\")\n    for (i <- 0 until hosts.length) {\n      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n      if (hosts(i).length <= 0 || hosts(i).length > 16) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n\n    if (part2.split(\"\\\\\\\\\").length > 1) {\n      val res = part2.split(\"\\\\\\\\\")(1)\n      if (res.filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n    out.println(\"YES\")\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n"}, {"source_code": "import java.util._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val user = next\n    if (user.split(\"@\").length != 2) {\n      out.println(\"NO\")\n      return 1\n    }\n    val name = user.split(\"@\")(0)\n    if (name.length <= 0 || name.length > 16) {\n      out.println(\"NO\")\n      return 1\n    }\n    val part2 = user.split(\"@\")(1)\n    val allow = \"QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_\".toCharArray\n    if (name.filter(x => !allow.contains(x)).length > 0) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"/\")(0).length <= 0 || part2.split(\"/\")(0).length > 32) {\n      out.println(\"NO\")\n      return 1\n    }\n\n    val hosts = part2.split(\"/\")(0).split(\"\\\\.\")\n    if (part2.startsWith(\".\") || (part2.endsWith(\".\"))) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"/\")(0).contains(\".\") && hosts.length == 0) {\n      out.println(\"NO\")\n      return 1\n    }\n    for (i <- 0 until hosts.length) {\n      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n      if (hosts(i).length <= 0 || hosts(i).length > 16) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n\n    if (part2.split(\"/\").length > 1) {\n      val res = part2.split(\"/\")(1)\n      if (res.filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n    if (user.endsWith(\"/\")) {\n      out.println(\"NO\")\n      return 1\n    }\n    out.println(\"YES\")\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}"}, {"source_code": "import java.util._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val user = next\n    if (user.split(\"@\").length != 2) {\n      out.println(\"NO\")\n      return 1\n    }\n    val name = user.split(\"@\")(0)\n    if (name.length <= 0 || name.length > 16) {\n      out.println(\"NO\")\n      return 1\n    }\n    val part2 = user.split(\"@\")(1)\n    val allow = \"QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_\".toCharArray\n    if (name.filter(x => !allow.contains(x)).length > 0) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"/\")(0).length <= 0 || part2.split(\"/\")(0).length > 32) {\n      out.println(\"NO\")\n      return 1\n    }\n\n    val hosts = part2.split(\"/\")(0).split(\"\\\\.\")\n    if (part2.split(\"/\")(0).startsWith(\".\") || part2.split(\"/\")(0).endsWith(\".\")) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"/\")(0).contains(\".\") && hosts.length == 0) {\n      out.println(\"NO\")\n      return 1\n    }\n    for (i <- 0 until hosts.length) {\n      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n      if (hosts(i).length <= 0 || hosts(i).length > 16) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n\n    if (part2.split(\"/\").length > 1) {\n      val res = part2.split(\"/\")(1)\n      if (res.filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n    if (user.endsWith(\"/\")) {\n      out.println(\"NO\")\n      return 1\n    }\n    out.println(\"YES\")\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}"}, {"source_code": "import java.util._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val user = next\n    if (user.split(\"@\").length != 2) {\n      out.println(\"NO\")\n      return 1\n    }\n    val name = user.split(\"@\")(0)\n    if (name.length <= 0 || name.length > 16) {\n      out.println(\"NO\")\n      return 1\n    }\n    val part2 = user.split(\"@\")(1)\n    val allow = \"QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_\".toCharArray\n    if (name.filter(x => !allow.contains(x)).length > 0) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"/\")(0).length <= 0 || part2.split(\"/\")(0).length > 32) {\n      out.println(\"NO\")\n      return 1\n    }\n\n    val hosts = part2.split(\"/\")(0).split(\".\")\n    for (i <- 0 until hosts.length) {\n      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n      if (hosts(i).length <= 0 || hosts(i).length > 16) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n\n    if (part2.split(\"/\").length > 1) {\n      val res = part2.split(\"/\")(1)\n      if (res.filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n    if (user.endsWith(\"/\")) {\n      out.println(\"NO\")\n      return 1\n    }\n    out.println(\"YES\")\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}"}, {"source_code": "import java.util._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val user = next\n    if (user.split(\"@\").length != 2) {\n      out.println(\"NO\")\n      return 1\n    }\n    val name = user.split(\"@\")(0)\n    if (name.length <= 0 || name.length > 16) {\n      out.println(\"NO\")\n      return 1\n    }\n    val part2 = user.split(\"@\")(1)\n    val allow = \"QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_\".toCharArray\n    if (name.filter(x => !allow.contains(x)).length > 0) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"/\")(0).length <= 0 || part2.split(\"/\")(0).length > 32) {\n      out.println(\"NO\")\n      return 1\n    }\n\n    val hosts = part2.split(\"/\")(0).split(\".\")\n    if (part2.startsWith(\".\") || (part2.endsWith(\".\"))) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"/\")(0).contains(\".\") && hosts.length == 0) {\n      out.println(\"NO\")\n      return 1\n    }\n    for (i <- 0 until hosts.length) {\n      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n      if (hosts(i).length <= 0 || hosts(i).length > 16) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n\n    if (part2.split(\"/\").length > 1) {\n      val res = part2.split(\"/\")(1)\n      if (res.filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n    if (user.endsWith(\"/\")) {\n      out.println(\"NO\")\n      return 1\n    }\n    out.println(\"YES\")\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}"}, {"source_code": "import java.util._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val user = next\n    if (user.split(\"@\").length != 2) {\n      out.println(\"NO\")\n      return 1\n    }\n    val name = user.split(\"@\")(0)\n    if (name.length <= 0 || name.length > 16) {\n      out.println(\"NO\")\n      return 1\n    }\n    val part2 = user.split(\"@\")(1)\n    val allow = \"QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_\".toCharArray\n    if (name.filter(x => !allow.contains(x)).length > 0) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"/\")(0).length <= 0 || part2.split(\"/\")(0).length > 32) {\n      out.println(\"NO\")\n      return 1\n    }\n\n    val hosts = part2.split(\"/\")(0).split(\".\")\n    if (part2.startsWith(\".\") || (part2.endsWith(\".\"))) {\n      out.println(\"NO\")\n      return 1\n    }\n    for (i <- 0 until hosts.length) {\n      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n      if (hosts(i).length <= 0 || hosts(i).length > 16) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n\n    if (part2.split(\"/\").length > 1) {\n      val res = part2.split(\"/\")(1)\n      if (res.filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n    if (user.endsWith(\"/\")) {\n      out.println(\"NO\")\n      return 1\n    }\n    out.println(\"YES\")\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}"}, {"source_code": "import java.util._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val user = next\n    if (user.split(\"@\").length != 2) {\n      out.println(\"NO\")\n      return 1\n    }\n    val name = user.split(\"@\")(0)\n    if (name.length <= 0 || name.length > 16) {\n      out.println(\"NO\")\n      return 1\n    }\n    val part2 = user.split(\"@\")(1)\n    val allow = \"QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_\".toCharArray\n    if (name.filter(x => !allow.contains(x)).length > 0) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"/\")(0).length <= 0 || part2.split(\"/\")(0).length > 32) {\n      out.println(\"NO\")\n      return 1\n    }\n\n    val hosts = part2.split(\"/\")(0).split(\".\")\n    if (part2.startsWith(\".\")) {\n      out.println(\"NO\")\n      return 1\n    }\n    for (i <- 0 until hosts.length) {\n      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n      if (hosts(i).length <= 0 || hosts(i).length > 16) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n\n    if (part2.split(\"/\").length > 1) {\n      val res = part2.split(\"/\")(1)\n      if (res.filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n    if (user.endsWith(\"/\")) {\n      out.println(\"NO\")\n      return 1\n    }\n    out.println(\"YES\")\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}"}, {"source_code": "import java.util._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val user = next\n    if (user.split(\"@\").length != 2) {\n      out.println(\"NO\")\n      return 1\n    }\n    val name = user.split(\"@\")(0)\n    if (name.length <= 0 || name.length > 16) {\n      out.println(\"NO\")\n      return 1\n    }\n    val part2 = user.split(\"@\")(1)\n    val allow = \"abcdefghijklmnopqrstuvwxyz1234567890_\".toCharArray\n    if (name.filter(x => !allow.contains(x)).length > 0) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"/\")(0).length <= 0 || part2.split(\"/\")(0).length > 32) {\n      out.println(\"NO\")\n      return 1\n    }\n\n    val hosts = part2.split(\"/\")(0).split(\".\")\n    for (i <- 0 until hosts.length) {\n      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n      if (hosts(i).length <= 0 || hosts(i).length > 16) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n\n    if (part2.split(\"/\").length > 1) {\n      val res = part2.split(\"/\")(1)\n      if (res.filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n    if (user.endsWith(\"/\")) {\n      out.println(\"NO\")\n      return 1\n    }\n    out.println(\"YES\")\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}"}, {"source_code": "import java.util._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val user = next\n    if (user.split(\"@\").length != 2) {\n      out.println(\"NO\")\n      return 1\n    }\n\n    val name = user.split(\"@\")(0)\n    if (name.length <= 0 || name.length > 16) {\n      out.println(\"NO\")\n      return 1\n    }\n    val part2 = user.split(\"@\")(1)\n    val allow = \"QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_\".toCharArray\n    val filter: String = name.filter(x => allow.contains(x))\n    if (filter.length != name.length) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"\\\\\\\\\")(0).length <= 0 || part2.split(\"\\\\\\\\\")(0).length > 32) {\n      out.println(\"NO\")\n      return 1\n    }\n\n    val hosts = part2.split(\"\\\\\\\\\")(0).split(\".\")\n    for (i <- 0 until hosts.length) {\n      val filter1: String = hosts(i).filter(x => allow.contains(x))\n      if (filter1.length != hosts(i).length) {\n        out.println(\"NO\")\n        return 1\n      }\n      if (hosts(i).length <= 0 || hosts(i).length > 16) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n\n    if (part2.split(\"\\\\\\\\\").length > 1) {\n      val res = part2.split(\"\\\\\\\\\")(1)\n      val filter1: String = res.filter(x => allow.contains(x))\n      if (filter1.length != res.length) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n    out.println(\"YES\")\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n"}, {"source_code": "import java.util._\nimport java.io._\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = {\n    return Integer.parseInt(next)\n  }\n\n  def nextLong: Long = {\n    return java.lang.Long.parseLong(next)\n  }\n\n  def solve: Int = {\n    val user = next\n    if (user.split(\"@\").length != 2) {\n      out.println(\"NO\")\n      return 1\n    }\n\n    val name = user.split(\"@\")(0)\n    if (name.length <= 0 || name.length > 16) {\n      out.println(\"NO\")\n      return 1\n    }\n    val part2 = user.split(\"@\")(1)\n    val allow = \"QWERTYUIOPASDFGHJKLZXCVBNMabcdefghijklmnopqrstuvwxyz1234567890_\".toCharArray\n    if (name.filter(x => !allow.contains(x)).length > 0) {\n      out.println(\"NO\")\n      return 1\n    }\n    if (part2.split(\"\\\\\\\\\")(0).length <= 0 || part2.split(\"\\\\\\\\\")(0).length > 32) {\n      out.println(\"NO\")\n      return 1\n    }\n\n    val hosts = part2.split(\"\\\\\\\\\")(0).split(\".\")\n    for (i <- 0 until hosts.length) {\n      if (hosts(i).filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n      if (hosts(i).length <= 0 || hosts(i).length > 16) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n\n    if (part2.split(\"\\\\\\\\\").length > 1) {\n      val res = part2.split(\"\\\\\\\\\")(1)\n      if (res.filter(x => !allow.contains(x)).length > 0) {\n        out.println(\"NO\")\n        return 1\n      }\n    }\n    out.println(\"YES\")\n    return 1\n  }\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n}\n"}], "src_uid": "2a68157e327f92415067f127feb31e24"}
{"source_code": "import java.util.Scanner\n\n/**\n  * Created by pinguinson on 6/17/2017.\n  */\nobject A extends App {\n val sc = new Scanner(System.in)\n  val palindromes = Seq(\n    ( 0, 0),\n    ( 1,10),\n    ( 2,20),\n    ( 3,30),\n    ( 4,40),\n    ( 5,50),\n    //6\n    //7\n    //8\n    //9\n    (10, 1),\n    (11,11),\n    (12,21),\n    (13,31),\n    (14,41),\n    (15,51),\n    //16\n    //17\n    //18\n    //19\n    (20, 2),\n    (21,12),\n    (22,22),\n    (23,32))\n  val s = sc.next()\n  val h = s.substring(0, 2).toInt\n  val m = s.substring(3, 5).toInt\n  val togo = palindromes.find {\n    case (hour, minute) =>\n        (hour > h) ||\n        ((hour == h) && (minute >= m))\n  } match {\n    case Some((hr, min)) => (hr - h) * 60 + (min - m)\n    case None => (23 - h) + (60 - m)\n  }\n  println(togo)\n}\n", "positive_code": [{"source_code": "object _816A extends CodeForcesApp {\n  import Utils._, annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._\n\n  override def apply(io: IO) = {import io.{read, readAll, write, writeAll, writeLine}\n    var Array(hh, mm) = read[String].split(':').map(_.toInt)\n    var ans = 0\n    while(!isPalindrome(hh, mm)) {\n      val (nh, nm) = next(hh, mm)\n      hh = nh\n      mm = nm\n      ans += 1\n    }\n    write(ans)\n  }\n\n  def pad(x: Int) = if (x < 10) s\"0$x\" else x.toString\n\n  def isPalindrome(hh: Int, mm: Int) = {\n    val t = s\"${pad(hh)}:${pad(mm)}\"\n    t == t.reverse\n  }\n\n  def next(hh: Int, mm: Int) = {\n    if (mm == 59) {\n      ((hh + 1)%24, 0)\n    } else {\n      (hh, mm + 1)\n    }\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\nobject Utils {\n  import scala.collection.mutable, mutable.{Map => Dict}\n  implicit class GenericExtensions[A](val a: A) extends AnyVal {\n    def in(set: collection.Set[A]): Boolean = set(a)\n    def some: Option[A] = Some(a)\n    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a\n  }\n  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {\n    def onlyElement: A = assuming(t.size == 1)(t.head)\n    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)\n    def duplicates(implicit b: C of A): C[A] = {\n      val elems = mutable.Set.empty[A]\n      (t collect {case i if !elems.add(i) => i}).to[C]\n    }\n    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}\n    def maxWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.max)\n    def minWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.min)\n    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]\n    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap\n    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)\n    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}\n    def toMutableMultiSet: Dict[A, Int] = {\n      val c = map[A] to 0\n      t.foreach(i => c(i) += 1)\n      c\n    }\n    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0\n    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)\n  }\n  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)\n  }\n  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)\n  }\n  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {\n    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t\n  }\n  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {\n    def key = p._1\n    def value = p._2\n  }\n  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {\n    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)\n    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])\n    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]\n  }\n  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {\n    def lastKeyOption: Option[K] = m.lastOption.map(_.key)\n    def firstKeyOption: Option[K] = m.headOption.map(_.key)\n    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap\n    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}\n    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m\n    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\n  }\n  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {\n    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)\n    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)\n    private def removeNode(kv: (K, V)): (K, V) = {\n      m -= kv.key\n      kv\n    }\n  }\n  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {\n    def notContains(x: A): Boolean = !(s contains x)\n    def toMutable = mutable.Set.empty[A] ++ s\n  }\n  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {\n    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}\n    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)\n    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)\n    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}\n    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)\n  }\n  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {\n    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero\n    def toEnglish = if(x) \"YES\" else \"NO\"\n  }\n  implicit class IntExtensions(val x: Int) extends AnyVal {\n    import java.lang.{Integer => JInt}\n    def withHighestOneBit: Int = JInt.highestOneBit(x)\n    def withLowestOneBit: Int = JInt.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)\n    def bitCount: Int = JInt.bitCount(x)\n    def setLowestBits(n: Int): Int = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Int = x & left(n, ~0)\n    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Int = x | left(i)\n    def clearBit(i: Int): Int = x & ~left(i)\n    def toggleBit(i: Int): Int = x ^ left(i)\n    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1\n    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)\n    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)\n  }\n  implicit class LongExtensions(val x: Long) extends AnyVal {\n    import java.lang.{Long => JLong}\n    def withHighestOneBitSet: Long = JLong.highestOneBit(x)\n    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)\n    def bitCount: Int = JLong.bitCount(x)\n    def setLowestBits(n: Int): Long = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Long = x & left(n, ~0L)\n    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Long = x | left(i)\n    def clearBit(i: Int): Long = x & ~left(i)\n    def toggleBit(i: Int): Long = x ^ left(i)\n    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1\n    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)\n  }\n  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {\n    import Numeric.Implicits._\n    def **(i: Int): A = if (i == 0) n.one else {\n      val h = x ** (i/2)\n      if (i%2 == 0) h * h else h * h * x\n    }\n    def distance(y: A) = (x - y).abs()\n    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)\n    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf \"Greg\" whenNegative Int.MaxValue\n  }\n  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {\n    import scala.collection.immutable.NumericRange, Integral.Implicits._\n    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x\n    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)\n    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)\n  }\n  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))\n  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)\n  def asc[A](implicit order: Ordering[A]): Ordering[A] = order\n  def map[K] = new {\n    def to[V](default: => V): Dict[K, V] = using(_ => default)\n    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {\n      override def apply(key: K) = getOrElseUpdate(key, f(key))\n    }\n  }\n  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]\n  def memoize[A, B](f: A => B): A ==> B = map[A] using f\n  implicit class FuzzyDouble(val x: Double) extends AnyVal {\n    def  >~(y: Double) = x > y + eps\n    def >=~(y: Double) = x >= y + eps\n    def  ~<(y: Double) = y >=~ x\n    def ~=<(y: Double) = y >~ x\n    def  ~=(y: Double) = (x distance y) <= eps\n  }\n  def toPolygon(points: Traversable[(Int, Int)]): java.awt.Polygon = {\n    val (xs, ys) = points.unzip\n    new java.awt.Polygon(xs.toArray, ys.toArray, points.size)\n  }\n  def toShape(points: Traversable[(Double, Double)]): java.awt.geom.GeneralPath = {\n    val shape = new java.awt.geom.GeneralPath()\n    points.headOption foreach {case (x, y) => shape.moveTo(x, y)}\n    points.tail foreach {case (x, y) => shape.lineTo(x, y)}\n    shape.closePath()\n    shape\n  }\n  def until(until: Int): Range = 0 until until\n  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}\n  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}\n  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None\n  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)\n  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]\n  type ==>[A, B] = collection.Map[A, B]\n  val mod: Int = (1e9 + 7).toInt\n  val eps: Double = 1e-9\n}\n/***********************************[Scala I/O]*********************************************/\nimport Utils._, java.io._, java.util.StringTokenizer\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    when(tokenizers.nonEmpty)(tokenizers.head)\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  def readAll[A: IO.Read]: (Int, Vector[A]) = {\n    val data = read[Vector[A]]\n    (data.length, data)\n  }\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any): this.type = {\n    printer.print(obj)\n    this\n  }\n  def writeLine(): this.type = {\n    printer.println()\n    this\n  }\n  def writeLine(obj: Any): this.type = {\n    printer.println(obj)\n    this\n  }\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n  def query[A: IO.Read](question: Any): A = writeLine(question).read\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                       : Read[String]       = new Read(_.next())\n    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)\n    implicit val int                                          : Read[Int]          = string.map(_.toInt)\n    implicit val long                                         : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                       : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                      : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n"}], "negative_code": [{"source_code": "import java.util.Scanner\n\n/**\n  * Created by pinguinson on 6/17/2017.\n  */\nobject A extends App {\n val sc = new Scanner(System.in)\n  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))\n  val s = sc.next()\n  val h = s.substring(0, 2).toInt\n  val m = s.substring(3, 5).toInt\n  val togo = palindromes.find {\n    case (hour, minute) => hour >= h && minute >= m\n  } match {\n    case Some((hr, min)) => (hr - h) * 60 + (min - m)\n    case None => (23 - h) + (60 - m)\n  }\n  println(togo)\n}\n"}], "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5"}
{"source_code": "object Main2 extends App {\n\n  import java.io._\n  import java.util.{StringTokenizer}\n\n  val in = new Reader()\n  val out: PrintWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)))\n\n  val n = in.nextInt\n  var s = in.next\n  (2 to n) filter(n % _ == 0) foreach { d =>\n    s = s.substring(0, d).reverse + s.substring(d, n)\n  }\n  out.print(s)\n  out.flush()\n  out.close()\n\n  class Reader @throws[IOException]\n  () {\n    var br: BufferedReader = new BufferedReader(new InputStreamReader(System.in))\n    var tok: StringTokenizer = null\n\n    def this(file: String) {\n      this()\n      br = new BufferedReader(new FileReader(file))\n    }\n\n    def next: String = {\n      while (tok == null || !tok.hasMoreElements) tok = new StringTokenizer(br.readLine)\n      tok.nextToken\n    }\n\n    def nextInt: Int = next.toInt\n\n    def nextLong: Long = next.toLong\n\n    def nextDouble: Double = next.toDouble\n\n    def nextLine: String = br.readLine\n  }\n\n}", "positive_code": [{"source_code": "object CF_490_3_B {\n\n  type In  = (Int, String)\n  type Out = String\n  \n  def solve(in: In): Out = {\n    val (n, s) = in\n\n    var ms = s\n    for {\n      i <- 1 to n\n      if n % i == 0\n    } {\n      val (a, b) = ms.splitAt(i)\n      ms = a.reverse + b\n    }\n\n    ms\n  }\n\n//   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n//   Specify Input and Output formats on RHS here:\n\n  def formatIn(i: Input): In       = (i.int, {i.nextLine; i.nextLine})\n  def formatOut(out: Out): String  = out.toString\n\n//   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n//   Boilerplate & utility methods that don't change (so ignore): \n\n  import java.util.Scanner\n  import java.io.InputStream\n  import language.implicitConversions\n \n  def main(args: Array[String]): Unit = {\n    val out = new java.io.PrintWriter(System.out)\n    val resultStr = new Input(System.in).solveStr\n    out.println(resultStr)\n    out.close()\n  }\n  \n  class Input(val sc: Scanner) {\n    // This class is useful for convenience, and for mock stdin in test scripts\n    // Remember to call nextLine to advance past the newline character (if required) before taking a whole line\n    def this(i: InputStream)       = this(new Scanner(i))\n    def this(s: String)            = this(new Scanner(s.stripMargin))\n    def int                        = sc.nextInt()\n    def long                       = sc.nextLong()\n    def double                     = sc.nextDouble()\n    def nextLine                   = sc.nextLine()\n    def collect[T](f: String => T) = sc.nextLine().split(\" \").toVector.map(f)\n    def intSeq                     = collect(_.toInt)\n    def doubleSeq                  = collect(_.toDouble)\n    def getLines: Vector[String]   = if (!sc.hasNextLine) Vector.empty \n                                     else sc.nextLine +: getLines\n    def getLines(lineCount: Int)   = {nextLine; (1 to lineCount).map(_ => sc.nextLine)}\n    def solveVal: Out              = (solve _).tupled(formatIn(this))\n    def solveStr: String           = formatOut(solveVal)\n  }\n\n  // Ceiling division for Int & Long\n  // `a` MUST be > 0. Incorrect otherwise.\n  def divideCeil(a: Int, b: Int)   = (a - 1)/b + 1\n  def divideCeil(a: Long, b: Long) = (a - 1)/b + 1\n  \n  // A frequently used number in these comps\n  val modulo = 1000000007\n\n  // For convenience in test scripts, treat a String as an Input \n  implicit def stringToInput(s: String): Input = new Input(s)\n  // Required to make `solveVal` work when input has just 1 value (i.e. not a Tuple)\n  implicit class makeTupledWorkOnFunction1[-T,+R](f: T => R) { \n    def tupled: T => R = x => f(x) \n  }\n}\n"}, {"source_code": "object B999 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    var str = read\n    for(fact <- 1 to n) {\n      if(n % fact == 0) {\n        str = (str.take(fact).reverse) ++ str.drop(fact)\n      }\n    }\n    out.println(str)\n\n    out.close()\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(\"src/input\")))\n    val out = new java.io.PrintWriter(System.out)\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}"}, {"source_code": "import scala.io.StdIn\n\nobject ReversingEncryption {\n  def decrypt(length: Int, line: String): String = {\n    var newString = line\n    for (i <- 1 to length) {\n      if (length % i == 0) {\n        newString = newString.replaceFirst(newString.substring(0, i), newString.substring(0, i).reverse)\n      }\n    }\n    newString\n  }\n\n  def main(args: Array[String]): Unit = {\n    val length = StdIn.readInt()\n    var line = StdIn.readLine()\n    println(decrypt(length, line))\n  }\n}"}, {"source_code": "import scala.io.StdIn._\nimport scala.annotation.tailrec\n\nobject ProblemB {\n  def readLineToList = readLine.split(\" \").map(_.toInt).toList\n\n  def main(args: Array[String]): Unit = {\n      val max = readLine.toInt\n      val encryptedStr = readLine\n      val divisors = (1 to max).filter(max % _ == 0)\n\n      val result = divisors.foldLeft(encryptedStr)((a,b) => {\n        a.substring(0, b).reverse + a.splitAt(b)._2\n      })\n      println(result)\n  }\n}"}, {"source_code": "import scala.io.StdIn\n\nobject ReverseEncryption {\n  def main(args: Array[String]): Unit = {\n    StdIn.readLine()\n    val string = StdIn.readLine()\n    println(solve(string))\n  }\n\n  def solve(input: String) = {\n    var result = input\n    divisor(input.length).foreach(n => result = flip(result, n))\n    result\n  }\n\n  private def divisor(n: Int): Seq[Int] = {\n    for {\n       i <- 2 to n\n       if n % i == 0\n    }\n    yield i\n  }\n\n  private def flip(input: String, n: Int): String = {\n    input.substring(0, n).reverse + input.substring(n)\n  }\n}"}, {"source_code": "import math._\nobject Main extends App {\n  val n = readInt\n  val s = readLine\n  val d = (1 to sqrt(n).toInt).filter(n % _ == 0)\n  val all_d = (d ++ d.map(n / _).reverse).distinct\n  val b = StringBuilder.newBuilder\n  b.append(s)\n  all_d.foreach(i => b.replace(0, i, b.substring(0, i).reverse))\n  println(b)\n}"}], "negative_code": [{"source_code": "import math._\nobject Main extends App {\n  val n = readInt\n  val s = readLine\n  val d = (1 to sqrt(n).toInt).filter(n % _ == 0)\n  val all_d = d ++ d.map(n / _).reverse\n  val b = StringBuilder.newBuilder\n  b.append(s)\n  all_d.foreach(i => b.replace(0, i, b.substring(0, i).reverse))\n  println(b)\n}"}], "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3"}
{"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport java.util.Arrays.binarySearch\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.collection.mutable.ArrayBuffer\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\n\nobject P108A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val List(hh, mm): List[String] = sc.nextLine.split(\":\").toList\n\n  def nextPalindromicTime(n: Int): String = {\n    val h = (n + 1) % 24\n    val m = f\"$h%02d\".reverse.toInt\n    if (m < 60) f\"$h%02d:$m%02d\"\n    else nextPalindromicTime(h)\n  }\n\n  val res = {\n    val rh = hh.reverse.toInt\n    if (rh < 60 && rh > mm.toInt) hh + \":\" + hh.reverse\n    else nextPalindromicTime(hh.toInt)\n  }\n\n  out.println(res)\n  out.close\n}\n\n\n\n\n\n", "positive_code": [{"source_code": "object P108A extends App {\n  \n  val Array(hh,mm) = readLine.split(\":\").map(_.toInt)\n  \n  def inc(t:(Int,Int)) = ((t._1 + (if (t._2==59) 1 else 0)) % 24,(t._2+1) % 60)\n  def f(s:Int) = \"%02d\".format(s)\n  def isPal(t:Int,s:Int) = (f(t) == f(s).reverse)\n  \n  var time = (hh,mm)\n  do time = inc(time) while(!isPal(time._1,time._2))\n  print(f(time._1) + \":\" + f(time._2))\n\n}"}, {"source_code": "object P108A extends App {\n  val Array(h,m)=readLine.split(\":\").map(_.toInt)\n  def i(t:(Int,Int))=((t._1+(if(t._2==59)1 else 0))%24,(t._2+1)%60)\n  def f(s:Int)=\"%02d\".format(s)\n  var t = (h,m)\n  do t = i(t) while(f(t._1) != f(t._2).reverse)\n  print(f(t._1) + \":\" + f(t._2))\n}"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  def pol(time: Int) = {\n    val minutes = time % 60\n    val hours = time / 60 % 24\n    minutes % 10 == hours / 10 && minutes / 10 == hours % 10\n  }\n\n  val in = Source.stdin.getLines()\n  val Array(hh, mm) = in.next().split(\":\").map(_.toInt)\n  var time = hh * 60 + mm + 1\n  while (!pol(time)) time += 1\n  val minutes = time % 60\n  val hours = time / 60 % 24\n  println(f\"$hours%02d:$minutes%02d\")\n}"}, {"source_code": "object A108 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def main(args: Array[String]): Unit = {\n    val in = {\n      val str = read\n      Array(str.take(2).toInt, str.takeRight(2).toInt)\n    }\n    var break = false\n    while(!break) {\n      if(in(0) == 23 && in(1) == 59) {\n        in(0) = 0\n        in(1) = 0\n      } else if(in(1) == 59){\n        in(0) += 1\n        in(1) = 0\n      } else {\n        in(1) += 1\n      }\n      val str = \"%02d\".format(in(0)) + \":\" + \"%02d\".format(in(1))\n      if(str == str.reverse) {\n        println(str)\n        break = true\n      }\n    }\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val Array(hh, mm) = readLine().split(\":\")\n    val h1 = \n      if (hh.reverse.toInt <= mm.toInt) hh.toInt + 1\n      else hh.toInt\n    val h2 = h1 match {\n      case 24 => \"00\"\n      case i if i < 6 => \"0\" + i\n      case i if i >= 6 && i <= 9 => \"10\"\n      case i if i >= 16 && i <= 19 => \"20\"\n      case i => i.toString\n    }\n    println(h2 + \":\" + h2.reverse)\n  }\n}"}], "negative_code": [{"source_code": "object P108A extends App {\n  \n  val Array(hh,mm) = readLine.split(\":\").map(_.toInt)\n  \n  def inc(t:(Int,Int)) = ((t._1 + (if (t._2==59) 1 else 0)) % 24,(t._2+1) % 60)\n  def isPal(t:(Int,Int)) = (t._1 == t._2.toString.reverse.toInt)\n  \n  var time = (hh,mm)\n  do time = inc(time) while(!isPal(time))\n  printf(\"%02d:%02d\", time._1, time._2)\n\n}"}, {"source_code": "object P108A extends App {\n  val Array(h,m)=readLine.split(\":\").map(_.toInt)\n  def i(t:(Int,Int))=((t._1+(if(t._2==59)1 else 0))%24,(t._2+1)%60)\n  def f(s:Int)=\"%02d\".format(s)\n  var t = (h,m)\n  do t = i(t) while(f(t._1) != f(t._2))\n  print(f(t._1) + \":\" + f(t._2))\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport java.util.Arrays.binarySearch\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.collection.mutable.ArrayBuffer\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\n\nobject P108A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val List(h, m) = sc.nextLine.split(\":\").toList\n\n  val res = if (h.reverse.toInt > m.toInt) out.println(h + \":\" + h.reverse)\n            else nextPalindromicTIme(h.toInt)\n\n  def nextPalindromicTIme(x: Int): String = {\n    val y = (x + 1) % 24\n    val z = f\"$y%02d\".reverse.toInt\n    if (z < 60) f\"$y%02d:$z%02d\"\n    else (nextPalindromicTIme(x + 1))\n  }\n\n  out.println(res)\n  out.close\n}\n\n\n\n\n\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport java.util.Arrays.binarySearch\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.collection.mutable.ArrayBuffer\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\n\nobject P108A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val List(h, m) = sc.nextLine.split(\":\").toList\n\n  if (h.reverse.toInt >= m.toInt) out.println(h + \":\" + h.reverse)\n  else nextPalindromicTIme(h.toInt)\n\n  def nextPalindromicTIme(x: Int): String = {\n    val y = (x + 1) % 24\n    val z = f\"$y%02d\".reverse.toInt\n    if (z < 60) f\"$y%02d:$z%02d\"\n    else (nextPalindromicTIme(x + 1))\n  }\n\n out.close\n}\n\n\n\n\n\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport java.util.Arrays.binarySearch\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.collection.mutable.ArrayBuffer\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\n\nobject P108A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val List(h, m) = sc.nextLine.split(\":\").toList\n\n  if (h.reverse.toInt > m.toInt) out.println(h + \":\" + h.reverse)\n  else nextPalindromicTIme(h.toInt)\n\n  def nextPalindromicTIme(x: Int): String = {\n    val y = (x + 1) % 24\n    val z = f\"$y%02d\".reverse.toInt\n    if (z < 60) f\"$y%02d:$z%02d\"\n    else (nextPalindromicTIme(x + 1))\n  }\n\n out.close\n}\n\n\n\n\n\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport java.util.Arrays.binarySearch\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.collection.mutable.ArrayBuffer\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\n\nobject P108A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val List(h, m) = sc.nextLine.split(\":\").toList\n\n  val res = if (h.reverse.toInt > m.toInt) h + \":\" + h.reverse\n            else nextPalindromicTIme(h.toInt)\n\n  def nextPalindromicTIme(x: Int): String = {\n    val y = (x + 1) % 24\n    val z = f\"$y%02d\".reverse.toInt\n    if (z < 60) f\"$y%02d:$z%02d\"\n    else nextPalindromicTIme(x + 1)\n  }\n\n  out.println(res)\n  out.close\n}\n\n\n\n\n\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport java.util.Arrays.binarySearch\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.collection.mutable.ArrayBuffer\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\n\nobject P108A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val n = sc.nextLine.split(\":\")(0).toInt\n\n  def nextPalindromicTIme(x: Int): String = {\n    val y = (x + 1) % 24\n    val z = f\"$y%02d\".reverse.toInt\n    if (z < 60) f\"$y%02d:$z%02d\"\n    else (nextPalindromicTIme(x + 1))\n  }\n\n  out.println(nextPalindromicTIme(n))\n  out.close\n}\n\n\n\n\n\n"}], "src_uid": "158eae916daa3e0162d4eac0426fa87f"}
{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val n = in.next().toInt\n  println(s\"$n 0 0\")\n}\n", "positive_code": [{"source_code": "import java.util.Scanner\n\nobject Main {\n\n\tdef main(args: Array[String]): Unit = {\n\t\tval scanner = new Scanner (System.in)\n\t\tval n = scanner nextInt ()\n\t\tprint (\"0 0 \")\n\t\tprintln (n)\n\t}\n\n}\n"}, {"source_code": "object A199 {\n\n  import IO._\n  import collection.{mutable => cu}\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readLongs(1)\n    println(s\"0 0 $n\")\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P199A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val N = sc.nextInt\n\n  def solve(): List[Int] = {\n\n    @tailrec\n    def loop(a: Int, b: Int, c: Int, d: Int, x: Int): List[Int] = {\n      if (x == N) List(a, b, d)\n      else loop(b, c, d, x, d + x)\n    }\n\n    N match {\n      case 0 => List(0, 0, 0)\n      case 1 => List(0, 0, 1)\n      case 2 => List(0, 1, 1)\n      case _ => loop(0, 1, 1, 2, 3)\n    }\n  }\n\n  out.println(solve.mkString(\" \"))\n  out.close\n}\n"}, {"source_code": "\nimport java.util\n\nimport scala.annotation.tailrec\n\n/**\n * @author pvasilyev\n * @since 16 Jun 2016\n */\nobject A199 extends App {\n\n  @tailrec\n  // fibs[from] <= f\n  def binarySearch(fibs: util.ArrayList[Int], f: Int, from: Int, to: Int): Int = {\n    if (to - from < 2) {\n      from\n    } else {\n      val mid: Int = (from + to) / 2\n      if (fibs.get(mid) <= f) {\n        binarySearch(fibs, f, mid, to)\n      } else {\n        binarySearch(fibs, f, from, mid)\n      }\n    }\n  }\n\n  def solve() = {\n    val f: Int = scala.io.StdIn.readInt()\n    if (f == 0) {\n      println(\"0 0 0\")\n    } else if (f == 1) {\n      println(\"0 0 1\")\n    } else {\n      val fibs = new util.ArrayList[Int]()\n      fibs.add(0)\n      fibs.add(1)\n      var k = 2\n      while (fibs.get(k - 1) + fibs.get(k - 2) < 1000000000) {\n        fibs.add(fibs.get(k - 1) + fibs.get(k - 2))\n        k += 1\n      }\n      val i: Int = binarySearch(fibs, f, 0, fibs.size())\n      println(\"0 \" + fibs.get(i-2) + \" \" + fibs.get(i-1))\n    }\n  }\n\n  solve()\n\n}\n"}, {"source_code": "import java.io._\nimport java.util.Locale\nimport scala.annotation.tailrec\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInt = reader.readLine().toInt\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n  def readLongs = reader.readLine().split(\" \").map(_.toLong)\n  def readLine = reader.readLine\n\n  def ans = Array(0, 0, readInt).mkString(\" \")\n\n  def main(a: Array[String]) {\n    println(ans)\n  }\n}\n"}, {"source_code": "object Main {\n  val fib: Stream[Int] = {\n    def fibf(a: Int, b: Int): Stream[Int] = {\n      a #:: fibf(b, a + b)\n    }\n    fibf(0, 1)\n  }\n\n  def main(args: Array[String]) = {\n    val n = readLine()\n    val i = fib.takeWhile(_ < 1000000000).indexOf(n)\n    if (i <= 3) println(\"0 0 \" + n) \n    else println(fib(i - 4) + \" \" + fib(i - 3) + \" \" + fib(i - 1))\n  }\n}"}, {"source_code": "object Solution extends App{\n    \n    val in = scala.io.Source.stdin.getLines()\n    val n = in.next().toInt\n    println(s\"$n 0 0\")\n}"}], "negative_code": [{"source_code": "object A199 {\n\n  import IO._\n  import collection.{mutable => cu}\n  def generateFib(till: Long): Array[Long] = {\n    var num1 = 1L\n    var num2 = 2L\n    var res = Array(1L, 2L)\n    while(num2 <= till) {\n      val temp = num1 + num2\n      num1 = num2\n      num2 = temp\n      res ++= Array(num2)\n    }\n    res\n  }\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readLongs(1)\n    val fibs = generateFib(1000000000L)\n    var break = false\n    for(i <- fibs; j <- fibs; k <- fibs if !break) {\n      if(i+j+k == n) {\n        println(s\"$i $j $k\")\n        break = true\n      }\n    }\n    if(!break)\n      println(\"I'm too stupid to solve this problem\")\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}], "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1"}
{"source_code": "object Main extends App with fastIO{\n  val s = readLine\n  val st = \"CODEFORCES\"\n  var bo = false\n  //if(s.contains(st)) bo = true\n  for(a <- 0 until s.length; b <- a to s.length){\n    if(s.substring(0,a)++s.substring(b,s.length)==st) bo = true\n  }\n  println(if(bo)\"YES\" else \"NO\")\n  flush\n}\n\ntrait fastIO {\n  import java.io._\n  val isFile = false\n  val input = \"file.in\"\n  val output = \"file.out\"\n  val bf = new BufferedReader(if(isFile) new FileReader(input) else new InputStreamReader(System.in))\n  val in = new StreamTokenizer(bf)\n  val out = new PrintWriter(if(isFile)new FileWriter(output) else new OutputStreamWriter(System.out))\n\n  def next: String = {\n    in.ordinaryChars('0', '9')\n    in.wordChars('0', '9')\n    in.nextToken()\n    in.sval\n  }\n  def nextInt: Int = {\n    in.nextToken()\n    in.nval.toInt\n  }\n  def nextLong:Long ={\n    in.nextToken()\n    in.nval.toLong\n  }\n  def nextDouble: Double = {\n    in.nextToken()\n    in.nval\n  }\n  def readLine: String = bf.readLine()\n  def println(o:Any) = out.println(o)\n  def print(o:Any) = out.print(o)\n  def printf(s:String,o:Any*) = out.printf(s,o)\n  def flush() = out.flush()\n}", "positive_code": [{"source_code": "import scala.io.StdIn._\n\nobject A_CuttingBanner extends App {\n  val banner = readLine()\n  val Code = \"CODEFORCES\"\n\n  private def isPossible: Boolean = {\n    if (banner.length > Code.length) {\n      val sizeToCut = banner.length - Code.length\n      for {\n        left <- 0 to banner.length\n      } {\n        val L = banner.take(left)\n        val R = banner.drop(left + sizeToCut)\n//        println(L + \"|\" + R)\n        if (L + R == Code) return true\n      }\n    }\n\n    false\n  }\n\n  println(if (isPossible) \"YES\" else \"NO\")\n}\n"}, {"source_code": "import java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  def solve: Int = {\n    val banner = next\n    val n = banner.length\n    for (i <- 0 until n) {\n      for (j <- i - 1 until n) {\n        if ((banner.substring(0, i) + banner.substring(j + 1)).equalsIgnoreCase(\"codeforces\")) {\n          out.println(\"YES\")\n          return 0\n        }\n      }\n    }\n    out.println(\"NO\")\n    return 0\n  }\n}\n"}, {"source_code": "import scala.io.Source\n\nobject A extends App {\n  val str = Source.stdin.getLines().next()\n  val a = (0 until str.length).exists(s => (s to str.length).exists(e => str.substring(0, s) + str.substring(e) == \"CODEFORCES\"))\n  println(if (a) \"YES\" else \"NO\")\n}\n"}, {"source_code": "import scala.collection._\n\nobject A extends App {\n  \n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val a = readLine\n  val b = \"CODEFORCES\"\n  var canCut = true\n  var hasCut = false\n  var ok = true\n  \n  var i = 0\n  while (i < a.length && i < b.length && a(i) == b(i)) {\n    i += 1\n  }\n  \n  var j = 0\n  while (j < a.length && j < b.length && a(a.length - j - 1) == b(b.length - j - 1)) {\n    j += 1\n  }\n//println(i, j)\n  println(if (i == b.length || j == b.length || i + j >= b.length) \"YES\" else \"NO\")\n}\n"}], "negative_code": [{"source_code": "object Main extends App with fastIO{\n  val s = readLine\n  val st = \"CODEFORCES\"\n  var bo = false\n  if(s.contains(st)) bo = true\n  else for(a <- 0 until s.length; b <- a until s.length){\n    if(s.substring(0,a)++s.substring(b,s.length)==st) bo = true\n  }\n  println(if(bo)\"YES\" else \"NO\")\n  flush\n}\n\ntrait fastIO {\n  import java.io._\n  val isFile = false\n  val input = \"file.in\"\n  val output = \"file.out\"\n  val bf = new BufferedReader(if(isFile) new FileReader(input) else new InputStreamReader(System.in))\n  val in = new StreamTokenizer(bf)\n  val out = new PrintWriter(if(isFile)new FileWriter(output) else new OutputStreamWriter(System.out))\n\n  def next: String = {\n    in.ordinaryChars('0', '9')\n    in.wordChars('0', '9')\n    in.nextToken()\n    in.sval\n  }\n  def nextInt: Int = {\n    in.nextToken()\n    in.nval.toInt\n  }\n  def nextLong:Long ={\n    in.nextToken()\n    in.nval.toLong\n  }\n  def nextDouble: Double = {\n    in.nextToken()\n    in.nval\n  }\n  def readLine: String = bf.readLine()\n  def println(o:Any) = out.println(o)\n  def print(o:Any) = out.print(o)\n  def printf(s:String,o:Any*) = out.printf(s,o)\n  def flush() = out.flush()\n}"}, {"source_code": "\nobject Main extends App with fastIO{\n  val s = readLine\n  val st = \"CODEFORCES\"\n  var bo = false\n  //if(s.contains(st)) bo = true\n  for(a <- 0 until s.length; b <- a until s.length){\n    if(s.substring(0,a)++s.substring(b,s.length)==st) bo = true\n  }\n  println(if(bo)\"YES\" else \"NO\")\n  flush\n}\n\ntrait fastIO {\n  import java.io._\n  val isFile = false\n  val input = \"file.in\"\n  val output = \"file.out\"\n  val bf = new BufferedReader(if(isFile) new FileReader(input) else new InputStreamReader(System.in))\n  val in = new StreamTokenizer(bf)\n  val out = new PrintWriter(if(isFile)new FileWriter(output) else new OutputStreamWriter(System.out))\n\n  def next: String = {\n    in.ordinaryChars('0', '9')\n    in.wordChars('0', '9')\n    in.nextToken()\n    in.sval\n  }\n  def nextInt: Int = {\n    in.nextToken()\n    in.nval.toInt\n  }\n  def nextLong:Long ={\n    in.nextToken()\n    in.nval.toLong\n  }\n  def nextDouble: Double = {\n    in.nextToken()\n    in.nval\n  }\n  def readLine: String = bf.readLine()\n  def println(o:Any) = out.println(o)\n  def print(o:Any) = out.print(o)\n  def printf(s:String,o:Any*) = out.printf(s,o)\n  def flush() = out.flush()\n}"}, {"source_code": "import scala.collection._\n\nobject A extends App {\n  \n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val a = readLine\n  val b = \"CODEFORCES\"\n  var canCut = true\n  var hasCut = false\n  var ok = true\n  \n  var i = 0\n  while (i < a.length && i < b.length && a(i) == b(i)) {\n    i += 1\n  }\n  \n  var j = 0\n  while (j < a.length && j < b.length && a(a.length - j - 1) == b(b.length - j - 1)) {\n    j += 1\n  }\n//println(i, j)\n  println(if (i == b.length || j == b.length || i + j == b.length) \"YES\" else \"NO\")\n}\n"}, {"source_code": "import scala.collection._\n\nobject A extends App {\n  \n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val a = readLine\n  val b = \"CODEFORCES\"\n  var canCut = true\n  var hasCut = false\n  var ok = true\n  \n  var i = 0\n  while (i < a.length && i < b.length && a(i) == b(i)) {\n    i += 1\n  }\n  \n  var j = 0\n  while (j < a.length && j < b.length && a(a.length - j - 1) == b(b.length - j - 1)) {\n    j += 1\n  }\n//println(i, j)\n  println(if (a == b || (i + j == b.length && (i > 0 || j > 0))) \"YES\" else \"NO\")\n}\n"}, {"source_code": "import java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  def solve: Int = {\n    val banner = next\n    val n = banner.length\n    for (i <- 0 until n) {\n      for (j <- i + 1 until n) {\n        if ((banner.substring(0, i) + banner.substring(j)).equalsIgnoreCase(\"codeforces\")) {\n          out.println(\"YES\")\n          return 0\n        }\n      }\n    }\n    out.println(\"NO\")\n    return 0\n  }\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject A_CuttingBanner extends App {\n  val banner = readLine()\n  val Code = \"CODEFORCES\"\n\n  private def isPossible: Boolean = {\n    if (banner.length > Code.length) {\n      val sizeToCut = banner.length - Code.length\n      for {\n        left <- 0 to (banner.length - Code.length)\n      } {\n        val L = banner.take(left)\n        val R = banner.drop(left + banner.length - Code.length)\n        if (L + R == Code) return true\n      }\n    }\n\n    false\n  }\n\n  println(if (isPossible) \"YES\" else \"NO\")\n}\n"}], "src_uid": "bda4b15827c94b526643dfefc4bc36e7"}
{"source_code": "object A676 {\n\n  import IO._\n\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    val in = readInts(n)\n    val idx1 = in.indexOf(1)\n    val idxN = in.indexOf(n)\n    var max = math.abs(idxN - idx1)\n    for(i <- 0 until n if i != idxN) {\n      max = math.max(max, math.abs(idxN - i))\n    }\n    for(i <- 0 until n if i != idx1) {\n      max = math.max(max, math.abs(idx1 - i))\n    }\n    println(max)\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n", "positive_code": [{"source_code": "object Solution extends App {\n  val lines = io.Source.stdin.getLines()\n  lines.next()\n  val data = lines.next().split(' ').map(_.toInt)\n  if (data.head == 1 || data.last == 1 || data.last == data.length || data.last == data.length) {\n    println(data.length - 1)\n  } else {\n    val indexOne = data.indexOf(1) + 1\n    val indexN = data.indexOf(data.length) + 1\n    var first = Math.max(indexOne - 1, indexN - 1)\n    var last = Math.max(data.length - indexOne, data.length - indexN)\n    println(Math.max(first, last))\n  }\n\n}\n"}, {"source_code": "import io.StdIn._\nimport scala.math._\n\nobject Permutation extends App {\n  val n = readInt()\n  val arr = readLine().split(\" \").map(_.toInt)\n\n  val pos1 = arr.indexOf(1)\n  val posMax = arr.indexOf(n)\n  val diff = abs(pos1-posMax)\n\n  if(diff == n){\n    println(n-1)\n  }else{\n    if(pos1>posMax){\n      if((n-1)-pos1>= posMax){\n        println((n-1)-posMax)\n      }else{\n        println(pos1)\n      }\n    }else{\n      if((n-1)-posMax>= pos1){\n        println((n-1)-pos1)\n      }else{\n        println(posMax)\n      }\n    }\n\n  }\n}"}, {"source_code": "import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._\n\nobject _676A extends CodeForcesApp {\n  override def apply(io: IO) = {\n    val a = io[Vector[Int]]\n    val n = a.length\n    val (p, q) = (a.indexOf(1) + 1, a.indexOf(n) + 1)\n    //debug(n, p, q)\n    val ans = (p - 1).abs max (n - p) max (q - 1).abs max (n - q)\n    io += ans\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\nobject Utils {\n  import scala.collection.mutable, mutable.{Map => Dict}\n  implicit class GenericExtensions[A](val a: A) extends AnyVal {\n    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a\n  }\n  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {\n    def onlyElement: A = t.head.ensuring(t.size == 1)\n    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)\n    def duplicates(implicit b: C of A): C[A] = {\n      val elems = mutable.Set.empty[A]\n      (t collect {case i if !elems.add(i) => i}).to[C]\n    }\n    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}\n    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]\n    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap\n    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)\n    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}\n    def toMutableMultiSet: Dict[A, Int] = {\n      val c = map[A] to 0\n      t.foreach(i => c(i) += 1)\n      c\n    }\n    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0\n    def prefixSum(implicit n: Numeric[A]) = t.scanLeft(n.zero) {case (acc, i) => n.plus(acc, i)}\n    def suffixSum(implicit n: Numeric[A]) = t.scanRight(n.zero) {case (i, acc) => n.plus(acc, i)}\n  }\n  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)\n  }\n  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)\n  }\n  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {\n    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t\n  }\n  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {\n    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_._1).mapValues(_._2)\n    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_._1).mapValues(_.map(_._2).to[C])\n    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]\n  }\n  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {\n    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap\n    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}\n    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m\n  }\n  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {\n    def notContains(x: A): Boolean = !(s contains x)\n    def toMutable = mutable.Set.empty[A] ++ s\n  }\n  implicit class SortedExtensions[A, C[A] <: collection.SortedSet[A]](val s: C[A]) extends AnyVal {\n    def greaterThanOrEqualTo(a: A): Option[A] = s.from(a).headOption\n    def lessThan(a: A): Option[A] = s.until(a).lastOption\n  }\n  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {\n    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}\n    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f) findWithIndex c\n  }\n  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {\n    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero\n  }\n  implicit class LongExtensions(val x: Long) extends AnyVal {\n    def bitCount: Int = java.lang.Long.bitCount(x)\n  }\n  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {\n    import Numeric.Implicits._\n    def **(i: Int): A = if (i == 0) n.one else {\n      val h = x ** (i/2)\n      if (i%2 == 0) h * h else h * h * x\n    }\n    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)\n    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf \"Greg\" whenNegative Int.MaxValue\n  }\n  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {\n    import scala.collection.immutable.NumericRange, Integral.Implicits._\n    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x\n    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(n.min(x, y), n.max(x, y), n.one)\n  }\n  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))\n  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)\n  def asc[A](implicit order: Ordering[A]): Ordering[A] = order\n  def map[K] = new {\n    def to[V](default: V): Dict[K, V] = Dict.empty[K, V] withDefaultValue default // also to(Dict.empty[K2, V])\n  }\n  def memoize[A, B](f: A => B): collection.Map[A, B] = new mutable.HashMap[A, B]() {\n    override def apply(key: A) = getOrElseUpdate(key, f(key))\n  }\n  implicit class FuzzyDouble(x: Double)(implicit eps: Double = 1e-9) {\n    def >~(y: Double) = x > y+eps\n    def >=~(y: Double) = x >= y-eps\n    def ~<(y: Double) = x < y-eps\n    def ~=<(y: Double) = x <= y+eps\n    def ~=(y: Double) = ~=<(y) && >=~(y)\n  }\n  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None\n  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)\n  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]\n  val mod: Int = (1e9 + 7).toInt\n}\n/***********************************[Scala I/O]*********************************************/\nimport Utils._, java.io._, java.util.StringTokenizer\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends PrintWriter(out, true) with Iterator[String] {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    if (tokenizers.nonEmpty) Some(tokenizers.head) else None\n  }\n\n  def apply[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def apply[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(apply).to[C]\n\n  def till(delim: String): String = tokenizer().get.nextToken(delim)\n  def tillEndOfLine(): String = till(\"\\n\\r\")\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  var separator = \" \"\n  private[this] var isNewLine = true\n\n  def +=[A](x: A)(implicit write: IO.Write[A]): this.type = {\n    write(this)(x)\n    this\n  }\n  def ++=[A: IO.Write](xs: Traversable[A]): this.type = (this += xs.size) appendNewLine xs\n\n  def appendNewLine[A: IO.Write](x: A): this.type = {\n    println()\n    this += x\n  }\n\n  override def print(obj: String) = {\n    if (isNewLine) isNewLine = false else super.print(separator)\n    super.print(obj)\n  }\n  override def println() = if (!isNewLine) {\n    super.println()\n    isNewLine = true\n  }\n  override def close() = {\n    flush()\n    in.close()\n    super.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r[C, A](r[Int]))\n    implicit val string                                       : Read[String]       = new Read(_.next())\n    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)\n    implicit val boolean                                      : Read[Boolean]      = string.map(_.toBoolean)\n    implicit val int                                          : Read[Int]          = string.map(_.toInt)\n    implicit val long                                         : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                       : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r[A], r[B]))\n    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r[A], r[B], r[C]))\n    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r[A], r[B], r[C], r[D]))\n  }\n  trait Write[-A] {\n    def apply(out: PrintWriter)(x: A): Unit\n  }\n  trait DefaultWrite {\n    implicit def any[A]: Write[A] = Write(_.toString)\n  }\n  object Write extends DefaultWrite {\n    def apply[A](f: A => String) = new Write[A] {\n      override def apply(out: PrintWriter)(x: A) = out.print(f(x))\n    }\n    implicit val boolean: Write[Boolean] = Write(b => if (b) \"YES\" else \"NO\")\n    implicit def tuple2[A, B]: Write[(A, B)] = Write {case (a, b) => s\"$a $b\"}\n    implicit def array[A]: Write[Array[A]] = Write(_ mkString \" \")\n    implicit def iterable[A](implicit write: Write[A]): Write[Traversable[A]] = new Write[Traversable[A]] {\n      override def apply(out: PrintWriter)(xs: Traversable[A]) = {\n        xs foreach write(out)\n        out.println()\n      }\n    }\n  }\n}\n\n"}], "negative_code": [{"source_code": "import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._\n\nobject _676A extends CodeForcesApp {\n  override def apply(io: IO) = {\n    val a = io[Vector[Int]]\n    val n = a.length\n    val (p, q) = (a.indexOf(1), a.indexOf(n))\n    val ans = p max (n - p) max q max (n - q)\n    io += (ans - 1)\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\nobject Utils {\n  import scala.collection.mutable, mutable.{Map => Dict}\n  implicit class GenericExtensions[A](val a: A) extends AnyVal {\n    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a\n  }\n  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {\n    def onlyElement: A = t.head.ensuring(t.size == 1)\n    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)\n    def duplicates(implicit b: C of A): C[A] = {\n      val elems = mutable.Set.empty[A]\n      (t collect {case i if !elems.add(i) => i}).to[C]\n    }\n    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}\n    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]\n    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap\n    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)\n    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}\n    def toMutableMultiSet: Dict[A, Int] = {\n      val c = map[A] to 0\n      t.foreach(i => c(i) += 1)\n      c\n    }\n    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0\n    def prefixSum(implicit n: Numeric[A]) = t.scanLeft(n.zero) {case (acc, i) => n.plus(acc, i)}\n    def suffixSum(implicit n: Numeric[A]) = t.scanRight(n.zero) {case (i, acc) => n.plus(acc, i)}\n  }\n  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)\n  }\n  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)\n  }\n  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {\n    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t\n  }\n  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {\n    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_._1).mapValues(_._2)\n    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_._1).mapValues(_.map(_._2).to[C])\n    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]\n  }\n  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {\n    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap\n    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}\n    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m\n  }\n  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {\n    def notContains(x: A): Boolean = !(s contains x)\n    def toMutable = mutable.Set.empty[A] ++ s\n  }\n  implicit class SortedExtensions[A, C[A] <: collection.SortedSet[A]](val s: C[A]) extends AnyVal {\n    def greaterThanOrEqualTo(a: A): Option[A] = s.from(a).headOption\n    def lessThan(a: A): Option[A] = s.until(a).lastOption\n  }\n  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {\n    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}\n    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f) findWithIndex c\n  }\n  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {\n    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero\n  }\n  implicit class LongExtensions(val x: Long) extends AnyVal {\n    def bitCount: Int = java.lang.Long.bitCount(x)\n  }\n  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {\n    import Numeric.Implicits._\n    def **(i: Int): A = if (i == 0) n.one else {\n      val h = x ** (i/2)\n      if (i%2 == 0) h * h else h * h * x\n    }\n    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)\n    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf \"Greg\" whenNegative Int.MaxValue\n  }\n  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {\n    import scala.collection.immutable.NumericRange, Integral.Implicits._\n    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x\n    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(n.min(x, y), n.max(x, y), n.one)\n  }\n  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))\n  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)\n  def asc[A](implicit order: Ordering[A]): Ordering[A] = order\n  def map[K] = new {\n    def to[V](default: V): Dict[K, V] = Dict.empty[K, V] withDefaultValue default // also to(Dict.empty[K2, V])\n  }\n  def memoize[A, B](f: A => B): collection.Map[A, B] = new mutable.HashMap[A, B]() {\n    override def apply(key: A) = getOrElseUpdate(key, f(key))\n  }\n  implicit class FuzzyDouble(x: Double)(implicit eps: Double = 1e-9) {\n    def >~(y: Double) = x > y+eps\n    def >=~(y: Double) = x >= y-eps\n    def ~<(y: Double) = x < y-eps\n    def ~=<(y: Double) = x <= y+eps\n    def ~=(y: Double) = ~=<(y) && >=~(y)\n  }\n  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None\n  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)\n  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]\n  val mod: Int = (1e9 + 7).toInt\n}\n/***********************************[Scala I/O]*********************************************/\nimport Utils._, java.io._, java.util.StringTokenizer\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends PrintWriter(out, true) with Iterator[String] {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    if (tokenizers.nonEmpty) Some(tokenizers.head) else None\n  }\n\n  def apply[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def apply[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(apply).to[C]\n\n  def till(delim: String): String = tokenizer().get.nextToken(delim)\n  def tillEndOfLine(): String = till(\"\\n\\r\")\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  var separator = \" \"\n  private[this] var isNewLine = true\n\n  def +=[A](x: A)(implicit write: IO.Write[A]): this.type = {\n    write(this)(x)\n    this\n  }\n  def ++=[A: IO.Write](xs: Traversable[A]): this.type = (this += xs.size) appendNewLine xs\n\n  def appendNewLine[A: IO.Write](x: A): this.type = {\n    println()\n    this += x\n  }\n\n  override def print(obj: String) = {\n    if (isNewLine) isNewLine = false else super.print(separator)\n    super.print(obj)\n  }\n  override def println() = if (!isNewLine) {\n    super.println()\n    isNewLine = true\n  }\n  override def close() = {\n    flush()\n    in.close()\n    super.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r[C, A](r[Int]))\n    implicit val string                                       : Read[String]       = new Read(_.next())\n    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)\n    implicit val boolean                                      : Read[Boolean]      = string.map(_.toBoolean)\n    implicit val int                                          : Read[Int]          = string.map(_.toInt)\n    implicit val long                                         : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                       : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r[A], r[B]))\n    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r[A], r[B], r[C]))\n    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r[A], r[B], r[C], r[D]))\n  }\n  trait Write[-A] {\n    def apply(out: PrintWriter)(x: A): Unit\n  }\n  trait DefaultWrite {\n    implicit def any[A]: Write[A] = Write(_.toString)\n  }\n  object Write extends DefaultWrite {\n    def apply[A](f: A => String) = new Write[A] {\n      override def apply(out: PrintWriter)(x: A) = out.print(f(x))\n    }\n    implicit val boolean: Write[Boolean] = Write(b => if (b) \"YES\" else \"NO\")\n    implicit def tuple2[A, B]: Write[(A, B)] = Write {case (a, b) => s\"$a $b\"}\n    implicit def array[A]: Write[Array[A]] = Write(_ mkString \" \")\n    implicit def iterable[A](implicit write: Write[A]): Write[Traversable[A]] = new Write[Traversable[A]] {\n      override def apply(out: PrintWriter)(xs: Traversable[A]) = {\n        xs foreach write(out)\n        out.println()\n      }\n    }\n  }\n}\n\n"}], "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4"}
{"source_code": "    object Main\n    {\n        def min(a:Int, b:Int, c:Int):Int = \n        {\n            var aorb = 0;\n            if (a < b)\n            {\n                aorb = a\n            }\n            else\n            {\n                aorb = b\n            }\n            \n            if (c < aorb)\n                return c;\n            return aorb;\n        }\n        def main(args:Array[String])\n        {\n            val a = readLine().split(\" \").map(i => i.toInt);\n            val n = a(0);\n            val k = a(1);\n            val l = a(2);\n            val c = a(3);\n            val d = a(4);\n            val p = a(5);\n            val nl = a(6);\n            val np = a(7);\n            \n            println(min(k * l / nl, c * d, p / np) / n);\n        }\n    }", "positive_code": [{"source_code": "import java.util.Scanner\nobject Cola {\n\n  def main(args: Array[String] ) {\n    val scanner = new Scanner(System.in)\n    val n, k, l, c, d, p, nl, np = scanner.nextInt();\n    val limes = c*d/n\n    val cola = k*l/(n*nl)\n    val salt = p/(n*np)\n    \n    println(Math.min(Math.min(limes,cola),salt))\n    \n  }\n}"}, {"source_code": "/**\n * Created by IntelliJ IDEA.\n * User: cm\n * Date: 17.02.12\n * Time: 23:06\n * To change this template use File | Settings | File Templates.\n */\n\nobject P151A extends App {\n  val Array(n, k, l, c, d, p, nl, np) = readLine().split(\" \").map(_.toInt)\n  print(List(k*l/nl,c*d,p/np).min / n)\n}\n"}, {"source_code": "import java.util.StringTokenizer\n\nobject _151A extends App {\n  var token = new StringTokenizer(\"\")\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n  val Array(n, k, l, c, d, p, nl, np) = (1 to 8).map(i => next.toInt).toArray\n  val ans = (k * l / nl) min (c * d) min (p / np)\n  println(ans / n)\n}\n"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val Array(n, k, l, c, d, p, nl, np) = in.next().split(\" \").map(_.toInt)\n  println(Math.min(c * d, Math.min((k * l) / nl, p / np)) / n)\n}\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P151A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val n, k, l, c, d, p, nl, np  = sc.nextInt\n\n  val drink = (k * l) / nl\n  val lime = c * d\n  val salt = p / np\n\n  val answer = List(drink, lime, salt).min / n\n\n  out.println(answer)\n  out.close\n}\n"}, {"source_code": "import java.io._\nimport scala.annotation.tailrec\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInt = reader.readLine().toInt\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n\n  val Array(n, k, l, c, d, p, nl, np) = readInts\n  def ans = ((k * l) / nl min c * d min p / np) / n\n\n  def main(a: Array[String]) {\n    println(ans)\n  }\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val nklcdpnlnp = readLine().split(\" \").map(_.toInt)\n    val n = nklcdpnlnp(0)\n    val k = nklcdpnlnp(1)\n    val l = nklcdpnlnp(2)\n    val c = nklcdpnlnp(3)\n    val d = nklcdpnlnp(4)\n    val p = nklcdpnlnp(5)\n    val nl = nklcdpnlnp(6)\n    val np = nklcdpnlnp(7)\n    \n    val tests = Seq(k * l / nl) ++ Seq(c * d) ++ Seq(p / np)\n    println(tests.min / n)\n  }\n}"}, {"source_code": "import java.util.Scanner\n\nobject SoftDrinking { \n  def main(args: Array[String]) { \n    val sc = new Scanner(System.in)\n    val n = sc.nextInt\n    val k = sc.nextInt\n    val l = sc.nextInt\n    val c = sc.nextInt\n    val d = sc.nextInt\n    val p = sc.nextInt\n    val nl = sc.nextInt\n    val np = sc.nextInt\n    println(List(k * l / nl, c * d, p / np).min / n)\n  }\n}\n"}], "negative_code": [{"source_code": "import java.util.StringTokenizer\n\nobject _151A extends App {\n  var token = new StringTokenizer(\"\")\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n  val Array(n, k, l, c, d, p, nl, np) = (1 to 8).map(i => next.toInt).toArray\n  val ans = (n * k / nl) min (c * d) min (p / np)\n  println(ans / n)\n}\n"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val Array(n, k, l, c, d, p, nl, np) = in.next().split(\" \").map(_.toInt)\n  println(Math.min(c * d, Math.min(n / nl, p / np)) / n)\n}\n"}], "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1"}
{"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val Array(n, p) = in.next().split(' ').map(_.toInt)\n  println((1 to n).map(_ => in.next()).reverse.tail.foldLeft((1l, p.toLong / 2)) {\n    case ((mayBuy, money), \"halfplus\") => (mayBuy * 2 + 1, money + p * mayBuy + p / 2)\n    case ((mayBuy, money), _) => (mayBuy * 2, money + p * mayBuy)\n  }._2)\n}", "positive_code": [{"source_code": "/**\n * Created by aborisenko on 21.02.16.\n */\n\nimport io.StdIn._\n\nobject Main extends App {\n  def a632 (){\n\n    val Array(n, p) = readLine().split(\" \").map(_.toInt)\n\n    var result: Long = 0\n    var nn: Long = 0\n\n    val a: Array[Int] = Array.fill[Int](n)(0)\n    for( i <- 0 to n-1)\n      if( readLine() == \"half\" )\n        a(i) = 1\n\n    for( i <- 1 to n) {\n      if (a(n-i) == 1) {\n        result += nn * p\n        nn *= 2\n      } else {\n        result += nn * p + p / 2\n        nn = nn * 2 + 1\n      }\n    }\n\n    println(result)\n  }\n\n  a632()\n}\n"}], "negative_code": [{"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val Array(n, p) = in.next().split(' ').map(_.toInt)\n  println((1 to n).map(_ => in.next()).reverse.tail.foldLeft((1, p / 2)) {\n    case ((mayBuy, money), \"halfplus\") => (mayBuy * 2 + 1, money + p * mayBuy + p / 2)\n    case ((mayBuy, money), _) => (mayBuy * 2, money + p * mayBuy)\n  }._2)\n}"}, {"source_code": "/**\n * Created by aborisenko on 21.02.16.\n */\n\nimport io.StdIn._\n\nobject Main extends App {\n  def a632 (){\n\n    val Array(n, p) = readLine().split(\" \").map(_.toInt)\n\n    var result: Long = 0\n    var nn: Long = 0\n\n    val a: Array[Int] = Array.fill[Int](n)(0)\n    for( i <- 0 to n-1)\n      if( readLine() == \"half\" )\n        a(i) = 1\n\n    for( i <- 0 to n-1) {\n      if (a(i) == 1) {\n        result += nn * p\n        nn *= 2\n      } else {\n        result += nn * p + p / 2\n        nn = nn * 2 + 1\n      }\n    }\n\n    println(result)\n  }\n\n  a632()\n}\n"}], "src_uid": "6330891dd05bb70241e2a052f5bf5a58"}
{"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val Array(a, b, c) = in.next().split(' ').map(_.toInt)\n  val r = (0 to a).find{ i =>\n    val ab = i\n    val ac = a - i\n    b - ab >= 0 && (b - ab) == (c - ac)\n  }\n  println(r.map{\n    i => s\"$i ${b - i} ${a - i}\"\n  }.getOrElse(\"Impossible\"))\n}", "positive_code": [{"source_code": "object B344 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val Array(a, b, c) = readInts(3)\n    var i = 0\n    var break = false\n    while(!break && i <= a) {\n      if(c-(a-i) >= 0 && c-a+2*i == b) {\n        println(s\"$i ${c-a+i} ${a-i}\")\n        break = true\n      }\n      i += 1\n    }\n\n    if(!break) {\n      println(\"Impossible\")\n    }\n  }\n}"}, {"source_code": "import scala.collection._\n\nobject B extends App {\n\n  def readString = Console.readLine\n  def tokenizeLine = new java.util.StringTokenizer(readString)\n  def readInts(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toInt) }\n  def readLongs(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toLong) }\n  def readBigs(n: Int) = { val t = tokenizeLine; Array.fill(n)(BigInt(t.nextToken)) }\n\n  val as = readInts(3)\n  val sort = as.zipWithIndex.sortBy(_._1)\n  \n  val d = math.abs(sort(1)._1 - sort(2)._1)\n  \n  def idx(a: Int, b: Int) = (a, b) match {\n      case (0, 1) | (1, 0) => 0\n      case (1, 2) | (2, 1) => 1\n      case (0, 2) | (2, 0) => 2\n    }\n  \n  if ((sort(0)._1 - d) % 2 == 1 || sort(0)._1 < d) {\n    println(\"Impossible\")\n  } else {\n    val dd = (sort(0)._1 - d) / 2\n    val bs = Array(dd, dd + d, sort(1)._1 - dd)\n    val cs = Array.ofDim[Int](3)\n    \n    cs(idx(sort(0)._2, sort(1)._2)) = bs(0)\n    cs(idx(sort(1)._2, sort(2)._2)) = bs(2)\n    cs(idx(sort(0)._2, sort(2)._2)) = bs(1)\n\n    println(cs.mkString(\" \"))\n  }\n\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport java.util.Arrays.binarySearch\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.collection.mutable.ArrayBuffer\nimport scala.collection.immutable.TreeSet\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\n\nobject P344B extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  def solve(): String = {\n    val A, B, C = sc.nextInt\n\n    val xyz2 = List(A + B - C, - A + B + C, A - B + C)\n\n    if (xyz2.forall { x => x >= 0 && x % 2 == 0 } ) {\n      xyz2.map(_ / 2).mkString(\" \")\n    }\n    else {\n      \"Impossible\"\n    }\n  }\n  \n  out.println(solve)\n  out.close\n}\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val a = readLine().split(\" \").map(_.toInt)\n    val s = a.map(_ => 0)\n    \n    s(0) = (a(0) + a(1) - a(2)) / 2\n    s(1) = (a(1) + a(2) - a(0)) / 2\n    s(2) = (a(2) + a(0) - a(1)) / 2\n    \n    if (s.min < 0 || a.sum % 2 != 0) println(\"Impossible\")\n    else println(s.mkString(\" \"))\n  }\n}"}], "negative_code": [{"source_code": "object B344 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val Array(a, b, c) = readInts(3)\n    var i = 0\n    var break = true\n    while(break && i <= a) {\n      if(c-(a-i) > 0 && c-a+2*i > 0 && c-a+2*i == b) {\n        println(s\"$i ${c-(a-i)} ${a-i}\")\n        break = false\n      }\n      i += 1\n    }\n\n    if(break) {\n      println(\"Impossible\")\n    }\n  }\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val a = readLine().split(\" \").map(_.toInt)\n    val s = a.map(_ => 0)\n    s(0) = (a(0) + a(1) - a(2)) / 2\n    s(1) = (a(1) + a(2) - a(0)) / 2\n    s(2) = (a(2) + a(0) - a(1)) / 2\n    \n    if (s.min < 0) println(\"Impossible\")\n    else println(s.mkString(\" \"))\n  }\n}"}], "src_uid": "b3b986fddc3770fed64b878fa42ab1bc"}
{"source_code": "\n/**\n  * Created by ruslan on 3/29/17.\n  */\nobject ProblemA extends App {\n    import java.io.{BufferedReader, IOException, InputStreamReader, PrintWriter}\nimport java.util.StringTokenizer\n\n  val in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)))\n  val out = new PrintWriter(System.out)\n\n  class FastScanner(val in: BufferedReader) {\n    var st: StringTokenizer = _;\n\n    def nextToken(): String = {\n      while (st == null || !st.hasMoreTokens()) {\n        st = new StringTokenizer(in.readLine);\n      }\n      return st.nextToken();\n    }\n\n    def nextInt(): Integer = {\n      Integer.parseInt(nextToken());\n    }\n\n    def nextLong(): Long = {\n      nextToken().toLong;\n    }\n\n    def nextDouble(): Double = {\n      nextToken().toDouble;\n    }\n  }\n\n  val n = in.nextInt()\n  val m = in.nextInt()\n\n  val k = in.nextInt()\n\n  var res = n + 1\n\n  for (i <- 1 to n) {\n    val emount = in.nextInt()\n    if (emount != 0 && emount <= k && Math.abs(i - m) < res) {\n      res = Math.abs(i - m)\n    }\n  }\n\n  println(res * 10)\n\n}\n", "positive_code": [{"source_code": "import scala.io.Source\nimport scala.math._\n\nobject a12 {\n  def main(args: Array[String]): Unit = {\n    val lines = Source.stdin.getLines().take(2).map(_.split(' ').map(_.toInt)).toArray\n    val Array(n,kk,l) = lines(0)\n    val k = kk-1\n    val (bb,cc) = lines(1).zipWithIndex.splitAt(k)\n    val (b,c) = (bb.filter(_._1!=0).reverse.dropWhile(_._1 > l).headOption,\n                 cc.tail.filter( _._1!=0).dropWhile(_._1 > l).headOption)\n    println(\n      (b,c) match {\n        case (Some(a), Some(b)) => min(k-a._2, b._2-k)*10\n        case (Some(d),None) => (k - d._2)*10\n        case (None, Some(d)) => (d._2 - k)*10\n        case (None,None) => -1\n       }\n    )\n  }\n}\n"}, {"source_code": "//package com.obarros.hackerrank.codechallenges.daysofcode.codeforces.Round_408\n\n\nobject ProblemA {\n  def main(args: Array[String]): Unit = {\n    val input = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    val n = input(0)\n    val m = input(1)\n    val k = input(2)\n    val houses = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    System.out.println(solution(n, m, k, houses))\n  }\n\n  def solution(n: Int, m: Int, k: Int, houses: Array[Int]): Int = {\n\n    var result = Int.MaxValue\n    for (i <- houses.indices) {\n      if (houses(i) != 0 && houses(i) <= k)\n        result = math.min(result, 10*math.abs(m -1 - i))\n    }\n    result\n  }\n}\n\n"}], "negative_code": [{"source_code": "import scala.io.Source\nimport scala.math._\n\nobject a12 {\n  def main(args: Array[String]): Unit = {\n    val lines = Source.stdin.getLines().take(2).map(_.split(' ').map(_.toInt)).toArray\n    val Array(n,k,l) = lines(0)\n    val (bb,cc) = lines(1).zipWithIndex.splitAt(k-1)\n    val (b,c) = (bb.filter(_._1!=0).reverse.dropWhile(_._1 > l).headOption,\n                 cc.tail.filter( _._1!=0).dropWhile(_._1 > l).headOption)\n    println(\n      (b,c) match {\n        case (Some(a), Some(b)) => min(k-a._2, b._2-k)*10\n        case (Some(d),None) => (k-1 - d._2)*10\n        case (None, Some(d)) => (d._2 - k+1)*10\n        case (None,None) => -1\n       }\n    )\n  }\n}\n"}, {"source_code": "//package com.obarros.hackerrank.codechallenges.daysofcode.codeforces.Round_408\n\n\nobject ProblemA {\n  def main(args: Array[String]): Unit = {\n    val input = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    val m = input(0)\n    val n = input(1)\n    val k = input(2)\n    val houses = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    var cond: Array[Int] = Array[Int]()\n    var res: Array[Int] = Array[Int]()\n\n    for (i <- houses.indices) {\n      if (houses(i) <= k && i != n && i != 0)\n        cond :+= 1\n      else\n        cond :+= 0\n    }\n\n    for (j <- houses.indices) {\n      res :+= cond(j) * (j + 1) * 10\n    }\n\n    val reset = n * 10\n    val result = {\n      res.filter(x => x != 0).map(x => math.abs(x - reset)).min\n    }\n\n\n    System.out.println(result)\n  }\n\n}"}, {"source_code": "//package com.obarros.hackerrank.codechallenges.daysofcode.codeforces.Round_408\n\n\nobject ProblemA {\n  def main(args: Array[String]): Unit = {\n    val input = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    val m = input(0)\n    val n = input(1)\n    val k = input(2)\n    val houses = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    var cond: Array[Int] = Array[Int]()\n    var res: Array[Int] = Array[Int]()\n\n    for (i <- houses.indices) {\n      if (houses(i) <= k && i != n && i != 0)\n        cond :+= 1\n      else\n        cond :+= 0\n    }\n\n    for (j <- houses.indices) {\n      res :+= cond(j) * (j + 1) * 10\n    }\n\n    val reset = n * 10\n    val result = {\n      res.map(x => x - reset).filter(x => x != 0).map(x => math.abs(x)).min\n    }\n\n\n    System.out.println(result)\n  }\n\n}"}, {"source_code": "//package com.obarros.hackerrank.codechallenges.daysofcode.codeforces.Round_408\n\n\nobject ProblemA {\n  def main(args: Array[String]): Unit = {\n    val input = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    val m = input(0)\n    val n = input(1)\n    val k = input(2)\n    val houses = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    var cond: Array[Int] = Array[Int]()\n    var res: Array[Int] = Array[Int]()\n\n    for (i <- houses.indices) {\n      if (houses(i) <= k && i != n && houses(i) != 0)\n        cond :+= 1\n      else\n        cond :+= 0\n    }\n\n    for (j <- houses.indices) {\n      res :+= cond(j) * (j + 1) * 10\n    }\n\n//    System.out.println(\"cond: \")\n//    cond.foreach(x => print(x + \" \"))\n//    System.out.println()\n//    System.out.println(\"res: \")\n//    res.foreach(x => print(x + \" \"))\n//    System.out.println()\n\n    val reset = n * 10\n    val result = {\n      res.filter(x => x != 0 ).map(x => math.abs(x - reset)).filter(x => x != 0 ).min\n    }\n\n\n    System.out.println(result)\n  }\n\n}"}, {"source_code": "//package Round_408\n\n/**\n  * Created by OMVB on 10/04/2017.\n  */\nobject Problem_A {\n  def main(args: Array[String]): Unit = {\n    val input = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    val m = input(0)\n    val n = input(1)\n    val k = input(2)\n    val houses = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    var cond: Array[Int] = Array[Int]()\n    var res: Array[Int] = Array[Int]()\n\n    for (i <- houses.indices) {\n      if (houses(i) <= k && i != n && i != 0)\n        cond :+= 1\n      else\n        cond :+= 0\n    }\n\n    for (j <- houses.indices) {\n      res :+= cond(j) * (j + 1) * 10\n    }\n\n    val reset = n * 10\n    val result = {\n      res.map(x => x - reset).filter(x => x > 0 && x != 0 && x != m).min\n    }\n\n    System.out.println(result)\n  }\n\n}\n"}], "src_uid": "57860e9a5342a29257ce506063d37624"}
{"source_code": "object _1141A extends CodeForcesApp {\n  import annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._, Math._\n\n  override def apply(io: IO): io.type = {\n    val n, m = io.read[Int]\n    val ans = if (m%n == 0) {\n      var r = m/n\n      var c = 0\n      while(r%3 == 0) {\n        r /= 3\n        c += 1\n      }\n      while(r%2 == 0) {\n        r /= 2\n        c += 1\n      }\n      if (r == 1) Some(c) else None\n    } else {\n      None\n    }\n    \n    io.write(ans.getOrElse(-1))\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\n/***********************************[Scala I/O]*********************************************/\nimport java.io._, java.util.StringTokenizer\nimport scala.collection.generic.CanBuild\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    tokenizers.headOption\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: CanBuild[A, C[A]]): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  def readAll[A: IO.Read]: (Int, Vector[A]) = {\n    val data = read[Vector[A]]\n    (data.length, data)\n  }\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any): this.type = {\n    printer.print(obj)\n    this\n  }\n  def writeLine(): this.type = {\n    printer.println()\n    this\n  }\n  def writeLine(obj: Any): this.type = {\n    printer.println(obj)\n    this\n  }\n  def writeLines(obj: Traversable[Any]): this.type = writeAll(obj, separator = \"\\n\")\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n  def query[A: IO.Read](question: Any): A = writeLine(question).read\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: CanBuild[A, C[A]]) : Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                                   : Read[String]       = new Read(_.next())\n    implicit val int                                                      : Read[Int]          = string.map(_.toInt)\n    implicit val long                                                     : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                                   : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                                   : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                               : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                                 : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                                  : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n", "positive_code": [{"source_code": "object Main {\n  def main(args: Array[String]): Unit = {\n    val s = new Main()\n    s.solve()\n    s.out.flush()\n  }\n}\n\nclass Main {\n  import java.io._\n  import java.util.StringTokenizer\n\n  import scala.collection.mutable\n  import scala.util.Sorting\n  import math.{abs, max, min}\n  import mutable.{ArrayBuffer, ListBuffer}\n  import scala.reflect.ClassTag\n\n  val MOD = 1000000007\n  val out = new PrintWriter(System.out)\n\n  def solve(): Unit = {\n    val N, M = ni()\n    REP(30) { two =>\n      REP(18) { three =>\n        val a = math.round(math.pow(2, two))\n        val b = math.round(math.pow(3, three))\n        debug(s\"$a $b\")\n        if (M % a == 0 && M % b == 0 && M / a / b == N) {\n          out.println(s\"${two + three}\")\n          return\n        }\n      }\n    }\n\n    out.println(-1)\n  }\n\n  private val oj = System.getenv(\"ATCODER_DEBUG\") == null\n\n  def DEBUG(f: => Unit): Unit = {\n    if (!oj){ f }\n  }\n\n  def debug(as: Array[Boolean]): Unit = DEBUG {\n    debug(as.map(x => if(x) \"1\" else \"0\").mkString)\n  }\n\n  def debug(as: Array[Int]): Unit = DEBUG {\n    debug(as.mkString(\" \"))\n  }\n\n  def debug(as: Array[Long]): Unit = DEBUG {\n    debug(as.mkString(\" \"))\n  }\n\n  def debug(s: => String): Unit = DEBUG {\n    System.err.println(s)\n  }\n\n  def debugL(num: => Long): Unit = DEBUG {\n    System.err.println(num)\n  }\n\n  class InputReader(val stream: InputStream) {\n    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)\n    private var tokenizer: StringTokenizer = _\n\n    def next(): String = {\n      while (tokenizer == null || !tokenizer.hasMoreTokens)\n        tokenizer = new StringTokenizer(reader.readLine)\n      tokenizer.nextToken\n    }\n\n    def nextInt(): Int = next().toInt\n    def nextLong(): Long = next().toLong\n    def nextChar(): Char = next().charAt(0)\n  }\n  val sc = new InputReader(System.in)\n  def ni(): Int = sc.nextInt()\n  def nl(): Long = sc.nextLong()\n  def nc(): Char = sc.nextChar()\n  def ns(): String = sc.next()\n  def ns(n: Int): Array[Char] = ns().toCharArray\n  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)\n  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {\n    val A1, A2 = Array.ofDim[Int](n)\n    REP(n) { i =>\n      A1(i) = ni() + offset\n      A2(i) = ni() + offset\n    }\n    (A1, A2)\n  }\n  def nm(n: Int, m: Int): Array[Array[Int]] = {\n    val A = Array.ofDim[Int](n, m)\n    REP(n) { i =>\n      REP(m) { j =>\n        A(i)(j) = ni()\n      }\n    }\n    A\n  }\n  def nal(n: Int): Array[Long] = map(n)(_ => nl())\n  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))\n  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = offset\n    val N = n + offset\n    while(i < N) { f(i); i += 1 }\n  }\n  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {\n    var i = n - 1 + offset\n    while(i >= offset) { f(i); i -= 1 }\n  }\n  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {\n    REP(to - from + 1, from) { i =>\n      f(i)\n    }\n  }\n\n  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {\n    val res = Array.ofDim[A](n)\n    REP(n)(i => res(i) = f(i + offset))\n    res\n  }\n\n\n  def sumL(as: Array[Int]): Long = {\n    var s = 0L\n    REP(as.length)(i => s += as(i))\n    s\n  }\n\n  def cumSum(as: Array[Int]) = {\n    val cum = Array.ofDim[Long](as.length + 1)\n    REP(as.length) { i =>\n      cum(i + 1) = cum(i) + as(i)\n    }\n    cum\n  }\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject Main {\n\n  def main(args: Array[String]): Unit = {\n    val sc  = new Scanner(System.in)\n    val n = sc.nextInt()\n    val m = sc.nextInt()\n    if(n == m)\n      println(0)\n\n    else if(n % 2 == 0 && m % 2 == 1)\n      println(-1)\n\n    else if(m % n == 0){\n      var division = m / n\n      var res = 0;\n      while(division % 3 == 0){\n        division = division / 3\n        res += 1\n      }\n      while (division % 2 == 0){\n        division = division / 2\n        res += 1\n      }\n      if(division == 1)\n        println(res)\n      else\n        println(-1)\n    }\n    else\n      println(-1)\n  }\n}\n"}, {"source_code": "object Competitive extends App {\n  val Array(x,y) = readLine.split(\" \").map(_.toInt)\n  if(x==y) println(0)\n  else if(y%x!=0) println(-1)\n  else {\n    var z = y / x\n    var count = 0\n    var stat = 1\n    while(z>1) {\n      if(z%2!=0 && z%3!=0) {\n        stat = 0\n        z = 1\n      }\n      else {\n        if(z%2==0) z/=2\n        else if(z%3==0) z/=3\n        count+=1\n      }\n    }\n    if(stat==0) println(-1)\n    else println(count)\n  }\n\n}\n"}, {"source_code": "\nimport scala.annotation.tailrec\n\nobject Main extends App {\n\n  val inputs = io.StdIn.readLine().split(\" \").map(x => x.toInt)\n\n  def solve(i: Int, i1: Int): Int = {\n    @tailrec\n    def solve(a: Int, acc: Int = 0): Int = {\n      if (a == 1) acc\n      else if (a == -1) -1\n      else solve(if (a % 3 == 0) a / 3 else if (a % 2 == 0) a / 2 else -1, acc + 1)\n\n    }\n\n    if (i1 % i != 0) -1\n    else solve(i1 / i)\n  }\n\n  println(solve(inputs(0), inputs(1)))\n\n\n}\n"}, {"source_code": "\nobject Main extends App {\n\n  val inputs = io.StdIn.readLine().split(\" \").map(x => x.toInt)\n\n  def solve(i: Int, i1: Int): Int = {\n    def solve(a: Int, acc: Int = 0): Int = {\n      if (a == 1) acc\n      else if (a == -1) -1\n      else solve(if (a % 3 == 0) a / 3 else if (a % 2 == 0) a / 2 else -1, acc + 1)\n\n    }\n\n    if (i1 % i != 0) -1\n    else solve(i1 / i)\n  }\n\n  println(solve(inputs(0), inputs(1)))\n\n\n}"}], "negative_code": [{"source_code": "object Main extends App {\n\n  val inputs = io.StdIn.readLine().split(\" \").map(x => x.toInt)\n\n  def solve(i: Int, i1: Int) : Int = {\n    def solve(a: Int, acc: Int = 0): Int = {\n      if (a == 1) acc\n      else solve(if (a % 3 == 0) a / 3 else a / 2, acc + 1)\n\n    }\n    if (i1 % i != 0) -1\n    else solve(i1 / i)\n  }\n\n  println(solve(inputs(0),inputs(1)))\n\n\n}\n"}, {"source_code": "object Main extends App {\n\n  val inputs = io.StdIn.readLine().split(\" \").map(x => x.toInt)\n\n  def solve(i: Int, i1: Int): Int = {\n    def solve(a: Int, acc: Int = 0): Int = {\n      if (a == 1) acc\n      else solve(if (a % 3 == 0) a / 3 else a / 2, acc + 1)\n\n    }\n\n    if (i1 % i != 0) -1\n    else if (i == i1) 0\n    else if (i1 % 2 != 0 && i1 % 3 != 0) -1\n    else solve(i1 / i)\n  }\n\n  println(solve(inputs(0), inputs(1)))\n\n\n}"}], "src_uid": "3f9980ad292185f63a80bce10705e806"}
{"source_code": "import scala.io.StdIn._ \nimport scala.util.control._\n\nobject cf697B {\n    def main (args: Array[String]) {\n        val line = readLine()\n\n        var b:Int = 0;\n        var ex_e = false\n\n        for (i <- 0 until line.length()) {\n            if (ex_e == true) {\n                b = b * 10 + line(i) - '0'\n            }\n            if (line(i) == 'e') ex_e = true\n        }\n\n        // println(b) \n        var ex_point = false\n        var buf = new StringBuilder()\n\n        var loop = new Breaks\n        loop.breakable {\n            for (i <- 0 until line.length()) {\n                if (line(i) == 'e') {\n                    if (b > 0) {\n                        while (b > 0) {\n                            buf += '0'\n                            b = b - 1\n                        }\n                        buf += '.'    \n                    }\n                    loop.break\n                }\n\n                if (ex_point == true) {\n                    if (b == 0) {\n                        buf += '.'\n                    }\n                    buf += line(i)\n                    b = b - 1\n                } else {\n                    if (line(i) == '.') {\n                        ex_point = true\n                    } else {\n                        buf += line(i)\n                    }\n                }\n            }\n        }\n        \n        var pos: Int = 0\n        // println(buf)\n        loop.breakable {\n            for (i <- 0 until buf.length()) {\n                var j = buf.length() - i - 1;\n                if (buf(j) == '.') {\n                    pos = j\n                    loop.break\n                }\n                if (buf(j) != '0') {\n                    pos = j + 1\n                    loop.break\n                }\n            }\n        }\n        // println(\"pos \" + pos) \n        var flag = false\n\n        for (i <- 0 until pos) {\n            if (flag == true) {\n                if (buf(i) == '.' && i == buf.length()-1) {\n                } else {\n                    print(buf(i))\n                }\n            } else {\n                if (buf(i) != '0') {\n                    print(buf(i))\n                    flag = true\n                } else if (buf(i + 1) == '.' ) {\n                    print(buf(i));\n                    flag = true\n                }    \n            }\n        }\n        println()        \n    }\n}", "positive_code": [{"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n  val Array(ns, es) = line.split('e')\n  val (ne, ee) = ns.split('.') match {\n    case Array(before, after) =>\n      val afterDrop = after.reverse.dropWhile(_ == '0').reverse\n      (before + afterDrop, -afterDrop.length)\n    case Array(before) => (before, 0)\n  }\n  val e = ee + es.toInt\n\n  if (e == 0)\n    println(ne)\n  else if (e < 0)\n    println(ne.take(ne.length + e) + '.' + ne.drop(ne.length + e))\n  else\n    println(ne + \"0\" * e)\n}\n"}, {"source_code": "object Solution {\n    def main(args : Array[String]) {\n        val line = readLine()\n        val r = \"^(.*)\\\\.(.*)e(.*)$\"r;\n        val r(a, d, e) = line\n        var n = a + d\n        val i = e.toInt\n        if (n.size < 1 + i) n = n + (\"0\" * (i + 1 - n.size))\n        n = n.substring(0, i + 1) +  \".\" + n.substring(i + 1);\n        println(post(n));\n    }\n    def post(s:String) :String = {\n        if (s.startsWith(\"0\") && !s.startsWith(\"0.\"))\n            post(s.substring(1))\n        else if (s.matches(\".*\\\\.0*\")) s.substring(0,s.indexOf('.'))\n        else s\n    }\n}"}], "negative_code": [{"source_code": "import scala.io.StdIn._ \nimport scala.util.control._\n\nobject cf697B {\n    def main (args: Array[String]) {\n        val line = readLine()\n\n        var b:Int = 0;\n        var ex_e = false\n\n        for (i <- 0 until line.length()) {\n            if (ex_e == true) {\n                b = b * 10 + line(i) - '0'\n            }\n            if (line(i) == 'e') ex_e = true\n        }\n\n        // println(b) \n        var ex_point = false\n        var buf = new StringBuilder()\n\n        var loop = new Breaks\n        loop.breakable {\n            for (i <- 0 until line.length()) {\n                if (line(i) == 'e') {\n                    while (b > 0) {\n                        buf += '0'\n                        b = b - 1\n                    }\n                    buf += '.'\n                    loop.break\n                }\n\n                if (ex_point == true) {\n                    if (b == 0) {\n                        buf += '.'\n                    }\n                    buf += line(i)\n                    b = b - 1\n                } else {\n                    if (line(i) == '.') {\n                        ex_point = true\n                    } else {\n                        buf += line(i)\n                    }\n                }\n            }\n        }\n        \n        var pos: Int = 0\n        // println(buf)\n        loop.breakable {\n            for (i <- 0 until buf.length()) {\n                var j = buf.length() - i - 1;\n                if (buf(j) == '.') {\n                    pos = j\n                    loop.break\n                }\n                if (buf(j) != '0') {\n                    pos = j + 1\n                    loop.break\n                }\n            }\n        }\n        // println(\"pos \" + pos) \n        var flag = false\n\n        for (i <- 0 until pos) {\n            if (flag == true) {\n                if (buf(i) == '.' && i == buf.length()-1) {\n                } else {\n                    print(buf(i))\n                }\n            } else {\n                if (buf(i) != '0') {\n                    print(buf(i))\n                    flag = true\n                } else if (buf(i + 1) == '.' ) {\n                    print(buf(i));\n                    flag = true\n                }    \n            }\n        }\n        println()        \n    }\n}"}, {"source_code": "import scala.io.StdIn._ \nimport scala.util.control._\n\nobject cf697B {\n    def main (args: Array[String]) {\n        val line = readLine()\n\n        var b:Int = 0;\n        var ex_e = false\n\n        for (i <- 0 until line.length()) {\n            if (ex_e == true) {\n                b = b * 10 + line(i) - '0'\n            }\n            if (line(i) == 'e') ex_e = true\n        }\n\n        // println(b) \n        var ex_point = false\n        var buf = new StringBuilder()\n\n        var loop = new Breaks\n        loop.breakable {\n            for (i <- 0 until line.length()) {\n                if (line(i) == 'e') {\n                    while (b > 0) {\n                        buf += '0'\n                        b = b - 1\n                    }\n                    loop.break\n                }\n\n                if (ex_point == true) {\n                    if (b == 0) {\n                        buf += '.'\n                    }\n                    buf += line(i)\n                    b = b - 1\n                } else {\n                    if (line(i) == '.') {\n                        ex_point = true\n                    } else {\n                        buf += line(i)\n                    }\n                }\n            }\n        }\n        \n        var pos: Int = 0\n        // println(buf)\n        loop.breakable {\n            for (i <- 0 until buf.length()) {\n                var j = buf.length() - i - 1;\n                if (buf(j) != '0') {\n                    pos = j\n                    loop.break;\n                }\n            }\n        }\n        // println(\"pos \" + pos) \n        var flag = false\n\n        for (i <- 0 until pos) {\n            if (flag == true) {\n                if (buf(i) == '.' && i == buf.length()-1) {\n                } else {\n                    print(buf(i))\n                }\n            } else {\n                if (buf(i) != '0') {\n                    print(buf(i))\n                    flag = true\n                } else if (buf(i + 1) == '.' ) {\n                    print(buf(i));\n                    flag = true\n                }    \n            }\n        }\n        println()\n/*\n        val loop = new Breaks;\n        loop.breakable {\n            for (i <- 0 until buf.length()) {\n                if (buf(i) == 'e') loop.break\n                print(buf(i))\n            }\n            println()\n        }\n*/\n        \n    }\n}"}, {"source_code": "import scala.io.StdIn._ \nimport scala.util.control._\n\nobject cf697B {\n    def main (args: Array[String]) {\n        val line = readLine()\n\n        var b:Int = 0;\n        var ex_e = false\n\n        for (i <- 0 until line.length()) {\n            if (ex_e == true) {\n                b = b * 10 + line(i) - '0'\n            }\n            if (line(i) == 'e') ex_e = true\n        }\n\n        // println(b) \n        var ex_point = false\n        var buf = new StringBuilder()\n\n        var loop = new Breaks\n        loop.breakable {\n            for (i <- 0 until line.length()) {\n                if (line(i) == 'e') {\n                    while (b > 0) {\n                        buf += '0'\n                        b = b - 1\n                    }\n                    loop.break\n                }\n\n                if (ex_point == true) {\n                    if (b == 0) {\n                        buf += '.'\n                    }\n                    buf += line(i)\n                    b = b - 1\n                } else {\n                    if (line(i) == '.') {\n                        ex_point = true\n                    } else {\n                        buf += line(i)\n                    }\n                }\n            }\n        }\n        \n        // println(buf)\n\n        var flag = false\n\n        for (i <- 0 until buf.length()) {\n            if (flag == true) {\n                if (buf(i) == '.' && i == buf.length()-1) {\n                } else {\n                    print(buf(i))\n                }\n            } else {\n                if (buf(i) != '0') {\n                    print(buf(i))\n                    flag = true\n                } else if (buf(i + 1) == '.' ) {\n                    print(buf(i));\n                    flag = true\n                }    \n            }\n        }\n        println()\n/*\n        val loop = new Breaks;\n        loop.breakable {\n            for (i <- 0 until buf.length()) {\n                if (buf(i) == 'e') loop.break\n                print(buf(i))\n            }\n            println()\n        }\n*/\n        \n    }\n}"}, {"source_code": "import scala.io.StdIn._ \nimport scala.util.control._\n\nobject cf697B {\n    def main (args: Array[String]) {\n        val line = readLine()\n\n        var b:Int = 0;\n        var ex_e = false\n\n        for (i <- 0 until line.length()) {\n            if (ex_e == true) {\n                b = b * 10 + line(i) - '0'\n            }\n            if (line(i) == 'e') ex_e = true\n        }\n\n        // println(b) \n        var ex_point = false\n        var buf = new StringBuilder()\n\n        var loop = new Breaks\n        loop.breakable {\n            for (i <- 0 until line.length()) {\n                if (line(i) == 'e') {\n                    while (b > 0) {\n                        buf += '0'\n                        b = b - 1\n                    }\n                    loop.break\n                }\n\n                if (ex_point == true) {\n                    if (b == 0) {\n                        buf += '.'\n                    }\n                    buf += line(i)\n                    b = b - 1\n                } else {\n                    if (line(i) == '.') {\n                        ex_point = true\n                    } else {\n                        buf += line(i)\n                    }\n                }\n            }\n        }\n        \n        var pos: Int = 0\n        // println(buf)\n        loop.breakable {\n            for (i <- 0 until buf.length()) {\n                var j = buf.length() - i - 1;\n                if (buf(j) == '.') {\n                    pos = j\n                    loop.break\n                }\n                if (buf(j) != '0') {\n                    pos = j + 1\n                    loop.break\n                }\n            }\n        }\n        // println(\"pos \" + pos) \n        var flag = false\n\n        for (i <- 0 until pos) {\n            if (flag == true) {\n                if (buf(i) == '.' && i == buf.length()-1) {\n                } else {\n                    print(buf(i))\n                }\n            } else {\n                if (buf(i) != '0') {\n                    print(buf(i))\n                    flag = true\n                } else if (buf(i + 1) == '.' ) {\n                    print(buf(i));\n                    flag = true\n                }    \n            }\n        }\n        println()        \n    }\n}"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n  val Array(ns, es) = line.split('e')\n  val n = ns.toDouble\n  val e = es.toInt\n  val ans = n * Math.pow(10, e)\n  if (ans == ans.toInt)\n    println(ans.toInt)\n  else\n    println(ans)\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n  val Array(ns, es) = line.split('e')\n  val n = ns.toDouble\n  val e = es.toInt\n  println(n * Math.pow(10, e))\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n  val Array(ns, es) = line.split('e')\n  val n = ns.filter(_ != '.')\n  val eee = ns.indexOf('.')\n  val ee = if (eee == -1) 0 else eee\n  val e = es.toInt + ee + n.reverse.takeWhile(_ == '0').length\n  val ne = n.reverse.dropWhile(_ == '0').reverse\n\n\n  if (e == ne.length)\n    println(ne)\n  else if (e < ne.length)\n    println(ne.take(e) + '.' + n.drop(e))\n  else\n    println(ne + \"0\" * (e - ne.length))\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n  val Array(ns, es) = line.split('e')\n  val (ne, ee) = ns.split('.') match {\n    case Array(before, after) =>\n      val afterDrop = after.reverse.dropWhile(_ == 0).reverse\n      (before + afterDrop, -afterDrop.length)\n    case Array(before) => (before, 0)\n  }\n  val e = ee + es.toInt\n\n  if (e == 0)\n    println(ne)\n  else if (e < ne.length)\n    println(ne.take(ne.length + e) + '.' + ne.drop(ne.length + e))\n  else\n    println(ne + \"0\" * (e - ne.length))\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n  val Array(ns, es) = line.split('e')\n  val (ne, ee) = ns.split('.') match {\n    case Array(before, after) =>\n      val afterDrop = after.reverse.dropWhile(_ == 0).reverse\n      (before + afterDrop, -afterDrop.length)\n    case Array(before) => (before, 0)\n  }\n  val e = ee + es.toInt\n\n  println(e)\n\n  if (e == 0)\n    println(ne)\n  else if (e < 0)\n    println(ne.take(ne.length + e) + '.' + ne.drop(ne.length + e))\n  else\n    println(ne + \"0\" * e)\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n  val Array(ns, es) = line.split('e')\n  val (ne, ee) = ns.split('.') match {\n    case Array(before, after) =>\n      val afterDrop = after.reverse.dropWhile(_ == 0).reverse\n      (before + afterDrop, -afterDrop.length)\n    case Array(before) => (before, 0)\n  }\n  val e = ee + es.toInt\n  if (e == ne.length)\n    println(ne)\n  else if (e < ne.length)\n    println(ne.take(ne.length + e) + '.' + ne.drop(ne.length + e))\n  else\n    println(ne + \"0\" * (e - ne.length))\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n  val Array(ns, es) = line.split('e')\n  val (ne, ee) = ns.split('.') match {\n    case Array(before, after) =>\n      val afterDrop = after.reverse.dropWhile(_ == 0).reverse\n      (before + afterDrop, -afterDrop.length)\n    case Array(before) => (before, 0)\n  }\n  val e = ee + es.toInt\n\n  println(e)\n\n  if (e == ne.length)\n    println(ne)\n  else if (e < ne.length)\n    println(ne.take(ne.length + e) + '.' + ne.drop(ne.length + e))\n  else\n    println(ne + \"0\" * (e - ne.length))\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n  val Array(ns, es) = line.split('e')\n  val n = ns.filter(_ != '.')\n  val eee = ns.indexOf('.')\n  val ee = if (eee == -1) 0 else eee\n  val e = es.toInt + ee\n  println(n.take(e) + '.' + n.drop(e))\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n  val Array(ns, es) = line.split('e')\n  val n = ns.filter(_ != '.')\n  val eee = ns.indexOf('.')\n  val ee = if (eee == -1) 0 else eee\n  val e = es.toInt - ee + n.reverse.takeWhile(_ == '0').length\n  val ne = n.reverse.dropWhile(_ == '0').reverse\n\n\n  if (e == ne.length)\n    println(ne)\n  else if (e < ne.length)\n    println(ne.take(e) + '.' + n.drop(e))\n  else\n    println(ne + \"0\" * (e - ne.length))\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n  val Array(ns, es) = line.split('e')\n  val (ne, ee) = ns.split('.') match {\n    case Array(before, after) =>\n      val afterDrop = after.reverse.dropWhile(_ == 0).reverse\n      (before + afterDrop, -afterDrop.length)\n    case Array(before) => (before, 0)\n  }\n  val e = ee + es.toInt\n\n  if (e == 0)\n    println(ne)\n  else if (e < 0)\n    println(ne.take(ne.length + e) + '.' + ne.drop(ne.length + e))\n  else\n    println(ne + \"0\" * e)\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n  val Array(ns, es) = line.split('e')\n  val (ne, ee) = ns.split('.') match {\n    case Array(before, after) =>\n      val afterDrop = after.reverse.dropWhile(_ == 0).reverse\n      (before + afterDrop, -afterDrop.length)\n    case Array(before) => (before, 0)\n  }\n  val e = ee + es.toInt\n\n  println(e)\n\n  if (e == 0)\n    println(ne)\n  else if (e < ne.length)\n    println(ne.take(ne.length + e) + '.' + ne.drop(ne.length + e))\n  else\n    println(ne + \"0\" * (e - ne.length))\n}\n"}, {"source_code": "object Solution extends App {\n  val in = io.Source.stdin.getLines()\n  val line = in.next()\n  val Array(ns, es) = line.split('e')\n  val n = ns.filter(_ != '.')\n  val eee = ns.indexOf('.')\n  val ee = if (eee == -1) 0 else eee\n  val e = es.toInt + ee + n.reverse.takeWhile(_ == '0').length\n  val ne = n.reverse.dropWhile(_ == '0').reverse\n\n\n  if (e == ne.length)\n    println(ne)\n  else if (e < ne.length)\n    println(ne.take(e) + '.' + n.drop(e))\n  else\n    println(ne + \"0\" * (e - ne.length + 1))\n}\n"}], "src_uid": "a79358099f08f3ec50c013d47d910eef"}
{"source_code": "import java.util.Scanner\n\nobject Main{\n  def main (args: Array[String]){\n    val sc = new Scanner(System.in)\n    val n = sc.nextInt()\n\n    val dp = new Array[(Int, Int)](n)\n    for(i <- 0 until n){\n      val tmp = sc.nextInt()\n      dp(i) = (tmp, i+1)\n    }\n\n   val ans = dp.sorted\n\n    for(i <- 0 until n / 2){\n      println(ans(i)._2 + \" \" + ans(n-1-i)._2)\n    }\n  }\n}\n", "positive_code": [{"source_code": "import scala.io.StdIn._\n\nobject Main extends App {\n  val n = readInt()\n  val a = readLine().split(\" \").map(_.toInt).zipWithIndex.sorted\n  val (f, s) = a.splitAt(n / 2)\n  val ans = f.zip(s.reverse)\n  for (((_, a), (_, b)) <- ans) println((a + 1) + \" \" + (b + 1))\n}"}, {"source_code": "object Solution extends App {\n  val lines = io.Source.stdin.getLines()\n  val n = lines.next().toInt\n  val data = lines.next().split(' ').map(_.toInt).zipWithIndex.sorted\n  println(data.take(n / 2).zip(data.drop(n / 2).reverse).map(a => s\"${a._1._2 + 1} ${a._2._2 + 1}\").mkString(\"\\n\"))\n}\n"}, {"source_code": "object A701 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    val input = readInts(n).zipWithIndex.sortBy(_._1)\n    for(i <- 1 to n/2) {\n      println(s\"${input(i-1)._2 + 1} ${input(n-i)._2 + 1}\")\n    }\n  }\n}"}, {"source_code": "object main {\n  def main (args: Array[String]) {\n    val n = scala.io.StdIn.readInt()\n    val input = (scala.io.StdIn.readLine().split(\" \") map (x => x.toInt)).toVector\n    val inputWithIndex = input zip (1 to n)\n    val sortedInputWithIndex = inputWithIndex.sortBy(pair => pair._1)\n    (0 until n/2) map (\n       i => println(sortedInputWithIndex(i)._2.toString + \" \" + sortedInputWithIndex(n - i - 1)._2).toString)\n  }\n}"}, {"source_code": "object A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(n) = readInts(1)\n  val xs = readInts(n).zipWithIndex.sortBy(_._1).map(_._2 + 1)\n\n  for (i <- 0 until n / 2) println(s\"${xs(i)} ${xs(n - i - 1)}\")\n}"}, {"source_code": "import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._\n\nobject _701A extends CodeForcesApp {\n  override def apply(io: IO) = {import io.{read, write, writeAll}\n    val cards = read[Vector[Int]]\n    val n = cards.length\n    val used = mutable.Set.empty[Int]\n    val sum = 2*cards.sum/n\n\n    val cz = cards.zipWithIndex\n\n    val ans = Vector.fill(n/2) {\n      val Some((c1, i1)) = cz find {case (c, i) => !used(i)}\n      used += i1\n      val Some((c2, i2)) = cz find {case (c, i) => !used(i) && c + c1 == sum}\n      used += i2\n      //debug(i1, i2, c1, c2, sum)\n      s\"${i1 + 1} ${i2 + 1}\"\n    }\n\n    writeAll(ans, \"\\n\")\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\nobject Utils {\n  import scala.collection.mutable, mutable.{Map => Dict}\n  implicit class GenericExtensions[A](val a: A) extends AnyVal {\n    def in(set: collection.Set[A]): Boolean = set(a)\n    def some: Option[A] = Some(a)\n    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a\n  }\n  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {\n    def onlyElement: A = assuming(t.size == 1)(t.head)\n    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)\n    def duplicates(implicit b: C of A): C[A] = {\n      val elems = mutable.Set.empty[A]\n      (t collect {case i if !elems.add(i) => i}).to[C]\n    }\n    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}\n    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]\n    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap\n    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)\n    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}\n    def toMutableMultiSet: Dict[A, Int] = {\n      val c = map[A] to 0\n      t.foreach(i => c(i) += 1)\n      c\n    }\n    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0\n    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)\n  }\n  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)\n  }\n  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)\n  }\n  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {\n    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t\n  }\n  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {\n    def key = p._1\n    def value = p._2\n  }\n  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {\n    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)\n    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])\n    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]\n  }\n  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {\n    def lastKeyOption: Option[K] = m.lastOption.map(_.key)\n    def firstKeyOption: Option[K] = m.headOption.map(_.key)\n    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap\n    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}\n    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m\n  }\n  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {\n    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)\n    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)\n    private def removeNode(kv: (K, V)): (K, V) = {\n      m -= kv.key\n      kv\n    }\n  }\n  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {\n    def notContains(x: A): Boolean = !(s contains x)\n    def toMutable = mutable.Set.empty[A] ++ s\n  }\n  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {\n    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)\n    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)\n    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}\n    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)\n  }\n  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {\n    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero\n    def toEnglish = if(x) \"YES\" else \"NO\"\n  }\n  implicit class IntExtensions(val x: Int) extends AnyVal {\n    import java.lang.{Integer => JInt}\n    def withHighestOneBit: Int = JInt.highestOneBit(x)\n    def withLowestOneBit: Int = JInt.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)\n    def bitCount: Int = JInt.bitCount(x)\n    def setLowestBits(n: Int): Int = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Int = x & left(n, ~0)\n    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Int = x | left(i)\n    def clearBit(i: Int): Int = x & ~left(i)\n    def toggleBit(i: Int): Int = x ^ left(i)\n    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1\n    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)\n    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)\n  }\n  implicit class LongExtensions(val x: Long) extends AnyVal {\n    import java.lang.{Long => JLong}\n    def withHighestOneBitSet: Long = JLong.highestOneBit(x)\n    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)\n    def bitCount: Int = JLong.bitCount(x)\n    def setLowestBits(n: Int): Long = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Long = x & left(n, ~0L)\n    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Long = x | left(i)\n    def clearBit(i: Int): Long = x & ~left(i)\n    def toggleBit(i: Int): Long = x ^ left(i)\n    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1\n    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)\n  }\n  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {\n    import Numeric.Implicits._\n    def **(i: Int): A = if (i == 0) n.one else {\n      val h = x ** (i/2)\n      if (i%2 == 0) h * h else h * h * x\n    }\n    def distance(y: A) = (x - y).abs()\n    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)\n    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf \"Greg\" whenNegative Int.MaxValue\n  }\n  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {\n    import scala.collection.immutable.NumericRange, Integral.Implicits._\n    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x\n    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)\n    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)\n  }\n  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))\n  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)\n  def asc[A](implicit order: Ordering[A]): Ordering[A] = order\n  def map[K] = new {\n    def to[V](default: => V): Dict[K, V] = using(_ => default)\n    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {\n      override def apply(key: K) = getOrElseUpdate(key, f(key))\n    }\n  }\n  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]\n  def memoize[A, B](f: A => B): A ==> B = map[A] using f\n  implicit class FuzzyDouble(val x: Double) extends AnyVal {\n    def  >~(y: Double) = x > y + eps\n    def >=~(y: Double) = x >= y + eps\n    def  ~<(y: Double) = y >=~ x\n    def ~=<(y: Double) = y >~ x\n    def  ~=(y: Double) = (x distance y) <= eps\n  }\n  def until(until: Int): Range = 0 until until\n  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}\n  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}\n  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None\n  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)\n  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]\n  type ==>[A, B] = collection.Map[A, B]\n  val mod: Int = (1e9 + 7).toInt\n  val eps: Double = 1e-9\n}\n/***********************************[Scala I/O]*********************************************/\nimport Utils._, java.io._, java.util.StringTokenizer\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    when(tokenizers.nonEmpty)(tokenizers.head)\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any, more: Any*): this.type = {\n    printer.print(obj)\n    more foreach {i =>\n      printer.print(' ')\n      printer.print(i)\n    }\n    this\n  }\n  def writeOnNextLine(obj: Any, more: Any*): this.type = {\n    printer.println()\n    write(obj, more: _*)\n    this\n  }\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                       : Read[String]       = new Read(_.next())\n    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)\n    implicit val int                                          : Read[Int]          = string.map(_.toInt)\n    implicit val long                                         : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                       : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                      : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n"}, {"source_code": "object main extends App {\n  import java.io.{InputStream, PrintStream}\n  import java.util.Scanner\n//  override\n  def solve(input: InputStream, output: PrintStream): Unit = {\n   val sc = new Scanner(input)\n    val n = sc.nextInt()\n    val cardsSorted = (1 to n).map(_ => sc.nextInt()).zipWithIndex.sortBy{case (v,_) => v}.toArray\n    (1 to n/2).foreach{\n      i => {\n        val (_,firstIndex) = cardsSorted(i-1)\n        val (_,secondIndex) = cardsSorted(n-i)\n        output.println((firstIndex+1)+\" \"+(secondIndex+1))\n      }\n    }\n  }\n  solve(System.in,System.out)\n}"}], "negative_code": [{"source_code": "object Solution extends App {\n  val lines = io.Source.stdin.getLines()\n  val n = lines.next().toInt\n  val data = lines.next().split(' ').map(_.toInt).zipWithIndex.sorted\n  println(data.take(n / 2).zip(data.drop(n / 2)).map(a => s\"${a._1._2 + 1} ${a._2._2 + 1}\").mkString(\"\\n\"))\n}\n"}, {"source_code": "object Solution extends App {\n  val lines = io.Source.stdin.getLines()\n  val n = lines.next().toInt\n  val data = lines.next().split(' ').map(_.toInt).sorted\n  println(data.take(n / 2).zip(data.drop(n / 2)).map(a => s\"${a._1} ${a._2}\").mkString(\"\\n\"))\n}\n"}], "src_uid": "6e5011801ceff9d76e33e0908b695132"}
{"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val n = in.next().toInt\n  val str = in.next()\n  val lU = Array.ofDim[Int](str.length)\n  val lD = Array.ofDim[Int](str.length)\n  val lR = Array.ofDim[Int](str.length)\n  val lL = Array.ofDim[Int](str.length)\n  str.indices.foreach { i =>\n    if (i != 0) {\n      lU(i) = lU(i - 1)\n      lD(i) = lD(i - 1)\n      lR(i) = lR(i - 1)\n      lL(i) = lL(i - 1)\n    }\n    if (str(i) == 'L') lL(i) += 1\n    else if (str(i) == 'U') lU(i) += 1\n    else if (str(i) == 'D') lD(i) += 1\n    else lR(i) += 1\n  }\n  println(str.indices.foldLeft(0) { case (acc, start) =>\n    (start + 1 until str.length by 2).foldLeft(acc) {\n      case (a, end) =>\n        val lCount = if (start == 0) lL(end) else lL(end) - lL(start - 1)\n        val rCount = if (start == 0) lR(end) else lR(end) - lR(start - 1)\n        val dCount = if (start == 0) lD(end) else lD(end) - lD(start - 1)\n        val uCount = if (start == 0) lU(end) else lU(end) - lU(start - 1)\n\n        if (lCount == rCount && dCount == uCount) a + 1 else a\n    }\n  })\n\n}", "positive_code": [{"source_code": "import scala.collection._\n\nobject A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  var res = 0\n  val Array(n) = readInts(1)\n  val s = readLine\n\n  for (i <- 0 until n) {\n    for (j <- i + 1 to n) {\n      val ss = s.substring(i, j)\n      if (ss.count(_ == 'L') == ss.count(_ == 'R') && ss.count(_ == 'U') == ss.count(_ == 'D')) res += 1\n    }\n  }\n\n  //FIXME Console.setOut(new java.io.BufferedOutputStream(Console.out))\n\n  println(res)\n\n  Console.flush\n}"}, {"source_code": "import io.StdIn._\n\nimport scala.collection.mutable._\n\nobject Solution {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  def main(args: Array[String]) {\n    val n = readLine().toInt\n    val s = readLine()\n\n    var res = 0\n\n    for (i <- 0 to n-1) {\n      var h = 0\n      var v = 0\n      for (j <- i to n-1) {\n        if (s(j) == 'R') v += 1\n        if (s(j) == 'L') v -= 1\n        if (s(j) == 'U') h += 1\n        if (s(j) == 'D') h -= 1\n\n        if (v == 0 && h == 0) res += 1\n      }\n    }\n\n    println(res)\n\n\n\n//    Console.withOut(new java.io.BufferedOutputStream(Console.out))\n//    println(res.mkString(\"\\n\"))\n//    Console.flush\n  }\n}"}, {"source_code": "import scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util._, control._\nimport scala.math.Ordering.Implicits._\n\nobject _626A extends CodeForcesApp {\n  override type Result = Int\n\n  override def solve(read: InputReader) = {\n    val n = read[Int]\n    val instr = read[String].toList\n    var ans = 0\n    for {\n      i <- 0 until n\n      j <- i+1 to n\n      s = instr.slice(i, j)\n      if isOkay(s)\n    } ans += 1\n    ans\n  }\n\n  @tailrec\n  def isOkay(instr: List[Char], x: Int = 0, y: Int = 0): Boolean = instr match {\n    case 'U' :: rest => isOkay(rest, x, y + 1)\n    case 'D' :: rest => isOkay(rest, x, y - 1)\n    case 'L' :: rest => isOkay(rest, x - 1, y)\n    case 'R' :: rest => isOkay(rest, x + 1, y)\n    case _ => x == 0 && y == 0\n  }\n\n  override def format(result: Result) = result.toString\n}\n/****************************[Ignore Template Below]****************************************/\nabstract class CodeForcesApp {\n  val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  type Result\n  def solve(scanner: InputReader): Result\n  def format(result: Result): String\n  def apply(scanner: InputReader): String = format(solve(scanner))\n  def main(args: Array[String]): Unit = println(apply(new InputReader(System.in)))\n}\n/*********************************[Scala Scanner]*******************************************/\nimport java.io.{BufferedReader, Reader, InputStreamReader, StringReader, InputStream}\nimport java.util.StringTokenizer\n\nclass InputReader(reader: BufferedReader) extends Iterator[String] with AutoCloseable {\n  def this(reader: Reader) = this(new BufferedReader(reader))\n  def this(inputStream: InputStream) = this(new InputStreamReader(inputStream))\n  def this(str: String) = this(new StringReader(str))\n\n  private[this] val tokenizers = Iterator.continually(reader.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n\n  @inline private[this] def tokenizer(): Option[StringTokenizer] = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    if (tokenizers.nonEmpty) Some(tokenizers.head) else None\n  }\n\n  def apply[A: Parser]: A = implicitly[Parser[A]].apply(this)\n\n  def apply[C[_], A: Parser](n: Int)(implicit cbf: Parser.Collection[C, A]): C[A] = {\n    val builder = cbf()\n    for {i <- 1 to n} builder += apply[A]\n    builder.result()\n  }\n\n  def till(delim: String): String = tokenizer().get.nextToken(delim)\n  def tillEndOfLine() = till(\"\\n\\r\")\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n  override def close() = reader.close()\n}\n\nclass Parser[A](val apply: InputReader => A) {\n  def map[B](f: A => B): Parser[B] = new Parser(apply andThen f)\n}\nobject Parser {\n  type Collection[C[_], A] = scala.collection.generic.CanBuildFrom[C[A], A, C[A]]\n  implicit def collection[C[_], A: Parser](implicit cbf: Collection[C, A])        : Parser[C[A]]                  = new Parser(r => r[C, A](r[Int]))\n  implicit val string                                                             : Parser[String]                = new Parser(_.next())\n  implicit val char                                                               : Parser[Char]                  = string.map(s => s.ensuring(_.length == 1, s\"Expected Char; found $s\").head)\n  implicit val boolean                                                            : Parser[Boolean]               = string.map(_.toBoolean)\n  implicit val int                                                                : Parser[Int]                   = string.map(_.toInt)\n  implicit val long                                                               : Parser[Long]                  = string.map(_.toLong)\n  implicit val bigInt                                                             : Parser[BigInt]                = string.map(BigInt(_))\n  implicit val double                                                             : Parser[Double]                = string.map(_.toDouble)\n  implicit val bigDecimal                                                         : Parser[BigDecimal]            = string.map(BigDecimal(_))\n  implicit def tuple2[T1: Parser, T2: Parser]                                     : Parser[(T1, T2)]              = new Parser(r => (r[T1], r[T2]))\n  implicit def tuple3[T1: Parser, T2: Parser, T3: Parser]                         : Parser[(T1, T2, T3)]          = new Parser(r => (r[T1], r[T2], r[T3]))\n  implicit def tuple4[T1: Parser, T2: Parser, T3: Parser, T4: Parser]             : Parser[(T1, T2, T3, T4)]      = new Parser(r => (r[T1], r[T2], r[T3], r[T4]))\n  implicit def tuple5[T1: Parser, T2: Parser, T3: Parser, T4: Parser, T5: Parser] : Parser[(T1, T2, T3, T4, T5)]  = new Parser(r => (r[T1], r[T2], r[T3], r[T4], r[T5]))\n}\n"}, {"source_code": "\n/**\n  * Created by octavian on 13/02/2016.\n  */\nobject Calvin {\n\n  def main(args: Array[String]) = {\n\n    //System.setIn(new FileInputStream(\"./src/calvin.in\"))\n    //System.setOut(new PrintStream(new FileOutputStream(\"./src/calvin.out\")))\n\n    val n = readInt()\n    val a: Array[Char] = readLine().toCharArray\n    var res = 0\n    for(i <- 0 until n - 1) {\n      var x = 0\n      var y = 0\n      for(j <- i until n) {\n        a(j) match {\n          case 'R' => x = x + 1\n          case 'L' => x = x - 1\n          case 'D' => y = y + 1\n          case 'U' => y = y - 1\n        }\n        if(x == 0 && y == 0) {\n          res += 1\n        }\n      }\n    }\n\n    println(res)\n\n  }\n\n}\n"}, {"source_code": "import scala.io.Source\n\nobject Main {\n  def isOk(s: Seq[(Int, Int)]): Boolean = {\n    var x = 0\n    var y = 0\n    s.foreach{t =>\n      x += t._1\n      y += t._2\n    }\n    x == 0 && y == 0\n  }\n\n  def run(in: Source): String = {\n    val tuples = in.getLines().toSeq(1).map{\n      case 'U' => (0, 1)\n      case 'R' => (1, 0)\n      case 'D' => (0, -1)\n      case 'L' => (-1, 0)\n    }\n    val result = (1 to tuples.size).map{ size =>\n      tuples.sliding(size).map(isOk).map {\n        case false => 0\n        case true => 1\n      }.sum\n    }.sum\n\n    result.toString\n  }\n\n  //\n\n  def readAll: String = {\n    Source.fromInputStream(System.in).mkString\n  }\n\n  def main(args: Array[String]): Unit = {\n    val in: Source = Source.fromString(readAll)\n    print(run(in))\n  }\n\n  def test(string: String): String = {\n    val in: Source = Source.fromString(string)\n    run(in)\n  }\n}"}], "negative_code": [], "src_uid": "7bd5521531950e2de9a7b0904353184d"}
{"source_code": "import scala.collection.mutable._\nimport scala.math._\nimport scala.util._\nimport scala.util.control.Breaks.break\nimport scala.util.control.Breaks.breakable\nimport java.util._\nobject Main extends App {\n  val sc = new Scanner(System.in)\n  val t = (for(i <- 1 to 4) yield sc.nextInt).toSet\n  println(4 - t.size)\n}\n", "positive_code": [{"source_code": "object Two28A extends App {\n\tval Array(s1, s2, s3, s4) = readLine.split(' ').map(_.toInt)\n\tval set = Set(s1, s2, s3, s4)\n\tprintln(4 - set.size)\n}"}, {"source_code": "import scala.io.StdIn\n\nobject Main extends App {\n  val colors = StdIn.readLine().split(\" \").toList\n  println(colors.size - colors.distinct.size)\n}"}, {"source_code": "object A {\n    def main(args: Array[String]) {\n        println(4 - readLine.split(\" \").distinct.size)\n    }\n}\n"}, {"source_code": "object Solution228A extends App {\n\n  def solution() {\n    println(4 - 1.to(4).map(_ => _int).groupBy(i => i).size)\n  }\n\n  //////////////////////////////////////////////////\n  import java.util.Scanner\n  val SC: Scanner = new Scanner(System.in)\n  def _line: String = SC.nextLine\n  def _int: Int = SC.nextInt\n  def _long: Long = SC.nextLong\n  def _string: String = SC.next\n  solution()\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val data = in.next().split(\" \")\n  println(data.length - data.distinct.length)\n}"}, {"source_code": "//package cf228\n\nobject A {\n\n  def main(args: Array[String]) {\n    val cs = readLine.split(' ').map(_.toInt)\n    println((cs.map((_,1)).groupBy(_._1).toSeq.map(_._2.size) /:\\ 0){_+_-1})\n  }\n\n}\n"}, {"source_code": "object A228 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val input  = readInts(4).toSet\n    println(4 - input.size)\n  }\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P228A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val shoes = Array.fill(4)(sc.nextInt)\n\n  val answer: Int = 4 - shoes.groupBy(identity[Int]).size\n\n  out.println(answer)\n  out.close\n}\n"}, {"source_code": "\n\nobject Horseshoe {\n\tdef main (args: Array[String]) {\n\t\tval scanner = new java.util.Scanner(System.in);\n\t\tval set = Set(scanner.nextInt(),scanner.nextInt(),scanner.nextInt(),scanner.nextInt())\n\t\tprintln(4-set.size)\n\t}\n}"}, {"source_code": "import java.io._\nimport scala.annotation.tailrec\n\nobject Easy {\n  val reader = new BufferedReader(new InputStreamReader(System.in))\n  def readInt = reader.readLine().toInt\n  def readInts = reader.readLine().split(\" \").map(_.toInt)\n\n  def ans = 4 - readInts.groupBy(x => x).size\n\n  def main(a: Array[String]) {\n    println(ans)\n  }\n}\n"}, {"source_code": "object test5 extends App {\n    val s=readLine.split(\" \").map(_.toInt)\n    println(4-s.groupBy(v=>v).size)\n}   \n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val s = readLine().split(\" \").map(_.toInt).toSet\n    println(4 - s.size)\n  }\n}"}, {"source_code": "// Codeforces 228A\n\nobject _228A extends App {\n  val scanner = new java.util.Scanner(System.in)\n  val horseshoes = Array.fill(4)(scanner.nextInt)\n  println(4-horseshoes.distinct.size)\n}\n\n"}, {"source_code": "\nimport scala.io.StdIn.readLine\nimport scala.io.StdIn.readInt\n\n\nobject HorseShoe {\n  \n   def readInts() : Array[Int] =\n     readLine.split(' ').map(_.toInt)\n  \n   def main(args: Array[String]) {\n     println(4  - readInts.toSet.size)\n   }\n  \n}"}, {"source_code": "\nobject Solution extends App {\n  val hh = readLine.split(\" \").map(_.toInt)\n  \n  println(4 - hh.distinct.size)\n}"}, {"source_code": "\nobject A00228 extends App {\n  def frequency[T](seq: Seq[T]) = seq.groupBy(identity).mapValues(_.size).withDefaultValue(0)\n  def parseInt(str: String, count: Int): Seq[Long] = {\n    val scanner = new java.util.Scanner(str)\n    val res = (1 to count) map (_ => scanner.nextLong())\n    scanner.close()\n    res\n  }\n  def scanInts(count: Int): Seq[Long] = parseInt(Console.readLine, count)\n  def readMatrix(row: Int, col: Int) = (1 to row) map (x => scanInts(col))\n\n  val hooves = readMatrix(1, 4).head.toList\n  println(4 - frequency(hooves).size)\n}"}], "negative_code": [{"source_code": "object A00228 extends App {\n  def frequencyList[T](lst: List[T]) = {\n    def iter(remLst: List[T], acc: List[(T, Int)]): List[(T, Int)] = (remLst, acc) match {\n      case (Nil, l) => l.reverse\n      case (x :: xs, Nil) => iter(xs, (x, 1) :: Nil)\n      case (x :: xs, (last, count) :: ys) if x == last => iter(xs, (last, count + 1) :: ys)\n      case (x :: xs, ys) => iter(xs, (x, 1) :: ys)\n    }\n    iter(lst, Nil)\n  }\n\n  def parseInt(str: String, count: Int): Seq[Long] = {\n    val scanner = new java.util.Scanner(str)\n    val res = (1 to count) map (_ => scanner.nextLong())\n    scanner.close()\n    res\n  }\n  def scanInts(count: Int): Seq[Long] = parseInt(Console.readLine, count)\n  def readMatrix(row: Int, col: Int) = (1 to row) map (x => scanInts(col))\n\n  println(4 - frequencyList(readMatrix(1, 4).head.toList).size)\n}\n"}], "src_uid": "38c4864937e57b35d3cce272f655e20f"}
{"source_code": "object Main extends App {\n\n  val n = readInt\n  val a = readLine.split(\" \").map(_.toInt)\n  val pairs = (a zip a.tail) map { case (a1,a2) => a2 - a1 }\n  val cur = pairs.max\n  val dropped = (pairs zip pairs.tail) map { case (a1, a2) => List(a1+a2, cur).max }\n  println(dropped.min)\n\n}", "positive_code": [{"source_code": "import java.util.StringTokenizer\n\nobject _496A extends App {\n  var token = new StringTokenizer(\"\")\n  def next = {\n    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)\n    token.nextToken()\n  }\n  val n = next.toInt\n  val a = (1 to n).map(i => next.toInt)\n  val d = (1 until n).map(i => a(i) - a(i - 1))\n  var ans = d.max\n  val dd = (1 until d.length).map(i => d(i) + d(i - 1))\n  ans = ans max dd.min\n  println(ans)\n}\n"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val n = in.next().toInt\n  val data = in.next().split(\" \").map(_.toInt)\n  var min = data.sliding(2).map{t => t.last - t.head}.max\n  println(Math.max(data.sliding(3).map{t => t.last - t.head}.min, min))\n}"}, {"source_code": "object A496 {\n\n  import IO._\n  def drop(a: Int, arr: Array[Int]) = arr.take(a) ++ arr.drop(a+1)\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    val in = readInts(n)\n    var res = Int.MaxValue\n    for(i <- 1 to n-2) {\n      val arr = drop(i, in.clone())\n      var inter = 0\n      for(j <- 1 until n-1) {\n        //i+1 is removed\n        inter = math.max(inter, arr(j)-arr(j-1))\n      }\n      res = math.min(res, inter)\n    }\n\n    println(res)\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "object P496A {\n\tdef zipSub(a: List[Int], b: List[Int]) : List[Int] = {\n\t\treturn (a, b).zipped.map(_ - _)\n\t}\n\n\tdef main(args: Array[String]) {\n\t\tval n = scala.io.StdIn.readInt()\n\t\tval a = scala.io.StdIn.readLine.split(\" \").map(_.toInt).toList\n\t\tprintln(math.max(zipSub(a.drop(1), a).max, zipSub(a.drop(2), a).min))\n\t}\n}\n"}, {"source_code": "object Main extends App {\n\n  val n = readInt\n  \n  val a = readLine.split(\" \").map(_.toInt).toList\n  \n  def trackDiff(a: List[Int], maxDiff: Int): Int = \n    if (a.tail.isEmpty) maxDiff else trackDiff(a.tail, maxDiff.max(a.tail.head - a.head))\n  \n  def trackDiffWithout(i: Int) = trackDiff(a.take(i) ::: a.drop(i + 1), -1)\n  \n  println((1 to n - 2).map(trackDiffWithout(_)).min)\n}"}], "negative_code": [], "src_uid": "8a8013f960814040ac4bf229a0bd5437"}
{"source_code": "import scala.collection._\nimport scala.collection.mutable.ArrayStack\n\nobject A extends App {\n  \n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(n) = readInts(1)\n  val s = ArrayStack.empty[Int]\n  \n  for (_ <- 1 to n) {\n    var x = 1\n    while (s.nonEmpty && s.head == x) {\n      x += 1\n      s.pop()\n    }\n    s.push(x)\n  }\n\n  Console.setOut(new java.io.BufferedOutputStream(Console.out))\n\n  println(s.toArray.reverse.mkString(\" \"))\n\n  Console.flush\n}\n", "positive_code": [{"source_code": "import scala.collection.mutable.ArrayBuffer\n\n/**\n  * Created by octavian on 30/01/2016.\n  */\nobject Slime {\n\n  def main(args: Array[String]) = {\n\n    //System.setIn(new FileInputStream(\"./src/slime.in\"))\n    //System.setOut(new PrintStream(new FileOutputStream(\"./src/slime.out\")))\n\n    val n = readInt()\n    var slimes = ArrayBuffer.empty[Int]\n    for(i <- 1 to n) {\n      slimes :+= 1\n      while(slimes.size > 1 && slimes(slimes.length - 1) == slimes(slimes.length - 2)) {\n        //println(\"condition holds\")\n        slimes(slimes.length - 2) += 1\n        slimes = slimes.dropRight(1)\n      }\n      //println(\"slimes is \" + slimes)\n    }\n    println(slimes.mkString(\" \"))\n  }\n}\n"}, {"source_code": "import scala.collection.mutable.ListBuffer\n\nobject A341{\n  def main(args: Array[String]){\n    def log2(x: Double) = scala.math.log(x)/scala.math.log(2)\n    var x=scala.io.StdIn.readDouble\n    val res = scala.collection.mutable.ArrayBuffer.empty[Int]\n    while (x > 1){\n      val p = log2(x)\n      x -= math.pow(2, p.toInt)\n      res+=(p.toInt+1)\n    }\n    if (x == 1){\n      res+=1\n    }\n    println(res.mkString(\" \"))\n  }\n}\n"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val string = in.next().toInt.toBinaryString.reverse\n  println(string.zipWithIndex.map{\n    case ('1', n) => n + 1\n    case _ => 0\n  }.filter(_ != 0).reverse.mkString(\" \"))\n}"}, {"source_code": "object A618 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    var res = Array.empty[Int]\n    for(i <- 0 to 30) {\n      if ((n & (1 << i)) != 0)\n        res ++= Array(i+1)\n    }\n    println(res.sorted.reverse.mkString(\" \"))\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "\nimport scala.collection.mutable\n\n/**\n * <a href=\"http://codeforces.com/problemset/problem/618/A\"/>\n *\n * @author pvasilyev\n * @since 25 Apr 2016\n */\nobject Problem156 extends App {\n\n  val n = scala.io.StdIn.readInt()\n\n  def solve(n: Int, binaryRepresentation: mutable.MutableList[Int], factor: Int): Unit = {\n    if (n > 0) {\n      if (n % factor == 0) {\n        binaryRepresentation += 0\n      } else {\n        binaryRepresentation += 1\n      }\n\n      solve(n / factor, binaryRepresentation, factor)\n    }\n  }\n\n  val binaryRepresentation: mutable.MutableList[Int] = mutable.MutableList.empty\n  solve(n, binaryRepresentation, 2)\n  val answer: mutable.MutableList[Int] = mutable.MutableList.empty\n  for (i <- binaryRepresentation.indices) {\n    if (binaryRepresentation.get(i).get == 1) {\n      answer += (i+1)\n    }\n  }\n  println(answer.reverse.mkString(\" \"))\n\n}\n"}, {"source_code": "\nimport scala.collection.mutable\n\n/**\n * <a href=\"http://codeforces.com/problemset/problem/618/A\"/>\n *\n * @author pvasilyev\n * @since 25 Apr 2016\n */\nobject Problem156 extends App {\n\n  val n = scala.io.StdIn.readInt()\n\n  def solve(n: Int, bits: mutable.MutableList[Int]): Unit = {\n    if (n > 0) {\n      bits += (n % 2)\n      solve(n / 2, bits)\n    }\n  }\n\n  val bits: mutable.MutableList[Int] = mutable.MutableList.empty\n  solve(n, bits)\n  val answer = bits.zipWithIndex.collect({case (1, i) => i + 1})\n  println(answer.reverse.mkString(\" \"))\n\n}\n"}, {"source_code": "import scala.io.Source\n\nobject Main {\n  val count = Source.stdin.getLines().mkString.toInt\n  val stack = scala.collection.mutable.Stack[Int]()\n\n  def foldStack(): Unit = {\n    while (stack.length > 1 && stack.elems.head == stack.elems.tail.head) {\n      val a = stack.pop()\n      val b = stack.pop()\n      stack.push(a + 1)\n    }\n  }\n\n  def main(args: Array[String]) {\n    for (i <- 0 until count) {\n      foldStack()\n      stack.push(1)\n    }\n    foldStack()\n    println(stack.reverse.mkString(\" \"))\n  }\n}\n"}, {"source_code": "import scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util._, control._\nimport scala.math.Ordering.Implicits._\n\nobject _618A extends CodeForcesApp {\n  override type Result = Seq[Int]\n\n  override def solve(scanner: Scanner) = {\n    import scanner._\n    val n = nextInt()\n    val bits = java.lang.Integer.toBinaryString(n).reverse.zipWithIndex\n    bits collect { case ('1', i) => i + 1}\n  }\n\n  override def format(result: Seq[Int]) = result.reverse mkString \" \"\n}\n/****************************[Ignore Template Below]****************************************/\nabstract class CodeForcesApp {\n  val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  val mod: Int = 1000000007\n  type Result\n  def solve(scanner: Scanner): Result\n  def format(result: Result): String = result.toString\n  def apply(scanner: Scanner): String = format(solve(scanner))\n  def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))\n}\n/*********************************[Scala Scanner]*******************************************/\nimport java.io._\nimport java.nio.file.{Files, Path}\nimport java.util.StringTokenizer\n\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/21125\n * All next methods throw NoSuchElementException when !hasNext\n */\nclass Scanner(reader: LineNumberReader) extends Iterator[String] with AutoCloseable {\n  def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n  def this(reader: Reader) = this(new BufferedReader(reader))\n  def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n  def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))\n  def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n  def this(str: String) = this(new StringReader(str))\n\n  val lines = Iterator.continually(reader.readLine()).takeWhile(_ != null)\n\n  private[this] val tokenizers = lines.map(new StringTokenizer(_)).filter(_.hasMoreTokens)\n  private[this] var current: Option[StringTokenizer] = None\n\n  @inline private[this] def tokenizer(): Option[StringTokenizer] = current.find(_.hasMoreTokens) orElse {\n    current = if (tokenizers.hasNext) Some(tokenizers.next()) else None\n    current\n  }\n\n  /**\n   * Unlike Java's scanner which returns till end of current line, this actually returns the next line\n   * @see line() if you want the Java behaviour\n   */\n  def nextLine(): String = {\n    current = None   // reset\n    lines.next()\n  }\n  def lineNumber: Int = reader.getLineNumber\n  def line(): String = tokenizer().get.nextToken(\"\\n\\r\")\n  def nextString(): String = next()\n  def nextChar(): Char = next().ensuring(_.length == 1).head\n  def nextBoolean(): Boolean = next().toBoolean\n  def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n  def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n  def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n  def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n  def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n  def nextFloat(): Float = next().toFloat\n  def nextDouble(): Double = next().toDouble\n  def nextBigDecimal(): BigDecimal = BigDecimal(next())\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n  override def close() = reader.close()\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject Main{\n  def main (args: Array[String]){\n    val sc = new Scanner(System.in)\n    var n = sc.nextInt()\n\n    // var ans = new List[Int]()\n\n    if(n == 1){\n      println(1)\n    }\n    else{\n      val a = (Math.log(n)/Math.log(2)).toInt\n      print(a + 1)\n      n -= Math.pow(2, a).toInt\n\n      def check(n: Int): Unit = {\n        n match{\n          case 0 =>\n            println()\n          case 1 =>\n            println(\" 1\")\n          case x =>\n            val b = (Math.log(n)/Math.log(2)).toInt\n            print(' ')\n            print(b + 1)\n            val c = x - Math.pow(2, b).toInt\n            check(c)\n        }\n      }\n\n      check(n)\n    }\n  }\n}\n"}, {"source_code": "object Runner {\n\n  def main(args: Array[String]) = {\n    val n = readInt()\n\n    val binaryStr = Integer.toBinaryString(n)\n    var res = List[Int]()\n    for (i <- 0 until binaryStr.length()) {\n      if (binaryStr.charAt(i).equals('1')) {\n        res = res :+ (binaryStr.length() - i)\n      }\n    }\n    var str = \"\"\n    for (i <- 0 until res.size) {\n      str += res(i)\n      if (i != res.size - 1) {\n        str += \" \"\n      }\n    }\n    println(str)\n  }\n}"}, {"source_code": "\nimport java.io._\nimport java.util.ArrayList\nimport java.util.StringTokenizer\nimport javax.print.attribute.standard.Sides\n\nobject CF2016_A {  \n  \n  \n  def main(args: Array[String]): Unit = {\n\n    //COMMENT ME !\n//    is = new ByteArrayInputStream(Test.sa1.trim.getBytes(\"ISO-8859-1\"))\n//    debugV = true\n\n\n    //---------------------------- parameters reading --------------------------\n    br = setupInputOutput(); \n    val line1 = readLine\n    val n = line1.int\n    \n    val arr = new ArrayList[Int]\n    for (i<- 1 to n) {\n      arr.add(1)\n      while (arr.size() > 1 && arr.get(arr.size()-1) == arr.get(arr.size()-2)) {\n        val vv = arr.remove(arr.size()-1) + 1 \n        arr.remove(arr.size()-1)\n        arr.add(vv)\n      }\n    }\n    for (i <- 0 until arr.size()) print(arr.get(i)+\" \")\n    \n    //---------------------------- parameters reading end ----------------------\n\n  }\n\n  \n  //---------------------------- service code ----------------------------------\n\n  \n  def readLine() = new Line  \n  class Line {\n    val tok = new StringTokenizer(br.readLine(), \" \")\n    def int = tok.nextToken().toInt\n    def long = tok.nextToken().toLong\n    def double = tok.nextToken().toDouble\n    def string = tok.nextToken()\n  }\n  \n  var debugV = false\n  var is = System.in\n  var br = setupInputOutput();  \n  def db(x: => String) = if (debugV) println(x) // nullary function\n  def setupInputOutput(): BufferedReader = {\n    val devEnv = this.getClass.getCanonicalName.contains(\".\")\n    if (!devEnv) {\n      is = System.in\n      debugV = false\n    }\n    val bis = new BufferedInputStream(is);\n    new BufferedReader(new InputStreamReader(bis));\n  }\n  \n//============================================================================================\nobject Test {\n  \nval sa1 = \"\"\"\n\n\"\"\"\n\n}\n\n}\n\n"}], "negative_code": [{"source_code": "\n\nimport scala.collection.mutable.ArrayBuffer\n\n/**\n  * Created by octavian on 30/01/2016.\n  */\nobject Slime {\n\n  def main(args: Array[String]) = {\n\n    //System.setIn(new FileInputStream(\"./src/slime.in\"))\n    //System.setOut(new PrintStream(new FileOutputStream(\"./src/slime.out\")))\n\n    val n = readInt()\n    var slimes = ArrayBuffer.empty[Int]\n    for(i <- 1 to n) {\n      slimes :+= 1;\n      //println(\"slimes is \" + slimes)\n      while(slimes.size > 1 && slimes(slimes.length - 1) == slimes(slimes.length - 2)) {\n        //println(\"condition holds\")\n        slimes(slimes.length - 2) += 1\n        slimes = slimes.dropRight(1)\n      }\n    }\n    println(slimes.mkString)\n  }\n}\n"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val string = in.next().toInt.toBinaryString\n  println(string.zip(string.indices.map(i => 1 << i)).map{\n    case ('1', n) => n\n    case _ => 0\n  }.filter(_ != 0).mkString(\" \"))\n}"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val string = in.next().toInt.toBinaryString.reverse\n  println(string.zip(string.indices.map(i => 1 << i)).map{\n    case ('1', n) => n\n    case _ => 0\n  }.filter(_ != 0).reverse.mkString(\" \"))\n}"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val string = in.next().toInt.toBinaryString.reverse\n  println(string.zip(string.indices.map(i => 1 << i)).map{\n    case ('1', n) => n\n    case _ => 0\n  }.filter(_ != 0).mkString(\" \"))\n}"}, {"source_code": "import java.util.Scanner\n\nobject Main{\n  def main (args: Array[String]){\n    val sc = new Scanner(System.in)\n    var n = sc.nextInt()\n\n    // var ans = new List[Int]()\n\n    if(n == 1){\n      println(1)\n    }\n    else{\n      val a = (Math.log(n)/Math.log(2)).toInt\n      print(a + 1)\n      n -= Math.pow(2, a).toInt\n\n      def check(n: Int): Unit = {\n        n match{\n          case 0 =>\n            println()\n          case 1 =>\n            println(\" 1\")\n          case x =>\n            val b = (Math.log(n)/Math.log(2)).toInt\n            print(b + 1)\n            val c = x - Math.pow(2, b).toInt\n            check(c)\n        }\n      }\n\n      check(n)\n    }\n  }\n}\n"}], "src_uid": "757cd804aba01dc4bc108cb0722f68dc"}
{"source_code": "/**\n * Created by IntelliJ IDEA.\n * User: ymatsux\n * Date: 12/05/06\n * Time: 2:02\n * To change this template use File | Settings | File Templates.\n */\n\nobject CF115A {\n  def main(args: Array[String]): Unit = {\n    val input = readLine()\n    var ans = -1\n    for (i <- 0 until input.length) {\n      for (j <- i + 1 until input.length) {\n        val s1 = input.substring(0, i)\n        val s2 = input.substring(i, j)\n        val s3 = input.substring(j)\n        if (isValid(s1) && isValid(s2) && isValid(s3)) {\n          ans = math.max(s1.toInt + s2.toInt + s3.toInt, ans)\n        }\n      }\n    }\n    println(ans)\n  }\n\n  def isValid(string: String): Boolean = {\n    if (string.length == 0) false\n    else if (string.length >= 2 && string.charAt(0) == '0') false\n    else {\n      val value = BigInt(string)\n      value <= 1000000\n    }\n  }\n}\n", "positive_code": [{"source_code": "import scala.math.max\n\nobject CF105A {\n\n  def parseScore(string: String): Option[Int] = {\n    if (string.length == 0) None\n    else if (string.length >= 2 && string.charAt(0) == '0') None\n    else if (string.length >= 8) None\n    else if (string.toInt > 1000000) None\n    else Some(string.toInt)\n  }\n\n  def main(args: Array[String]): Unit = {\n    val input = readLine()\n    var maxSum = -1\n    for (i <- 0 until input.length) {\n      for (j <- i until input.length) {\n        val string1 = input.substring(0, i)\n        val string2 = input.substring(i, j)\n        val string3 = input.substring(j)\n        (parseScore(string1), parseScore(string2), parseScore(string3)) match {\n          case (Some(value1), Some(value2), Some(value3)) => {\n            maxSum = max(value1 + value2 + value3, maxSum)\n          }\n          case _ => Unit\n        }\n      }\n    }\n    println(maxSum)\n  }\n}\n"}], "negative_code": [], "src_uid": "bf4e72636bd1998ad3d034ad72e63097"}
{"source_code": "import java.util.Scanner\n\nobject Try1 {\n  def main(args: Array[String]) {\n    val in = new Scanner(System.in)\n    var a,b,len,x, m, k, n, j, i: Int = 0\n//    val lb = \"abcdefghijklmnopqrstuvwxyz\"\n//    val lc = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n//    var a = new Array[Int](51)\n//    n = in.nextInt()\n//    k = in.nextInt()\n//    x=0\n    val la = in.nextLine()\n    a=0\n    b=0\n    m = la.length()\n    i=0\n    while (i<m)\n      {\n        if (la(i)=='D' || la(i)=='O' ||la(i)=='S' ||la(i)=='A' ||la(i)=='N') {\n          if (i+4<m && la(i)=='D') {\n            if (la(i+1)=='a' && la(i+2)=='n' &&la(i+3)=='i' && la(i+4)=='l')\n              a+=1\n          }\n          if (i+3<m && la(i)=='O') {\n            if (la(i+1)=='l' && la(i+2)=='y' &&la(i+3)=='a')\n              a+=1\n          }\n          if (i+4<m && la(i)=='S') {\n            if (la(i+1)=='l' && la(i+2)=='a' &&la(i+3)=='v' && la(i+4)=='a')\n              a+=1\n          }\n          if (i+2<m && la(i)=='A') {\n            if (la(i+1)=='n' && la(i+2)=='n')\n              a+=1\n          }\n          if (i+5<m && la(i)=='N') {\n            if (la(i+1)=='i' && la(i+2)=='k' &&la(i+3)=='i' && la(i+4)=='t' && la(i+5)=='a')\n              a+=1\n          }\n        }\n//        if (la(i)>='a' && la(i)<='z') a+=1\n//        else b+=1\n        i+=1\n      }\n    if (a==1) println(\"YES\")\n    else println(\"NO\")\n//    if (a>=b)\n//      {\n//        i=0\n//        while (i<m)\n//        {\n//          if (la(i)>='a' && la(i)<='z') print(la(i))\n//          else print(lb(la(i)-'A'))\n//          i+=1\n//        }\n//      }\n//    else\n//      {\n//        i=0\n//        while (i<m)\n//        {\n//          if (la(i)>='a' && la(i)<='z') print(lc(la(i)-'a'))\n//          else print(la(i))\n//          i+=1\n//        }\n//      }\n//    m = la.compareToIgnoreCase(lb)  //不区分大小写判断字符串是否相等\n\n\n//    i=0\n//    n=line.length()\n//    while (i<n-2 && line(i)=='W' && line(i+1)=='U' && line(i+2)=='B') i+=3\n//    while (n>2 && line(n-3)=='W' && line(n-2)=='U' && line(n-1)=='B') n-=3\n//    while (i<n) {\n//      if (line(i)=='W') {\n//        if (i<n-2) {\n//          if (line(i+1)=='U' && line(i+2)=='B') {\n//            print(' ')\n//           i+=2\n//          }\n//          else print(line(i))\n//        }\n//        else print(line(i))\n//      }\n//      else print(line(i))\n//      i+=1\n//    }\n\n  }\n}", "positive_code": [{"source_code": "import scala.io.StdIn._\n\nobject Codeforces extends App {\n  val contest = readLine()\n  val friends = List(\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\")\n  var count: Int = 0\n  friends.foreach(count += _.r.findAllIn(contest).length)\n  println(if (count == 1) \"YES\" else \"NO\")\n}\n"}, {"source_code": "object A extends App {\n  def countSubstring(str1: String, str2: String): Int = {\n    def count(pos: Int, c: Int): Int = {\n      val idx = str1 indexOf(str2, pos)\n      if (idx == -1) c else count(idx + str2.length, c+1)\n    }\n    count(0, 0)\n  }\n\n  val friends = List(\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\")\n  val str1 = scala.io.StdIn.readLine()\n\n  if (friends.foldLeft(0)((acc, str2) => acc + countSubstring(str1, str2)) == 1) println(\"YES\")\n  else println(\"NO\")\n}\n"}, {"source_code": "object _877A extends CodeForcesApp {\n  import Utils._, annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._\n\n  override def apply(io: IO): io.type = {\n    val friends = List(\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\")\n    val input = io.read[String]\n    val result = friends.sumWith {f =>\n      if (input.contains(f)) {\n        if (input.indexOf(f) == input.lastIndexOf(f)) {\n          1\n        } else {\n          2\n        }\n      } else {\n        0\n      }\n    }\n\n\n    io.write((result == 1).toEnglish.toUpperCase())\n  }\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\nobject Utils {\n  import scala.collection.mutable, mutable.{Map => Dict}\n  implicit class GenericExtensions[A](val a: A) extends AnyVal {\n    def in(set: collection.Set[A]): Boolean = set(a)\n    def some: Option[A] = Some(a)\n    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a\n  }\n  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {\n    def onlyElement: A = assuming(t.size == 1)(t.head)\n    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)\n    def duplicates(implicit b: C of A): C[A] = {\n      val elems = mutable.Set.empty[A]\n      (t collect {case i if !elems.add(i) => i}).to[C]\n    }\n    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}\n    def maxWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.max)\n    def minWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.min)\n    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]\n    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap\n    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)\n    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}\n    def toMutableMultiSet: Dict[A, Int] = {\n      val c = map[A] to 0\n      t.foreach(i => c(i) += 1)\n      c\n    }\n    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0\n    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)\n  }\n  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)\n  }\n  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)\n  }\n  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {\n    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t\n  }\n  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {\n    def key = p._1\n    def value = p._2\n    def toSeq(implicit ev: A =:= B): Seq[A] = Seq(p._1, p._2.asInstanceOf[A])\n  }\n  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {\n    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)\n    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])\n    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]\n  }\n  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {\n    def lastKeyOption: Option[K] = m.lastOption.map(_.key)\n    def firstKeyOption: Option[K] = m.headOption.map(_.key)\n    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap\n    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}\n    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m\n    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\n  }\n  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {\n    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)\n    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)\n    private def removeNode(kv: (K, V)): (K, V) = {\n      m -= kv.key\n      kv\n    }\n  }\n  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {\n    def notContains(x: A): Boolean = !(s contains x)\n    def toMutable = mutable.Set.empty[A] ++ s\n  }\n  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {\n    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}\n    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)\n    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)\n    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}\n    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)\n  }\n  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {\n    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero\n    def toEnglish = if(x) \"Yes\" else \"No\"\n  }\n  implicit class IntExtensions(val x: Int) extends AnyVal {\n    import java.lang.{Integer => JInt}\n    def withHighestOneBit: Int = JInt.highestOneBit(x)\n    def withLowestOneBit: Int = JInt.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)\n    def bitCount: Int = JInt.bitCount(x)\n    def setLowestBits(n: Int): Int = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Int = x & left(n, ~0)\n    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Int = x | left(i)\n    def clearBit(i: Int): Int = x & ~left(i)\n    def toggleBit(i: Int): Int = x ^ left(i)\n    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1\n    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)\n    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)\n  }\n  implicit class LongExtensions(val x: Long) extends AnyVal {\n    import java.lang.{Long => JLong}\n    def withHighestOneBitSet: Long = JLong.highestOneBit(x)\n    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)\n    def bitCount: Int = JLong.bitCount(x)\n    def setLowestBits(n: Int): Long = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Long = x & left(n, ~0L)\n    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Long = x | left(i)\n    def clearBit(i: Int): Long = x & ~left(i)\n    def toggleBit(i: Int): Long = x ^ left(i)\n    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1\n    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)\n  }\n  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {\n    import Numeric.Implicits._\n    def **(i: Int): A = if (i == 0) n.one else {\n      val h = x ** (i/2)\n      if (i%2 == 0) h * h else h * h * x\n    }\n    def distance(y: A) = (x - y).abs()\n    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)\n    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf \"Greg\" whenNegative Int.MaxValue\n  }\n  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {\n    import scala.collection.immutable.NumericRange, Integral.Implicits._\n    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x\n    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)\n    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)\n  }\n  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))\n  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)\n  def asc[A](implicit order: Ordering[A]): Ordering[A] = order\n  def map[K] = new {\n    def to[V](default: => V): Dict[K, V] = using(_ => default)\n    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {\n      override def apply(key: K) = getOrElseUpdate(key, f(key))\n    }\n  }\n  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]\n  def memoize[A, B](f: A => B): A ==> B = map[A] using f\n  implicit class FuzzyDouble(val x: Double) extends AnyVal {\n    def  >~(y: Double) = x > y + eps\n    def >=~(y: Double) = x >= y + eps\n    def  ~<(y: Double) = y >=~ x\n    def ~=<(y: Double) = y >~ x\n    def  ~=(y: Double) = (x distance y) <= eps\n  }\n  def toPolygon(points: Traversable[(Int, Int)]): java.awt.Polygon = {\n    val (xs, ys) = points.unzip\n    new java.awt.Polygon(xs.toArray, ys.toArray, points.size)\n  }\n  def toShape(points: Traversable[(Double, Double)]): java.awt.geom.GeneralPath = {\n    val shape = new java.awt.geom.GeneralPath()\n    points.headOption foreach {case (x, y) => shape.moveTo(x, y)}\n    points.tail foreach {case (x, y) => shape.lineTo(x, y)}\n    shape.closePath()\n    shape\n  }\n  def until(until: Int): Range = 0 until until\n  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}\n  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}\n  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None\n  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)\n  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]\n  type ==>[A, B] = collection.Map[A, B]\n  val mod: Int = (1e9 + 7).toInt\n  val eps: Double = 1e-9\n}\n/***********************************[Scala I/O]*********************************************/\nimport Utils._, java.io._, java.util.StringTokenizer\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    when(tokenizers.nonEmpty)(tokenizers.head)\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  def readAll[A: IO.Read]: (Int, Vector[A]) = {\n    val data = read[Vector[A]]\n    (data.length, data)\n  }\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any): this.type = {\n    printer.print(obj)\n    this\n  }\n  def writeLine(): this.type = {\n    printer.println()\n    this\n  }\n  def writeLine(obj: Any): this.type = {\n    printer.println(obj)\n    this\n  }\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n  def query[A: IO.Read](question: Any): A = writeLine(question).read\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                       : Read[String]       = new Read(_.next())\n    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)\n    implicit val int                                          : Read[Int]          = string.map(_.toInt)\n    implicit val long                                         : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                       : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                      : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n"}], "negative_code": [], "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710"}
{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val n = in.next().toInt\n  val str = in.next()\n  val small = str.count(_ == 'x')\n  var change = Math.abs(n / 2 - small)\n  println(change)\n  if (small > n / 2) {\n    println(str.map{\n      case ('x') if change > 0 =>\n        change -= 1\n        'X'\n      case t => t\n    })\n  } else {\n    println(str.map{\n      case ('X') if change > 0 =>\n        change -= 1\n        'x'\n      case t => t\n    })\n  }\n}", "positive_code": [{"source_code": "\nobject A {\n  def main(args: Array[String]): Unit = {\n    val n = Console.readInt\n    val s = new StringBuilder(Console readLine)\n    var c = 0\n    for (x <- s) c += (if (x == 'X') 1 else 0)\n    if (c < n/2) {\n      var q = n/2-c\n      for (x <- 0 until n) {\n        if (s(x) == 'x' && q > 0) {\n          s(x) = 'X'\n          q -= 1;\n        }\n      }\n    } else {\n      var q = c-n/2\n      for (x <- 0 until n) {\n        if (s(x) == 'X' && q > 0) {\n          s(x) = 'x'\n          q -= 1;\n        }\n      }\n    }\n    println(Math.abs(c-n/2))\n    println(s)\n  }\n}\n"}], "negative_code": [], "src_uid": "fa6311c72d90d8363d97854b903f849d"}
{"source_code": "object A extends App {\n\n  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }\n  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }\n  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }\n\n  val Array(s, v1, v2, t1, t2) = readInts(5)\n\n  val x1 = s * v1 + 2 * t1\n  val x2 = s * v2 + 2 * t2\n\n  val r = if (x1 < x2) \"First\"\n  else if (x2 < x1) \"Second\"\n  else \"Friendship\"\n\n  println(r)\n}\n", "positive_code": [{"source_code": "import scala.io.StdIn\n\nobject Main extends App {\n\n  val Array(s, v1, v2, t1, t2) = StdIn.readLine().split(\" \").map(_.toInt)\n\n  val first = 2*t1 + v1*s\n  val second = 2*t2 + v2*s\n  if(first < second) println(\"First\")\n  else if(first > second) println(\"Second\")\n  else if(first == second) println(\"Friendship\")\n\n}\n"}, {"source_code": "object AKeyRaces extends App {\n  def result: (Int, Int, Int, Int, Int) => Int = (s: Int, v1: Int, v2: Int, t1: Int, t2: Int) => {\n    val r1 = 2 * t1 + s * v1\n    val r2 = 2 * t2 + s * v2\n    if (r1 == r2) 0\n    else if (r1 < r2) 1\n    else -1\n  }\n\n  val Array(s, v1, v2, t1, t2) = scala.io.StdIn.readLine.split(\" \").map(_.toInt)\n  val r = result(s, v1, v2, t1, t2)\n  if (r == 0) print(\"Friendship\")\n  else if (r == 1) print(\"First\")\n  else print(\"Second\")\n}\n"}], "negative_code": [], "src_uid": "10226b8efe9e3c473239d747b911a1ef"}
{"source_code": "//package solutions\n\nimport java.io.PrintWriter\nimport java.util.Scanner\n\nimport scala.math\n\n/**\n  * @author traff\n  */\n\n\nobject SolTaskA extends App {\n  override def main(args: Array[String]): Unit = {\n    val out = new PrintWriter(System.out)\n\n    run(new Scanner(System.in), out)\n\n    out.close()\n  }\n\n  def run(s: Scanner, out: PrintWriter): Unit = {\n    val a = s.nextInt()\n    val b = s.nextInt()\n\n    val n = (math.log(b) - math.log(a)) / (math.log(3) - math.log(2))\n    var res = math.ceil(n).toInt\n    if (res < n + 0.0000001) {\n      res += 1\n    }\n    out.print(res)\n  }\n}\n", "positive_code": [{"source_code": "object Problem extends App{\n  val ln = readLine\n  val vals = ln.split(\" \")\n  var a = vals(0).toInt\n  var b = vals(1).toInt\n  var counter = 0\n  do{\n    a *= 3\n    b *= 2\n    counter += 1\n  } while (a <= b)\n  println(counter)\n}"}, {"source_code": "object BearAndBigBrother extends App {\n\n    val inputs = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    val liak = inputs(0)\n    val bob = inputs(1)\n\n    def solution(x: Int, y: Int): Int = {\n        def helper(a: Int, b:Int, c: Int):Int = {\n            \n            if (a > b) c\n            else {\n                helper(a*3, b*2, c+1)\n        }\n        \n    }\n        helper(x,y,0)\n}\n\n    println(solution(liak,bob))\n}"}, {"source_code": "object tanya extends App{\nvar twoNum = readLine().split(\" \")\nvar a = twoNum(0).toInt\nvar b = twoNum(1).toInt\nvar c = 0\n\nwhile(a <= b){\n    c += 1\n    a = a * 3\n    b = b * 2\n}\nprintln(c)\n}\n"}, {"source_code": "import scala.io.StdIn\n\nobject BearAndBigBrother extends App {\n\n  val l1 = StdIn.readLine().split(\" \")\n  val a = l1(0).toInt\n  val b = l1(1).toInt\n  print(impl(a, b))\n\n  def impl(a: Int, b: Int): Int = {\n    var years = 0\n    var currA = a\n    var currB = b\n    while (currA <= currB) {\n      currA = 3 * currA\n      currB = 2 * currB\n      years += 1\n    }\n    years\n  }\n}\n"}, {"source_code": "import scala.io.StdIn.readLine\nobject BearBrother extends App\n{\n    val input = readLine().split(' ').map(_.toInt)\n    var sum = 0\n    var a: Int = input(0)\n    var b: Int = input(1)\n    while(!(a > b))\n    {\n        a *= 3\n        b *= 2\n        sum += 1\n    }\n    println(sum)\n}"}, {"source_code": "import scala.io.StdIn.readLine\n\nobject A791 {\n  def main(args: Array[String]): Unit = {\n    val List(limak, bob) = readToListInts\n    println(solve(limak, bob))\n  }\n\n  def solve(limak: Int, bob: Int): Int = {\n    def aux(a: Int, b: Int, count: Int): Int = {\n      if (a > b) {\n        count\n      } else {\n        aux(a*3, b*2, count + 1)\n      }\n    }\n    aux(limak, bob, 0)\n  }\n\n  def readToListInts: List[Int] = readLine.split(\" \").map(_.toInt).toList\n}\n\n"}, {"source_code": "import io.StdIn._\nobject BearAndBigBrother {\n\n  def main(args: Array[String]): Unit = {\n    var inputs:Array[Int] = readLine().split(\" \").map(t=> s\"$t\".toInt)\n    var i = 0\n    while(inputs(0) <= inputs(1)){\n      inputs(0) *= 3\n      inputs(1) *= 2\n      i += 1\n    }\n    println(i)\n  }\n\n}"}, {"source_code": "object _791A extends CodeForcesApp {\n  import Utils._, annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._\n\n  override def apply(io: IO) = {import io.{read, readAll, write, writeAll, writeLine}\n    val a, b = read[Long]\n    write(solve(a, b))\n  }\n\n  def solve(a: Long, b: Long): Int = if (a > b) 0 else 1 + solve(3*a, 2*b)\n}\n/****************************[Ignore Template Below]****************************************/\ntrait CodeForcesApp {\n  lazy val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)\n  def apply(io: IO): io.type\n  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()\n}\nobject Utils {\n  import scala.collection.mutable, mutable.{Map => Dict}\n  implicit class GenericExtensions[A](val a: A) extends AnyVal {\n    def in(set: collection.Set[A]): Boolean = set(a)\n    def some: Option[A] = Some(a)\n    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a\n  }\n  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {\n    def onlyElement: A = assuming(t.size == 1)(t.head)\n    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)\n    def duplicates(implicit b: C of A): C[A] = {\n      val elems = mutable.Set.empty[A]\n      (t collect {case i if !elems.add(i) => i}).to[C]\n    }\n    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}\n    def maxWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.max)\n    def minWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.min)\n    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]\n    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap\n    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)\n    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}\n    def toMutableMultiSet: Dict[A, Int] = {\n      val c = map[A] to 0\n      t.foreach(i => c(i) += 1)\n      c\n    }\n    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0\n    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)\n  }\n  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)\n  }\n  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {\n    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)\n  }\n  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {\n    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t\n  }\n  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {\n    def key = p._1\n    def value = p._2\n  }\n  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {\n    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)\n    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])\n    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]\n  }\n  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {\n    def lastKeyOption: Option[K] = m.lastOption.map(_.key)\n    def firstKeyOption: Option[K] = m.headOption.map(_.key)\n    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap\n    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}\n    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m\n    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\n  }\n  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {\n    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)\n    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)\n    private def removeNode(kv: (K, V)): (K, V) = {\n      m -= kv.key\n      kv\n    }\n  }\n  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {\n    def notContains(x: A): Boolean = !(s contains x)\n    def toMutable = mutable.Set.empty[A] ++ s\n  }\n  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {\n    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}\n    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)\n    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)\n    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}\n    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)\n  }\n  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {\n    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero\n    def toEnglish = if(x) \"YES\" else \"NO\"\n  }\n  implicit class IntExtensions(val x: Int) extends AnyVal {\n    import java.lang.{Integer => JInt}\n    def withHighestOneBit: Int = JInt.highestOneBit(x)\n    def withLowestOneBit: Int = JInt.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)\n    def bitCount: Int = JInt.bitCount(x)\n    def setLowestBits(n: Int): Int = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Int = x & left(n, ~0)\n    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Int = x | left(i)\n    def clearBit(i: Int): Int = x & ~left(i)\n    def toggleBit(i: Int): Int = x ^ left(i)\n    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1\n    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)\n    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)\n  }\n  implicit class LongExtensions(val x: Long) extends AnyVal {\n    import java.lang.{Long => JLong}\n    def withHighestOneBitSet: Long = JLong.highestOneBit(x)\n    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)\n    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)\n    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)\n    def bitCount: Int = JLong.bitCount(x)\n    def setLowestBits(n: Int): Long = x | (left(n) - 1)\n    def clearLowestBits(n: Int): Long = x & left(n, ~0L)\n    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)\n    def setBit(i: Int): Long = x | left(i)\n    def clearBit(i: Int): Long = x & ~left(i)\n    def toggleBit(i: Int): Long = x ^ left(i)\n    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1\n    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)\n  }\n  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {\n    import Numeric.Implicits._\n    def **(i: Int): A = if (i == 0) n.one else {\n      val h = x ** (i/2)\n      if (i%2 == 0) h * h else h * h * x\n    }\n    def distance(y: A) = (x - y).abs()\n    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)\n    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf \"Greg\" whenNegative Int.MaxValue\n  }\n  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {\n    import scala.collection.immutable.NumericRange, Integral.Implicits._\n    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x\n    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)\n    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)\n  }\n  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))\n  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)\n  def asc[A](implicit order: Ordering[A]): Ordering[A] = order\n  def map[K] = new {\n    def to[V](default: => V): Dict[K, V] = using(_ => default)\n    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {\n      override def apply(key: K) = getOrElseUpdate(key, f(key))\n    }\n  }\n  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]\n  def memoize[A, B](f: A => B): A ==> B = map[A] using f\n  implicit class FuzzyDouble(val x: Double) extends AnyVal {\n    def  >~(y: Double) = x > y + eps\n    def >=~(y: Double) = x >= y + eps\n    def  ~<(y: Double) = y >=~ x\n    def ~=<(y: Double) = y >~ x\n    def  ~=(y: Double) = (x distance y) <= eps\n  }\n  def toPolygon(points: Traversable[(Int, Int)]): java.awt.Polygon = {\n    val (xs, ys) = points.unzip\n    new java.awt.Polygon(xs.toArray, ys.toArray, points.size)\n  }\n  def toShape(points: Traversable[(Double, Double)]): java.awt.geom.GeneralPath = {\n    val shape = new java.awt.geom.GeneralPath()\n    points.headOption foreach {case (x, y) => shape.moveTo(x, y)}\n    points.tail foreach {case (x, y) => shape.lineTo(x, y)}\n    shape.closePath()\n    shape\n  }\n  def until(until: Int): Range = 0 until until\n  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}\n  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}\n  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None\n  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)\n  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]\n  type ==>[A, B] = collection.Map[A, B]\n  val mod: Int = (1e9 + 7).toInt\n  val eps: Double = 1e-9\n}\n/***********************************[Scala I/O]*********************************************/\nimport Utils._, java.io._, java.util.StringTokenizer\n\nclass IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {\n  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))\n  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))\n\n  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n  val printer = new PrintWriter(out, true)\n\n  @inline private[this] def tokenizer() = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    when(tokenizers.nonEmpty)(tokenizers.head)\n  }\n\n  def read[A](implicit read: IO.Read[A]): A = read.apply(this)\n  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]\n\n  def readTill(delim: String): String = tokenizer().get.nextToken(delim)\n  def readTillEndOfLine(): String = readTill(\"\\n\\r\")\n\n  def readAll[A: IO.Read]: (Int, Vector[A]) = {\n    val data = read[Vector[A]]\n    (data.length, data)\n  }\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n\n  def write(obj: Any): this.type = {\n    printer.print(obj)\n    this\n  }\n  def writeLine(): this.type = {\n    printer.println()\n    this\n  }\n  def writeLine(obj: Any): this.type = {\n    printer.println(obj)\n    this\n  }\n  def writeAll(obj: Traversable[Any], separator: String = \" \"): this.type = write(obj mkString separator)\n  def query[A: IO.Read](question: Any): A = writeLine(question).read\n\n  override def flush() = printer.flush()\n  def close() = {\n    flush()\n    in.close()\n    printer.close()\n  }\n}\nobject IO {\n  class Read[A](val apply: IO => A) {\n    def map[B](f: A => B): Read[B] = new Read(apply andThen f)\n  }\n  object Read {\n    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))\n    implicit val string                                       : Read[String]       = new Read(_.next())\n    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)\n    implicit val int                                          : Read[Int]          = string.map(_.toInt)\n    implicit val long                                         : Read[Long]         = string.map(_.toLong)\n    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))\n    implicit val double                                       : Read[Double]       = string.map(_.toDouble)\n    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))\n    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))\n    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]))\n    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]))\n    implicit val boolean                                      : Read[Boolean]      = string map {s =>\n      s.toLowerCase match {\n        case \"yes\" | \"true\" | \"1\" => true\n        case \"no\" | \"false\" | \"0\" => false\n        case _ => s.toBoolean\n      }\n    }\n  }\n}\n\n"}, {"source_code": "import java.util.Scanner\n\nobject Main{\n  def main (args: Array[String]){\n    val sc = new Scanner(System.in)\n\n    var a = sc.nextInt()\n    var b = sc.nextInt()\n\n    var flag = true\n\n    var ans = 0\n    while(flag){\n      ans += 1\n      a = a*3\n      b = b*2\n\n      if(a > b)\n        flag = false\n    }\n\n    println(ans)\n  }\n}\n"}, {"source_code": "object BearandBigBrother791A // extends TSolver {\n                     extends App {\n    import java.io.{InputStream, PrintStream}\n    import java.util.Scanner\n    solve(System.in,System.out)\n    def solve(in: InputStream, out: PrintStream): Unit = {\n      val scanner = new Scanner(in)\n      val a = scanner.nextInt()\n      val b = scanner.nextInt()\n\n      val numYears = (1 to 10).\n        scanLeft((a,b,0: Int)){case ((ap,bp,_),year) => (ap*3,bp*2,year)}.\n        filter{case (at,bt,_) => at>bt}.\n        head._3\n\n      out.println(numYears)\n\n    }\n}"}, {"source_code": "import scala.io.StdIn\n\nobject Codeforces791a extends App {\n  var Array(a, b) = StdIn.readLine().split(\"\\\\s\").map(s => s.toInt)\n  var years = 0\n  while (a <= b) {\n    a *= 3\n    b *= 2\n    years += 1\n  }\n  println(years)\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject Main2 {\n  def main(args: Array[String]): Unit = {\n    val scanner = new Scanner(System.in)\n    val limakWeight = scanner.nextInt()\n    val bobWeight = scanner.nextInt()\n    println(Math.ceil(Math.log(bobWeight.toDouble / limakWeight + 0.00001)/Math.log(1.5)).toInt)\n  }\n}\n"}, {"source_code": "/**\n  * Created by ruslan on 3/18/17.\n  */\nobject ProblemA extends App {\n\n  import java.io.{BufferedReader, InputStreamReader, PrintWriter}\n  import java.util.StringTokenizer\n\n\n  override def main(args: Array[String]): Unit = {\n\n    val br = new BufferedReader(new InputStreamReader(System.in))\n    var st: StringTokenizer = null\n    val out = new PrintWriter(System.out)\n\n    def next: String = {\n      while (st == null || !st.hasMoreTokens) st =\n        new StringTokenizer(br.readLine)\n      st.nextToken\n    }\n\n    def nextInt: Int = next.toInt\n\n    var massLimak: Long = nextInt\n    var massBoba: Long = nextInt\n    var res = 0\n\n    while (massLimak <= massBoba) {\n      res += 1\n      massLimak *= 3\n      massBoba *= 2\n    }\n\n    println(res)\n\n  }\n}"}, {"source_code": "import scala.io.StdIn._\nimport scala.math.pow\n\nobject TaskA extends App {\n  var a :: b :: Nil = readLine().split(\" \").map(_.toInt).toList\n  var year = 1\n  while (a * pow(3, year) <= b * pow(2, year)) year += 1\n  print(year)\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject Solution {\n\tvar Array(a, b) = readLine.split(\" \").map(_.toInt)\n\n\tdef main(args:Array[String]):Unit = {\n\n\t\tvar n = 0\n\t\twhile(a <= b) {\n\t\t\ta *= 3\n\t\t\tb *= 2\n\t\t\tn += 1\n\t\t}\n\t\tprintln(n)\n\t\n\t}\n}\n"}], "negative_code": [{"source_code": "object BearAndBigBrother extends App {\n\n    val inputs = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    val liak = inputs(0)\n    val bob = inputs(1)\n\n    def solution(x: Int, y: Int): Int = {\n        def helper(a: Int, b:Int, c: Int):Int = {\n            if (a == b) 1\n            else if (a > b) c\n            else {\n                helper(a*3, b*2, c+1)\n        }\n        \n    }\n        helper(x,y,2)\n}\n\n    println(solution(liak,bob))\n}"}, {"source_code": "object BearAndBigBrother extends App {\n\n    /*val weights = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    var iLiak = weights(0)\n    var iBob = weights(1)\n    var years = 1\n    while(iLiak <= iBob){\n        iLiak*=3\n        iBob*=2\n        years +=1\n    }\n    println(years)\n\n    */\n    val inputs = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    val liak = inputs(0)\n    val bob = inputs(1)\n\n    def solution(x: Int, y: Int): Int = {\n        def helper(a: Int, b:Int, c: Int):Int = {\n            if (a == b) 1\n            else if (a > b) c\n            else {\n                helper(a*3, b*2, c+1)\n        }\n        \n    }\n        helper(x,y,0)\n}\n\n    println(solution(liak,bob))\n}"}, {"source_code": "object BearAndBigBrother extends App {\n    def solution(x: Int, y: Int): Int = {\n        def helper(a: Int, b:Int, c: Int):Int = {\n            if (a == b) 1\n            else if (a > b) c\n            else {\n                helper(a*3, b*2, c+1)\n            }\n        }\n        helper(x,y,1)\n    }\n    println(solution(4,7))\n}"}, {"source_code": "object BearAndBigBrother extends App {\n\n    val inputs = scala.io.StdIn.readLine().split(\" \").map(_.toInt)\n    val liak = inputs(0)\n    val bob = inputs(1)\n\n    def solution(x: Int, y: Int): Int = {\n        def helper(a: Int, b:Int, c: Int):Int = {\n            if (a == b) 1\n            else if (a > b) c\n            else {\n                helper(a*3, b*2, c+1)\n        }\n        \n    }\n        helper(x,y,1)\n}\n\n    println(solution(liak,bob))\n}"}, {"source_code": "object tanya extends App{\nvar twoNum = readLine().split(\" \")\nvar a = twoNum(0).toInt\nvar b = twoNum(1).toInt\n\n\nfor (n <- 1 to b){\nif(a % 10 == 0){\n    a = a/10\n}else{\n    a = a - 1\n}\n}\nprintln(a)\n}\n"}, {"source_code": "object tanya extends App{\nvar twoNum = readLine().split(\" \")\nvar a = twoNum(0).toInt\nvar b = twoNum(1).toInt\nvar c = 0\n\nwhile(a < b){\n    c += 1\n    a = a * 3\n    b = b * 2\n}\nprintln(c)\n}"}, {"source_code": "import scala.io.StdIn.readLine\n\nobject A791 {\n  def main(args: Array[String]): Unit = {\n    val List(limak, bob) = readToListInts\n    println(solve(limak, bob))\n  }\n\n  def solve(limak: Int, bob: Int): Int = {\n    def aux(a: Int, b: Int, count: Int): Int = {\n      if (a >= b) {\n        count\n      } else {\n        aux(a*3, b*2, count + 1)\n      }\n    }\n    aux(limak, bob, 0)\n  }\n\n  def readToListInts: List[Int] = readLine.split(\" \").map(_.toInt).toList\n}\n\n"}, {"source_code": "import scala.io.StdIn\n\nobject Codeforces971A extends App {\n  val Array(a, b) = StdIn.readLine().split(\"\\\\s\").map(a => a.toDouble)\n\n  if (a == b) {\n    println(\"1\")\n  } else {\n    val r = Math.log(b/a) / (Math.log(3) - Math.log(2))\n    println(Math.ceil(r).toInt.toString)\n  }\n}\n"}, {"source_code": "import java.util.Scanner\n\nobject Main2 {\n  def main(args: Array[String]): Unit = {\n    val scanner = new Scanner(System.in)\n    val limakWeight = scanner.nextInt()\n    val bobWeight = scanner.nextInt()\n    println(Math.ceil(Math.log(((bobWeight + 0000.1) / limakWeight))/Math.log(1.5)).toInt)\n  }\n}\n"}], "src_uid": "a1583b07a9d093e887f73cc5c29e444a"}
{"source_code": "import java.util._\n\nobject CF268A {\n\n    def main(args: Array[String]) {\n        var list1 = Array[Int]()\n        var list2 = Array[Int]()\n        val in = new Scanner(System.in)\n        \n        val n = in.nextInt\n        \n        for (i <- 0 to n - 1) {\n            list1 = list1 :+ in.nextInt\n            list2 = list2 :+ in.nextInt\n        }\n        \n        var count = 0\n        for (i <- 0 to n - 1) {\n            for (j <- 0 to n - 1) {\n                if (i != j && list2(j) == list1(i)) {\n                    count += 1\n                }\n            }\n        }\n        \n        println(count)\n    }\n    \n}", "positive_code": [{"source_code": "object Two68A extends App {\n\n\timport java.io.PrintWriter\n\timport java.util.Scanner\n\tval in = new Scanner(System.in)\n\tval out = new PrintWriter(System.out)\n\timport in._\n\timport out._\n\n\tval n = nextInt\n\tval arr = new Array[(Int, Int)](n)\n\tfor (i <- 0 until n) {\n\t\tarr(i) = (nextInt, nextInt)\n\t}\n\tvar sum = 0\n\tfor (i <- 0 until n; j <- i + 1 until n) {\n\t\tval x1 = arr(i)\n\t\tval x2 = arr(j)\n\t\tif (x1._1 == x2._2) sum += 1\n\t\tif (x2._1 == x1._2) sum += 1\n\t}\n\tprintln(sum)\n\tin.close\n\tout.close\n}"}, {"source_code": "import scala.annotation.tailrec\nimport scala.io.StdIn.readInt\nimport scala.io.StdIn.readLine\n\nobject Main extends App {\n  case class Team(homeColor: Int, guestColor: Int)\n\n  val n = readInt()\n  val teams = (for {\n    _ <- 0 until n\n    Array(hColor, gColor) = readLine().split(\" \").map(_.toInt)\n  } yield Team(hColor, gColor)).toList\n\n  val ans = teams.foldLeft(0)((sum, host) => sum + count(host, teams, 0))\n  println(ans)\n\n  @tailrec\n  def count(host: Team, others: List[Team], acc: Int): Int = others match {\n    case Nil => acc\n    case x :: xs =>\n      if (x.guestColor == host.homeColor) count(host, xs, acc + 1)\n      else count(host, xs, acc)\n  }\n}"}, {"source_code": "import scala.io.StdIn\nimport scala.collection.mutable.ArrayBuffer\n\nobject Main extends App {\n  val n = StdIn.readInt()\n  val array = ArrayBuffer[(Int, Int)]()\n\n  for (_ <- 1 to n) {\n    val str = StdIn.readLine().split(\" \").map(_.toInt)\n    array += ((str(0), str(1)))\n  }\n\n  var count = 0\n\n  for (i <- 1 to n) {\n    for (j <- (i + 1) to n) {\n      if (array(i - 1)._1 == array(j - 1)._2) count += 1\n      if (array(i - 1)._2 == array(j - 1)._1) count += 1\n    }\n  }\n\n  println(count)\n}"}, {"source_code": "import scala.collection.mutable._\nimport scala.math._\nimport scala.util._\nimport scala.util.control.Breaks.break\nimport scala.util.control.Breaks.breakable\nimport java.util._\nobject Main extends App {\n  val sc = new Scanner(System.in)\n  val n = sc.nextInt\n  val t = for(i <- 1 to n) yield (sc.nextInt, sc.nextInt)\n  var cnt = 0\n  for(i <- t) for(j <- t) if(i._1 == j._2) cnt += 1\n  println(cnt)\n}\n"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val n = in.next().toInt\n  val data = Range(0, n).map{ i => in.next().split(\" \")}\n  println(data.map(el => data.count{t => t.last == el.head}).sum)\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val n = readLine().toInt\n    val h = new Array[Int](n)\n    val a = new Array[Int](n)\n    for (i <- 0 to n-1) {\n      val Array(vh, va) = readLine().split(\" \").map(_.toInt)\n      h(i) = vh\n      a(i) = va\n    }\n    \n    println((for (x <- h.iterator; y <- a.iterator) yield (x, y)).filter(x => x._1 == x._2).length)\n  }\n}"}, {"source_code": "object A268 {\n  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)\n\n  def readInts(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)\n  }\n\n  def readLongs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)\n  }\n\n  def readBigs(n: Int) = {\n    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))\n  }\n\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    val input = Array.fill(n)(readInts(2))\n\n    var res = 0\n    for(i <- 0 until n) {\n      for(j <- 0 until n if i != j) {\n        if(input(i)(0) == input(j)(1)) res += 1\n      }\n    }\n\n    println(res)\n  }\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util.Random\n\nobject P268A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val N = sc.nextInt\n  val hs = new Array[Int](N)\n  val as = new Array[Int](N)\n  for (i <- 0 until N) {\n    hs(i) = sc.nextInt\n    as(i) = sc.nextInt\n  }\n\n  val answer: Int = {\n    for {\n      h <- hs\n      a <- as\n      if h == a\n    } yield 1\n  } sum\n\n  out.println(answer)\n  out.close\n}\n"}, {"source_code": "\n\nobject Games {\n\tdef main (args: Array[String]) {\n\t\tval scanner = new java.util.Scanner(System.in);\n\t\tval n = scanner.nextInt();\n\t\t// Parsing input\n\t\tvar teams = new Array[(Int,Int)](n);\n\t\tfor (i <- 0 to n-1) {\n\t\t  teams(i) = (scanner.nextInt(), scanner.nextInt());\n\t\t}\n\t\t// Computation\n\t\tvar output = 0\n\t\tfor (i <- 0 to n-1) {\n\t\t  for (j <- 0 to n-1) {\n\t\t    if (i!=j) {\n\t\t      val (home,_) = teams(i)\n\t\t      val (_, guest) = teams(j)\n\t\t      if (home == guest)\n\t\t        output += 1\n\t\t    }\n\t\t  }\n\t\t}\n\t\tprintln(output)\n\t}\n}"}, {"source_code": "object Matchi extends App {\n  var ss = (Console.readLine.split(\" \")) map (_.toInt)\n  val n = ss(0)\n  \n  def readMatches(nn:Int):List[(Int,Int)] = \n    if (nn == 0) List()\n    else {\n        val sss = (Console.readLine.split(\" \")) map (_.toInt)\n        (sss(0), sss(1)) :: readMatches(nn-1)\n    }\n  \n  \n  def cntMatch(pl:List[(Int,Int)], ac:Int, bc:Int):Int =\n  \tpl match {\n  \tcase Nil => 0\n  \tcase (a,b) :: tl => ((if (b==ac) 1 else 0) +\n  \t\t(if (a==bc) 1 else 0) +\n  \t\tcntMatch(tl, ac,bc))\n  \t}                                         //> cntMatch: (pl: List[(Int, Int)], ac: Int, bc: Int)Int\n  \t\n  def cntSame(pl:List[(Int,Int)]):Int =\n  \tpl match {\n  \tcase Nil => 0\n  \tcase (a,b) :: tl => cntMatch(tl, a,b) + cntSame(tl)\n  \t}   \n  \n  val pl = readMatches(n)\n  println(cntSame(pl))\n}"}, {"source_code": "object A\n{\n    def main(args: Array[String])\n    {\n        val n = readLine().toInt\n        val colors=Array.ofDim[Int](n,2)\n        for (i <- 0 until n)\n        {\n            colors(i)=readLine.split(\" \").map(_.toInt)\n        }\n        println((for(x<- colors.iterator; y<-colors.iterator) yield(x,y)).filter(x => x._1(0) == x._2(1)).length)\n    }\n}\n"}, {"source_code": "import java.io.PrintWriter\nimport java.io.File\nimport java.util.Scanner\n\nobject test5 extends App {\n    val n=readLine.toInt\n    val colors=Array.ofDim[Int](n,2)\n    for(i<-0 until n){\n        colors(i)=readLine.split(\" \").map(_.toInt)\n    }\n    \n    val list=for(i<-0 until n; j<-0 until n if i!=j) yield\n        if(colors(i)(0)==colors(j)(1)) 1 else 0\n        \n    println(list.sum)\n}   \n\n"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val num = readInt()\n    var s = List[(Int, Int)]()\n    for (i <- 0 until num) {\n      val a = readLine().split(\" \").map(_.toInt)\n      s = (a(0), a(1)) :: s\n    }\n    val r = s.foldLeft(0) { (acc, t) => \n      acc + s.foldLeft(0) { (acc, tt) => if (t._1 == tt._2) acc + 1 else acc }\n    }\n    println(r)\n  }\n}"}, {"source_code": "import scala.collection.mutable._\nimport scala.math._\nimport scala.util._\nimport scala.util.control.Breaks.break\nimport scala.util.control.Breaks.breakable\nimport java.util._\nobject problem extends App {\n  val cin = new Scanner(System.in)\n  val n = cin.nextInt()\n  var cnt = 0\n  val t = for(i <- 1 to n) yield (cin.nextInt(), cin.nextInt())\n  for(i <-  t) for(j <- t) if(i._1 == j._2) cnt += 1\n  println(cnt)\n}"}, {"source_code": "\nimport scala.io.StdIn.readLine\nimport scala.io.StdIn.readInt\n\n\nobject Games {\n  \n   def readInts() : Array[Int] =\n     readLine.split(' ').map(_.toInt)\n  \n   def main(args: Array[String]) {\n     val n = readInt\n     val colors = for {\n       i <- 1 to n \n       line = readInts\n     } yield(line(0),line(1))\n     val games = \n       for {\n         i <- 0 to n-1\n         j <- 0 to n-1\n         if (i != j)\n       } yield (i,j)\n     println(games.count(p => colors(p._1)._1 == colors(p._2)._2))\n   }\n  \n}"}, {"source_code": "import scala.Math.pow;\nimport scala.collection.mutable.LinkedList\n\nobject App {\n\tdef readInts:Array[Int] = (readLine split \" \") map (_.toInt)\n                                                  //> readInts: => Array[Int]                              //> solve: (n: Int, m: Int, prev: Int, a: Int, b: Int)(Int, Int)\n\t\n\tdef f1_io() = {\n\t\tval Array(n) = readInts\n\t\tval homeColor = new Array[Int](n)\n\t\tval outColor = new Array[Int](n)\n\t\tfor (i <- 1 to n) {\n\t\t  val a = readInts\n\t\t  homeColor(i - 1) = a(0)\n\t\t  outColor(i - 1) = a(1)\n\t\t}\n\t\t\n\t\tprint ((homeColor map (x => (outColor filter (y => x == y)).length)).sum)\n\t}  \n  def main(args: Array[String]): Unit = {\n\tf1_io\n  }\n\n}"}, {"source_code": "  object Games extends App {\n  \tdef resolve(): Int = {\n  \t\tvar hs = Map[Int, Int]()\n  \t\tvar as = Map[Int, Int]()\n  \t\t\n  \t\tval lines = io.Source.stdin.getLines.toList.tail\n  \t\t\n  \t\tfor (elem <- lines) {\n  \t\t\tval (homekit: Int, awaykit: Int) = {\n  \t\t\t\tval tokens = elem.split(\" \")\n  \t\t\t\t(tokens(0).toInt, tokens(1).toInt)\n  \t\t\t}\n  \t\t\t\n  \t\t\ths = hs + (homekit -> (hs.getOrElse(homekit, 0) + 1))\n  \t\t\tas = as + (awaykit -> (as.getOrElse(awaykit, 0) + 1))\n  \t\t}\n  \t\t\n  \t\tvar sum = 0\n  \t\tfor ((k, v) <- hs) {\n  \t\t\tsum += v * as.getOrElse(k, 0)\n  \t\t}\n  \t\t\n  \t\tsum\n  \t}\n\t\n\tprint(resolve())\n  }"}, {"source_code": "object A00268 extends App {\n  def parseInt(str: String, count: Int): Seq[Int] = {\n    val scanner = new java.util.Scanner(str)\n    val res = (1 to count) map (_ => scanner.nextInt())\n    scanner.close()\n    res\n  }\n  def scanInts(count: Int): Seq[Int] = parseInt(Console.readLine, count)\n  def readMatrix(row: Int, col: Int) = (1 to row) map (x => scanInts(col))\n\n  def oneIntLine = {\n    val Seq(count) = parseInt(Console.readLine(), 1);\n    count\n  }\n\n  def frequency[T](seq: Seq[T]) = seq.groupBy(identity).mapValues(_.size).withDefaultValue(0)\n  \n  val nTeams = oneIntLine\n  val colors = readMatrix(nTeams, 2)\n  val guestColorFreq = frequency(colors.map(_(1)))\n  val result = colors.map(x => guestColorFreq(x(0))).sum\n  println(result)\n}\n"}], "negative_code": [{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val n = in.next().toInt\n  println(in.next().split(\"WUB\").filter(_.nonEmpty).mkString(\" \"))\n}"}, {"source_code": "  object Games extends App {\n  \tdef resolve(): Int = {\n  \t\tvar hs = Map[Int, Int]()\n  \t\tvar as = Map[Int, Int]()\n  \t\t\n  \t\tval lines = io.Source.stdin.getLines.toList.tail\n  \t\t\n  \t\tfor (elem <- lines) {\n  \t\t\tval (homekit: Int, awaykit: Int) = {\n  \t\t\t\tval tokens = elem.split(\" \")\n  \t\t\t\t(tokens(0).toInt, tokens(1).toInt)\n  \t\t\t}\n  \t\t\t\n  \t\t\ths = hs + (homekit -> (hs.getOrElse(homekit, 0) + 1))\n  \t\t\tas = as + (awaykit -> (as.getOrElse(awaykit, 0) + 1))\n  \t\t}\n  \t\t\n  \t\tvar sum = 0\n  \t\tfor ((k, v) <- hs) {\n  \t\t\tsum += v * as.getOrElse(k, 0)\n  \t\t}\n  \t\t\n  \t\tsum\n  \t}\n  }"}], "src_uid": "745f81dcb4f23254bf6602f9f389771b"}
{"source_code": "import scala.util.Sorting\nimport scala.io.StdIn\nobject App {\n  def main(args: Array[String]) {\n\n\n\n    val n = scala.io.StdIn.readInt()\n    val A:Array[Long] = StdIn.readLine().split(\" \").map(_.toLong).sortWith( _ > _)\n\n\n    print(A.zipWithIndex.foldLeft((0L,0L))({\n      case(b,(a,i)) =>\n        if(i == 0) {\n          (a,a)\n        } else {\n          val k = math.max(0, math.min(b._2 - 1, a))\n          (b._1 + k, k)\n        }\n    })._1)\n  }\n\n\n}\n", "positive_code": [{"source_code": "\n/**\n  * Created by octavian on 06/02/2016.\n  */\nobject MakeClass {\n\n  val INF = 1000000005\n\n  def main(args: Array[String]) = {\n\n    //System.setIn(new FileInputStream(\"./src/makeClass.in\"))\n    //System.setOut(new PrintStream(new FileOutputStream(\"./src/makeClass.out\")))\n\n    val N = readInt()\n    val vals = readLine().split(\" \").map(_.toInt).sorted\n\n    var res: BigInt = 0\n    var last = INF\n    for(i <- vals.length - 1 to 0 by -1) {\n      val toAdd = Math.min(vals(i), last - 1)\n      last = toAdd\n      if(toAdd > 0) {\n        res += toAdd\n      }\n    }\n\n    println(res)\n\n  }\n\n}\n"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val n = in.next().toInt\n  var used = Set.empty[Int]\n  println(in.next().split(' ').map(_.toInt).zipWithIndex.foldLeft(0l) {\n    case (acc, (count, index)) =>\n      var nc = count\n      while (nc > 0 && used.contains(nc)) nc -= 1\n      if (nc != 0) {\n        used += nc\n      }\n      acc + nc\n  })\n}"}, {"source_code": "\n\nimport java.io._\nimport java.util\nimport java.util.StringTokenizer\n\nimport scala.annotation.implicitNotFound\nimport scala.collection.mutable\nimport scala.reflect.ClassTag\n\n/**\n  * Created by nimas on 2/4/16.\n  */\nobject MakingAString extends App{\n\n  class Template(val delim: String = \" \") {\n\n    val in = new BufferedReader(new InputStreamReader(System.in))\n    val out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)))\n    val it = Iterator.iterate(new StringTokenizer(\"\"))(tok => if (tok.hasMoreTokens) tok else new StringTokenizer(in.readLine(), delim))\n\n\n    def nextTs[T: ParseAble](n: Int)(delim: String = \" \")(implicit ev: ClassTag[T]) = (Array fill n) {\n      nextT[T](delim)\n    }\n\n    def nextT[T: ParseAble](delim: String = \" \") = {\n      val x = it.find(_.hasMoreTokens)\n      implicitly[ParseAble[T]].parse(x get)\n    }\n\n    def close(): Unit = {\n      in.close()\n      out.close()\n    }\n\n    @implicitNotFound(\"No member of type class ParseAble in scope for ${T}\")\n    trait ParseAble[T] {\n      def parse(strTok: StringTokenizer): T\n    }\n\n    object ParseAble {\n\n      implicit object ParseAbleInt extends ParseAble[Int] {\n        override def parse(strTok: StringTokenizer): Int = strTok nextToken() toInt\n      }\n\n      implicit object ParseAbleLong extends ParseAble[Long] {\n        override def parse(strTok: StringTokenizer): Long = strTok nextToken() toLong\n      }\n\n      implicit object ParseAbleDouble extends ParseAble[Double] {\n        override def parse(strTok: StringTokenizer): Double = strTok nextToken() toDouble\n      }\n\n      implicit object ParseAbleBigInt extends ParseAble[BigInt] {\n        override def parse(strTok: StringTokenizer): BigInt = BigInt(strTok nextToken())\n      }\n\n    }\n\n  }\n\n  val io = new Template()\n\n  import io._\n\n  val n = nextT[Int]()\n  val a = nextTs[Long](n)() sorted Ordering.Long\n\n  val map = new mutable.HashMap[Long, Boolean]()\n\n  out.println((a.iterator map {\n    x => {\n      if (map getOrElse(x, true)) {\n        map put(x, false)\n        x\n      } else {\n        val find = x - 1 to(1, -1) find {\n          !map.contains(_)\n        } getOrElse 0l\n        if (find != 0) map put(find, false)\n        find\n      }\n    }\n  }).sum)\n\n  close()\n\n}\n"}, {"source_code": "import scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util._, control._\nimport scala.math.Ordering.Implicits._\n\nobject _624B extends CodeForcesApp {\n  override type Result = Long\n\n  override def solve(read: Scanner) = {\n    val n = read[Int]\n    val seen = mutable.Set.empty[Long]\n    @tailrec def add(i: Long): Unit = if (seen(i)) add(i-1) else if (i > 0) {val _ = seen += i}\n    repeat(n)(add(read[Long]))\n    seen.sum\n  }\n\n  def repeat(n: Int)(f: => Unit): Unit = (1 to n).foreach(_ => f)\n\n  override def format(result: Result) = result.toString\n}\n/****************************[Ignore Template Below]****************************************/\nabstract class CodeForcesApp {\n  val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  type Result\n  def solve(scanner: Scanner): Result\n  def format(result: Result): String\n  def apply(scanner: Scanner): String = format(solve(scanner))\n  def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))\n}\n/*********************************[Scala Scanner]*******************************************/\nimport java.io.{BufferedReader, Reader, InputStreamReader, StringReader, InputStream}\nimport java.util.StringTokenizer\n\nclass Scanner(reader: BufferedReader) extends Iterator[String] with AutoCloseable {\n  def this(reader: Reader) = this(new BufferedReader(reader))\n  def this(inputStream: InputStream) = this(new InputStreamReader(inputStream))\n  def this(str: String) = this(new StringReader(str))\n\n  private[this] val tokenizers = Iterator.continually(reader.readLine()).takeWhile(_ != null)\n                                         .map(new StringTokenizer(_)).filter(_.hasMoreTokens)\n  private[this] var current: Option[StringTokenizer] = None\n\n  @inline private[this] def tokenizer(): Option[StringTokenizer] = current.find(_.hasMoreTokens) orElse {\n    current = if (tokenizers.hasNext) Some(tokenizers.next()) else None\n    current\n  }\n\n  def apply[A: Parser]: A = implicitly[Parser[A]].apply(next())\n\n  def nextLine(): String = tokenizer().get.nextToken(\"\\n\\r\")\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n  override def close() = reader.close()\n}\n\ntrait Parser[A] {\n  def apply(s: String): A\n}\nobject Parser {\n  def apply[A](f: String => A) = new Parser[A] {\n    override def apply(s: String) = f(s)\n  }\n  implicit val tokenString: Parser[String] = Parser(identity)\n  implicit val tokenChar: Parser[Char] = Parser(s => s.ensuring(_.length == 1, s\"Expected Char; found $s\").head)\n  implicit val tokenBool: Parser[Boolean] = Parser(_.toBoolean)\n  implicit val tokenInt: Parser[Int] = Parser(_.toInt)\n  implicit val tokenLong: Parser[Long] = Parser(_.toLong)\n  implicit val tokenBigInt: Parser[BigInt] = Parser(BigInt(_))\n  implicit val tokenDouble: Parser[Double] = Parser(_.toDouble)\n  implicit val tokenBigDecimal: Parser[BigDecimal] = Parser(BigDecimal(_))\n}\n"}, {"source_code": "import scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util._, control._\nimport scala.math.Ordering.Implicits._\n\nobject _624B extends CodeForcesApp {\n  override type Result = Long\n\n  override def solve(read: InputReader) = {\n    val n = read[Int]\n    val seen = mutable.Set.empty[Long]\n    @tailrec def add(i: Long): Unit = if (seen(i)) add(i-1) else if (i > 0) {val _ = seen += i}\n    repeat(n)(add(read[Long]))\n    seen.sum\n  }\n\n  def repeat(n: Int)(f: => Unit): Unit = (1 to n).foreach(_ => f)\n\n  override def format(result: Result) = result.toString\n}\n/****************************[Ignore Template Below]****************************************/\nabstract class CodeForcesApp {\n  val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  type Result\n  def solve(scanner: InputReader): Result\n  def format(result: Result): String\n  def apply(scanner: InputReader): String = format(solve(scanner))\n  def main(args: Array[String]): Unit = println(apply(new InputReader(System.in)))\n}\n/*********************************[Scala Scanner]*******************************************/\nimport java.io.{BufferedReader, Reader, InputStreamReader, StringReader, InputStream}\nimport java.util.StringTokenizer\n\nclass InputReader(reader: BufferedReader) extends Iterator[String] with AutoCloseable {\n  def this(reader: Reader) = this(new BufferedReader(reader))\n  def this(inputStream: InputStream) = this(new InputStreamReader(inputStream))\n  def this(str: String) = this(new StringReader(str))\n\n  private[this] val tokenizers = Iterator.continually(reader.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n\n  @inline private[this] def tokenizer(): Option[StringTokenizer] = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    if (tokenizers.nonEmpty) Some(tokenizers.head) else None\n  }\n\n  def apply[A: Parser]: A = implicitly[Parser[A]].apply(this)\n\n  def apply[C[_], A: Parser](n: Int)(implicit cbf: Parser.Collection[C, A]): C[A] = {\n    val builder = cbf()\n    for {i <- 1 to n} builder += apply[A]\n    builder.result()\n  }\n\n  def tillEndOfLine(): String = tokenizer().get.nextToken(\"\\n\\r\")\n\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n  override def close() = reader.close()\n}\n\ntrait Parser[A] {\n  def apply(reader: InputReader): A\n}\nobject Parser {\n  def apply[A](f: String => A) = new Parser[A] {\n    override def apply(reader: InputReader) = f(reader.next())\n  }\n  type Collection[C[_], A] = scala.collection.generic.CanBuildFrom[C[A], A, C[A]]\n  implicit def collectionParser[C[_], A: Parser](implicit cbf: Collection[C, A]): Parser[C[A]] = new Parser[C[A]] {\n    override def apply(reader: InputReader) = reader[C, A](reader[Int])\n  }\n  implicit val stringParser: Parser[String] = Parser(identity)\n  implicit val charParser: Parser[Char] = Parser(s => s.ensuring(_.length == 1, s\"Expected Char; found $s\").head)\n  implicit val booleanParser: Parser[Boolean] = Parser(_.toBoolean)\n  implicit val intParser: Parser[Int] = Parser(_.toInt)\n  implicit val longParser: Parser[Long] = Parser(_.toLong)\n  implicit val bigIntParser: Parser[BigInt] = Parser(BigInt(_))\n  implicit val doubleParser: Parser[Double] = Parser(_.toDouble)\n  implicit val bigDecimalParser: Parser[BigDecimal] = Parser(BigDecimal(_))\n}\n"}, {"source_code": "import scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util._, control._\nimport scala.math.Ordering.Implicits._\n\nobject _624B extends CodeForcesApp {\n  override type Result = Long\n\n  override def solve(read: InputReader) = {\n    val n = read[Int]\n    val seen = mutable.Set.empty[Long]\n    @tailrec def add(i: Long): Unit = if (seen(i)) add(i-1) else if (i > 0) {val _ = seen += i}\n    repeat(n)(add(read[Long]))\n    seen.sum\n  }\n\n  def repeat(n: Int)(f: => Unit): Unit = (1 to n).foreach(_ => f)\n\n  override def format(result: Result) = result.toString\n}\n/****************************[Ignore Template Below]****************************************/\nabstract class CodeForcesApp {\n  val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  type Result\n  def solve(scanner: InputReader): Result\n  def format(result: Result): String\n  def apply(scanner: InputReader): String = format(solve(scanner))\n  def main(args: Array[String]): Unit = println(apply(new InputReader(System.in)))\n}\n/*********************************[Scala Scanner]*******************************************/\nimport java.io.{BufferedReader, Reader, InputStreamReader, StringReader, InputStream}\nimport java.util.StringTokenizer\n\nclass InputReader(reader: BufferedReader) extends Iterator[String] with AutoCloseable {\n  def this(reader: Reader) = this(new BufferedReader(reader))\n  def this(inputStream: InputStream) = this(new InputStreamReader(inputStream))\n  def this(str: String) = this(new StringReader(str))\n\n  private[this] val tokenizers = Iterator.continually(reader.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered\n\n  @inline private[this] def tokenizer(): Option[StringTokenizer] = {\n    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()\n    if (tokenizers.nonEmpty) Some(tokenizers.head) else None\n  }\n\n  def apply[A: Parser]: A = implicitly[Parser[A]].apply(next())\n\n  def tillEndOfLine(): String = tokenizer().get.nextToken(\"\\n\\r\")\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n  override def close() = reader.close()\n}\n\ntrait Parser[A] {\n  def apply(s: String): A\n}\nobject Parser {\n  def apply[A](f: String => A) = new Parser[A] {\n    override def apply(s: String) = f(s)\n  }\n  implicit val stringParser: Parser[String] = Parser(identity)\n  implicit val charParser: Parser[Char] = Parser(s => s.ensuring(_.length == 1, s\"Expected Char; found $s\").head)\n  implicit val booleanParser: Parser[Boolean] = Parser(_.toBoolean)\n  implicit val intParser: Parser[Int] = Parser(_.toInt)\n  implicit val longParser: Parser[Long] = Parser(_.toLong)\n  implicit val bigIntParser: Parser[BigInt] = Parser(BigInt(_))\n  implicit val doubleParser: Parser[Double] = Parser(_.toDouble)\n  implicit val bigDecimalParser: Parser[BigDecimal] = Parser(BigDecimal(_))\n}\n"}, {"source_code": "import scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util._, control._\nimport scala.math.Ordering.Implicits._\n\nobject _624B extends CodeForcesApp {\n  override type Result = Long\n\n  override def solve(scanner: Scanner) = {\n    import scanner._\n    val seen = mutable.Set.empty[Long]\n    @tailrec def add(i: Long): Unit = if (seen(i)) add(i-1) else if (i > 0) seen += i\n    repeat(nextInt())(add(nextLong()))\n    seen.sum\n  }\n\n  def repeat(n: Int)(f: => Unit): Unit = (1 to n).foreach(_ => f)\n\n  override def format(result: Result) = result.toString\n}\n/****************************[Ignore Template Below]****************************************/\nabstract class CodeForcesApp {\n  val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  val mod: Int = 1000000007\n  type Result\n  def solve(scanner: Scanner): Result\n  def format(result: Result): String\n  def apply(scanner: Scanner): String = format(solve(scanner))\n  def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))\n}\n/*********************************[Scala Scanner]*******************************************/\nimport java.io._\nimport java.nio.file.{Files, Path}\nimport java.util.StringTokenizer\n\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/21125\n * All next methods throw NoSuchElementException when !hasNext\n */\nclass Scanner(reader: LineNumberReader) extends Iterator[String] with AutoCloseable {\n  def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n  def this(reader: Reader) = this(new BufferedReader(reader))\n  def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n  def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))\n  def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n  def this(str: String) = this(new StringReader(str))\n\n  val lines = Iterator.continually(reader.readLine()).takeWhile(_ != null)\n\n  private[this] val tokenizers = lines.map(new StringTokenizer(_)).filter(_.hasMoreTokens)\n  private[this] var current: Option[StringTokenizer] = None\n\n  @inline private[this] def tokenizer(): Option[StringTokenizer] = current.find(_.hasMoreTokens) orElse {\n    current = if (tokenizers.hasNext) Some(tokenizers.next()) else None\n    current\n  }\n\n  /**\n   * Unlike Java's scanner which returns till end of current line, this actually returns the next line\n   * @see line() if you want the Java behaviour\n   */\n  def nextLine(): String = {\n    current = None   // reset\n    lines.next()\n  }\n  def lineNumber: Int = reader.getLineNumber\n  def line(): String = tokenizer().get.nextToken(\"\\n\\r\")\n  def nextString(): String = next()\n  def nextChar(): Char = next().ensuring(_.length == 1).head\n  def nextBoolean(): Boolean = next().toBoolean\n  def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n  def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n  def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n  def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n  def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n  def nextFloat(): Float = next().toFloat\n  def nextDouble(): Double = next().toDouble\n  def nextBigDecimal(): BigDecimal = BigDecimal(next())\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n  override def close() = reader.close()\n}\n"}, {"source_code": "/**\n  * Created by Andrew Tsibin https://github.com/Evilnef.\n  */\nobject Problemset624 {\n  def main(args: Array[String]): Unit = {\n    val problem = new ProblemB\n    problem.solve()\n  }\n\n  private abstract class Problem {\n    def solve()\n  }\n\n  private class ProblemA extends Problem {\n    override def solve(): Unit = {\n      val Array(d, l, v1, v2) = scala.io.StdIn.readLine().split(\" \").map(_.toDouble)\n      val result = (l - d) / (v1 + v2)\n      println(result)\n    }\n  }\n\n  private class ProblemB extends Problem {\n    override def solve(): Unit = {\n      var maxStringLengths: BigInt = 0\n      val n = scala.io.StdIn.readInt()\n      val a = scala.io.StdIn.readLine().split(\" \").map(BigInt(_)).sortWith(_ > _)\n      for (i <- a.indices) {\n        if (i == 0) maxStringLengths += a(i)\n        else maxStringLengths += {\n          if (a(i) >= a(i - 1))\n            a(i) = a(i - 1) - 1\n          if (a(i) < 0) 0 else a(i)\n        }\n      }\n      println(maxStringLengths)\n    }\n  }\n\n}\n"}, {"source_code": "import scala.util.Sorting\nimport scala.io.StdIn\nobject App {\n  def main(args: Array[String]) {\n\n\n\n    val n = scala.io.StdIn.readInt()\n    val A:Array[Long] = StdIn.readLine().split(\" \").map(_.toLong)\n    Sorting.quickSort(A)\n\n\n    print(A.reverse.zipWithIndex.foldLeft((0L,0L))({\n      case(b,(a,i)) =>\n        if(i == 0) {\n          (a,a)\n        } else {\n          val k = math.max(0, math.min(b._2 - 1, a))\n          (b._1 + k, k)\n        }\n    })._1)\n  }\n\n\n}\n"}, {"source_code": "import scala.util.Sorting\nimport scala.io.StdIn\nobject App {\n  def main(args: Array[String]) {\n\n\n\n    val n = scala.io.StdIn.readInt()\n    val A:Array[Long] = StdIn.readLine().split(\" \").map(_.toLong)\n    Sorting.quickSort(A)\n\n\n    var acc:Long = 0\n    A.reverse.zipWithIndex.foldLeft(0L)({\n      case(b,(a,i)) =>\n        if(i == 0) {\n          acc+=a\n          a\n        } else {\n          acc += math.max(math.min(b - 1, a),0)\n          math.max(math.min(b - 1, a),0)\n        }\n    })\n\n    print(acc)\n\n  }\n\n\n}\n"}, {"source_code": "import scala.util.Sorting\nimport scala.io.StdIn\nobject App {\n  def main(args: Array[String]) {\n\n\n\n    val n = scala.io.StdIn.readInt()\n    val A:Array[Long] = StdIn.readLine().split(\" \").map(_.toLong).sorted.reverse\n\n\n    print(A.zipWithIndex.foldLeft((0L,0L))({\n      case(b,(a,i)) =>\n        if(i == 0) {\n          (a,a)\n        } else {\n          val k = math.max(0, math.min(b._2 - 1, a))\n          (b._1 + k, k)\n        }\n    })._1)\n  }\n\n\n}\n"}], "negative_code": [{"source_code": "\n/**\n  * Created by octavian on 06/02/2016.\n  */\nobject MakeClass {\n\n  val INF = 1000000005\n\n  def main(args: Array[String]) = {\n\n    //System.setIn(new FileInputStream(\"./src/makeClass.in\"))\n    //System.setOut(new PrintStream(new FileOutputStream(\"./src/makeClass.out\")))\n\n    val N = readInt()\n    var vals = readLine().split(\" \").map(_.toInt)\n\n    var res = 0\n    var last = INF\n    for(i <- vals.length - 1 to 0 by -1) {\n      val toAdd = Math.min(vals(i), last - 1)\n      last = toAdd\n      if(toAdd > 0) {\n        res += toAdd\n      }\n    }\n\n    println(res)\n\n  }\n\n}\n"}, {"source_code": "\n/**\n  * Created by octavian on 06/02/2016.\n  */\nobject MakeClass {\n\n  val INF = 1000000005\n\n  def main(args: Array[String]) = {\n\n    //System.setIn(new FileInputStream(\"./src/makeClass.in\"))\n    //System.setOut(new PrintStream(new FileOutputStream(\"./src/makeClass.out\")))\n\n    val N = readInt()\n    val vals = readLine().split(\" \").map(_.toInt).sorted\n\n    var res = 0\n    var last = INF\n    for(i <- vals.length - 1 to 0 by -1) {\n      val toAdd = Math.min(vals(i), last - 1)\n      last = toAdd\n      if(toAdd > 0) {\n        res += toAdd\n      }\n    }\n\n    println(res)\n\n  }\n\n}\n"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val n = in.next().toInt\n  val arr = Array.ofDim[Int](26)\n  var used = Set.empty[Int]\n  in.next().split(' ').map(_.toInt).zipWithIndex.foreach {\n    case (count, index) =>\n      var nc = count\n      while (nc > 0 && used.contains(nc)) nc -= 1\n      if (nc != 0) {\n        arr(index) = nc\n        used += nc\n      }\n  }\n  println(arr.sum)\n\n\n}"}, {"source_code": "\nimport java.io._\nimport java.util\nimport java.util.StringTokenizer\n\nimport scala.annotation.implicitNotFound\nimport scala.collection.mutable\nimport scala.reflect.ClassTag\n\n/**\n  * Created by nimas on 2/4/16.\n  */\nobject MakingAString extends App{\n\n  class Template(val delim: String = \" \") {\n\n    val in = new BufferedReader(new InputStreamReader(System.in))\n    val out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)))\n    val it = Iterator.iterate(new StringTokenizer(\"\"))(tok => if (tok.hasMoreTokens) tok else new StringTokenizer(in.readLine(), delim))\n\n\n    def nextTs[T: ParseAble](n: Int)(delim: String = \" \")(implicit ev: ClassTag[T]) = (Array fill n) {\n      nextT[T](delim)\n    }\n\n    def nextT[T: ParseAble](delim: String = \" \") = {\n      val x = it.find(_.hasMoreTokens)\n      implicitly[ParseAble[T]].parse(x get)\n    }\n\n    def close(): Unit = {\n      in.close()\n      out.close()\n    }\n\n    @implicitNotFound(\"No member of type class ParseAble in scope for ${T}\")\n    trait ParseAble[T] {\n      def parse(strTok: StringTokenizer): T\n    }\n\n    object ParseAble {\n\n      implicit object ParseAbleInt extends ParseAble[Int] {\n        override def parse(strTok: StringTokenizer): Int = strTok nextToken() toInt\n      }\n\n      implicit object ParseAbleLong extends ParseAble[Long] {\n        override def parse(strTok: StringTokenizer): Long = strTok nextToken() toLong\n      }\n\n      implicit object ParseAbleDouble extends ParseAble[Double] {\n        override def parse(strTok: StringTokenizer): Double = strTok nextToken() toDouble\n      }\n\n      implicit object ParseAbleBigInt extends ParseAble[BigInt] {\n        override def parse(strTok: StringTokenizer): BigInt = BigInt(strTok nextToken())\n      }\n\n    }\n\n  }\n\n  val io = new Template()\n\n  import io._\n\n  val n = nextT[Int]()\n  val a = nextTs[Int](n)() sorted Ordering.Int\n\n  val map = new mutable.HashMap[Int, Boolean]()\n\n\n  out.println((a.iterator map {\n    x => {\n      if (map getOrElse(x, true)) {\n        map put(x, false)\n        x\n      } else {\n        x - 1 to(1, -1) find {\n          !map.contains(_)\n        } getOrElse 0\n      }\n    }\n  }).sum)\n\n  close()\n\n}\n"}, {"source_code": "\n\nimport java.io._\nimport java.util\nimport java.util.StringTokenizer\n\nimport scala.annotation.implicitNotFound\nimport scala.collection.mutable\nimport scala.reflect.ClassTag\n\n/**\n  * Created by nimas on 2/4/16.\n  */\nobject MakingAString extends App{\n\n  class Template(val delim: String = \" \") {\n\n    val in = new BufferedReader(new InputStreamReader(System.in))\n    val out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)))\n    val it = Iterator.iterate(new StringTokenizer(\"\"))(tok => if (tok.hasMoreTokens) tok else new StringTokenizer(in.readLine(), delim))\n\n\n    def nextTs[T: ParseAble](n: Int)(delim: String = \" \")(implicit ev: ClassTag[T]) = (Array fill n) {\n      nextT[T](delim)\n    }\n\n    def nextT[T: ParseAble](delim: String = \" \") = {\n      val x = it.find(_.hasMoreTokens)\n      implicitly[ParseAble[T]].parse(x get)\n    }\n\n    def close(): Unit = {\n      in.close()\n      out.close()\n    }\n\n    @implicitNotFound(\"No member of type class ParseAble in scope for ${T}\")\n    trait ParseAble[T] {\n      def parse(strTok: StringTokenizer): T\n    }\n\n    object ParseAble {\n\n      implicit object ParseAbleInt extends ParseAble[Int] {\n        override def parse(strTok: StringTokenizer): Int = strTok nextToken() toInt\n      }\n\n      implicit object ParseAbleLong extends ParseAble[Long] {\n        override def parse(strTok: StringTokenizer): Long = strTok nextToken() toLong\n      }\n\n      implicit object ParseAbleDouble extends ParseAble[Double] {\n        override def parse(strTok: StringTokenizer): Double = strTok nextToken() toDouble\n      }\n\n      implicit object ParseAbleBigInt extends ParseAble[BigInt] {\n        override def parse(strTok: StringTokenizer): BigInt = BigInt(strTok nextToken())\n      }\n\n    }\n\n  }\n\n  val io = new Template()\n\n  import io._\n\n  val n = nextT[Int]()\n  val a = nextTs[Int](n)() sorted Ordering.Int\n\n  val map = new mutable.HashMap[Int, Boolean]()\n\n\n  out.println((a.iterator map {\n    x => {\n      if (map getOrElse(x, true)) {\n        map put(x, false)\n        x\n      } else {\n        val find = x - 1 to(1, -1) find {\n          !map.contains(_)\n        } getOrElse 0\n        if (find != 0) map put(find, false)\n        find\n      }\n    }\n  }).sum)\n\n  close()\n\n}\n"}, {"source_code": "import scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.util._, control._\nimport scala.math.Ordering.Implicits._\n\nobject _624B extends CodeForcesApp {\n  override type Result = Int\n\n  override def solve(scanner: Scanner) = {\n    import scanner._\n    val n = nextInt()\n    val seen = mutable.Set.empty[Int]\n    @tailrec def add(i: Int): Unit = if (seen(i)) add(i-1) else if (i > 0) seen += i\n    repeat(n)(add(nextInt()))\n    seen.sum\n  }\n\n  def repeat(n: Int)(f: => Unit): Unit = (1 to n).foreach(_ => f)\n\n  override def format(result: Result) = result.toString\n}\n/****************************[Ignore Template Below]****************************************/\nabstract class CodeForcesApp {\n  val isOnlineJudge: Boolean = sys.props.get(\"ONLINE_JUDGE\").exists(_.toBoolean)\n  def debug(x: Any): Unit = if (!isOnlineJudge) println(x)\n  val mod: Int = 1000000007\n  type Result\n  def solve(scanner: Scanner): Result\n  def format(result: Result): String\n  def apply(scanner: Scanner): String = format(solve(scanner))\n  def main(args: Array[String]): Unit = println(apply(new Scanner(System.in)))\n}\n/*********************************[Scala Scanner]*******************************************/\nimport java.io._\nimport java.nio.file.{Files, Path}\nimport java.util.StringTokenizer\n\nimport scala.io.Codec\n\n/**\n * Scala implementation of a faster java.util.Scanner\n * See: http://codeforces.com/blog/entry/21125\n * All next methods throw NoSuchElementException when !hasNext\n */\nclass Scanner(reader: LineNumberReader) extends Iterator[String] with AutoCloseable {\n  def this(reader: BufferedReader) = this(new LineNumberReader(reader))\n  def this(reader: Reader) = this(new BufferedReader(reader))\n  def this(inputStream: InputStream)(implicit codec: Codec) = this(new InputStreamReader(inputStream, codec.charSet))\n  def this(path: Path)(implicit codec: Codec) = this(Files.newBufferedReader(path, codec.charSet))\n  def this(file: File)(implicit codec: Codec) = this(file.toPath)(codec)\n  def this(str: String) = this(new StringReader(str))\n\n  val lines = Iterator.continually(reader.readLine()).takeWhile(_ != null)\n\n  private[this] val tokenizers = lines.map(new StringTokenizer(_)).filter(_.hasMoreTokens)\n  private[this] var current: Option[StringTokenizer] = None\n\n  @inline private[this] def tokenizer(): Option[StringTokenizer] = current.find(_.hasMoreTokens) orElse {\n    current = if (tokenizers.hasNext) Some(tokenizers.next()) else None\n    current\n  }\n\n  /**\n   * Unlike Java's scanner which returns till end of current line, this actually returns the next line\n   * @see line() if you want the Java behaviour\n   */\n  def nextLine(): String = {\n    current = None   // reset\n    lines.next()\n  }\n  def lineNumber: Int = reader.getLineNumber\n  def line(): String = tokenizer().get.nextToken(\"\\n\\r\")\n  def nextString(): String = next()\n  def nextChar(): Char = next().ensuring(_.length == 1).head\n  def nextBoolean(): Boolean = next().toBoolean\n  def nextByte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)\n  def nextShort(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)\n  def nextInt(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)\n  def nextLong(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)\n  def nextBigInt(radix: Int = 10): BigInt = BigInt(next(), radix)\n  def nextFloat(): Float = next().toFloat\n  def nextDouble(): Double = next().toDouble\n  def nextBigDecimal(): BigDecimal = BigDecimal(next())\n  override def next() = tokenizer().get.nextToken()\n  override def hasNext = tokenizer().nonEmpty\n  override def close() = reader.close()\n}\n"}, {"source_code": "/**\n  * Created by Andrew Tsibin https://github.com/Evilnef.\n  */\nobject Problemset624 {\n  def main(args: Array[String]): Unit = {\n    val problem = new ProblemB\n    problem.solve()\n  }\n\n  private abstract class Problem {\n    def solve()\n  }\n\n  private class ProblemA extends Problem {\n    override def solve(): Unit = {\n      val Array(d, l, v1, v2) = scala.io.StdIn.readLine().split(\" \").map(_.toDouble)\n      val result = (l - d) / (v1 + v2)\n      println(result)\n    }\n  }\n\n  private class ProblemB extends Problem {\n    override def solve(): Unit = {\n      var maxStringLengths = 0\n      val n = scala.io.StdIn.readInt()\n      val a = scala.io.StdIn.readLine().split(\" \").map(_.toInt).sortWith(_ > _)\n      for (i <- a.indices) {\n        if (i == 0) maxStringLengths += a(i)\n        else maxStringLengths += {\n          if (a(i) >= a(i - 1))\n            a(i) = a(i - 1) - 1\n          if (a(i) < 0) 0 else a(i)\n        }\n      }\n      println(maxStringLengths)\n    }\n  }\n\n}\n"}, {"source_code": "import scala.util.Sorting\nimport scala.io.StdIn\nobject App {\n  def main(args: Array[String]) {\n\n\n\n    val n = scala.io.StdIn.readInt()\n    val A:Array[Int] = StdIn.readLine().split(\" \").map(_.toInt)\n    Sorting.quickSort(A)\n\n\n    var acc = 0\n    A.reverse.zipWithIndex.foldLeft(0)({\n      case(b,(a,i)) =>\n        if(i == 0) {\n          acc+=a\n          a\n        } else {\n          acc += math.max(math.min(b - 1, a),0)\n          math.max(math.min(b - 1, a),0)\n        }\n    })\n\n    print(acc)\n\n  }\n\n\n}\n"}], "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f"}
{"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport java.util.Arrays.binarySearch\nimport scala.annotation.tailrec\nimport scala.annotation.switch\nimport scala.annotation.unchecked\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.collection.mutable.ArrayBuffer\nimport scala.collection.immutable.TreeSet\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\n\nobject P133B extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n    // \">\"  →  1000,\n    // \"<\"  →  1001,\n    // \"+\"  →  1010,\n    // \"-\"  →  1011,\n    // \".\"  →  1100,\n    // \",\"  →  1101,\n    // \"[\"  →  1110,\n    // \"]\"  →  1111. \n\n  \n  val M = Map('>' -> 8,\n              '<' -> 9,\n              '+' -> 10,\n              '-' -> 11,\n              '.' -> 12,\n              ',' -> 13,\n              '[' -> 14,\n              ']' -> 15)\n\n  val P = 1000003\n\n  def solve(): Int = {\n    val BF = sc.nextLine\n\n    BF.foldLeft(0) { (b, a) =>\n      ((b << 4) | M(a)) % P\n    }\n  }\n\n  out.println(solve)\n  out.close\n}\n", "positive_code": [{"source_code": "object Main {\n    def main(args : Array[String]) =\n        println (readLine.foldLeft (0) (\n            (ans, x) => ((ans << 4) | ((\"><+-.,[]\" indexOf x) + 8)) % 1000003\n        ))\n}"}, {"source_code": "object Main {\n    def main(args : Array[String]) =\n        println (readLine.foldLeft (0) (\n            (ans, x) => ((ans << 4) | ((\"><+-.,[]\" indexOf x) + 8)) % 1000003\n        ))\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val s = readLine()\n    val tr = s.map{\n      case '>' => 8\n      case '<' => 9\n      case '+' => 10\n      case '-' => 11\n      case '.' => 12\n      case ',' => 13\n      case '[' => 14\n      case ']' => 15\n    }\n    println(tr.foldLeft(0){ (acc, i) => (acc * 16 + i) % 1000003} )\n  }\n}"}, {"source_code": "object Main {\n    def main(args : Array[String]) =\n        println (readLine.foldLeft (0) (\n            (ans, x) => ((ans << 4) | ((\"><+-.,[]\" indexOf x) + 8)) % 1000003\n        ))\n}"}, {"source_code": "object Main {\n    def main(args : Array[String]) =\n        println (readLine.foldLeft (0) (\n            (ans, x) => ((ans << 4) | ((\"><+-.,[]\" indexOf x) + 8)) % 1000003\n        ))\n}"}, {"source_code": "import java.util.Scanner\nobject P133B extends App {\n  \n  val map = Map('>' -> \"1000\", '<' -> \"1001\", '+' -> \"1010\", '-' -> \"1011\", \n      '.' -> \"1100\", ',' -> \"1101\", '[' -> \"1110\", ']' -> \"1111\")\n  val s = new Scanner(System.in).next()\n\n  var res = \"\"\n  for(c <- s) res += map(c) \n\n  println(BigInt(res,2) % 1000003)\n  \n}"}, {"source_code": "import java.util.Scanner\nobject P133B extends App {\n  val m = Map('>'->\"1000\",'<'->\"1001\",'+'->\"1010\",'-'->\"1011\",'.'->\"1100\",','->\"1101\",'['->\"1110\",']'->\"1111\")\n  val s = new Scanner(System.in).next()\n  println(BigInt(s.map(m).mkString,2) % 1000003)\n}"}, {"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val str = in.next()\n\n  val map = Map(\n    '>' -> 8,\n    '<' -> 9,\n    '+' -> 10,\n    '-' -> 11,\n    '.' -> 12,\n    ',' -> 13,\n    '[' -> 14,\n    ']' -> 15)\n\n  println(str.foldLeft(0l) {\n    case (acc, ch) => ((acc << 4)  | map(ch)) % 1000003\n  } % 1000003)\n\n}"}, {"source_code": "\nobject Main {\n    def main(args : Array[String]) =\n        println (readLine.foldLeft (0) (\n            (ans, x) => ((ans << 4) | ((\"><+-.,[]\" indexOf x) + 8)) % 1000003\n        ))\n}\n"}], "negative_code": [{"source_code": "object Solution extends App {\n  val in = scala.io.Source.stdin.getLines()\n  val str = in.next()\n\n  val map = Map(\n    '>' -> 8,\n    '<' -> 9,\n    '+' -> 10,\n    '-' -> 11,\n    '.' -> 12,\n    ',' -> 13,\n    '[' -> 14,\n    ']' -> 15)\n\n  println(str.foldLeft(0l) {\n    case (acc, ch) => Math.abs(acc << 4) + map(ch)\n  } % 1000003)\n\n}"}], "src_uid": "04fc8dfb856056f35d296402ad1b2da1"}
{"source_code": "object Solution extends App{\n  val in = scala.io.Source.stdin.getLines()\n  var Array(t, s, q) = in.next().split(\" \").map(_.toInt)\n  var count = 0\n  while (s < t) {\n    s *= q\n    count += 1\n  }\n  println(count)\n\n}\n", "positive_code": [{"source_code": "object A569 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def main(args: Array[String]): Unit = {\n    var Array(t, s, q) = readInts(3)\n    var res = 0\n    while(s < t) {\n      s *= q\n      res += 1\n    }\n    out.println(res)\n    out.close()\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(\"src/input\")))\n    val out = new java.io.PrintWriter(System.out)\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject A extends App {\n  val Array(t, s, q) = readLine().split(\" \").map(_.toInt)\n\n  var played = 0\n  var started = 1\n  var current = 0\n\n  while (s + (current * ((q - 1.0) / q)) < t) {\n    if (played + 1 <= s + ((current + 1) * ((q - 1.0) / q))) {\n      played += 1\n    } else {\n      played = 1\n      started += 1\n    }\n\n    current += 1\n  }\n\n  println(started)\n}\n"}, {"source_code": "\nimport java.util.Scanner\n\nobject PA extends App {\n    var in = new Scanner(System.in)\n    val Vector(t, s, q) = (1 to 3).map(_ => in.nextInt())\n    def sol(ns:Int):Int = if(ns >= t) 0 else sol(ns*q) + 1\n    println(sol(s).toString)\n}\n\n\n"}, {"source_code": "import java.io._\nimport java.util._\n\nimport scala.collection.mutable\n\nobject A {\n\n  var out: PrintWriter = null\n  var br: BufferedReader = null\n  var st: StringTokenizer = null\n\n  def main(args: Array[String]): Unit = {\n    br = new BufferedReader(new InputStreamReader(System.in))\n    out = new PrintWriter(new BufferedOutputStream(System.out))\n    solve\n    out.close\n  }\n\n  def next: String = {\n    while (st == null || !st.hasMoreTokens) {\n      st = new StringTokenizer(br.readLine)\n    }\n    return st.nextToken\n  }\n\n  def nextInt: Int = return Integer.parseInt(next)\n\n  def nextLong: Long = return java.lang.Long.parseLong(next)\n\n  def nextDouble: Double = return java.lang.Double.parseDouble(next)\n\n  class MultiHashSet[T <% Comparable[T]] {\n    val map = new mutable.HashMap[T, Int]()\n\n    def count(x: T): Int = {\n      return map.getOrElse(x, 0)\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  class MultiTreeSet[T <% Comparable[T]] {\n    val map = new TreeMap[T, Int]()\n\n    def count(x: T): Int = {\n      val res = map.get(x)\n      if (res == null)\n        return 0\n      return res\n    }\n\n    def add(x: T): Unit = map.put(x, count(x) + 1)\n\n    def first(): T = return map.firstKey()\n\n    def last(): T = return map.lastKey()\n\n    def remove(x: T): Boolean = {\n      val prev = count(x)\n      if (prev == 0)\n        return false\n      if (prev == 1) {\n        map.remove(x)\n      } else {\n        map.put(x, prev - 1)\n      }\n      return true\n    }\n  }\n\n  /**\n   * Segment tree for any commutative function\n   * @param values Array of Int\n   * @param commutative function like min, max, sum\n   * @param zero zero value - e.g. 0 for sum, Inf for min, max\n   */\n  class SegmentTree(values: Array[Int])(commutative: (Int, Int) => Int)(zero: Int) {\n    private val SIZE = 1e5.toInt\n    private val n = values.length\n    val t = new Array[Int](2 * n)\n    Array.copy(values, 0, t, n, n)\n\n    // build segment tree\n    def build = {\n      for (i <- n - 1 until 0 by -1) {\n        t(i) = commutative(t(2 * i), t(2 * i + 1))\n      }\n    }\n\n    // change value at position p to x\n    // TODO beatify\n    def modify(p: Int, x: Int) = {\n      var pos = p + n\n      t(pos) = x\n      while (pos > 1) {\n        t(pos / 2) = commutative(t(pos), t(pos ^ 1))\n        pos /= 2\n      }\n    }\n\n    // TODO implement me!\n    def modify(p: Int, left: Int, right: Int) = ???\n\n    def query(p: Int) = ???\n\n    // sum [l, r)\n    // min l = 0\n    // max r = n\n    // TODO beatify\n    def query(left: Int, right: Int): Int = {\n      var res = zero\n      var r = right + n\n      var l = left + n\n      while (l < r) {\n        if (l % 2 == 1) {\n          res = commutative(res, t(l))\n          l += 1\n        }\n        if (r % 2 == 1) {\n          r -= 1\n          res = commutative(res, t(r))\n        }\n        l /= 2\n        r /= 2\n      }\n      res\n    }\n  }\n\n  def solve: Int = {\n    val t = nextInt\n    var s = nextInt\n    val q = nextInt\n    var count = 0\n    while (s < t) {\n      s *= q\n      count += 1\n    }\n    out.println(count)\n    return 0\n  }\n}\n"}], "negative_code": [{"source_code": "import scala.io.StdIn._\n\nobject A extends App {\n  val Array(t, s, q) = readLine().split(\" \").map(_.toInt)\n\n  var downloaded = s.toDouble\n  var played = 0\n  var started = 1\n\n  var speed = (q - 1.0) / q\n\n  while (downloaded < t) {\n    downloaded += speed\n\n    if (played + 1 <= downloaded) {\n      played += 1\n    } else {\n      played = 0\n      started += 1\n    }\n  }\n\n  println(started)\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject A extends App {\n  val Array(t, s, q) = readLine().split(\" \").map(_.toInt)\n\n  var downloaded = s.toDouble\n  var played = 0\n  var started = 1\n\n  var speed = (q - 1.0) / q\n\n  while (downloaded < t) {\n    downloaded += speed\n\n    if (played + 1 <= downloaded) {\n      played += 1\n    } else {\n      played = 1\n      started += 1\n    }\n  }\n\n  println(started)\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject A extends App {\n  val Array(t, s, q) = readLine().split(\" \").map(_.toInt)\n\n  var downloaded = s.toDouble\n  var played = 0\n  var started = 1\n\n  var speed = (q - 1.0) / q\n\n  downloaded += speed\n\n  while (downloaded < t) {\n\n    if (played + 1 <= downloaded) {\n      played += 1\n    } else {\n      played = 1\n      started += 1\n    }\n\n    downloaded += speed\n  }\n\n  println(started)\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject A extends App {\n  val Array(t, s, q) = readLine().split(\" \").map(_.toInt)\n\n  var downloaded = s.toDouble\n  var played = 0\n  var started = 1\n\n  var speed = (q - 1.0) / q\n\n  downloaded += speed\n\n  while (downloaded < t) {\n\n    if (played + 1 <= downloaded) {\n      played += 1\n    } else {\n      played = 0\n      started += 1\n    }\n\n    downloaded += speed\n  }\n\n  println(started)\n}\n"}, {"source_code": "import scala.io.StdIn._\n\nobject A extends App {\n  val Array(t, s, q) = readLine().split(\" \").map(_.toInt)\n\n  var downloaded = s.toDouble\n  var played = 0\n  var started = 1\n\n  var speed = (q - 1.0) / q\n\n  while (downloaded < t) {\n    downloaded += speed\n\n    if (downloaded < t && played + 1 <= downloaded) {\n      played += 1\n    } else if (downloaded < t) {\n      played = 0\n      started += 1\n    }\n  }\n\n  println(started)\n}\n"}, {"source_code": "object Solution extends App{\n  val in = scala.io.Source.stdin.getLines()\n  val Array(t, s, q) = in.next().split(\" \").map(_.toInt)\n  var downloaded = 2 * s * (q - 1)\n  var count = 1\n  while (downloaded < t) {\n    downloaded += downloaded * (q - 1)\n    count += 1\n  }\n  println(count)\n\n}\n"}], "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9"}
{"source_code": "object Main {\n  def main(args: Array[String]) {\n    val Array(n, r1, r0) = readLine().split(\" \").map(_.toInt)\n    if (n == 1 && r1 >= r0) println(\"YES\")\n    else if (r1 > r0) {\n      val angle = math.Pi / n\n      if (r0.toDouble / (r1 - r0).toDouble - math.sin(angle) <= 0.000000001) println(\"YES\")\n      else (println(\"NO\"))\n    } else println(\"NO\")\n  }\n}", "positive_code": [{"source_code": "object P140A extends App {\n\n  val Array(n, bigR, r) = readLine.split(\" \").map(_.toInt)\n\n  def findSide(angle: Double, a: Double) = a / math.sin(math.toRadians(angle))\n\n  val condition = if (n < 3) bigR >= n * r else math.abs(findSide(180.0 / n, r)) + r <= bigR\n\n  print(if (condition) \"YES\" else \"NO\")\n\n}\n"}, {"source_code": "object main {\n  \n    \n \n    def main(args: Array[String]) = {\n        \n        val tokens = (readLine()) split \" \" map Integer.parseInt\n        val n = tokens apply 0\n        val R = tokens apply 1\n        val r = tokens apply 2\n        if (n == 1) {if (R >= r) println (\"YES\") else println(\"NO\")}\n        else if ((R-r)*math.sin(math.Pi/n)>=r-0.00000001) println (\"YES\") else println(\"NO\")\n    }\n}"}, {"source_code": "import scala.io.Source\nobject A {\n\n  def main(arg: Array[String]) = {\n    val in = Source.stdin.getLine(0).split(\" \").map(_.toInt)\n    val n = in(0)\n    val R = in(1).toDouble\n    val r = in(2).toDouble\n\n    if (n == 1) {\n      if (r <= R)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    } else if (r*2.0 > R)\n      println(\"NO\")\n    else {\n      val a = Math.asin(r / (R - r))\n      val fit = Math.floor(2 * Math.Pi / a + 1E-7).toInt / 2\n\n      if (n <= fit)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    }\n  }\n}"}], "negative_code": [{"source_code": "import scala.io.Source\nobject A {\n\n  def main(arg: Array[String]) = {\n    val in = Source.stdin.getLine(0).split(\" \").map(_.toInt)\n    val n = in(0)\n    val R = in(1).toDouble\n    val r = in(2).toDouble\n\n    if (n == 1) {\n      if (r <= R)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    } else if (r*2.0 > R)\n      println(\"NO\")\n    else {\n      val a = Math.asin(r / (R - r))\n      val fit = Math.floor(2 * Math.Pi / (a-(1E-7))).toInt / 2\n\n      if (n <= fit)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    }\n  }\n}"}, {"source_code": "import scala.io.Source\nobject A {\n\n  def main(arg: Array[String]) = {\n    val in = Source.stdin.getLine(0).split(\" \").map(_.toInt)\n    val n = in(0)\n    val R = in(1).toDouble\n    val r = in(2).toDouble\n\n    if (n == 1) {\n      if (r <= R)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    } else if (r*2.0 > R)\n      println(\"NO\")\n    else {\n      val a = Math.asin(r / (R - r))\n      val fit = Math.floor(2 * Math.Pi / (a-0.001)).toInt / 2\n\n      if (n <= fit)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    }\n  }\n}"}, {"source_code": "import scala.io.Source\nobject A {\n\n  def main(arg: Array[String]) = {\n    val in = Source.stdin.getLine(0).split(\" \").map(_.toInt)\n    val n = in(0)\n    val R = in(1).toDouble\n    val r = in(2).toDouble\n\n    if (n == 1) {\n      if (r <= R)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    } else if (r*2.0 > R)\n      println(\"NO\")\n    else {\n      val a = Math.asin(r / (R - r))\n      val fit = Math.floor(2 * Math.Pi / a).toInt / 2\n\n      if (n <= fit)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    }\n  }\n}"}, {"source_code": "import scala.io.Source\nobject A {\n\n  def main(arg: Array[String]) = {\n    val in = Source.stdin.getLine(0).split(\" \").map(_.toInt)\n    val n = in(0)\n    val R = in(1).toDouble\n    val r = in(2).toDouble\n\n    if (n == 1) {\n      if (r <= R)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    } else if (r*2.0 > R)\n      println(\"NO\")\n    else {\n      val a = Math.asin(r / (R - r))\n      val fit = Math.floor(2 * Math.Pi / a + Math.EPS_DOUBLE).toInt / 2\n\n      if (n <= fit)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    }\n  }\n}"}, {"source_code": "import scala.io.Source\nobject A {\n\n  def main(arg: Array[String]) = {\n    val in = Source.stdin.getLine(0).split(\" \").map(_.toInt)\n    val n = in(0)\n    val R = in(1).toDouble\n    val r = in(2).toDouble\n\n    if (n == 1) {\n      if (r <= R)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    } else if (r*2.0 > R)\n      println(\"NO\")\n    else {\n      val a = Math.asin(r / (R - r))\n      val fit = Math.floor(2 * Math.Pi / (a-(Math.EPS_DOUBLE))).toInt / 2\n\n      if (n <= fit)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    }\n  }\n}"}, {"source_code": "import scala.io.Source\nobject A {\n\n  def main(arg: Array[String]) = {\n    val in = Source.stdin.getLine(0).split(\" \").map(_.toInt)\n    val n = in(0)\n    val R = in(1).toDouble\n    val r = in(2).toDouble\n\n    if (n == 1) {\n      if (r <= R)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    } else if (r*2.0 > R)\n      println(\"NO\")\n    else {\n      val a = Math.asin(r / (R - r))\n      val fit = Math.floor(2 * Math.Pi / (a+(Math.EPS_DOUBLE))).toInt / 2\n\n      if (n <= fit)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    }\n  }\n}"}, {"source_code": "import scala.io.Source\nobject A {\n\n  def main(arg: Array[String]) = {\n    val in = Source.stdin.getLine(0).split(\" \").map(_.toInt)\n    val n = in(0)\n    val R = in(1).toDouble\n    val r = in(2).toDouble\n\n    if (n == 1) {\n      if (r <= R)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    } else if (r*2.0 > R)\n      println(\"NO\")\n    else {\n      val a = Math.asin(r / (R - r))\n      \n      println (a)\n      val fit = Math.floor(2 * Math.Pi / a + Math.EPS_DOUBLE).toInt / 2\n\n      \n      println (fit)\n      if (n <= fit)\n        println(\"YES\")\n      else\n        println(\"NO\")\n    }\n  }\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val Array(n, r1, r0) = readLine().split(\" \").map(_.toInt)\n    if (n == 1 && r1 >= r0) println(\"YES\")\n    else if (r1 > r0) {\n      val angle = math.Pi / n\n      if (r0.toDouble / (r1 - r0).toDouble <= math.sin(angle)) println(\"YES\")\n      else (println(\"NO\"))\n    } else println(\"NO\")\n  }\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val Array(n, r1, r0) = readLine().split(\" \").map(_.toInt)\n    if (n == 1 && r1 >= r0) println(\"YES\")\n    else if (r1 > r0) {\n      val angle = math.Pi / n\n      if (r0.toDouble / (r1 - r0).toDouble - math.sin(angle) <= 0.0000001) println(\"YES\")\n      else (println(\"NO\"))\n    } else println(\"NO\")\n  }\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val Array(n, r1, r0) = readLine().split(\" \").map(_.toInt)\n    if (n == 1 && r1 >= r0) println(\"YES\")\n    else if (r1 > r0) {\n      val angle = math.Pi / n\n      if (r0.toDouble / (r1 - r0).toDouble - math.sin(angle) <= 0.001) println(\"YES\")\n      else (println(\"NO\"))\n    } else println(\"NO\")\n  }\n}"}], "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6"}
{"source_code": "import scala.collection._\n\nobject A extends App {\n  \n  def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toInt) }\n  def readLongs(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toLong) }\n  def readBigs(n: Int) = { val t = tokenizeLine; Array.fill(n)(BigInt(t.nextToken)) }\n\n  val n = readInt\n  val xs = readInts(n)\n  \n  for (i <- 1 until n) {\n    val l1 = math.min(xs(i - 1), xs(i))\n    val r1 = math.max(xs(i - 1), xs(i)) \n    for (j <- 1 until n) {\n      val l2 = math.min(xs(j - 1), xs(j))\n      val r2 = math.max(xs(j - 1), xs(j))\n      if ((l1 < l2 && r1 > l2 && r1 < r2) || (r1 > r2 && l1 > l2 && l1 < r2) ||\n          (l2 < l1 && r2 > l1 && r2 < r1) || (r2 > r1 && l2 > l1 && l2 < r1)) {\n        println(\"yes\")\n        //println(i, j)\n        exit\n      }\n    } \n  }\n\n  println(\"no\")\n}", "positive_code": [{"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\nobject P358A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val N = sc.nextInt\n  val P = Array.fill(N)(sc.nextInt)\n\n  var flag = false\n  breakable {\n    for (i <- 0 until N - 2; j <- (i + 2) until N - 1) {\n      val a = P(i)\n      val b = P(i + 1)\n      val c = P(j)\n      val d = P(j + 1)\n      if ((c - a).signum * (c - b).signum * (d - a).signum * (d - b).signum < 0) {\n        flag = true\n        break\n      }\n    }\n  }\n\n  val res = if (flag) \"yes\" else \"no\"\n\n  out.println(res)\n  out.close\n}\n\n\n\n\n\n"}, {"source_code": "import java.util.Scanner\nimport scala.collection.mutable.ArrayBuffer\n\nobject Solver extends App {\n  val cin = new Scanner(System.in)\n  \n  val n = cin.nextInt\n  cin.nextLine\n  val points = cin.nextLine.split(\" \").map(_.toInt).toSeq\n\n  val connections = for (i <- 0 until n - 1) yield (points(i), points(i + 1))\n  \n  var intersection = \"no\"\n  connections.foreach { case (a, d) =>\n    val p1 = Seq(a, d)\n    val A = p1.min\n    val D = p1.max\n    \n    connections.foreach { case (b, c) =>\n      val p2 = Seq(b, c)\n      val B = p2.min\n      val C = p2.max\n      \n      if (B < D && D < C && A < B)\n        intersection = \"yes\"\n    }\n  }\n  \n  println(intersection)\n}"}, {"source_code": "object Main {\n  def main(args: Array[String]) {\n    val n=readLine().toInt\n    val a=readLine().split(\" \").map(_ toInt)\n    val b=(0 until n-1).map(i=>(math.min(a(i),a(i+1)),math.max(a(i),a(i+1))))\n    println(  if (b.exists(e1=>b.exists(e2=>(e1._1<e2._1 && e2._1<e1._2 && e1._2<e2._2)\n     || (e2._1<e1._1 && e1._1<e2._2 && e2._2<e1._2))))\n        \"yes\"\n    else \"no\")\n  }\n}\n"}, {"source_code": "object Solution358A extends App {\n\n  def solution() {\n    val n = _int\n    val coords = 1.to(n).map(_ => _int)\n    val intervals = coords.zip(coords.tail)\n\n    def norm(a: (Int, Int)): (Int, Int) = (scala.math.min(a._1, a._2), scala.math.max(a._1, a._2))\n\n    def inside(a: (Int, Int), x: Int): Boolean = a._1 < x && x < a._2\n    def oneInside(a: (Int, Int), b: (Int, Int)): Boolean = inside(a, b._1) ^ inside(a, b._2)\n\n    def intersects(a: (Int,Int), b: (Int, Int)): Boolean = {\n      val x = norm(a)\n      val y = norm(b)\n      val res = oneInside(x, y) && oneInside(y, x)\n      if (res) {\n        //println(a)\n        //println(b)\n      }\n      res\n    }\n\n    val hasInt = intervals.find(a => {\n      intervals.find(b => intersects(a, b)).isDefined\n    }).isDefined\n\n    if (hasInt) {\n      println(\"yes\")\n    } else {\n      println(\"no\")\n    }\n  }\n\n  //////////////////////////////////////////////////\n  import java.util.Scanner\n  val SC: Scanner = new Scanner(System.in)\n  def _line: String = SC.nextLine\n  def _int: Int = SC.nextInt\n  def _long: Long = SC.nextLong\n  def _string: String = SC.next\n  solution()\n}"}, {"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val n = in.next().toInt\n  val data = in.next().split(' ').map(_.toInt).sliding(2).toList\n  val r = data.forall{i => data.forall { j =>\n    val minFirst = Math.min(i.head, i.last)\n    val maxFirst = Math.max(i.head, i.last)\n    val minSecond = Math.min(j.head, j.last)\n    val maxSecond = Math.max(j.head, j.last)\n    if (i == j)\n      true\n    else {\n      val r = maxFirst <= minSecond || minFirst >= maxSecond || (maxFirst <= maxSecond && minFirst >= minSecond) ||\n        (maxSecond <= maxFirst && minSecond >= minFirst)\n      r\n    }}}\n  if (!r)\n    println(\"yes\")\n  else\n    println(\"no\")\n}"}, {"source_code": "object A358 {\n\n  import IO._\n  import collection.{mutable => cu}\n\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    val in = readInts(n)\n    val x = cu.ArrayBuffer.empty[(Int, Int)]\n    for(i <- 1 until n)\n      x.append((math.min(in(i-1), in(i)), math.max(in(i-1), in(i))))\n    val res = x.sorted\n    var break = false\n    for(i <- res.indices; j <- res.indices if i!=j && !break) {\n      if(res(i)._1 < res(j)._1 && res(i)._2 > res(j)._1 && res(j)._2 > res(i)._2) {\n        println(\"yes\")\n        break = true\n      }\n    }\n    if(!break){\n      println(\"no\")\n    }\n  }\n\n  object IO {\n    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))\n\n    @inline def read: String = input.readLine()\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInt: Int = tokenizeLine.nextToken.toInt\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n"}], "negative_code": [{"source_code": "import scala.io.Source\n\nobject Solution extends App {\n  val in = Source.stdin.getLines()\n  val n = in.next().toInt\n  val data = in.next().split(' ').map(_.toInt).sliding(2)\n  val r = data.forall{i => data.forall { j =>\n    val minFirst = Math.min(i.head, i.last)\n    val maxFirst = Math.max(i.head, i.last)\n    val minSecond = Math.min(j.head, j.last)\n    val maxSecond = Math.max(j.head, j.last)\n    if (i == j)\n      true\n    else {\n      maxFirst <= minSecond || minFirst >= maxSecond || (maxFirst <= maxSecond && minFirst >= minSecond) ||\n        (maxSecond <= maxFirst && minSecond >= minFirst)\n    }}}\n  if (!r)\n    println(\"yes\")\n  else\n    println(\"no\")\n}"}, {"source_code": "import scala.collection._\n\nobject A extends App {\n  \n  def tokenizeLine = new java.util.StringTokenizer(readLine)\n  def readInts(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toInt) }\n  def readLongs(n: Int) = { val t = tokenizeLine; Array.fill(n)(t.nextToken.toLong) }\n  def readBigs(n: Int) = { val t = tokenizeLine; Array.fill(n)(BigInt(t.nextToken)) }\n\n  val n = readInt\n  val xs = readInts(n)\n  \n  for (i <- 1 until n) {\n    val l1 = xs(i - 1)\n    val r1 = xs(i) \n    for (j <- 1 until n) {\n      val l2 = xs(j - 1)\n      val r2 = xs(j)\n      if ((l1 < l2 && r1 > l2 && r1 < r2) || (r1 > r2 && l1 > l2 && l1 < r2) ||\n          (l2 < l1 && r2 > l1 && r2 < r1) || (r2 > r1 && l2 > l1 && l2 < r1)) {\n        println(\"yes\")\n        //println(i, j)\n        exit\n      }\n    } \n  }\n\n  println(\"no\")\n}"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.util.Random\n\nobject P358A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val N = sc.nextInt\n  val ps = List.fill(N / 2, 2)(sc.nextInt)\n  val res = if (ps(0) == ps(0).sorted && ps(1) == ps(1).sorted.reverse) \"no\"\n            else \"yes\"\n\n  out.println(res)\n  out.close\n}\n\n\n\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\nobject P358A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val N = sc.nextInt\n  val P = Array.fill(N)(sc.nextLong)\n\n  var flag = false\n  breakable {\n    for (i <- 0 until N - 2; j <- (i + 1) until N - 1) {\n      val a = P(i)\n      val b = P(i + 1)\n      val c = P(j)\n      val d = P(j + 1)\n      if ((c - a) * (c - b) * (d - a) * (d - b) < 0) {\n        flag = true\n        break\n      }\n    }\n  }\n\n  val res = if (flag) \"YES\" else \"NO\"\n\n  out.println(res)\n  out.close\n}\n\n\n\n\n\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.util.Random\nimport scala.util.control.Breaks._\n\nobject P358A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val N = sc.nextInt\n  val P = Array.fill(N)(sc.nextLong)\n\n  var flag = false\n  breakable {\n    for (i <- 0 until N - 2; j <- (i + 1) until N - 1) {\n      val a = P(i)\n      val b = P(i + 1)\n      val c = P(j)\n      val d = P(j + 1)\n      if ((c - a) * (c - b) * (d - a) * (d - b) < 0) {\n        flag = true\n        break\n      }\n    }\n  }\n\n  val res = if (flag) \"yes\" else \"no\"\n\n  out.println(res)\n  out.close\n}\n\n\n\n\n\n"}, {"source_code": "import java.util.Scanner\nimport java.io.PrintWriter\nimport scala.annotation.tailrec\nimport scala.collection.mutable\nimport scala.collection.mutable.ListBuffer\nimport scala.util.Random\n\nobject P358A extends App {\n  val sc = new Scanner(System.in)\n  val out = new PrintWriter(System.out)\n\n  val N = sc.nextInt\n  val ps = List.fill(N / 2, 2)(sc.nextInt).transpose\n  val res = if (ps(0) == ps(0).sorted && ps(1) == ps(1).sorted.reverse) \"no\"\n            else \"yes\"\n\n  out.println(res)\n  out.close\n}\n\n\n\n"}], "src_uid": "f1b6b81ebd49f31428fe57913dfc604d"}
{"source_code": "object A672 {\n\n  import IO._\n\n  def main(args: Array[String]): Unit = {\n    val Array(n) = readInts(1)\n    val ret = (1 to 500).flatMap(x => x.toString.toCharArray)\n    println(ret(n-1))\n  }\n\n  object IO {\n    @inline def read: String = scala.io.StdIn.readLine\n\n    @inline def tokenizeLine = new java.util.StringTokenizer(read)\n\n    def readInts(n: Int): Array[Int] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toInt)\n    }\n\n    def readLongs(n: Int): Array[Long] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(tl.nextToken.toLong)\n    }\n\n    def readBigs(n: Int): Array[BigInt] = {\n      val tl = tokenizeLine;\n      Array.fill(n)(BigInt(tl.nextToken))\n    }\n  }\n\n}\n", "positive_code": [{"source_code": "import scala.collection.mutable.ArrayBuffer\nimport scala.io.StdIn\n\n/**\n  * Created by whimsy on 16/7/11.\n  */\n\n\n\nobject P672A extends App {\n    def work() : Int = {\n//        val n : Int = StdIn.readInt()\n        val n = 3\n        var cnt: Int = 0\n\n\n        for (i <- 1 to n) {\n            var t = i\n            var ab = ArrayBuffer[Int]()\n            while (t > 0) {\n                ab += t % 10\n                t = t / 10\n//                println(t)\n            }\n\n            for (j <- 0 to ab.length) {\n                println(cnt)\n                cnt = cnt + 1\n                if (cnt == n) {\n                    println(ab(j))\n                    return 1\n                }\n            }\n        }\n        return 0\n    }\n\n    def work2() : Int = {\n        val n = StdIn.readInt()\n\n        var content = \"\"\n        var cnt = 0\n        while (true) {\n            cnt = cnt + 1\n            content += cnt\n\n            if (content.length >= n) {\n                println(content.charAt(n - 1))\n                return 1\n            }\n        }\n        return 0\n    }\n\n    work2()\n}"}, {"source_code": "object Solution extends App {\n  val lines = io.Source.stdin.getLines()\n  val n = lines.next().toInt\n  val str = (0 to 1000).mkString\n  println(str(n))\n}\n"}], "negative_code": [], "src_uid": "2d46e34839261eda822f0c23c6e19121"}
{"source_code": "import scala.io._\n\nobject Main {\n\n\tdef main(args: Array[String]) = {\n\t\t\n\t\tvar P = nextInt\n\t\t\n\t\tdef isPrimitiveRoot(x: Int, P: Int): Boolean = {\n\n\t\t\tdef rec(n: Int, powX: Int): Boolean =\n\t\t\t\tif (n == P - 1)\n\t\t\t\t\tpowX == 1\n\t\t\t\telse\n\t\t\t\t\tpowX != 1 && rec(n + 1, powX * x % P)\n\t\t\t\t\n\t\t\trec(1, x)\n\t\t}\n\n\t\tval roots = (1 until P) filter (isPrimitiveRoot(_, P))\n\t\t\n\t\tprintln(roots.size)\n\t}\n\n\tval in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));\n\tvar st = new java.util.StringTokenizer(\"\");\n\n\tdef next() = {\n\t\twhile (!st.hasMoreTokens())\n\t\t\tst = new java.util.StringTokenizer(in.readLine());\n\t\tst.nextToken();\n\t}\n\n\tdef nextInt() = java.lang.Integer.parseInt(next());\n\tdef nextDouble() = java.lang.Double.parseDouble(next());\n\tdef nextLong() = java.lang.Long.parseLong(next());\n}", "positive_code": [{"source_code": "import scala.io._\nimport java.util.StringTokenizer\nimport java.io.BufferedReader\n\nobject Main {\n    \n    def main(args: Array[String]): Unit = {\n        val P = nextInt\n        \n        def isPrimitiveRoot(x: Int, p: Int, acc: Int): Boolean =\n            if (p == P - 1)\n                acc == 1\n            else\n                acc != 1 &&\n                isPrimitiveRoot(x, p + 1, acc * x % P)\n                \n        val answer = 1 until P count (x => isPrimitiveRoot(x, 1, x))                \n        \n        println (answer)\n    }\n    \n    class Tokenizer(in: BufferedReader, splitOn: String = \" \\n\\t\\r\\f\")\n    {\n        private var tokenizer = new StringTokenizer(\"\")\n        def readLine() = in.readLine()      \n        def nextToken(): String = {\n            while (!tokenizer.hasMoreTokens) {\n                val line = readLine\n                if (line == null) return null\n                tokenizer = new StringTokenizer(line, splitOn)\n            }\n            tokenizer.nextToken\n        }       \n        def next[A](f: String => A) = f(nextToken)\n        def nextSeq[A](f: () => A, count: Int) = (for (i <- 0 until count) yield f())\n    }\n    \n    implicit val tokenizer = new Tokenizer(Console.in)\n    \n    def nextInt()(implicit t: Tokenizer) = t.next(_.toInt)\n    def nextLong()(implicit t: Tokenizer) = t.next(_.toLong)\n    def nextDouble()(implicit t: Tokenizer) = t.next(_.toDouble)\n    def nextBigInt()(implicit t: Tokenizer) = t.next(BigInt(_))\n    def nextSeq[A](f: () => A, count: Int = nextInt())(implicit t: Tokenizer) =\n        (for (i <- 0 until count) yield f())\n}\n"}], "negative_code": [], "src_uid": "3bed682b6813f1ddb54410218c233cff"}