{"source_code": "n = gets.chomp.to_i\n\nif n % 2 == 0\n print \"Mahmoud\"\nelse\n print \"Ehab\"\nend\n", "positive_code": [{"source_code": "n = gets.to_i\nif n % 2 == 1\n puts \"Ehab\"\nelse\n puts \"Mahmoud\"\nend\n"}, {"source_code": "#bismillahir rahmanir rahim \n\nn = gets.to_i \n\nif n%2==0 \n puts \"Mahmoud\" \nelse \n puts \"Ehab\" \nend "}, {"source_code": "puts [:Mahmoud,:Ehab][gets.to_i%2]"}, {"source_code": "# https://codeforces.com/problemset/problem/959/A\n\nnumber = gets.to_i\n\nif number % 2 == 0\n puts \"Mahmoud\"\nelse\n puts \"Ehab\"\nend\n"}, {"source_code": "t = gets.chomp.to_i\n\ncase t%2==0\n when true\n puts \"Mahmoud\"\n when false\n puts \"Ehab\"\nend\n"}, {"source_code": "n = gets.chomp.to_i\n\nif n.odd?\n puts \"Ehab\"\nelse\n puts \"Mahmoud\"\nend"}, {"source_code": "puts gets.to_i.odd? ? \"Ehab\" : \"Mahmoud\""}, {"source_code": "n = gets.to_i\nputs n.odd? ? 'Ehab' : 'Mahmoud'"}, {"source_code": "##Please tell me this problmem can't be solved with this please\n\ndef winner(n)\n\treturn \"Ehab\" if n % 2 != 0\n\treturn \"Mahmoud\" if n % 2 == 0\nend\n\nn = gets.chomp.to_i\nputs(winner(n))"}, {"source_code": "n = gets.to_i\nputs [:Mahmoud, :Ehab][n & 1]\n"}, {"source_code": "# coding: utf-8\n\n# if __FILE__ == $0\n# end\n\nn = gets.to_i\n\n# picking -> Mahmoud picks 'a' and it is even.\n# -> Ehab picks 'a' and it is odd.\n# -> repeat until someone wins\n\n# optimal play\n# no fun\n\nputs \"Ehab\" if n.odd?\nputs \"Mahmoud\" if n.even?"}, {"source_code": "puts gets.chomp.to_i.even? ? \"Mahmoud\" : \"Ehab\""}, {"source_code": "n = Integer(gets.chomp)\nif n%2 == 0\n puts \"Mahmoud\"\nelse \n puts \"Ehab\"\nend"}, {"source_code": "n = gets.to_i\nputs(n%2 == 0 ? 'Mahmoud' : 'Ehab')\n\n"}, {"source_code": "puts gets.to_i.even? ? 'Mahmoud' : 'Ehab'\n"}, {"source_code": "puts (gets.to_i&1)==1?\"Ehab\":\"Mahmoud\"\n"}], "negative_code": [{"source_code": "n = gets.to_i\nputs n == 1 ? \"Ehab\" : \"Mahmoud\""}, {"source_code": "n = gets.chomp\nif n%2 == 0\n puts \"Mahmoud\"\nelse\n puts \"Ehab\"\nend"}, {"source_code": "puts (gets.to_i&1)?\"Ehab\":\"Mahmoud\"\n"}], "src_uid": "5e74750f44142624e6da41d4b35beb9a"} {"source_code": "a, b, c = gets.split.map &:to_i\n\n\n\ndef solve(a,b,c)\n ar = Array.new(1000001) { 0 }\n ans = 0\n mod = 1073741824\n for i in 1..a do\n for j in 1..b do\n for k in 1..c do\n d = i*j*k\n ans += ret_div(ar, d, mod)\n end\n end\n end\n puts ans\nend\n\ndef ret_div(ar, el, mod)\n return ar[el] if ar[el]>0\n j = 1\n div = 0\n while j*j<=el do\n if el%j == 0\n div+=2\n end\n j+=1\n\n end\n div-=1 if (j-1)*(j-1) == el\n ar[el] = div % mod\n ar[el]\nend\n\nsolve a, b ,c", "positive_code": [{"source_code": "a, b, c = gets.split.map &:to_i\n\n\ndef solve(a,b,c)\n ar = Array.new(1000001) { 0 }\n ans = 0\n mod = 1073741824\n for i in 1..a do\n for j in 1..b do\n for k in 1..c do\n d = i*j*k\n ans += ret_div(ar, d, mod)\n end\n end\n end\n puts ans\nend\n\ndef ret_div(ar, el, mod)\n return ar[el] if ar[el]>0\n j = 1\n div = 0\n while j*j<=el do\n if el%j == 0\n div+=2\n end\n j+=1\n\n end\n div-=1 if (j-1)*(j-1) == el\n ar[el] = div % mod\n ar[el]\nend\n\nsolve a, b ,c"}], "negative_code": [], "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401"} {"source_code": "dx = gets.chomp.split(\"|\")\ndx[0] ||= \"\"\ndx[1] ||= \"\"\nf = false\n\nif dx[0].length > dx[1].length\n f = true\n dx[0], dx[1] = dx[1], dx[0]\nend\ndx[0] += gets.chomp\nif dx[0].length < dx[1].length or (dx[0].length - dx[1].length) % 2 != 0\n puts \"Impossible\"\nelse\n tmp = dx[0].length - dx[1].length\n dx = [dx[0][0...(dx[1].length + (tmp / 2))], dx[1] + dx[0][(dx[1].length + (tmp / 2))..-1]]\n if f\n puts dx[1] + \"|\" + dx[0]\n else\n puts dx[0] + \"|\" + dx[1]\n end\nend\n", "positive_code": [{"source_code": "a, b = gets.chomp.split '|'\na = '' if not a\nb = '' if not b\nc = gets\n(c ? c.chomp : '').each_char { |ch|\n if a.size < b.size then a += ch\n else b += ch end\n}\nputs a.size == b.size ? a + '|' + b : 'Impossible'\n"}, {"source_code": "s = gets.strip\na, b = s.split(\"|\")\n\na = a.to_s\nb = b.to_s\n\nc = gets.strip\nc = c.to_s\n\nif a.size > b.size then\n diff = a.size - b.size\n if diff <= c.size then\n b += c[0...diff]\n c = c[diff..-1]\n end\nend\nif a.size < b.size then\n diff = b.size - a.size\n if diff <= c.size then\n a += c[0...diff]\n c = c[diff..-1]\n end\nend\n\nif a.size == b.size\n if c.size.even?\n puts \"#{a}#{c[0...c.size/2]}|#{b}#{c[c.size/2..-1]}\"\n else\n puts \"Impossible\"\n end\nelse\n puts \"Impossible\"\nend\n"}, {"source_code": "s=gets.chomp+'|x'\nt=gets.chomp\nl,r=s.split '|'\nt.each_char{|c|l.size>r.size ? r<=0 && q>=0\n l< 8, 2 -> 4, 3 -> 2, 4 -> 6,\n# 5 -> 8, 6 -> 4, 7 -> 2, 8 -> 6,\n# 9 -> ...\n# 4n + 1\nn = gets.to_i\nif n == 0\n puts 1\nelse\n puts 8 if n%4 == 1\n puts 4 if n%4 == 2\n puts 2 if n%4 == 3\n puts 6 if n%4 == 0\nend\n", "positive_code": [{"source_code": "n=gets.to_i\nm=1\nr=8\nwhile n>0\n\tif n%2==1 then\n\t\tm=(m*r)%10\n\tend\n\tr=(r*r)%10\n\tn/=2\nend\nputs m\n\n"}, {"source_code": "n= gets.to_i\nputs n==0? 1 : n%4 == 1? 8: n%4 ==2? 4 : n%4==3? 2 : 6\n"}, {"source_code": "n = gets.chomp.to_i\nif n == 0\n\tputs 1\nelse\n\tputs [8,4,2,6][(n-1)%4]\nend\n"}, {"source_code": "n=gets.to_i\nx=1378\nr=1\nwhile n>0\n r=r*x%10 if n.odd?\n x=x*x%10\n n>>=1\nend\np r\n"}, {"source_code": "n = gets.chomp.to_i\nif n == 0\n\tprint 1\nelse\n\tif n % 4 == 2\n\t\tprint 4\n\telsif n % 4 == 3\n\t\tprint 2\n\telsif n % 4 == 0\n\t\tprint 6\n\telsif n % 4 == 1\n\t\tprint 8\n\tend\nend\n\t\t"}, {"source_code": "n = gets.strip.to_i\nif n.zero?\n puts 1\n exit\nend\na = [8, 4, 2, 6]\nn -= 1\nputs a[n % 4]"}, {"source_code": "n=gets.to_i\nif n==0\n puts 1\nelse\n puts [8,4,2,6][(n-1)%4]\nend"}, {"source_code": "s = gets.to_i\nputs s == 0 ? 1 : \"8426\"[s % 4 - 1]\n"}, {"source_code": "n=gets.to_i\nif n == 0\n puts 1\nelse\n puts \"8426\"[(n+3)%4]\nend"}, {"source_code": "a = [8, 4, 2, 6]\nn = gets.to_i\nputs(n == 0 ? 1 : a[(n - 1)%4])\n"}, {"source_code": "n = gets.to_i\n\nif n.zero?\n puts 1\nelse\n puts [6, 8, 4, 2][n%4]\nend\n"}, {"source_code": "def modPow( x, n, m )\n answer = 1\n while n > 0\n if n % 2 != 0\n answer = ( answer * x ) % m\n end\n x = (x*x) % m;\n n /= 2\n end\n return answer\nend\n\nexponent = gets.chomp.to_i\nputs modPow(1378, exponent, 10) "}, {"source_code": "n = gets.to_i \n\nif n == 0 \n puts \"1\" \nelse \n case n%4 \n when 1\n puts \"8\" \n when 2 \n puts \"4\"\n when 3 \n puts \"2\" \n when 0 \n puts \"6\"\n end\nend \n\n"}, {"source_code": "a = gets.chomp.to_i\nif a==0\n p 1\nelsif a%4==1\n p 8\nelsif a%4==2\n p 4\nelsif a%4==3\n p 2\nelse\n p 6\nend"}, {"source_code": "n=gets.to_i;puts n==0?1:'6842'[n%4]"}, {"source_code": "n = gets.chomp.to_i\nif n == 0\n puts 1\n exit\nend\ncase n%4\nwhen 0\n puts 6\nwhen 1\n puts 8\nwhen 2\n puts 4\nwhen 3\n puts 2\nend\n"}, {"source_code": "n = gets.to_i\nputs n == 0 ? 1 : [6, 8, 4, 2][n % 4]\n"}, {"source_code": "num = [8,4,2,6]\nn = gets.to_i\nputs n == 0 ? 1 : num[(n-1) % 4]\n"}], "negative_code": [{"source_code": "n = gets.to_i \n\nif n == 0 \n puts \"1\" \nelse \n case n%4 \n when 1\n puts \"8\" \n when 2 \n puts \"4\"\n when 3 \n puts \"2\" \n when 4 \n puts \"6\"\n end\nend \n"}, {"source_code": "n = gets.chomp.to_i\ncase n%4\nwhen 0\n puts 6\nwhen 1\n puts 8\nwhen 2\n puts 4\nwhen 3\n puts 2\nend\n"}, {"source_code": "n = gets.chomp.to_i\nprint 1378**n%10"}, {"source_code": "n = gets.to_i\nputs n <= 2 ? (1378 ** n) % 10 : 6\n"}, {"source_code": "num = [8,4,6,2]\nn = gets.to_i\nputs n == 0 ? 1 : num[(n-1) % 4]\n"}, {"source_code": "n= gets.to_i%4\nputs n==0? 1: n == 1? 8: n ==2? 4 : n==3? 2 : 6\n"}, {"source_code": "n= gets.to_i%4\nputs n == 1? 8: n ==2? 4 : n==3? 2 : 6\n"}, {"source_code": "# coding: utf-8\n\n# if __FILE__ == $0\n# end\n\n# power of 1378, and last digit\n# and cyclic.\n# 1 -> 8, 2 -> 6, 3 -> 2, 4 -> 6, 5 -> 8\nn = gets.to_i\nbase = 8\n((n-1)%6).times {\n base *= 8\n base = base % 10\n}\n\nputs base"}, {"source_code": "# coding: utf-8\n\n# if __FILE__ == $0\n# end\n\n# power of 1378, and last digit\n# and cyclic.\n# 1 -> 8, 2 -> 4, 3 -> 2, 4 -> 6,\n# 5 -> 8, 6 -> 4, 7 -> 2, 8 -> 6,\n# 9 -> ...\n# 4n + 1\nn = gets.to_i\nputs 1 if n == 0\nputs 8 if n%4 == 1\nputs 4 if n%4 == 2\nputs 2 if n%4 == 3\nputs 6 if n%4 == 0"}, {"source_code": "# coding: utf-8\n\n# if __FILE__ == $0\n# end\n\n# power of 1378, and last digit\n# and cyclic.\n# 1 -> 8, 2 -> 4, 3 -> 2, 4 -> 6,\n# 5 -> 8, 6 -> 4, 7 -> 2, 8 -> 6,\n# 9 -> ...\n# 4n + 1\nn = gets.to_i\n\nputs 8 if n%4 == 1\nputs 4 if n%4 == 2\nputs 2 if n%4 == 3\nputs 6 if n%4 == 0"}, {"source_code": "n = gets.strip.to_i\na = [8, 4, 2, 6]\nn -= 1\nputs a[n % 4]"}, {"source_code": "s = gets.to_i\nputs \"8426\"[s % 4 - 1]\n"}, {"source_code": "puts (1378**gets.to_i).to_s.chars.last\n"}], "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f"} {"source_code": "#!/usr/bin/ruby\na=Array(1024)\n1024.times{|i| a[i]=i.to_s(2).to_i}\nn=gets.chomp.to_i\n1024.times{|i| if a[i+1]>n then puts i;exit end}\n", "positive_code": [{"source_code": "ns = gets.chomp\ns2 = \"\"\nfor i in 0..ns.length-1\n\twk = ns[i].to_i\n\tif wk > 1\n\t\tfor j in i..ns.length-1\n\t\t\ts2 << \"1\"\n\t\tend\n\t\tbreak\n\telse\n\t\ts2 << ns[i]\n\tend\nend\nputs s2.to_i(2)\n"}, {"source_code": "n = gets.to_i\nm = 0\nloop do\n\tbreak if ('%b' % m).to_i > n\n\tm += 1\nend\np m - 1\n\n"}, {"source_code": "n=gets.to_i\nans=0\n(1<<12).times{|i|\n v=0\n for j in 0..11\n v*=10\n if ((i>>j)&1)==1 then\n v+=1\n end\n end\n if v<=n then\n ans+=1\n end\n}\np ans-1"}, {"source_code": "$n = gets.to_i\n\n$counter = 0\n$len = Math.log10($n).to_i + 1\n\ndef solve(num, depth)\n\tif depth == $len\n\t\t$counter += 1 if num > 0 and num <= $n\n\t\treturn\n\tend\n\n\t[0, 1].each do |i|\n\t\tsolve(num*10 + i, depth+1)\n\tend\nend\n\nsolve(0, 0)\n\nputs $counter\n"}, {"source_code": "def bin2dec (b)\n ans = 0\n base = 1\n while b > 0 do\n ans += (b % 2) * base\n b = b >> 1\n base = base * 10\n end\n return ans\nend\nn = gets.to_i;\nm = n\nlen = 0\nwhile m != 0 do\n len += 1\n m /= 10\nend\ncand = (1 << len) - 1\n#p cand\nans = 0\nfor i in 1..cand do\n v = bin2dec(i)\n if v >= 1 && v <= n then ans += 1 end\n# print i, \" \" , v\n# puts\nend\nprint ans\nputs\n\n\n\n"}, {"source_code": "n = gets.to_i\nres = 0\nns = [1]\ni = 10\nwhile ns.last<(10**9 + 1)\n break if i>n\n temp = [i]\n flag = false\n ns.each do |x|\n if (x+i)<=n\n temp << x+i\n else\n flag = true\n end\n end\n ns += temp.sort\n break if flag\n i *= 10\nend\nputs ns.size\n"}, {"source_code": "n = gets.to_i\ni = 1\na = 1\nc = 0\nwhile a <= n\n\tc += 1\n\ti += 1\n\ta = i.to_s(2).to_i\nend\nputs c"}, {"source_code": "n = gets.to_i\nm = 0\nloop do\n break if (m.to_s(2)).to_i > n\n m += 1\nend\np m - 1"}, {"source_code": "s = gets.strip\n\none = false\n\n0.upto(s.length-1) do |i|\n if (s[i] > ?1) or (one)\n s[i] = ?1\n one = true\n end\nend\n\nn = s.to_i(2)\nputs n"}, {"source_code": "$n = 0\n$res = 0\ndef go(x)\n if x <= $n then\n $res += 1\n go(10 * x + 0)\n go(10 * x + 1)\n end\nend\n$n = gets.chomp.to_i\ngo(1)\np $res\n"}, {"source_code": "n = gets.to_i\n\n\nz = 1\nres=0\nwhile z.to_s(2).to_i <= n \n z+=1\n res+=1\nend\n\nputs res"}], "negative_code": [{"source_code": "ns = gets.chomp\ns2 = \"\"\nfor i in 0..ns.length-1\n\twk = ns[i].to_i\n\twk = 1 if wk > 1\n\ts2 << wk.to_s\nend\nputs s2.to_i(2)\n"}, {"source_code": "$n = gets.to_i\n\n$counter = 0\n$len = Math.log10($n).to_i + 1\n\ndef solve(num, depth)\n\tif depth == $len\n\t\t$counter += 1 if num < $n\n\t\treturn\n\tend\n\n\t[0, 1].each do |i|\n\t\tsolve(num*10 + i, depth+1)\n\tend\nend\n\nsolve(0, 0)\n\nputs $counter\n"}], "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb"} {"source_code": "# Try Codeforces\n# author: Leonardone @ NEETSDKASU\n\nn, k = gets.strip.split.map &:to_i\n\nv = n / k\n\nif v.even?\n puts :NO\nelse\n puts :YES\nend", "positive_code": [{"source_code": "n,k=gets.split.map &:to_i;puts [:NO,:YES][n/k%2]"}, {"source_code": "# Codeforces My Practice\n# author: Leonardone @ NEETSDKASU\n\nn, k = gets.strip.split.map &:to_i\n\nk2 = k * 2\nv = n % k2\n\nif v < k\n puts :NO\nelse\n puts :YES\nend"}, {"source_code": "n, k = gets.split.map(&:to_i)\n\nputs (n / k).odd? ? 'YES' : 'NO'"}, {"source_code": "n, k = gets.strip.split.map(&:to_i)\nans = \"YES\"\ndiv = n / k\nans = \"NO\" if div.even?\nputs ans\n"}, {"source_code": "n,k=gets.split.map{|e| e.to_i}\nt=n/k\nif t%2==1 then\n\tputs \"YES\"\nelse\n\tputs \"NO\"\nend\n\n"}, {"source_code": "n, k=gets.split.map &:to_i\nputs (n/k).odd? ? \"YES\" : \"NO\"\n"}, {"source_code": "n,m = gets.split\nn = n.to_i\nm = m.to_i\nk = Integer(n / m)\nif k % 2 == 1 then\n\tputs \"YES\"\nelse\n\tputs \"NO\"\nend"}, {"source_code": "# coding: utf-8\n\n# if __FILE__ == $0\n# end\n\nn, k = gets.split.map(&:to_i)\n\nif (n/k).odd?\n puts \"YES\"\nelse\n puts \"NO\"\nend"}, {"source_code": "nk = gets.chomp.split.map(&:to_i)\nn = nk[0]\nk = nk[1]\n\nif (n/k)%2 == 0\n\tprint \"NO\"\nelse\n\tprint \"YES\"\nend"}, {"source_code": "n,k = gets.split.map(&:to_i)\nn/=k\nputs (n&1!=0 ? \"YES\" : \"NO\")"}, {"source_code": "n,k = gets.strip.split.map(&:to_i)\n\ndef kek(n,k)\n (n/k).even? ? 'NO' : 'YES'\nend\nputs kek(n,k)"}, {"source_code": "a=gets.split.map &:to_i\nputs (a[0]/a[1])%2==0 ?\"NO\":\"YES\""}, {"source_code": "n, k = gets.split.map(&:to_i)\ncase (n - k)%(2*k)\nwhen 0..k-1\n puts \"YES\"\nwhen k..2*k-1\n puts \"NO\"\nend"}, {"source_code": "# https://codeforces.com/problemset/problem/832/A\ns = gets.chomp\narr = s.split(' ')\n\nn = arr[0].to_i\nk = arr[1].to_i\nif ((n % k == 0) && (n / k % 2 != 0)) || ((n % k != 0) && (n / k % 2 != 0))\n puts 'YES'\nelse\n puts 'NO'\nend\n"}, {"source_code": "n, k=gets.split.map(&:to_i)\n\nif (n/k)%2==1\n puts 'YES'\nelse\n puts 'NO'\nend\n"}], "negative_code": [{"source_code": "n,k=gets.split.map &:to_i;puts [:YES,:NO][n/k%2]"}, {"source_code": "# Try Codeforces\n# author: Leonardone @ NEETSDKASU\n\nn, k = gets.strip.split.map &:to_i\n\nk2 = k * 2\nv = n % k2\n\nif v < n\n puts :NO\nelse\n puts :YES\nend"}, {"source_code": "# Try Codeforces\n# author: Leonardone @ NEETSDKASU\n\nn, k = gets.strip.split.map &:to_i\n\nk2 = k * 2\nv = n % k2\n\nif v <= n\n puts :NO\nelse\n puts :YES\nend"}, {"source_code": "# Try Codeforces\n# author: Leonardone @ NEETSDKASU\n\nn, k = gets.strip.split.map &:to_i\n\nv = n / k\n\nif v.odd?\n puts :NO\nelse\n puts :YES\nend"}, {"source_code": "n, k = gets.strip.split.map(&:to_i)\nans = \"YES\"\nmod = n % k\ndiv = n / k\nans = \"NO\" if div.even? && mod > 0\nputs ans\n"}, {"source_code": "nk = gets.chomp.split.map(&:to_i)\nn = nk[0]\nk = nk[1]\n\nif n%k == 0\n\tprint \"YES\"\nelse\n\tif (n/k)%2 == 0\n\t\tprint \"NO\"\n\telse\n\t\tprint \"YES\"\n\tend\nend"}, {"source_code": "a=gets.split.map &:to_i\nputs (a[1]/a[0])%2==0 ?\"NO\":\"YES\""}, {"source_code": "a=gets.split.map &:to_i\np (a[1]/a[0])%2==0 ?\"NO\":\"YES\""}], "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50"} {"source_code": "h,m=gets.split(':').map(&:to_i)\nputs ((Time.gm(2,1,1,h,m)+gets.to_i*60).strftime('%H:%M'))", "positive_code": [{"source_code": "h,m=gets.split(':').map(&:to_i)\nt=Time.gm(2008,7,7,h,m)+gets.to_i*60\nputs t.strftime('%H:%M')"}, {"source_code": "h, m = gets.split( \":\" ).map( &:to_i )\na = gets.to_i\nt = Time.local( 2016, 1, 1, h, m, 0 )\nputs ( t + a * 60 ).strftime( \"%H:%M\" )\n\n"}, {"source_code": "#!/usr/bin/ruby\ndef encode(n) '%02d:%02d'%[n/60,n%60] end\ndef decode(s)\n\th,m=s.split(':').map(&:to_i)\n\th*60+m\nend\nputs encode((decode(gets)+gets.to_i)%1440)"}, {"source_code": "h, m = gets.chomp.split(':').map(&:to_i)\na = gets.chomp.to_i\n\nt = Time.new(2002, 10, 31, h, m, 0)\nt2 = t + a * 60\n\nputs \"#{t2.hour.to_s.rjust(2, '0')}:#{t2.min.to_s.rjust(2, '0')}\"\n"}], "negative_code": [], "src_uid": "20c2d9da12d6b88f300977d74287a15d"} {"source_code": "n, k=gets.split.map &:to_i\ns=gets.split.map(&:to_i).inject(0, :+)\nr=0\nwhile 2*s<2*k*n-n\n\tr+=1\n\ts+=k;\n\tn+=1\nend\nputs r\n", "positive_code": [{"source_code": "n,k,*a=$<.read.split.map &:to_i\np [0,(k*2-1)*n-a.reduce(:+)*2].max"}, {"source_code": "# Try Codeforces\n# author: Leonardone @ NEETSDKASU\n############################################################\ndef gs() gets.strip end\ndef gi() gets.to_i end\ndef gss() gs.split end\ndef gis() gss.map(&:to_i) end\ndef nmapf(n,f) n.times.map{ __send__ f } end\ndef ngs(n) nmapf n,:gs end\ndef ngi(n) nmapf n,:gi end\ndef ngss(n) nmapf n,:gss end\ndef ngis(n) nmapf n,:gis end\ndef arr2d(h,w,v=0) h.times.map{[v] * w} end\ndef for2p(hr,wr,&pr) hr.each{|i|wr.each{|j| yield(i,j)}} end\ndef nsum(n) n * (n + 1) / 2 end\ndef vcount(d,r=Hash.new(0)) d.inject(r){|m,e| m[e]+=1;m} end\n############################################################\n\n\nn, k = gis\na = gis\n\nsum = a.inject(:+) * 10\n\nlim = (k - 1) * 10 + 5\n\ni = n\nloop do\n break if sum / i >= lim\n sum += k * 10\n i += 1\nend\n\nputs (i - n)\n\n\n\n\n"}], "negative_code": [{"source_code": "n,k,*a=$<.read.split.map &:to_i\np [0,(k*2-1)*n-a.reduce(:+)*2]"}], "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900"} {"source_code": "a = gets.split.map(&:to_i)\nif (a[2] == 0 and a[3] != 0) or (a[0] == 0 and a[1] != 0 && a[2]*a[3] != 0)\n puts \"Ron\"\nelse\n puts(a[0]*a[2]*a[4] < a[1]*a[3]*a[5] ? \"Ron\" : \"Hermione\")\nend\n", "positive_code": [{"source_code": "a, b, c, d, e, f = gets.split.map(&:to_i)\nputs (c == 0 && d > 0) ||\n\t(a == 0 && b > 0 && c > 0 && d > 0) ||\n\t(e == 0 && f > 0 && a > 0 && b > 0 && c > 0 && d > 0) ||\n\ta * c * e < b * d * f ? :Ron : :Hermione\n"}, {"source_code": "a, b, c, d, e, f = gets.split.map {|n| n.to_f }\nconv_ratio = (a/b)*(c/d)*(e/f)\n\nif d == 0\n puts \"Hermione\"\nelsif c == 0 or (a == 0 and b > 0)\n puts \"Ron\"\nelsif conv_ratio < 1\n puts \"Ron\"\nelse\n puts \"Hermione\"\nend"}, {"source_code": "a, b, c, d, e, f = gets.split.map {|n| n.to_f }\nconv_ratio = (a/b)*(c/d)*(e/f)\n\nif d == 0\n puts \"Hermione\"\nelsif c == 0\n puts \"Ron\"\nelsif b == 0\n puts \"Hermione\"\nelsif a == 0\n puts \"Ron\"\nelsif f == 0\n puts \"Hermione\"\nelsif conv_ratio < 1\n puts \"Ron\"\nelse\n puts \"Hermione\"\nend"}, {"source_code": "a = gets.split.map(&:to_i)\nputs(((a[2] == 0 && a[3] != 0) or (a[0] == 0 && a[1] != 0 && a[2] * a[3] != 0) or (a[0] * a[2] * a[4] < a[1] * a[3] * a[5])) ? \"Ron\" : \"Hermione\")"}, {"source_code": "a, b, c, d, e, f = gets.chomp.split.map{|e| e.to_i}\n\nif (a * b * c * d * e * f != 0)\n if (a * c * e < b * d * f)\n puts \"Ron\"\n else\n puts \"Hermione\"\n end\nelse\n if (d == 0)\n puts \"Hermione\"\n elsif (c == 0)\n puts \"Ron\"\n else # d, c > 0\n if (b == 0)\n puts \"Hermione\"\n elsif (a == 0)\n puts \"Ron\"\n else # a, b > 0\n if (f == 0)\n puts \"Hermione\"\n else\n puts \"Ron\"\n end\n end\n end\nend \n\n"}, {"source_code": "a,b,c,d,e,f = gets.split(' ').map(&:to_i)\nif (c==0 && d !=0) || (a==0 && b !=0 && c*d !=0)\n puts \"Ron\"\nelse\n if (a*c*e) < (b*d*f)\n puts \"Ron\"\n else\n puts \"Hermione\"\n end\nend"}, {"source_code": "a, b, c, d, e, f = gets.split(' ').map{|s| s.to_i}\nab, cd, ef = [[a, b], [c, d], [e, f]].map{|aa, bb|bb/aa.to_f}\ng = ab*cd*ef\nm = [cd.infinite?, ab.infinite?&&cd>0, ef.infinite?&&ab>0&&cd>0]\nputs (m.any?||g>1.0) ? 'Ron' : 'Hermione'"}, {"source_code": "def foo(a)\n if a[3] == 0\n return false\n end\n\n if a[2] == 0 && a[3] > 0\n return true\n end\n\n if a[1]*a[3] == 0\n return false\n end\n\n if a[0]*a[2] == 0 && a[1]*a[3] > 0\n return true\n end\n\n if a[1]*a[3]*a[5] == 0\n return false\n end\n\n if a[0]*a[2]*a[4] == 0 && a[1]*a[3]*a[5] > 0\n return true\n end\n\n pr = 1.0\n 0.step(4, 2) do |i|\n pr = pr / a[i] * a[i-1]\n end\n if pr > 1\n return true\n else\n return false\n end\nend\n\na = gets.split.map(&:to_i)\nputs(foo(a) ? \"Ron\" : \"Hermione\")\n"}], "negative_code": [{"source_code": "a = gets.split.map(&:to_i)\nif a[2] == 0 and a[3] != 0\n puts \"Ron\"\nelse\n puts(a[0]*a[2]*a[4] < a[1]*a[3]*a[5] ? \"Ron\" : \"Hermione\")\nend\n"}, {"source_code": "a = gets.split.map(&:to_i)\nputs(a[0]*a[2]*a[4] < a[1]*a[3]*a[5] ? \"Ron\" : \"Hermione\")\n"}, {"source_code": "a, b, c, d, e, f = gets.split.map {|n| n.to_f }\nconv_ratio = (a/b)*(c/d)*(e/f)\n\nif d == 0\n puts \"Hermione\"\nelsif c == 0\n puts \"Ron\"\nelsif b == 0 or f == 0\n puts \"Hermione\"\nelsif conv_ratio < 1\n puts \"Ron\"\nelse\n puts \"Hermione\"\nend"}, {"source_code": "a, b, c, d, e, f = gets.split(' ').map{|s| s.to_i}\nab, cd, ef = [[a, b], [c, d], [e, f]].map{|aa, bb|bb/aa.to_f}\ng = ab*cd*ef\nputs (cd.infinite?||g>1.0) ? 'Ron' : 'Hermione'"}, {"source_code": "a, b, c, d, e, f = gets.split(' ').map{|s| s.to_i}\ng = (b/a.to_f) * (d/c.to_f) * (f/e.to_f)\nputs (g>1.0) ? 'Ron' : 'Hermione'"}, {"source_code": "a, b, c, d, e, f = gets.split(' ').map{|s| s.to_i}\nab, cd, ef = [[a, b], [c, d], [e, f]].map{|aa, bb|bb/aa.to_f}\ng = ab*cd*ef\nm = [cd.infinite?, ab.infinite?&&!cd.nan?, ef.infinite?&&!ab.nan?&&!cd.nan?]\nputs (m.any?||g>1.0) ? 'Ron' : 'Hermione'\n"}], "src_uid": "44d608de3e1447f89070e707ba550150"} {"source_code": "n, a, b = gets.split.map(&:to_i)\nans, k = 1, 2\nuntil (a-1)/k == (b-1)/k do\n k *= 2\n ans += 1\nend\nputs k == n ? \"Final!\" : ans", "positive_code": [{"source_code": "n, a, b = gets.chomp.split(\" \").map {|k| k.to_i}\n\ntr = 0\nwhile n != 0\n\tn = n/2\n\ttr +=1\nend\ntr -=1\nout = 0\nwhile true\n\tr = 0\n\tr = 1 if a % 2 != 0\n\ta = (a/2) + r\n\tr = 0\n\tr = 1 if b % 2 != 0\n\tb = (b/2) + r\n\tout += 1\n\tif a == b\n\t\tbreak\n\tend\nend\nout = \"Final!\" if out == tr\nputs out\n"}, {"source_code": "n,a,b=gets.split.map &:to_i\na-=1\nb-=1\nc=1\nwhile a/2!=b/2\n\ta/=2\n\tb/=2\n\tc+=1\nend\nputs 1< 3\n\t\tcount += 1 #3, 1\n\tend\n\t\n\tif remaining == 1\n\t\tcount += 1\t\n\tend\n\t\n\tcount = 1 if count == 0\n\t\n\tcount\nend\n\nstones = gets.chomp.to_i\n\nputs calc(stones)", "positive_code": [{"source_code": "n = gets.to_i\n\nans = n / 3 * 2\nans += 1 if n % 3 != 0\nputs ans"}, {"source_code": "n=gets.to_i\nif n%3==0 #then\n p n/3*2\nelse\n p n/3*2+1\nend\n"}, {"source_code": "n=gets.to_i;p n/3*2+[0,1,1][n%3]"}, {"source_code": "\nn = gets.to_i\nbegin\n puts n%3 == 0 ? n/3 * 2 : n/3 * 2 + 1\nrescue\nend\n"}, {"source_code": "#! ruby\n# Try Codeforces\n# author: Leonardone @ NEETSDKASU\n############################################################\ndef gs() gets.chomp end\ndef gi() gets.to_i end\ndef gss() gs.split end\ndef gis() gss.map(&:to_i) end\ndef nmapf(n,f) n.times.map{ __send__ f } end\ndef ngs(n) nmapf n,:gs end\ndef ngi(n) nmapf n,:gi end\ndef ngss(n) nmapf n,:gss end\ndef ngis(n) nmapf n,:gis end\ndef arr2d(h,w,v=0) h.times.map{[v] * w} end\ndef for2p(hr,wr,&pr) hr.each{|i|wr.each{|j| yield(i,j)}} end\ndef nsum(n) n * (n + 1) / 2 end\ndef vcount(d,r=Hash.new(0)) d.inject(r){|r,e| r[e]+=1;r} end\n############################################################\n\nn = gi\n\nif n < 3\n puts 1\n exit\nend\n\n=begin\n\nn = 3\n1 2\n\nn = 4\n1 2 1\n\nn = 5\n1 2 1\n\nn = 6\n1 2 1 2\n\nn = 7\n1 2 1 2 1\n\nn = 8\n1 2 1 2 1\n\nn = 9\n1 2 1 2 1 2\n\nn = 10\n1 2 1 2 1 2 1\n\nn = 11\n1 2 1 2 1 2 1\n\na n\n3 4 5\n4 6\n5 7 8\n6 9\n7 10 11\n8 12\n\n=end\n\nif n % 3 == 0\n n /= 3\n puts 2 * n\nelse\n n /= 3\n puts 2 * n + 1\nend\n"}, {"source_code": "n = readline.to_i\nct = n / 3\nct *= 2\nif n % 3 != 0\n ct += 1\nend\nputs ct\n"}, {"source_code": "a=gets.chomp.to_i\nans=((a/3.0).ceil)*2\nif a%3==0\nputs \"#{ans}\"\nelse\nputs \"#{ans-1}\"\nend"}, {"source_code": "n = gets.to_i\nans = n / 3 * 2\nif (n % 3 == 0) \n\tp ans\n\nelse \n\tp ans + 1\nend "}, {"source_code": "n = gets.to_i\n\nans = 0\n\nans += n/3 * 2\nn %= 3\n\nans += 1 if n > 0\n\nputs ans\n"}, {"source_code": "a=gets.chomp.to_i\nans=((a/3.0).ceil)*2\nif a%3==0\nputs \"#{ans}\"\nelse\nputs \"#{ans-1}\"\nend"}, {"source_code": "n = gets.chomp.to_i\n\n#if n % 2 == 1\n#\tn -= 1\n#end\n\nputs ((n - n % 3) / 3 * 2) + [n % 3, 1].min \n"}, {"source_code": "n = gets.chomp.to_i\n\na = n / 3\nb = n % 3\nif b != 0 then\n puts a * 2 + 1\nelse\n puts a * 2\nend\n"}, {"source_code": "n = gets.to_i\nputs n/3*2 + (n%3 + 2)/3\n"}, {"source_code": "n = gets.to_i\ncnt = (n / 3) * 2\nres = n % 3\ncnt += 1 if res >= 1\nputs cnt\n"}], "negative_code": [{"source_code": "stones = gets.chomp.to_i\n\nthrees = (stones / 3).to_i\n\nremaining = stones - (threes * 3)\n\ncount = threes * 2\n\ncount += 1 if remaining == 1\n\ncount = 1 if count == 0\n\nputs count"}, {"source_code": "n=gets.to_i;p (2*n)/3+([0,1,1][n%3])"}, {"source_code": "n=gets.to_i;p (2*n)/3+[0,1,1][n%3]"}, {"source_code": "\nn = gets.to_i\nbegin\n puts n%3 == 0 ? n/3 : n/3 + 1\nrescue\nend\n"}, {"source_code": "#! ruby\n# Try Codeforces\n# author: Leonardone @ NEETSDKASU\n############################################################\ndef gs() gets.chomp end\ndef gi() gets.to_i end\ndef gss() gs.split end\ndef gis() gss.map(&:to_i) end\ndef nmapf(n,f) n.times.map{ __send__ f } end\ndef ngs(n) nmapf n,:gs end\ndef ngi(n) nmapf n,:gi end\ndef ngss(n) nmapf n,:gss end\ndef ngis(n) nmapf n,:gis end\ndef arr2d(h,w,v=0) h.times.map{[v] * w} end\ndef for2p(hr,wr,&pr) hr.each{|i|wr.each{|j| yield(i,j)}} end\ndef nsum(n) n * (n + 1) / 2 end\ndef vcount(d,r=Hash.new(0)) d.inject(r){|r,e| r[e]+=1;r} end\n############################################################\n\nn = gi\n\nif n < 3\n puts 1\n exit\nend\n\n=begin\n\nn = 3\n1 2\n\nn = 4\n1 2 1\n\nn = 5\n1 2 1\n\nn = 6\n1 2 1 2\n\nn = 7\n1 2 1 2 1\n\nn = 8\n1 2 1 2 1\n\nn = 9\n1 2 1 2 1 2\n\nn = 10\n1 2 1 2 1 2 1\n\na n\n3 4 5\n4 6\n5 7 8\n6 9\n7 10 11\n8 12\n\n=end\n\nif n % 3 == 0\n puts 2 * n / 3\nelse\n puts 2 * n / 3 + 1\nend"}, {"source_code": "n = readline.to_i\nct = n / 3\nif n % 3 != 0\n ct += 1\nend\nputs ct\n"}], "src_uid": "a993069e35b35ae158d35d6fe166aaef"} {"source_code": "a=[]\n4.times do\na << gets.chomp.split(\"\")\nend\nans=0\n0.upto(2) do |i|\n0.upto(2) do |j|\nw=0\nb=0\nif a[i][j]==\"#\"\nb+=1\nelse \nw+=1\nend\nif a[i+1][j]==\"#\"\nb+=1\nelse \nw+=1\nend\nif a[i][j+1]==\"#\"\nb+=1\nelse \nw+=1\nend\nif a[i+1][j+1]==\"#\"\nb+=1\nelse \nw+=1\nend\nif w>2 || b>2\nans=1\nend\nbreak if ans==1\nend\nbreak if ans==1\nend\nif ans==1\nputs \"YES\"\nelse \nputs \"NO\"\nend", "positive_code": [{"source_code": "res = \"NO\"\ndata = []\n\n4.times do\n s = gets.split(\"\")\n data << s\nend\n\n3.times do |i|\n if data[1][i] == data[1][i+1] then\n if data[0][i] == data[1][i] || data[0][i+1] == data[1][i] then\n res = \"YES\"\n end\n if data[2][i] == data[1][i] || data[2][i+1] == data[1][i] then\n res = \"YES\"\n end\n end\nend\n\nif res == \"NO\" then\n 3.times do |i|\n if data[-1][i] == data[-1][i+1] then\n if data[2][i] == data[1][i] || data[2][i+1] == data[1][i] then\n res = \"YES\"\n end\n end\n end\nend\n\nputs res"}, {"source_code": "s1 = gets.split(\"\")\ns2 = gets.split(\"\")\ns3 = gets.split(\"\")\ns4 = gets.split(\"\")\ns= s1.zip(s2,s3,s4)\n\nyes=false\ni=0\n3.times do\n j=0\n 3.times do\n count=0\n if s[i][j]=='#'\n count+=1\n end\n if s[i+1][j]=='#'\n count+=1\n end\n if s[i+1][j+1]=='#'\n count+=1\n end\n if s[i][j+1]=='#'\n count+=1\n end\n if count!=2\n yes=true\n break\n end\n j+=1\n end\n i+=1\nend\n\n\nif yes\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "matrix = []\n4.times { matrix << gets.chomp.chars.to_a }\n\ntiles = []\n(0..2).each do |i|\n (0..2).each do |j|\n tiles << [matrix[i][j], matrix[i][j+1], matrix[i+1][j], matrix[i+1][j+1]]\n end\nend\n\nfreq = tiles.map { |t| [t.count('.'), t.count('#')].max }\n\nprint freq.max >= 3 ? \"YES\" : \"NO\""}, {"source_code": "#!/usr/bin/ruby1.9\n\ngrid = []\n\n4.times do\n\tgrid.push(STDIN.readline.strip)\nend\n\n3.times do |r|\n\t3.times do |c|\n\t\tcount = 0\n\t\tcount += 1 if grid[r][c] == '.'\n\t\tcount += 1 if grid[r+1][c] == '.'\n\t\tcount += 1 if grid[r][c+1] == '.'\n\t\tcount += 1 if grid[r+1][c+1] == '.'\n\t\tnext if count == 2\n\t\tputs 'YES'\n\t\texit\n\tend\nend\n\nputs 'NO'\n"}, {"source_code": "def run\n ary = []\n $stdin.readlines.each do |line|\n ary << line.split(//)\n end\n\n 3.times do |x|\n 3.times do |y|\n if [ary[x][y], ary[x+1][y], ary[x][y+1], ary[x+1][y+1]].select {|x| x == '#'}.length != 2\n $stdout.puts \"YES\"\n return\n end\n end\n end\n $stdout.puts \"NO\"\nend\n\nrun if $0 == __FILE__\n"}, {"source_code": "class A\n def initialize\n @cells = []\n @list = [[1,1],[1,2],[2,1],[2,2]]\n @pos1 = [[-1,0],[-1,1],[0,1]]\n @pos2 = [[-1,0],[-1,-1],[0,-1]]\n @pos3 = [[0,-1],[1,-1],[1,0]]\n @pos4 = [[0,1],[1,1],[1,0]]\n 4.times do\n @cells << $stdin.gets.chomp.split('')\n end\n\n check\n puts \"NO\"\n end\n\n def check\n flag = false\n @list.each do |elem|\n y = elem[0]\n x = elem[1]\n\n flag ||= right_up(y, x)\n flag ||= left_up(y, x)\n flag ||= left_up(y, x)\n flag ||= right_down(y, x)\n\n if flag \n puts \"YES\"\n exit\n end\n end\n end\n\n def right_up(ypos,xpos)\n white = 0\n black = 0\n if @cells[ypos][xpos] == \"#\"\n black += 1\n else\n white += 1\n end\n\n @pos1.each do |pos|\n y = pos[0]\n x = pos[1]\n\n if @cells[ypos+y][xpos+x] == \"#\"\n black += 1\n else\n white += 1\n end\n\n end\n if black >= 3 || white >= 3\n true\n else\n false\n end\n end\n\n def left_up(ypos,xpos)\n white = 0\n black = 0\n if @cells[ypos][xpos] == \"#\"\n black += 1\n else\n white += 1\n end\n\n @pos2.each do |pos|\n y = pos[0]\n x = pos[1]\n\n if @cells[ypos+y][xpos+x] == \"#\"\n black += 1\n else\n white += 1\n end\n\n end\n if black >= 3 || white >= 3\n true\n else\n false\n end\n end\n def left_down(ypos,xpos)\n white = 0\n black = 0\n if @cells[ypos][xpos] == \"#\"\n black += 1\n else\n white += 1\n end\n\n @pos3.each do |pos|\n y = pos[0]\n x = pos[1]\n\n if @cells[ypos+y][xpos+x] == \"#\"\n black += 1\n else\n white += 1\n end\n\n end\n if black >= 3 || white >= 3\n true\n else\n false\n end\n end\n\n def right_down(ypos,xpos)\n white = 0\n black = 0\n if @cells[ypos][xpos] == \"#\"\n black += 1\n else\n white += 1\n end\n\n @pos4.each do |pos|\n y = pos[0]\n x = pos[1]\n\n if @cells[ypos+y][xpos+x] == \"#\"\n black += 1\n else\n white += 1\n end\n end\n if black >= 3 || white >= 3\n true\n else\n false\n end\n end\nend\n\na = A.new"}, {"source_code": "a=[]\n4.times do\na << gets.chomp.split(\"\")\nend\nans=0\n0.upto(2) do |i|\n0.upto(2) do |j|\nw=0\nb=0\nif a[i][j]==\"#\"\nb+=1\nelse \nw+=1\nend\nif a[i+1][j]==\"#\"\nb+=1\nelse \nw+=1\nend\nif a[i][j+1]==\"#\"\nb+=1\nelse \nw+=1\nend\nif a[i+1][j+1]==\"#\"\nb+=1\nelse \nw+=1\nend\nif w>2 || b>2\nans=1\nend\nbreak if ans==1\nend\nbreak if ans==1\nend\nif ans==1\nputs \"YES\"\nelse \nputs \"NO\"\nend\n"}, {"source_code": "A = [gets, gets, gets, gets]\ndef rr(t)\n if (t[0] == t[1] and t[1] == t[2] and t[2] == t[3]) then return true end\n t = t.chars.partition { |x| x == '.' }\n if t[0].length == 1 or t[0].length == 3 then return true end\n return false\nend\ndef solve()\n i, j = 0, 0\n while i != 3\n if rr(A[i][j] + A[i][j+1] + A[i+1][j] + A[i+1][j+1]) then return \"YES\" end\n j = j+1\n if j == 3 then i, j = i+1, 0 end\n end\n return \"NO\"\nend\nputs solve()\n"}, {"source_code": "a = 4.times.map { gets.chop }\n3.times do |i|\n 3.times do |j|\n if [a[i][j], a[i][j+1], a[i+1][j], a[i+1][j+1]].count('#') != 2\n puts 'YES'\n exit\n end\n end\nend\nputs 'NO'\n"}, {"source_code": "lines = [\"\"]*4\nlines[0] = gets.chomp.split(\"\")\nlines[1] = gets.chomp.split(\"\")\nlines[2] = gets.chomp.split(\"\")\nlines[3] = gets.chomp.split(\"\")\n\ns = \"\"\nt = \"\"\nok = false\n(0..2).each {|l|\n\t(0..2).each {|c|\n\t\ts = \"#{lines[l][c]}#{lines[l][c+1]}#{lines[l+1][c]}#{lines[l+1][c+1]}\"\n\t\tt = s.gsub(\".\",\"\")\n\t\tif t.length==4 or t.length==3 or t.length==1 or t.length==0 \n\t\t\tok=true\n\t\tend\n\t}\n}\n\nif ok\n\tputs \"YES\"\nelse\n\tputs \"NO\"\nend"}, {"source_code": "m = Array.new\n\n4.times do\n m << gets.chomp\nend\n\n3.times do |y|\n 3.times do |x|\n c = (m[y][x] + m[y+1][x] + m[y][x+1] + m[y+1][x+1]).delete(\".\").length\n unless c == 2\n puts 'YES'\n exit 0\n end\n end\nend\n\nputs 'NO'\n"}, {"source_code": "a=[]\n4.times do\na << gets.chomp.split(\"\")\nend\nans=0\n0.upto(2) do |i|\n0.upto(2) do |j|\nw=0\nb=0\nif a[i][j]==\"#\"\nb+=1\nelse \nw+=1\nend\nif a[i+1][j]==\"#\"\nb+=1\nelse \nw+=1\nend\nif a[i][j+1]==\"#\"\nb+=1\nelse \nw+=1\nend\nif a[i+1][j+1]==\"#\"\nb+=1\nelse \nw+=1\nend\nif w>2 || b>2\nans=1\nend\nbreak if ans==1\nend\nbreak if ans==1\nend\nif ans==1\nputs \"YES\"\nelse \nputs \"NO\"\nend"}, {"source_code": "a=[*$<]\nputs ([0,1,2].product([0,1,2]).map{|x,y|\n [x,x+1].product([y,y+1]).count{|u,v| a[u][v]=='#'}\n} - [2]).empty? ? :NO : :YES"}], "negative_code": [{"source_code": "A = [gets, gets, gets, gets]\ndef rr(t)\n t = t.chars.sort {|x,y| y <=> x}.join\n puts t\n if (t[0] == t[1] and t[1] == t[2] and t[2] == t[3]) then return true end\n if t[0] != t[1] then return true end\n return false\nend\ndef solve()\n i, j = 0, 0\n while i != 3\n if rr(A[i][j] + A[i][j+1] + A[i+1][j] + A[i+1][j+1]) then return \"YES\" end\n j = j+1\n if j == 3 then i, j = i+1, 0 end\n end\n return \"NO\"\nend\nputs solve()\n"}, {"source_code": "A = [gets, gets, gets, gets]\ndef rr(t)\n t = t.chars.sort {|x,y| y <=> x}.join\n if (t[0] == t[1] and t[1] == t[2] and t[2] == t[3]) then return true end\n if t[0] != t[1] then return true end\n return false\nend\ndef solve()\n i, j = 0, 0\n while i != 3\n if rr(A[i][j] + A[i][j+1] + A[i+1][j] + A[i+1][j+1]) then return \"YES\" end\n j = j+1\n if j == 3 then i, j = i+1, 0 end\n end\n return \"NO\"\nend\nputs solve()\n"}, {"source_code": "m = Array.new\n\n4.times do\n m << gets.chomp\nend\n\n3.times do |y|\n 3.times do |x|\n if (m[y][x] + m[y+1][x] + m[y][x+1] + m[y+1][x+1]).delete(\".\").length >= 3\n puts 'YES'\n exit 0\n end\n end\nend\n\nputs 'NO'\n"}, {"source_code": "a=[*$<]\nputs [0,1,2].product([0,1,2]).map{|x,y| [x,x+1].product([y,y+1]).count{|u,v| a[u][v]=='#'} }.max >= 3 ? :YES : :NO"}], "src_uid": "01b145e798bbdf0ca2ecc383676d79f3"} {"source_code": "#!/usr/bin/env ruby\n\nrequire 'prime'\n\nn = gets.chop.to_i\n\nm = 1\nwhile m < 10**3 do\n result = m * n + 1\n break unless result.prime?\n m += 1\nend\n\nputs m\n", "positive_code": [{"source_code": "n = gets.chomp.to_i\ncase n\nwhen 1\n puts 3\nwhen 2\n puts 4\nelse\n puts (n - 2)\nend\n"}, {"source_code": "require'prime';n=gets.to_i;p (1..1/0.0).find{|i|!(n*i+1).prime?}"}, {"source_code": "n=gets.to_i;p n>2?n-2:n+2"}, {"source_code": "n = gets.to_i\nputs n <= 2 ? n + 2 : n - 2\n"}, {"source_code": "def prime(n)\n\treturn false if n == 0 || n == 1\n\n\ti = 2\n\twhile i * i <= n \n\t\treturn false if n % i == 0\n\t\ti += 1\n\tend\n\n\treturn true\nend\n\ndef main\n\tn = gets.to_i\n\n\tfor m in (1..1000)\n\t\tif not prime(n * m + 1)\n\t\t\tputs m\n\t\t\tbreak\n\t\tend\n\tend\nend\n\nmain"}, {"source_code": "require 'prime'\nn = gets.strip.to_i\nans = 1\nif n > 2\n (1..n).each do |i|\n if !Prime.prime?(n * i + 1)\n ans = i\n break\n end\n end\nelse\n ans = n + 2\nend\nputs ans\n"}, {"source_code": "require 'prime'\nn=gets.to_i\nm=1\nwhile Prime.prime?(n*m+1)\n\tm+=1\nend\nputs m"}, {"source_code": "require 'prime'\nn= gets.to_i\n\nfor i in 1..1000\n if !(Prime.prime?((i*n) + 1))\n print i\n break\n end\nend\n"}, {"source_code": "require 'prime'\nn=gets.to_i\nfor m in 1..999\n unless (n*m+1).prime?\n p m\n break\n end\nend\n"}, {"source_code": "require 'prime'\nN = gets.to_i\n(1..1000).each { |i| next if Prime.prime? N * i + 1\n p i\n exit\n}\n"}, {"source_code": "require'prime'\nN=gets.to_i\np (1..1000).find{|i|!Prime.prime?N*i+1}"}, {"source_code": "n=gets.chomp.to_i\ndef is_prime(a)\n i=2\n while i*i<=a do\n return 0 if a % i == 0\n #ruby不支持++运算!\n i += 1\n end\n return 1\nend\ni=1\nwhile true do\n #print \"#{i} \"\n #puts i*n+1\n #if i==5 break end\n #get_character\n #puts is_prime(i*n+1)\n\n if is_prime(i*n+1) == 1\n i+=1\n else\n puts i\n break\n end\nend\n"}, {"source_code": "n=gets.to_i;p n>2?n-2:n+2"}], "negative_code": [{"source_code": "def prime(n)\n\treturn false if n == 0 || n == 1\n\n\ti = 2\n\twhile i * i <= n \n\t\treturn false if n % i == 0\n\t\ti += 1\n\tend\n\n\treturn true\nend\n\ndef main\n\tn = gets.to_i\n\n\tfor m in (1..1000)\n\t\tif prime(n * m + 1)\n\t\t\tputs m\n\t\t\tbreak\n\t\tend\n\tend\nend\n\nmain"}, {"source_code": "require 'prime'\n\nn = gets.strip.to_i\nans = 0\n(1..n).each do |i|\n if !Prime.prime?(n * i + 1)\n ans = i\n break\n end\nend\nputs ans\n"}, {"source_code": "require 'prime'\n\nn = gets.strip.to_i\nans = 1\n(1..n).each do |i|\n if !Prime.prime?(n * i + 1)\n ans = i\n break\n end\nend\nputs ans\n"}, {"source_code": "p 4+gets.to_i%2"}, {"source_code": "require 'prime'\nN = gets.to_i\n(1..1000).each { |i| next if Prime.prime? N * i + 1\n at_exit { p i }\n}\n"}, {"source_code": "n=gets.chomp.to_i\ndef is_prime(a)\n i=2\n while i*i<=a do\n return 0 if a % i == 0\n #ruby不支持++运算!\n i += 1\n end\n return 1\nend\ni=1\nwhile true do\n #print \"#{i} \"\n #puts i*n+1\n if i==5\n break\n end\n #get_character\n #puts is_prime(i*n+1)\n\n if is_prime(i*n+1) == 1\n i+=1\n else\n puts i\n break\n end\nend\n"}], "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97"} {"source_code": "n = gets.chomp.to_i\n\nputs \"O-|-OOOO\" if n == 0\nwhile n != 0 do\n i = n%10\n row = \"\"\n if i < 5\n row += \"O-|\"\n else\n i = i - 5\n row += \"-O|\"\n end\n case i\n when 0\n row += \"-OOOO\"\n when 1\n row += \"O-OOO\"\n when 2\n row += \"OO-OO\"\n when 3\n row += \"OOO-O\"\n when 4\n row += \"OOOO-\"\n end\n puts row\n n = n/10\nend\n", "positive_code": [{"source_code": "n = gets.chomp\nrep = {0 => 'O-|-OOOO', \n 1 => 'O-|O-OOO', \n 2 => 'O-|OO-OO', \n 3 => 'O-|OOO-O', \n 4 => 'O-|OOOO-', \n 5 => '-O|-OOOO', \n 6 => '-O|O-OOO', \n 7 => '-O|OO-OO', \n 8 => '-O|OOO-O', \n 9 => '-O|OOOO-'\n}\n\narr = []\nn.each_char do |c|\n\tarr << rep[c.to_i]\nend\narr.reverse!\narr.each do |a|\n\tputs a\nend"}, {"source_code": "digital = {'0'=>'O-|-OOOO', '1'=>'O-|O-OOO', '2'=>'O-|OO-OO', '3'=>'O-|OOO-O', '4'=>'O-|OOOO-',\\\n '5'=>'-O|-OOOO', '6'=>'-O|O-OOO', '7'=>'-O|OO-OO', '8'=>'-O|OOO-O', '9'=>'-O|OOOO-'}\nn = gets.chomp.split('')\nn.reverse.each{|i| puts digital[i]}\n"}, {"source_code": "def rod(d)\n if d < 5\n print \"O-\"\n else\n print \"-O\"\n d -= 5\n end\n print \"|\"\n remain = 4-d\n while d > 0\n print \"O\"\n d -= 1\n end\n print \"-\"\n while remain > 0\n print \"O\"\n remain -= 1\n end\n puts \"\"\nend\n\ngets.strip.reverse.each_char do |c|\n d = c.to_i\n rod(d)\nend\n"}, {"source_code": "gets.chomp.split('').map { |x| x.to_i }.reverse.each { |x|\n left = x < 5 ? 'O-' : '-O'\n m = x % 5\n right = 'O' * m + '-' + 'O' * (4 - m)\n puts left + '|' + right\n}"}, {"source_code": "#f = File.open('test1.txt', 'r')\na = {\n '0' => 'O-|-OOOO',\n '1' => 'O-|O-OOO',\n '2' => 'O-|OO-OO',\n '3' => 'O-|OOO-O',\n '4' => 'O-|OOOO-',\n '5' => '-O|-OOOO',\n '6' => '-O|O-OOO',\n '7' => '-O|OO-OO',\n '8' => '-O|OOO-O',\n '9'=> '-O|OOOO-'\n}\nwhile(s = gets)\n s.chomp.reverse.chars.each do |ch|\n puts a[ch]\n end\nend"}, {"source_code": "n = gets.chomp.to_i\n\ndef draw(i)\n str = \"\"\n if i >= 5\n str = \"-O|\"\n else\n str = \"O-|\"\n end\n\n (i % 5).times do\n str += \"O\"\n end\n\n str += \"-\"\n (4 - (i % 5)).times do\n str += \"O\"\n end\n puts str\nend\n\nif n == 0\n draw(n)\nend\n\nwhile n != 0\n draw(n % 10)\n n /= 10\nend\n"}, {"source_code": "String.class_eval do\n ROD = %w[\n O-|-OOOO O-|O-OOO O-|OO-OO O-|OOO-O O-|OOOO-\n -O|-OOOO -O|O-OOO -O|OO-OO -O|OOO-O -O|OOOO-\n ]\n def soroban\n self.each_char{|s|puts ROD[s.to_i]}\n end\nend\n\ngets.chop.reverse.soroban\n"}, {"source_code": "#!/usr/bin/ruby\nT=[\n\t'O-|-OOOO',\n\t'O-|O-OOO',\n\t'O-|OO-OO',\n\t'O-|OOO-O',\n\t'O-|OOOO-',\n\t'-O|-OOOO',\n\t'-O|O-OOO',\n\t'-O|OO-OO',\n\t'-O|OOO-O',\n\t'-O|OOOO-',\n]\ngets.chomp.reverse.chars{|e|puts T[e.to_i]}"}, {"source_code": "str = gets.chomp\nstr.reverse.split(//).each do |c|\n if c.to_i >= 5\n print \"-O|\"\n else\n print \"O-|\"\n end\n tmp = (c.to_i - 5 < 0 ? c.to_i : c.to_i - 5)\n case tmp\n when 0 then\n puts \"-OOOO\"\n when 1 then \n puts \"O-OOO\"\n when 2 then \n puts \"OO-OO\"\n when 3 then \n puts \"OOO-O\"\n when 4 then \n puts \"OOOO-\"\n else\n puts \"-OOOO\"\n end\nend\n"}, {"source_code": "n = gets.chomp.to_i\ndigits = [\"O-|-OOOO\", \"O-|O-OOO\", \"O-|OO-OO\", \"O-|OOO-O\", \"O-|OOOO-\", \"-O|-OOOO\", \"-O|O-OOO\",\n \"-O|OO-OO\", \"-O|OOO-O\", \"-O|OOOO-\"]\nans = []\nif n == 0\n puts digits[0]\nelse\n while n > 0\n last = n % 10\n ans << digits[last]\n n -= last\n n /= 10\n end\n ans.each do |a|\n puts a\n end\nend\n"}, {"source_code": "a=gets.chomp.split(\"\")\n0.upto(a.length-1) {|i| a[i]=a[i].to_i}\na.reverse!\na.each do |i|\nans=(\"O\"*(1-i/5))+\"-\"+(\"O\"*(i/5))+\"|\"+(\"O\"*(i%5))+\"-\"+(\"O\"*(4-(i%5)))\nputs ans\nend"}], "negative_code": [{"source_code": "# encoding: utf-8\n\nstr = gets.chomp\nstr.reverse.split(//).each do |c|\n if c.to_i >= 5\n print \"-0|\"\n else\n print \"0-|\"\n end\n tmp = (c.to_i - 5 < 0 ? c.to_i : c.to_i - 5)\n case tmp\n when 0 then\n puts \"-0000\"\n when 1 then \n puts \"0-000\"\n when 2 then \n puts \"00-00\"\n when 3 then \n puts \"000-0\"\n when 4 then \n puts \"0000-\"\n else\n puts \"-0000\"\n end\nend\n"}, {"source_code": "n = gets.chomp.to_i\ndigits = [\"O-|-OOOO\", \"O-|O-OOO\", \"O-|OO-OO\", \"O-|OOO-O\", \"O-|OOOO-\", \"-O|-OOOO\", \"-O|O-OOO\",\n \"-O|OO-OO\", \"-O|OOO-O\", \"-O|OOOO-\"]\nans = []\nwhile n > 0\n last = n % 10\n ans << digits[last]\n n -= last\n n /= 10\nend\nans.each do |a|\n puts a\nend\n"}, {"source_code": "a=gets.chomp.split(\"\")\n0.upto(a.length-1) {|i| a[i]=a[i].to_i}\na.reverse!\na.each do |i|\nif i>=5\np=1\nq=0\nelse \np=0\nq=1\nend\nans=(\"o\"*(1-i/5))+\"-\"+(\"o\"*(i/5))+\"|\"+(\"o\"*(i%5))+\"-\"+(\"o\"*(4-(i%5)))\nputs ans\n\nend"}, {"source_code": "n = gets.chomp.to_i\nwhile n != 0 do\n i = n%10\n row = \"\"\n if i < 5\n row += \"O-|\"\n else\n i = i - 5\n row += \"-O|\"\n end\n case i\n when 0\n row += \"-OOOO\"\n when 1\n row += \"O-OOO\"\n when 2\n row += \"OO-OO\"\n when 3\n row += \"OOO-O\"\n when 4\n row += \"OOOO-\"\n end\n puts row\n n = n/10\nend\n"}, {"source_code": "n = gets.chomp\nrep = {0 => '0-|-0000', \n 1 => '0-|0-000', \n 2 => '0-|00-00', \n 3 => '0-|000-0', \n 4 => '0-|0000-', \n 5 => '-0|-0000', \n 6 => '-0|0-000', \n 7 => '-0|00-00', \n 8 => '-0|000-0', \n 9 => '-0|0000-'\n}\n\narr = []\nn.each_char do |c|\n\tarr << rep[c.to_i]\nend\narr.reverse!\narr.each do |a|\n\tputs a\nend"}, {"source_code": "gets.chomp.split('').map { |x| x.to_i }.reverse.each { |x|\n left = x < 5 ? '0-' : '-0'\n m = x % 5\n right = '0' * m + '-' + '0' * (4 - m)\n puts left + '|' + right\n}"}, {"source_code": "#f = File.open('test1.txt', 'r')\na = {\n '0' => 'O-|-OOOO',\n '1' => 'O-|O-OOO',\n '2' => 'O-|OO-OO',\n '3' => 'O-|OOO-O',\n '4' => 'O-|OOOO-',\n '5' => '-O|-OOOO',\n '6' => '-O|O-OOO',\n '7' => '-O|OO-OO',\n '8' => '-O|OOO-O',\n '9'=> '-O|OOOO-'\n}\nwhile(s = gets)\n s.chomp.reverse.chars.each do |ch|\n p a[ch]\n end\nend"}, {"source_code": "n = gets.chomp.to_i\n\ndef draw(i)\n str = \"\"\n if i >= 5\n str = \"-0|\"\n else\n str = \"0-|\"\n end\n\n (i % 5).times do\n str += \"0\"\n end\n\n str += \"-\"\n (4 - (i % 5)).times do\n str += \"0\"\n end\n puts str\nend\n\nwhile n != 0\n draw(n % 10)\n n /= 10\nend\n"}, {"source_code": "n = gets.chomp.to_i\n\ndef draw(i)\n str = \"\"\n if i >= 5\n str = \"-O|\"\n else\n str = \"O-|\"\n end\n\n (i % 5).times do\n str += \"O\"\n end\n\n str += \"-\"\n (4 - (i % 5)).times do\n str += \"O\"\n end\n puts str\nend\n\nwhile n != 0\n draw(n % 10)\n n /= 10\nend\n"}], "src_uid": "c2e3aced0bc76b6484360563355d23a7"} {"source_code": "require 'openssl'\nn,m,k=gets.split.map(&:to_i)\nd=10**9+9\np=n/k\nq=m-n+p\nif q<=0\n puts m\n exit\nend\nr=2.to_bn.mod_exp(q+1,d).to_i\nr=((d+r-2)%d*k+m-q*k)%d\np r\n", "positive_code": [{"source_code": "require 'openssl'\nMOD = 10 ** 9 + 9\nn, m, k = gets.chop.split.map(&:to_i)\nextra = n - m\nif(extra * k >= n)\n print m % MOD\nelse\n st = n - extra * k\n cnt = st / k\n rest = st % k\n total = ((2.to_bn.mod_exp(cnt + 1,MOD) - 2 + MOD) % MOD * k + rest + extra *(k - 1)) % MOD\n print total\nend\n"}, {"source_code": "MOD = 10 ** 9 + 9\ndef pow2(x)\n st = 1\n pow = 2\n while(x != 0)\n if((x & 1) != 0)\n st = (st * pow) % MOD\n end\n pow = (pow * pow) % MOD\n x >>= 1\n end\n return st\nend\nn, m, k = gets.chop.split.map(&:to_i)\nextra = n - m\nif(extra * k >= n)\n print m % MOD\nelse\n st = n - extra * k\n cnt = st / k\n rest = st % k\n total = pow2(cnt + 1)\n total = (total - 2 + MOD) % MOD\n total = (total * k + rest) % MOD\n total += extra * (k - 1)\n total %= MOD\n print total\nend\n"}, {"source_code": "module STL\n module Algorithm\n def power_mod(a, b, c) #compute (a ^ b) mod c\n ans, tich = 1, a\n while b > 0\n ans = (ans * tich) % c if b % 2 == 1\n tich = (tich * tich) % c\n b /= 2\n end\n ans\n end\n end\nend\n\ninclude STL::Algorithm\nMOD = 1000_000_009\ndef solve(f)\n n, m, k = f.gets.split.map(&:to_i)\n t = (n / k) * (k - 1) + n % k\n if m <= t\n puts m\n else\n a = m - t\n\n tmp = power_mod(2, (a + 1), MOD)\n puts (k * (tmp - 2) + m - a * k) % MOD\n end\nend\n\ndef debug\n (1..3).each do |e|\n f = File.new(\"test#{e}.txt\", 'r')\n solve f\n f.close\n end\nend\n\ndef release\n solve STDIN\nend\n\nrelease"}, {"source_code": "require 'openssl'\n\nn, m, k = gets.chomp.split(' ').map(&:to_i)\nd = 1000000009\nx = [0, m - (n - n % k) / k * (k-1) - n % k].max\n\nr = 2.to_bn.mod_exp(x+1, d)\nr = (r-2)*k % d\nr = (r + (m-x*k)) % d\n\nwhile r < 0 \n\tr += d\nend\n\nputs r"}], "negative_code": [{"source_code": "require 'openssl'\n\nn, m, k = gets.chomp.split(' ').map(&:to_i)\nd = 1000000009\nx = [0, m - (n - n % k) / k * (k-1) - n % k].max\nputs x\n\nr = 2.to_bn.mod_exp(x+1, d)\nr = (r-2)*k % d\nr = (r + (m-x*k)) % d\n\nwhile r < 0 \n\tr += d\nend\n\nputs r"}, {"source_code": "n, m, k = gets.chomp.split(' ').map(&:to_i)\n\nx = [0, m - (n - n % k) / k * (k-1) - n % k].max\nr = (2**(x+1)-2)*k + m-x*k\n\nr = r % 1000000009\n\nputs r"}, {"source_code": "require 'openssl'\n\nn, m, k = gets.chomp.split(' ').map(&:to_i)\nd = 1000000009\nx = [0, m - (n - n % k) / k * (k-1) - n % k].max\n#puts x\n\nr = 2.to_bn.mod_exp(x+1, d)\nr = (r-2)*k % d\nr = (r + (m-x*k)) % d\n\nputs r"}, {"source_code": "MOD = 10 ** 9 + 9\nn, m, k = gets.chop.split.map(&:to_i)\nextra = n - m\ntotal = 0\nif(extra * k >= n)\n\tprint m % mod\nelse\n\tst = n - extra * k\n\t1.upto(st) do |i|\n\t\ttotal += 1\n\t\tif(i % k == 0)\n\t\t\ttotal *= 2\n\t\tend\n\tend\n\ttotal += extra * (k - 1)\n\tprint total\nend"}, {"source_code": "MOD = 10 ** 9 + 9\ndef pow2(x)\n st = 1\n pow = 2\n while(x != 0)\n if(x & 1)\n st = (st * pow) % MOD\n end\n pow = (pow * pow) % MOD\n x >>= 1\n end\n return st\nend\nn, m, k = gets.chop.split.map(&:to_i)\nextra = n - m\nif(extra * k >= n)\n print m % MOD\nelse\n st = n - extra * k\n cnt = st / k\n rest = st % k\n total = pow2(cnt)\n total = (total - 2 + MOD) % MOD\n total = (total * k + rest) % MOD\n total += extra * (k - 1)\n total %= MOD\n print total\nend\n"}, {"source_code": "MOD = 10 ** 9 + 9\nn, m, k = gets.chop.split.map(&:to_i)\nextra = n - m\nif(extra * k >= n)\n print m % MOD\nelse\n st = n - extra * k\n cnt = st / k\n rest = st % k\n total = (2 ** (cnt + 1) - 2) * k + rest\n total += extra * (k - 1)\n total %= MOD\n print total\nend\n"}, {"source_code": "require 'openssl'\nn,m,k=gets.split.map(&:to_i)\nd=10^9+9\np=n/k\nq=m-n+p\nif q<=0\n puts m\n exit\nend\nr=2.to_bn.mod_exp(q+1,d)\nr=((r-2)%d*k%d+m-q*k)%d\np r\n"}, {"source_code": "require 'openssl'\nn,m,k=gets.split.map(&:to_i)\nd=10^9+9\np=n/k\nq=m-n+p\nif q<=0\n puts m\n exit\nend\nr=2.to_bn.mod_exp(q+1,d).to_i\nr=((d+r-2)%d*k+m-q*k)%d\np r\n"}, {"source_code": "require 'openssl'\nn,m,k=gets.split.map(&:to_i)\nd=10^9+9\np=n/k\nq=m-n+p\nif q<=0\n puts m\n exit\nend\nr=2.to_bn.mod_exp(q+1,d).to_i\nr=((r-2)%d*k+m-q*k)%d\np r\n"}, {"source_code": "module Containers\n class Stack\n\n end\nend\n\nmodule Algorithm\n def pow_mod(a, b, c) #compute (a ^ b) mod c\n ans, tich = 1, a\n while b > 0\n ans = (ans * tich) % c if b % 2 == 1\n tich = (tich * tich) % c\n b /= 2\n end\n ans\n end\nend\n\ndef solve\n n, m, k = gets.split.map(&:to_i)\n t = (n / k) * (k - 1) + n % k\n if m <= t\n puts m\n else\n a = m - t\n puts k * ((1 << (a + 1)) - 2) + m - a * k\n end\nend\n\nsolve"}], "src_uid": "9cc1aecd70ed54400821c290e2c8018e"} {"source_code": "n,*a=$<.map &:to_i;p a[0,2].min*(2--~n/n)+a.min*[0,n-2].max", "positive_code": [{"source_code": "\nn,a,b,c = (gets+gets+gets+gets).split.map(&:to_i)\n\nif n==1\n p 0;exit\nend\nlen = 0\n\nx = [a,b].min\nlen += x\nn-=2\n\nif n > 0\n len += [x,c].min*n\nend\n\np len"}, {"source_code": "#! /usr/bin/env ruby\n\nn = gets.to_i\na = gets.to_i\nb = gets.to_i\nc = gets.to_i\n\nn -= 1\n\nans = 0\n\nif n > 0\n ans += [a, b].min\n n -= 1\nend\n\nans += [a, b, c].min * n\nn -= n\n\nputs ans\n"}, {"source_code": "n = gets.to_i\na = gets.to_i\nb = gets.to_i\nc = gets.to_i\nn -= 1\nx = [a, b, c].min\ntot = 0\nif n >= 1\n tot += [a, b].min\n tot += (n - 1) * x\nend\nputs tot\n"}, {"source_code": "n = gets.strip.to_i\na = gets.strip.to_i\nb = gets.strip.to_i\nc = gets.strip.to_i\ncurr = 1\nans = 0\nif n > 1\n i = 1\n while i < n\n dist = 0\n case curr\n when 1\n if a <= b\n dist = a\n curr = 2\n else\n dist = b\n curr = 3\n end\n when 2\n if a <= c\n dist = a\n curr = 1\n else\n dist = c\n curr = 2\n end\n when 3\n if c <= b\n dist = c\n curr = 2\n else\n dist = b\n curr = 1\n end\n end\n ans += dist\n i += 1\n end\nend\nputs ans\n"}], "negative_code": [{"source_code": "n,*a=$<.map &:to_i;p a[0,2].min*(-~n/n-1)+a.min*[0,n-2].max"}, {"source_code": "n,*a=$<.map &:to_i;p a.min*~-n"}, {"source_code": "n = gets.strip.to_i\na = gets.strip.to_i\nb = gets.strip.to_i\nc = gets.strip.to_i\ncurr = 1\nans = 0\nif n > 1\n i = 1\n while i < n\n dist = 0\n if curr.odd?\n dist = [a, b].min\n curr = 2\n else\n dist = [a, b, c].min\n curr = 1\n end\n ans += dist\n i += 1\n end\nend\nputs ans\n"}, {"source_code": "\nn,a,b,c = (gets+gets+gets+gets).split.map(&:to_i)\n\nif n==1\n p 0\nend\nlen = 0\n\nx = [a,b].min\nlen += x\nn-=2\n\nif n > 0\n len += [x,c].min*n\nend\n\np len"}, {"source_code": "#! /usr/bin/env ruby\n\nn = gets.to_i\na = gets.to_i\nb = gets.to_i\nc = gets.to_i\n\nn -= 1\n\nans = 0\n\nans += [a, b].min\nn -= 1\n\nans += [a, b, c].min * n\nn -= n\n\nputs ans\n"}, {"source_code": "n = gets.to_i\na = gets.to_i\nb = gets.to_i\nc = gets.to_i\nn -= 1\nx = [0, a, b, c].sort\ntot = (n / 3) * (a + b + c)\nfor i in 1 .. 3\n x[i] += x[i - 1]\nend\ntot += x[n % 3]\nputs tot\n"}, {"source_code": "n = gets.to_i\na = gets.to_i\nb = gets.to_i\nc = gets.to_i\nx = [a, b, c].min\ntot = (n - 1) * x\nputs tot\n"}], "src_uid": "6058529f0144c853e9e17ed7c661fc50"} {"source_code": "def run\n n = $stdin.gets.to_i\n a = $stdin.gets.split.map(&:to_i)\n max = a.delete_at(a.index(a.max))\n min = a.delete_at(a.index(a.min))\n\n puts ([max] + a.sort + [min]).join(\" \")\nend\n\nrun if $0 == __FILE__\n", "positive_code": [{"source_code": "n = gets.to_i\narray = gets.chomp!.split(' ').map(&:to_i).sort\narray[0], array[-1] = array[-1], array[0]\nputs array.join(' ')"}, {"source_code": "class A\n def initialize\n n = gets.chomp.to_i\n num_list = gets.chomp.split(' ').map(&:to_i)\n max_num = num_list.max\n min_num = num_list.min\n num_list.delete_at(num_list.find_index(max_num))\n num_list.delete_at(num_list.find_index(min_num))\n\n answer = [max_num] + num_list.sort + [min_num]\n\n puts answer.join(' ')\n end\nend\n\na = A.new"}], "negative_code": [], "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4"} {"source_code": "N,k=gets.split.map &:to_i\ns=gets.chomp\ndp=(0..100).map{[0]*101}\ndp[0][0]=1\nN.times{|i|\n\t(1..i+1).each{|j|\n\t\t0.upto(i){|k|dp[i+1][j]+=dp[k][j-1]}\n\t\ti.times{|k|dp[i+1][j]-=dp[k+1][j] if s[i]==s[k]}\n\t}\n}\nSUM=(0..N).map{|i|t=0;(0..N).each{|j|t+=dp[j][i]};t}\nans=0\nN.downto(0){|i|\n\tt=[SUM[i],k].min\n\tk-=t\n\tans+=t*(N-i)\n}\np k>0 ? -1 : ans", "positive_code": [{"source_code": "MOD=10**9+7\ncnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)\ndef gs() gets.chomp end\ndef gi() gets.to_i end\ndef gsmi() gets.chomp.split.map(&:to_i) end\n\ndef desc(ar) ar.sort{|x,y|y<=>x} end##\ndef min(a,b) a<=b ? a : b end\ndef max(a,b) a>=b ? a : b end\ndef sum(ar) ar.inject(:+) end\n\ndef C(a,b) b==0||a==b ? 1 : (b=a-b if a/20 do\n ar=[]\n prev.each do |pr|\n l.times do |i|\n st=pr[0,i]+pr[(i+1)..-1]\n ar<=1\nend\n\nputs cnt"}], "negative_code": [], "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b"} {"source_code": "5.times do |i|\n j = gets.split.index(\"1\")\n if j\n puts (2 - i).abs + (2 - j).abs \n break\n end\nend", "positive_code": [{"source_code": "5.times do|i|\nj=gets.split.index(?1)and puts (i-2).abs+(j-2).abs\nend"}, {"source_code": "for i in 1..5\n\tstr = gets.chomp\n\tif str.include? \"1\"\n\t\ty = i\n\t\tx = (((\" \" + str).index \"1\") + 1) / 2\n\tend\nend\nputs (x - 3).abs + (y - 3).abs"}, {"source_code": "arr = []\nx = nil\ny = nil\n\n5.times do |tx|\n arr << gets.chomp.split(' ')\n y ||= arr.last.index '1'\n (x ||= tx) if y\nend\n\nputs (x-2).abs + (y-2).abs\n"}, {"source_code": "1.upto(5) { |i| gets.chomp.split.each_with_index { |x,j| puts (i-3).abs + (j-2).abs if x == '1'} }"}, {"source_code": "$<.each_with_index{|x,r|c=x.split.index('1');(puts (r-2).abs+(c-2).abs; break) if c}\n"}, {"source_code": "ar = []\n5.times do\n ar << gets.split(' ').map(&:to_i)\nend\nrow = ar.map{|x| x.inject(:+)}.index(1)\ncol = ar[row].index(1)\nputs (row-2).abs+(col-2).abs"}, {"source_code": "def abs(x)\n if x < 0 then\n return -x\n else\n return x\n end\nend\n\nn = 0\nm = 0\nmatrix = []\n5.times do |i|\n matrix[i] = gets.split\n if q = matrix[i].index(\"1\") then\n n = i + 1\n m = q + 1\n end\nend\n\nresult = abs(n-3) + abs(m-3)\nputs result"}, {"source_code": "5.times do |i|\n j = gets.split.index(?1)\n puts (i-2).abs + (j-2).abs if j\nend"}, {"source_code": "d,r=$<.read.split.each_with_index.find{|e,i|e==?1}[1].divmod(5)\np (d-2).abs+(r-2).abs"}, {"source_code": "matrix = [] ; 5.times{ matrix << gets.chomp.split(\" \").map(&:to_i) }\nmatrix.each_with_index do |line, i|\n if line.include?(1)\n count_heigth = (3 - (i+1)).abs\n line.each_with_index do |element, index|\n if element == 1\n count_element = (3 - (index+1)).abs\n puts count_heigth + count_element\n end\n end\n end\nend"}, {"source_code": "s = $<.gets ?1\ni = s.count(?\\n)\nj = s[/.*1/].count ?0\np (2-i).abs + (2-j).abs"}, {"source_code": "def read_tokens\n return gets.chomp.to_s.strip.split(' ')\nend\n\ndef read_ints\n data = []\n read_tokens.each { |s|\n data.push(s.to_i)\n }\n return data\nend\n\n\nr_1, c_1 = 0, 0\n(0...5).each { |r|\n row = read_ints\n c = row.find_index(1)\n if c != nil\n r_1, c_1 = r, c\n end\n}\n\ndef solve(row, col)\n dest_r, dest_c = 2, 2\n return (dest_r - row).abs + (dest_c - col).abs\nend\n\n\nprint(solve(r_1, c_1))"}, {"source_code": "f = false\nm = 0\n0.upto 4 do |t|\n\tif !f\n\t\ta = gets.chomp.split(\" \")\n\t\tif a.include? \"1\"\n\t\t\tm += (2 - t).abs\n\t\t\tm += (2 - a.index(\"1\")).abs\n\t\t\tf = true\n\t\tend\n\telse\n\t\tgets\n\tend\nend\nputs m"}, {"source_code": "5.times{|r|c=gets.index(?1);(c)?(p (r-2).abs+(c/2-2).abs):(0)}\n\n"}, {"source_code": "a=Array.new\ns=1\n5.times do \nj=0\na=gets.split.map(&:to_i)\nfor i in 0..4 do\nif a[i]==1 then \nputs (s-3).abs+(i+1-3).abs\nj=1\nend\nend\nbreak if j== 1\ns+=1\nend\n\n\n"}, {"source_code": "r1 = gets.chomp\nrow1 = r1.split(\" \")\nr2 = gets.chomp\nrow2 = r2.split(\" \")\nr3 = gets.chomp\nrow3 = r3.split(\" \")\nr4 = gets.chomp\nrow4 = r4.split(\" \")\nr5 = gets.chomp\nrow5 = r5.split(\" \")\n\nspaces = 0\nif row1.include? \"1\" \n\tif row1[2] == \"1\"\n\t\tspaces = 0\n\telsif row1[0] == \"1\" || row1[4] == \"1\"\n\t\tspaces += 2\n\telse\n\t\tspaces += 1\n\tend\n\tspaces += 2\nelsif row2.include? \"1\"\n\tif row2[2] == \"1\"\n\t\tspaces = 0\n\telsif row2[0] == \"1\" || row2[4] == \"1\"\n\t\tspaces += 2\n\telse\n\t\tspaces += 1\n\tend\t\n\tspaces += 1\t\nelsif row3.include? \"1\"\n\tif row3[2] == \"1\"\n\t\tspaces = 0\n\telsif row3[0] == \"1\" || row3[4] == \"1\"\n\t\tspaces += 2\n\telse\n\t\tspaces += 1\n\tend\t\t\nelsif row4.include? \"1\"\n\tif row4[2] == \"1\"\n\t\tspaces = 0\n\telsif row4[0] == \"1\" || row4[4] == \"1\"\n\t\tspaces += 2\n\telse\n\t\tspaces += 1\n\tend\t\t\n\tspaces += 1\nelse\n\tif row5[2] == \"1\"\n\t\tspaces = 0\n\telsif row5[0] == \"1\" || row5[4] == \"1\"\n\t\tspaces += 2\n\telse\n\t\tspaces += 1\n\tend\n\tspaces += 2\nend\n\t\nputs spaces"}, {"source_code": "5.times{|r|c=gets.index(?1);(c)?(p (r-2).abs+(c/2-2).abs):(0)}\n"}, {"source_code": "5.times{|r|c=gets.index(?1);(c)?(p (r-2).abs+(c/2-2).abs):(0)}\n\n"}, {"source_code": "mat = []\n5.times{\n\tmat << STDIN.readline.split\n}\n\n(0..4).each{|i|\n\t(0..4).each{|j|\n\t\tif mat[i][j] == '1'\n\t\t\tp (i-2).abs+(j-2).abs\n\t\tend\n\t}\n}"}, {"source_code": "arr = []\ni = 0\nj = 0\n5.times {\n arr.push(gets.split(\" \").map(&:to_i))\n}\narr.each_with_index do |row,i_ind|\n val = row.index(1)\n i = i_ind and j = val if val\nend\nputs (i - 2).abs + (2 - j ).abs"}, {"source_code": "(1..5).each do |i|\n m = gets.split(/\\s+/).map(&:to_i)\n i_th = m.index(1)\n unless i_th.nil?\n movements = (3-(i_th+1)).abs + (3-i).abs\n puts movements\n break\n end\nend\n"}, {"source_code": "m = 0\nn = 0\nfor i in 0...5\n x = gets.split.map(&:to_i)\n for j in 0...5 \n if x[j]==1\n m = j\n n = i\n break\n end\n end\n \n\nend\n\nputs (n-2).abs + (m-2).abs "}, {"source_code": "#!/usr/bin/ruby1.9\n\n5.times do |r|\n\trow = STDIN.readline.split\n\t5.times do |c|\n\t\tif row[c] == '1'\n\t\t\tputs ((r-2).abs+(c-2).abs)\n\t\t\texit\n\t\tend\n\tend\nend\n"}, {"source_code": "x = 0\ny = 0\n(0...5).each do |i|\n a = []\n a = gets.split.map &:to_i\n (0...5).each do |j|\n if a[j] == 1\n x = i + 1\n y = j + 1\n end\n end\nend\n\nputs (3 - x).abs + (3 - y).abs"}, {"source_code": "5.times { |row|\n c = gets.chomp.gsub(\" \", \"\").index(\"1\")\n puts (2-row).abs + (2-c).abs if c\n}\n"}, {"source_code": "5.times{|x|a=gets.split.index(?1);!a ?(0):(puts (a-2).abs+(x-2).abs)}"}, {"source_code": "5.times{|x|a=gets.split.index(?1);!a ?(0):(puts (a-2).abs+(x-2).abs)}"}, {"source_code": "matrix = []\n5.times do\n row_string = gets.strip\n row = row_string.split(' ').map(&:to_i)\n matrix.push(row)\nend\n\nrow = nil\ncolumn = nil\n5.times do |row_index|\n 5.times do |column_index|\n next unless matrix[row_index][column_index].eql?(1)\n\n row = row_index\n column = column_index\n break\n end\nend\n\ndiff_row = (row - 2).abs\ndiff_column = (column - 2).abs\nresult = diff_row + diff_column\nputs result\n"}, {"source_code": "a=[]\ni=0\nx=0\ny=0\n5.times do\n\trow=gets.chomp.split(' ')\n\t#print row\n\t#puts\n\trow.each_index do |char|\n\t\t#puts row[char]\n\t\tif row[char]=='1'\n\t\t\tx=i\n\t\t\ty=char\n\t\tend\n\tend\n\ta.push(row)\n\ti+=1\nend\n#puts '('+x.to_s+','+y.to_s+')'\nputs (x-2).abs+(y-2).abs\n"}, {"source_code": "# https://codeforces.com/problemset/problem/263/A\n0.upto(4) do |i|\n line = gets.chomp\n chars = line.split(' ')\n chars.each_with_index do |c, j|\n if c == '1'\n p (2 - i).abs + (2 - j).abs\n end\n end\nend\n"}, {"source_code": "5.times{|x|a=gets.split.index(?1);!a ?(0):(puts (a-2).abs+(x-2).abs)}"}, {"source_code": "5.times{|r|c=gets.index(?1);(c)?(p (r-2).abs+(c/2-2).abs):(0)}"}, {"source_code": "l = []\n(1..5).each { l << gets.split.map(&:to_i) }\n\nx = 0\ny = 0\n\nl.each_with_index { |i, in1| \n\ti.each_with_index { |j, in2| \n\t\t\tif j == 1 \n\t\t\t\tx = in2\n\t\t\t\ty = in1\n\t\t\t\tbreak\n\t\t\tend\n\t\t} \n\t}\n\nputs (x - 2).abs + (y - 2).abs"}, {"source_code": "coco = 0\nmoco = 0\n5.times do |x|\n a = gets.split.map(&:to_i)\n if a.include? 1\n coco = x\n moco = a.index(1)\n end\nend\n\nputs (coco - 2).abs + (moco - 2).abs"}, {"source_code": "i = 1\nrow_num = 0\noutput = 0\nwhile i <= 5\n input_row = gets.chomp.split\n if input_row.include?(\"1\") then\n input_row = input_row.map{|i| i.to_i}\n colum_num = input_row.index{|i| i == 1}\n row_num = i\n colum_num = colum_num +1\n end\n i = i+1\nend\nif 3 > row_num then\n output = 3 - row_num\nelsif 3 < row_num then\n output = row_num -3\nend\nif 3 > colum_num then\n output = 3 - colum_num + output\nelsif 3 < colum_num then\n output = colum_num - 3 + output\nend\nprint output\n"}, {"source_code": "line1 = gets.chomp.split(\" \")\nline2 = gets.chomp.split(\" \")\nline3 = gets.chomp.split(\" \")\nline4 = gets.chomp.split(\" \")\nline5 = gets.chomp.split(\" \")\n\ni = 0\nj = 0\nif line1.index(\"1\")\n\tj = line1.index(\"1\")\n\ti = 0\nend\n\nif line2.index(\"1\")\n\tj = line2.index(\"1\")\n\ti = 1\nend\n\nif line3.index(\"1\")\n\tj = line3.index(\"1\")\n\ti = 2\nend\n\nif line4.index(\"1\")\n\tj = line4.index(\"1\")\n\ti = 3\nend\n\nif line5.index(\"1\")\n\tj = line5.index(\"1\")\n\ti = 4\nend\n\nputs \"#{(i-2).abs+(j-2).abs}\""}, {"source_code": "i,j = nil, nil\n(0..4).each do |k|\n a = $stdin.readline.split.map(&:to_i)\n t = a.find_index(1)\n if !t.nil?\n i,j=k,t\n end\nend\n\ndi = (2-i).abs\ndj = (2-j).abs\n\nputs di+dj"}, {"source_code": "a = Array.new(5, Array.new(5))\nii, jj = 0, 0;\nfor i in 0...5\n a[i] = gets.split(\" \").map(&:to_i)\n for j in 0...5\n if a[i][j] == 1\n ii ,jj = i, j;\n end\n end\nend\nputs (ii - 2).abs + (jj - 2).abs"}, {"source_code": "5.times{|r|c=gets.index(?1);(c)?(p (r-2).abs+(c/2-2).abs):(0)}"}, {"source_code": "def run\n ARGF.readlines.each_with_index do |line, i|\n line.chomp.split(\" \").each_with_index do |c, j|\n if c == \"1\"\n puts (i - 2).abs + (j - 2).abs\n return\n end\n end\n end\nend\n\nrun if $0 == __FILE__\n"}, {"source_code": "# cook your code here\narr = Array.new(5,Array.new(5))\none_row =0 \none_col=0\n(0..4).each do |row|\n val = gets.split(\" \").map(&:to_i)\n (0..4).each do |col|\n arr[row][col] = val[col]\n if val[col] == 1 \n one_row = row \n one_col = col \n end \n end \nend \nputs (one_row - 2).abs + (one_col-2).abs"}, {"source_code": "inp = Array.new\n5.times do\n inp << gets.chomp\nend\ninp.each do |str|\n if str =~ /^.*1.*$/\n str.scan(/1/) { |ch| puts (inp.index(str) - 2).abs + (str.delete(\" \").index(ch) - 2).abs }\n end\nend\n"}, {"source_code": "5.times{|r|c=gets.index(?1);(c)?(p (r-2).abs+(c/2-2).abs):(0)}\n\n"}, {"source_code": "#!/usr/bin/env ruby -w\n\nv = (1..5).map do\n gets.split(/\\s+/).map(&:to_i)\nend\n\nfound = false\n(0..4).each do |i|\n break if found\n (0..4).each do |j|\n if v[i][j] == 1\n puts (i - 2).abs + (j - 2).abs\n found = true\n break\n end\n end\nend\n"}, {"source_code": "grids = []\none_id = nil\n5.times do |i|\n line = gets.split.map(&:to_i)\n one_id = line.index(1)\n if one_id\n puts (i - 2).abs + (one_id - 2).abs\n end\nend"}, {"source_code": "def check (n,r)\n\tif n.include?(1)\n\t\tputs (3-r).abs + (3-(n.index(1)+1)).abs\n\tend\nend\n\nx = []\nx = gets.split.map(&:to_i)\n\ny = []\ny = gets.split.map(&:to_i)\n\nz = []\nz = gets.split.map(&:to_i)\n\na = []\na = gets.split.map(&:to_i)\n\nb = []\nb = gets.split.map(&:to_i)\n\ncheck(x,1)\ncheck(y,2)\ncheck(z,3)\ncheck(a,4)\ncheck(b,5)\n"}, {"source_code": "\narr_input = []\ni, j = -1\n5.times do |n|\n \tarr = gets.chomp\n \tarr_input << arr\nend\n\narr_input.each.with_index do |row, index|\n\trow.split(' ').each.with_index do |col, idx|\n\t\tif col.to_i == 1\n\t\t\ti = index\n\t\t\tj = idx\n\t\tend\n\tend\nend\nmin_distance = (2 - i).abs + (2 - j).abs\n\nputs min_distance"}, {"source_code": "\narr_input = []\ni, j = -1\n5.times do |n|\n \tarr = gets.chomp\n \tarr_input << arr\n \tarr.split(' ').each.with_index do |col, idx|\n\t\tif col.to_i == 1\n\t\t\ti = n\n\t\t\tj = idx\n\t\tend\n\tend\nend\nmin_distance = (2 - i).abs + (2 - j).abs\n\nputs min_distance"}, {"source_code": "5.times{|r|c=gets.index(?1);(c)?(p (r-2).abs+(c/2-2).abs):(0)}\n\n"}, {"source_code": "5.times{|r|c=gets.index(?1);(c)?(p (r-2).abs+(c/2-2).abs):(0)}"}, {"source_code": "5.times do |i|\n a = gets.split.map(&:to_i)\n 5.times do |j|\n if a[j] == 1\n puts (2 - i).abs() + (2 - j).abs()\n exit 0\n end\n end\nend\n"}, {"source_code": "#!/usr/bin/env ruby\n\n5.times do |i|\n\tgets.split.each_with_index do |v, j|\n\t\tif v == \"1\"\n\t\t\tputs (i - 2).abs + (j - 2).abs\n\t\t\texit 0\n\t\tend\n\tend\nend\n"}, {"source_code": "n = 0\n5.times.each_with_index do |row, ind|\n line = gets.chomp.match(/1/)\n if line\n n = (ind - 2).abs + (line.begin(0) / 2 - 2).abs\n end\nend\nputs n\n"}, {"source_code": "5.times{|r|c=gets.index(?1);(c)?(p (r-2).abs+(c/2-2).abs):(0)}\n\n"}, {"source_code": "5.times{|r|c=gets.index(?1);(c)?(p (r-2).abs+(c/2-2).abs):(0)}\n\n"}, {"source_code": "include Math\nBEGIN{\n\tdef gint()\n\t\treturn gets.split.map(&:to_i)\n\tend\n\tdef main()\n\t\ta = []\n\t\tx = y = 0\n\t\t5.times do |i|\n\t\t\ta[i] = gint\n\t\t\ta[i].each_with_index do |ta,w|\n\t\t\t\tif ta == 1 then\n\t\t\t\t\tx, y = i, w \n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tputs (x-2).abs + (y-2).abs\n\tend\n\tTest_case = 1\n\tTest_case.times do\n\t\tmain()\n\tend\n}\n"}, {"source_code": "line = 0\npos = 0\nwhile true\n line += 1\n pos = gets.split.map(&:to_i).index(1)\n if pos != nil\n break\n end\nend\npos += 1\nputs (3-line).abs + (3-pos).abs\n"}, {"source_code": "_2d = []\n5.times{ _2d = _2d + [gets.chomp.split.map(&:to_i)]}\nfor i in (0...5) do\n for j in (0...5) do\n unless _2d[i][j].zero?\n puts (3-(i+1)).abs + (3-(j+1)).abs\n end\n end\nend\n"}, {"source_code": "t = 5\n\nt.times do |i|\n\ts = gets.split.collect{|x| x.to_i}\n\n\ts.each_index{|j|\n\t\tif s[j] == 1\n\t\t\tputs (i-2).abs + (j-2).abs\n\t\tend\n\t}\nend"}, {"source_code": "x=nil\ny=nil\n\n5.times do |i|\n a=gets.split.map{|e|e.to_i}\n n=a.index 1\n if n\n x=n\n y=i\n break\n end\nend\n\nputs (2-x).abs+(2-y).abs\n"}, {"source_code": "5.times{|r|c=gets.index(?1);(c)?(p (r-2).abs+(c/2-2).abs):(0)}\n\n"}, {"source_code": "matrix = []\nrow, column = 0, 0\n\n(0...5).each do |iterNum|\n\tmatrix << gets.chomp.split(' ').map {|item| item.to_i}\n\trow, column = iterNum, matrix[iterNum].index(1) unless matrix[iterNum].index(1).nil?\nend\n\nputs (2 - row).abs + (2 - column).abs"}, {"source_code": "matrix = []\npos_one = [-1, -1]\nbeautiful_pos = [3, 3]\n(1..5).each do |index|\n row = gets.chomp.split(/ /).map(&:to_i)\n matrix << row\n pos_one = [index, row.index( 1 ) + 1] if row.include? 1\nend\nputs (pos_one[0] - beautiful_pos[0]).abs + (pos_one[1] - beautiful_pos[1]).abs\n"}, {"source_code": "5.times{|r|c=gets.index(?1);(c)?(p (r-2).abs+(c/2-2).abs):(0)}\n"}, {"source_code": "$<.each_with_index{|x,r|c=x.split.index(?1);(c)?(puts (r-2).abs+(c-2).abs):(0)}\n"}, {"source_code": "# http://codeforces.com/problemset/problem/263/A\n\nrows = []\n\none_row_index = -1\none_col_index = -1\n\n5.times do |t|\n row = gets.chomp.split\n if row.include? \"1\"\n one_row_index = t\n one_col_index = row.find_index(\"1\")\n end\n rows << row\nend\n\nputs \"#{(2 - one_row_index).abs + (2 - one_col_index).abs}\""}, {"source_code": "runner = 0\nheight = 0\nwidth = 0\nwhile line = gets.to_s.strip do\n break if line == ''\n columns = line.split(' ')\n if columns.include? '1'\n width = columns.index '1'\n height = runner\n end\n runner += 1\nend\n\nneeded_height = 2\nneeded_width = 2\n\nputs (needed_width - width).abs + (needed_height - height).abs\n"}, {"source_code": "n = Array.new\nfor i in 0...5\n n[i] = Array.new\nend\nfor i in 0...5\n input = gets.chomp\n for j in 0...5\n nums = input.split\n n[i][j] = Integer(nums[j])\n end\nend\n\na = 0\nb = 0\nfor i in 0...5\n for j in 0...5\n if n[i][j] == 1\n a = i\n b = j\n end\n end\nend\n\nif a >= 2 && b >= 2\n puts a - 2 + b - 2\nelsif a < 2 && b >= 2\n puts 2 - a + b - 2\nelsif a < 2 && b < 2\n puts 2 - a + 2 - b\nelse a >= 2 && b < 2\n puts a - 2 + 2 - b\nend\n"}, {"source_code": "5.times do |i|\n j=gets.split.find_index(?1)\n puts (i-2).abs+(j-2).abs if j\nend\n"}, {"source_code": "5.times {|i|\n j=gets.split.index(?1)\n puts (i-2).abs+(j-2).abs if j\n}\n"}, {"source_code": "r=0\nc=0\n1.upto(5) do |i|\na=gets.chomp\nif a.count(\"1\")==1\nr=i\na.each_char do |k|\nif k==\"0\" || k==\"1\"\nc+=1\nend\nbreak if k== \"1\"\nend\nend\nend\nans= (r-3).abs+(c-3).abs\n\nputs \"#{ans}\""}, {"source_code": "a = Array.new(5)\n5.times do |i|\n a[i] = gets.split.map(&:to_i)\nend\nxi = 0\nxj = 0\n5.times do |i|\n 5.times do |j|\n if a[i][j] == 1\n xi = i + 1\n xj = j + 1\n break\n end\n end\nend\nputs (xi - 3).abs + (xj - 3).abs\n"}, {"source_code": "total = 0\n5.times{|i|\n\tj = gets.split(' ').index(?1)\n\tputs (i-2).abs + (j-2).abs if j\t\n}"}, {"source_code": "r=0\nc=0\n1.upto(5) do |i|\na=gets.chomp\nif a.count(\"1\")==1\nr=i\na.each_char do |k|\nif k==\"0\" || k==\"1\"\nc+=1\nend\nbreak if k== \"1\"\nend\nend\nend\nans= (r-3).abs+(c-3).abs\n\nputs \"#{ans}\"\n\n"}, {"source_code": "a, s, ans = Array.new, 1, {[[1, 0, 0, 0, 0],[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]=>4,[[0, 1, 0, 0, 0],[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]=>3,[[0, 0, 1, 0, 0],[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]=>2,[[0, 0, 0, 1, 0],[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]=>3,[[0, 0, 0, 0, 1],[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]=>4,[[0, 0, 0, 0, 0],[0, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]=>2,[[0, 0, 0, 0, 0],[0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]=>1,[[0, 0, 0, 0, 0],[0, 0, 0, 1, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]=>2,[[0, 0, 0, 0, 0],[0, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]=>3,[[0, 0, 0, 0, 0],[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]=>0,[[0, 0, 0, 0, 0],[0, 0, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]=>1,[[0, 0, 0, 0, 0],[0, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]=>2,[[0, 0, 0, 0, 0],[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0]]=>2,[[0, 0, 0, 0, 0],[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0]]=>3,[[0, 0, 0, 0, 0],[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]=>4}\n5.times{a << gets.split.map(&:to_i)}\nans.key?(a) ? (puts ans[a]) : (puts ans[a.transpose])\n"}, {"source_code": "x, y = 0, 0\n5.times do |i|\n a = gets.split(\" \").map{|x| x.to_i}\n x, y = i, a.index(1) if a.include?(1)\nend\nputs (2 - x).abs + (2 - y).abs"}, {"source_code": "# -*- encoding: utf-8 -*-\n\nx, y = 0, 0\n\nfor i in 0 .. 4 do\n cols = gets.chomp.split(\" \").map{|n| n.to_i}\n \n for j in 0 .. 4 do\n if cols[j] == 1\n x = j\n y = i\n break\n end\n end \nend\nputs (2 - x).abs + (2 - y).abs\n"}, {"source_code": "5.times{|r|c=gets.index(?1);(c)?(p (r-2).abs+(c/2-2).abs):(0)}\n\n"}, {"source_code": "require 'set'\ninclude Math\n$stdin = File.open(\"./input.txt\", \"r\") if ENV[\"USER\"] == \"new\"\n# ====================================\n\nmatrix = []\n5.times do\n matrix << gets.strip.split.map(&:to_i)\nend\n\nx, y = 0, 0\ncatch (:done) do\n for i in 0...5 do\n for j in 0...5 do\n if matrix[i][j] == 1\n x, y = i, j\n throw :done\n end\n end\n end\nend\n\nmoves = (x - 2).abs + (y - 2).abs\nputs moves"}, {"source_code": "5.times{|r|c=gets.index(?1);(c)?(p (r-2).abs+(c/2-2).abs):(0)}"}], "negative_code": [{"source_code": "l = []\n(1..5).each { l << gets.split.map(&:to_i) }\n\nx = 0\ny = 0\n\nl.each_with_index { |i, in1| \n\ti.each_with_index { |j, in2| \n\t\t\tif j == 1 \n\t\t\t\tx = in2\n\t\t\t\ty = in1\n\t\t\t\tbreak\n\t\t\tend\n\t\t} \n\t}\n\nputs (x - 3).abs + (y - 3).abs"}, {"source_code": "p gets.casecmp gets\n"}, {"source_code": "_2d = []\n5.times{ _2d = _2d + gets.chomp.split.map(&:to_i)}\n_2d.each_with_index{|x, index| puts ((index+1)-13).abs unless x.zero?}"}, {"source_code": "5.times do |i|\n j = gets.split.find_index(1)\n puts (i-2).abs + (j-2).abs if j\nend"}, {"source_code": "x = 0\ny = 0\n(0...5).each do |i|\n a = []\n a = gets.split.map &:to_i\n (0...5).each do |j|\n if a[j] == 1\n x = i\n y = j\n end\n end\nend\nputs (3 - x).abs + (3 - y).abs"}, {"source_code": "a=[]\ni=0\nx=0\ny=0\n5.times do\n\trow=gets.chomp.split(' ').map(&:to_i)\n\trow.each_index do |char|\n\t\tif char==1\n\t\t\tx=i\n\t\t\ty=char\n\t\tend\n\tend\n\ta.push(row)\n\ti+=1\nend\nputs (x+y-4).abs\n"}, {"source_code": "a=[]\ni=0\nx=0\ny=0\n5.times do\n\trow=gets.chomp.split(' ').map(&:to_i)\n\trow.each_index do |char|\n\t\tif char==1\n\t\t\tx=i\n\t\t\ty=char\n\t\tend\n\tend\n\ta.push(row)\n\ti+=1\nend\nputs (x-2).abs+(y-2).abs\n"}, {"source_code": "arr = []\nx = nil\ny = nil\n\n5.times do |tx|\n arr << gets.chomp.split(' ')\n y ||= arr.last.index '1'\n (x ||= tx) if y\nend\n\nputs \"COORDS: \" + x.to_s + \" \" + y.to_s\nputs (x-2).abs + (y-2).abs\n"}, {"source_code": "i,j = nil, nil\n(0..4).each do |k|\n a = $stdin.readline.split.map(&:to_i)\n t = a.find_index(1)\n if !t.nil?\n i,j=k,t\n end\nend\n\ndi = (2-i).abs\ndj = (2-i).abs\n\nputs 1+di+dj"}, {"source_code": "a=gets.chomp.split(\" \").map {|i| i.to_i}\nb=gets.chomp.split(\" \").map {|i| i.to_i}\nb.sort!\nif a[0]-a[1]>=0\nc=b[a[0]-a[1]]\nputs \"#{c} #{c-1}\"\nelse\nputs \"-1\"\nend\n"}, {"source_code": "5.times{|r|c=gets.index(?1);puts c;puts r;(c)?(p (r-2).abs+(c/2-2).abs):(0)}\n"}, {"source_code": "n = Array.new\nfor i in 0...5\n n[i] = Array.new\nend\nfor i in 0...5\n input = gets.chomp\n for j in 0...5\n nums = input.split\n n[i][j] = Integer(nums[j])\n end\nend\n\na = 0\nb = 0\nfor i in 0...5\n for j in 0...5\n if n[i][j] == 1\n a = i\n b = j\n end\n end\nend\n\nif a > b\n puts a - b\nelsif a == 0 && b == 0\n puts 4\nelsif a == 1 && b == 1\n puts 2\nelsif a == 2 && b == 2\n puts 0\nelsif a == 3 && b == 3\n puts 2\nelsif a == 4 && b == 4\n puts 4\n\nelse\n a < b\n puts b - a\nend\n"}], "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9"} {"source_code": "a,b,c,d,e=gets.chomp.split.map(&:to_i)\nputs (Math.hypot((d-b),(e-c))/(2*a)).ceil\n", "positive_code": [{"source_code": "r, x, y, x_, y_ = gets.split.map &:to_i\n\nd = Math.sqrt(((x_ - x) ** 2) + ((y_ - y) ** 2))\n\nputs (d / (2 * r).to_f).ceil\n"}, {"source_code": "r,x,y,x1,y1 = gets.chomp.split \n\nr = r.to_f \nx = x.to_f \ny = y.to_f \nx1= x1.to_f \ny1= y1.to_f \n\nl = Math.sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1)) \nl = l/(2*r) \nl = l.ceil \n\nputs l.to_i"}, {"source_code": "#!/usr/bin/env ruby\nr,*_=gets.split.map(&:to_f)\nd=Math.hypot(*_.each_slice(2).to_a.transpose.map{|e|e.reduce(:-)})\np (d/r/2).ceil"}, {"source_code": "a,b,c,d,e=gets.chomp.split.map(&:to_i)\nputs (Math.hypot((d-b),(e-c))/(2*a)).ceil\n"}, {"source_code": "a,b,c,d,e=gets.chomp.split.map(&:to_i)\nputs (Math.hypot((d-b),(e-c))/(2*a)).ceil\n"}, {"source_code": "a,b,c,d,e=gets.chomp.split.map(&:to_i)\nputs (Math.hypot((d-b),(e-c))/(2*a)).ceil"}, {"source_code": "a,b,c,d,e=gets.chomp.split.map(&:to_i)\nputs (Math.hypot((d-b),(e-c))/(2*a)).ceil"}, {"source_code": "def run\n r, x, y, xp, yp = $stdin.gets.split.map(&:to_i)\n\n dx = xp - x\n dy = yp - y\n\n n = (Math.sqrt(dx * dx + dy * dy) / (r * 2)).ceil\n puts n\nend\n\nrun if $0 == __FILE__\n"}, {"source_code": "a,b,c,d,e=gets.chomp.split.map(&:to_i)\nputs (Math.hypot((d-b),(e-c))/(2*a)).ceil\n"}, {"source_code": "r,x1,y1,x2,y2=gets.split.map{|e| e.to_f}\nr2=Math.hypot(x1-x2,y1-y2)\nr4=r*2\nif r2==0 then\n\tputs 0\nelse\n\tr3=r2.to_i\n\tans=(r2/r4).floor\n\t#p [r2,r4,ans]\n\td=r2-r4*ans\n\tif d>0 && d 0\n # subtract 1 step and make into 2 step to fulfill 2r < R < 4r\n steps += 1\nend\nputs steps\n"}, {"source_code": "a,b,c,d,e=gets.chomp.split.map(&:to_i)\nputs (Math.hypot((d-b),(e-c))/(2*a)).ceil\n"}, {"source_code": "r,x,y,x1,y1 = gets.split(\" \").map(&:to_i)\nd = Math.sqrt((y1-y)**2 + (x1-x)**2)\nputs (d/(2*r).to_f).ceil"}, {"source_code": "a,b,c,d,e=gets.chomp.split.map(&:to_i)\nputs (Math.hypot((d-b),(e-c))/(2*a)).ceil"}, {"source_code": "def stop\n\tputs \"stop\"\n\tsleep(2)\nend\ndef readarr\n\tgets.split.map{|i| i.to_i}\nend\ndef write(foo)\n\tif foo.is_a?(Array)\n\t\tputs foo.map{|i| i.to_s}.join(\" \")\n\telse \n\t\tputs foo\n\tend\nend\nr, x, y, x1, y1 = readarr\nN = ((x1-x)**2+(y1-y)**2)\nl = (4*r*r)\nans =(N/l)**0.5\nif(ans*ans*l==N)\n\tputs ans.to_i\nelse\n\tputs ans.to_i+1\nend\n#sleep(300)"}, {"source_code": "a,b,c,d,e=gets.chomp.split.map(&:to_i)\nputs (Math.hypot((d-b),(e-c))/(2*a)).ceil\n"}, {"source_code": "r, x, y, xd, yd = gets.split(\" \").map &:to_f\n\nlen = Math.sqrt((xd - x)**2 + (yd - y)**2)\n\nputs (len / (2 * r)).ceil"}, {"source_code": "a,b,c,d,e=gets.chomp.split.map(&:to_i)\nputs (Math.hypot((d-b),(e-c))/(2*a)).ceil\n"}, {"source_code": "#!ruby\n\nr, x0, y0, x1, y1 = gets.split.map{|e| e.to_i}\n\ndistance = Math.sqrt((x1-x0)**2 + (y1-y0)**2)\n\ncount = 0\n\nwhile ( distance > 0 )\n count += 1\n distance -= r*2\nend\n\nputs count\n"}, {"source_code": "a,b,c,d,e=gets.chomp.split.map(&:to_i)\nputs (Math.hypot((d-b),(e-c))/(2*a)).ceil\n"}], "negative_code": [{"source_code": "r,x1,y1,x2,y2=gets.split.map{|e| e.to_f}\nr2=Math.hypot(x1-x2,y1-y2)\nr4=r*2\nif r2==0 then\n\tputs 0\nelse\n\tr3=r2.to_i\n\tans=(r2/r4).floor\n\t#p [r2,r4,ans]\n\td=r2-r4*ans\n\tif ans==0 then\n\t\tans=2\n\telsif d>0 && d0||j&1>0;puts i\n", "positive_code": [{"source_code": "x = STDIN.gets.chomp.to_i\nif (x < 0)\n x = -x\nend\nn = 0\ni = 0\nwhile true\n n += i;\n if (n == x)\n puts i\n break;\n elsif(n > x && (n-x) % 2 == 0)\n puts i\n break;\n end\n i += 1\nend\n"}, {"source_code": "j=gets.to_i.abs;i=0;j-=i+=1 while j>0||j&1>0;puts i\n"}, {"source_code": "j=gets.to_i.abs;i=0;j-=i+=1 while j>0||j&1>0;puts i"}, {"source_code": "j=-gets.to_i.abs;i=0;j+=i+=1 while j<0||j&1>0;puts i"}, {"source_code": "x=gets.to_i.abs;i=j=0;while j0 do j+=i+=1 end;puts i"}, {"source_code": "j=gets.to_i.abs;i=0;j-=i+=1 while j>0||j&1>0;puts i"}, {"source_code": "j=gets.to_i.abs;i=0;j-=i+=1 while j>0||j&1>0;puts i\n"}, {"source_code": "j=gets.to_i.abs;i=0;j-=i+=1 while j>0||j&1>0;puts i"}, {"source_code": "n=gets.to_i.abs;s=i=0;s+=i+=1 while s0;p i"}, {"source_code": "j=gets.to_i.abs;i=0;j-=i+=1 while j>0||j&1>0;puts i\n"}, {"source_code": "j=gets.to_i.abs;i=0;j-=i+=1 while j>0||j&1>0;puts i\n"}, {"source_code": "j=gets.to_i.abs;i=0;j-=i+=1 while j>0||j&1>0;puts i\n"}, {"source_code": "#!/usr/bin/ruby\n\nclass Solver\n def solve(x)\n x = x.abs()\n i = 0\n sum = 0\n \n while sum < x or (x - sum)%2 != 0 do\n i += 1\n sum += i\n end\n \n puts i\n end\nend\n\nx = STDIN.gets.to_i\nsolver = Solver.new\nsolver.solve(x)"}, {"source_code": "j=gets.to_i.abs;i=0;j-=i+=1 while j>0||j&1>0;puts i\n"}, {"source_code": "j=gets.to_i.abs;i=0;j-=i+=1 while j>0||j&1>0;puts i\n"}, {"source_code": "n=gets.to_i.abs\nif n==0 then puts \"0\";exit end\n\ni=1\nk=0\nloop do\n k+=i\n if k>=n && (k-n)%2==0 then break end\n i+=1\nend\n\nputs i\n"}, {"source_code": "j=gets.to_i.abs;i=0;j-=i+=1 while j>0||j&1>0;puts i\n"}], "negative_code": [{"source_code": "n=gets.to_i.abs\ni=1\nk=0\nwhile k0\n k+=i\n i+=1\nend\n#p k\nputs i-1\n"}, {"source_code": "x = STDIN.gets.chomp.to_i\nn = 0\ni = 0\nwhile true\n n += i;\n if (n == x)\n puts i\n break;\n elsif(n > x && i % 2 != 0)\n puts i\n break;\n end\n i += 1\nend\n \n"}, {"source_code": "x=gets.to_i;i=j=0;while j0 do j+=i+=1 end;puts i"}], "src_uid": "18644c9df41b9960594fdca27f1d2fec"} {"source_code": "#!/usr/bin/ruby\n\nn = gets.to_i\n\nret = \"BigInteger\"\nret = \"long\" if n <= 9223372036854775807\nret = \"int\" if n <= 2147483647\nret = \"short\" if n <= 32767\nret = \"byte\" if n <= 127\nputs ret\n", "positive_code": [{"source_code": "a = [\n\t[(-128 .. 127), :byte],\n\t[(-32768 .. 32767), :short],\n\t[(-2147483648 .. 2147483647), :int],\n\t[(-9223372036854775808 .. 9223372036854775807), :long]]\nn = gets.to_i\na.each do |r, t|\n\tif r.include? n\n\t\tputs t\n\t\texit\n\tend\nend\nputs :BigInteger\n"}, {"source_code": "n = gets.to_i\n\nif -128 <= n && n <= 127\n puts \"byte\"\nelsif -32768 <= n && n <= 32767\n puts \"short\"\nelsif -2147483648 <= n && n <= 2147483647\n puts \"int\"\nelsif -9223372036854775808 <= n && n <= 9223372036854775807\n puts \"long\"\nelse puts \"BigInteger\"\nend\n"}, {"source_code": "#! /usr/bin/ruby\n$a = gets.to_i\ndef f\n if $a < -9223372036854775808 or $a > 9223372036854775807\n return 'BigInteger'\n end\n\n if $a < -2147483648 or $a > 2147483647\n return 'long'\n end\n\n if $a < -32768 or $a > 32767\n return 'int'\n end\n\n if $a < -128 or $a > 127\n return 'short'\n end\n\n return 'byte'\nend\n\nputs f"}, {"source_code": "y = [1 << 7, 1 << 15, 1 << 31, 1 << 63]\nname = ['byte', 'short', 'int', 'long', 'BigInteger']\n\nx = gets.to_i\n\nadd = 0\nif x > 0\n add = -1\nelse\n add = 0\n x = -x\nend\n\nans = ''\nfor i in 0...4\n\n if x <= y[i] + add\n ans = name[i]\n break\n end\n\nend\n\nif ans == ''\n ans = 'BigInteger'\nend\n\nputs ans\n"}, {"source_code": "n = gets.to_i\nputs [[\"byte\", 7], [\"short\", 15], [\"int\", 31], [\"long\", 63], [\"BigInteger\", 1000]].select{ |a| 2 ** a[1] > n}[0][0]"}, {"source_code": "N = gets.to_i\n\nif N > 9223372036854775807\n puts \"BigInteger\"\nelsif N > 2147483647\n puts \"long\"\nelsif N > 32767\n puts \"int\"\nelsif N > 127\n puts \"short\"\nelse\n puts \"byte\"\nend\n"}, {"source_code": "#=================================\nrequire 'prime'\ninclude Math\n\nif ARGV.include?(\"ONLINE_JUDGE\")\n\t$stdin = File.open(\"./input.txt\", \"r\")\n\tARGV.delete(\"ONLINE_JUDGE\")\nend\n#=================================\n\nn=gets.strip.to_i\n\nif n>-129 && n<128\n\tputs :byte\nelsif n>-32769 && n<32768\n\tputs :short\nelsif n>-2147483649 && n<2147483648\n\tputs :int\nelsif n>-9223372036854775809 && n<9223372036854775808\n\tputs :long\nelse\n\tputs :BigInteger\nend\n"}, {"source_code": "arr=[\"byte\",\"short\",\"int\",\"long\",\"BigInteger\"]\nn=(gets.chomp.to_i).abs\nif n > 9223372036854775807\n\tputs arr[4]\nelsif n > 2147483647\n\tputs arr[3]\nelsif n > 32767\n\tputs arr[2]\nelsif n >127\n\tputs arr[1]\nelse\n\tputs arr[0]\nend\n"}, {"source_code": "n = gets.to_i\nif n >= -128 && n <= 127\n puts \"byte\"\nelsif n >= -32768 && n <= 32767\n puts \"short\"\nelsif n >= -2147483648 && n <= 2147483647\n puts \"int\"\nelsif n >= -9223372036854775808 && n <= 9223372036854775807\n puts \"long\"\nelse\n puts \"BigInteger\"\nend\n"}, {"source_code": "d=gets.to_i\nif d>=-128 and d<=127 then puts 'byte'\nelsif d>=-32768 and d<=32767 then puts 'short'\nelsif d>=-2147483648 and d<=2147483647 then puts 'int'\nelsif d>=-9223372036854775808 and d<=9223372036854775807 then puts 'long'\nelse puts 'BigInteger' \nend"}, {"source_code": "a = gets.to_i\na=a<0? a*(-1)-1:a\nputs a<128 ?\"byte\":(a<32768 ?\"short\":(a<2147483648 ?\"int\":(a<9223372036854775808 ?\"long\":\"BigInteger\")))"}, {"source_code": "case gets.to_i\n\twhen -128..127\n\t\tputs \"byte\"\n\twhen -32768..32767\n\t\tputs \"short\"\n\twhen -2147483648..2147483647\n\t\tputs \"int\"\n\twhen -9223372036854775808..9223372036854775807\n\t\tputs \"long\"\n\telse\n\t\tputs \"BigInteger\"\nend"}, {"source_code": "n = gets.to_i\n\nif (n >= -128 && n <= 127)\n puts \"byte\"\n exit\nend\nif (n >= -32768 && n <= 32767)\n puts \"short\"\n exit\nend\nif (n >= -2147483648 && n <= 2147483647)\n puts \"int\"\n exit\nend\nif (n >= -9223372036854775808 && n <= 9223372036854775807)\n puts \"long\"\n exit\nend\n\nputs \"BigInteger\""}, {"source_code": "n = gets\nif n.length > 20\n puts \"BigInteger\"\nelse\n k = n.to_i\n if k >= -128 && k <= 127\n puts \"byte\"\n elsif k >= -32768 && k <= 32767\n puts \"short\"\n elsif k >= -2147483648 && k <= 2147483647\n puts \"int\"\n elsif k >= -9223372036854775808 && k <= 9223372036854775807\n puts \"long\"\n else\n puts \"BigInteger\"\n end\nend\n"}, {"source_code": "n = gets.chomp.to_i\n\nputs case n\nwhen -128..127 then 'byte'\nwhen -32768..32767 then 'short'\nwhen -2147483648..2147483647 then 'int'\nwhen -9223372036854775808..9223372036854775807 then 'long'\nelse 'BigInteger'\nend"}, {"source_code": "n = gets.to_i\n\nif -128 <= n && n <= 127\n puts \"byte\"\nelsif -32768 <= n && n <= 32767\n puts \"short\"\nelsif -2147483648 <= n && n <= 2147483647\n puts \"int\"\nelsif -9223372036854775808 <= n && n <= 9223372036854775807\n puts \"long\"\nelse\n puts \"BigInteger\"\nend\n"}, {"source_code": "n = gets.to_i\nif( n >= -128 && n <= 127)\n puts \"byte\"\n exit\nend\nif( n >= -32768 && n <= 32767)\n puts \"short\"\n exit\nend\nif( n >= -2147483648 && n <= 2147483647)\n puts \"int\"\n exit\nend\nif( n >= -9223372036854775808 && n <= 9223372036854775807)\n puts \"long\"\n exit\nend\nif( n > 9223372036854775807)\n puts \"BigInteger\"\n exit\nend"}, {"source_code": "a = gets.to_i\nres = 'BigInteger'\nres = 'long' if a <= 9223372036854775807\nres = 'int' if a <= 2147483647\nres = 'short' if a <= 32767\nres = 'byte' if a <= 127\nputs res\n"}, {"source_code": "print case gets.to_i\nwhen -128..127\n \"byte\"\nwhen -32768..32767\n \"short\"\nwhen -2147483648..2147483647\n \"int\"\nwhen -9223372036854775808..9223372036854775807\n \"long\"\nelse\n \"BigInteger\"\nend\n"}], "negative_code": [], "src_uid": "33041f1832fa7f641e37c4c638ab08a1"} {"source_code": "n, k = gets.strip.split.map(&:to_i)\nary = gets.strip.split.map(&:to_i)\nans = 0\nsi = -1\n0.upto(n-1).each do |i|\n if ary[i] <= k\n ans += 1\n si = i\n else\n break\n end\nend\n(n-1).downto(si+1).each do |i|\n if ary[i] <= k\n ans += 1\n else\n break\n end\nend\nputs ans", "positive_code": [{"source_code": "n, k = gets.split.map &:to_i\n\nnums = gets.split.map &:to_i\n\ncount = 0\n\nindex = 0\nfor i in 0..n-1\n if nums[i]<=k\n count+=1\n else\n index = i \n break\n end\nend\n\nif count!=n\n for i in 0..n-index-1\n if nums[n-i-1]<=k\n count+=1\n else\n break\n end\n end\n puts count\nelse \n puts count\nend"}, {"source_code": "\ndef solution\n _, k = read_ints\n ps = read_ints\n\n count = 0\n\n while ps.first && ps.first <= k\n count += 1\n ps.shift\n end\n\n while ps.last && ps.last <= k\n count += 1\n ps.pop\n end\n\n puts count\nend\n\ndef read_int\n gets.to_i\nend\n\ndef read_ints\n gets.split.map(&:to_i)\nend\n\ndef read_string\n gets.chomp\nend\n\nsolution unless ENV['TEST__MODE']\n\n"}, {"source_code": "n,k = readline.split.map(&:to_i)\na = readline.split.map(&:to_i)\n\nans=0\ni=0\nwhile i=0 and a[i]<=k\n\tans += 1\n\ti -= 1\nend\n\nputs [ans,n].min\n"}, {"source_code": "n, k = gets.split.map(&:to_i)\nas = gets.split.map(&:to_i)\n\nans = 0\n(0..n-1).each do |i|\n a = as[i]\n if a <= k\n ans += 1\n else\n break\n end\nend\n\n(n-1).downto(ans) do |i|\n a = as[i]\n if a <= k\n ans += 1\n else\n break\n end\nend\n\nputs ans"}, {"source_code": "# https://codeforces.com/problemset/problem/999/A\ndef solution(n, k, a)\n count = 0\n\n i = 0\n while i < n && a[i] <= k do\n count += 1\n i += 1\n end\n\n return count if count == n\n\n i = n - 1\n while i > 0 && a[i] <= k do\n count += 1\n i -= 1\n end\n\n return count\nend\n\nn, k = gets.chomp.split(\" \").map(&:to_i)\na = gets.chomp.split(\" \").map(&:to_i)\n\nputs solution(n, k, a)\n"}, {"source_code": "n, k = gets.chomp.split.map(&:to_i)\nlist = gets.chomp.split.map(&:to_i)\n\ni, j = 0, n - 1\n\nwhile i < n\n break i if list[i] > k\n i += 1\nend\n\nwhile j >= 0\n break j if list[j] > k\n j -= 1\nend\n\nif i == n && j == -1\n puts n\nelse\n puts (n - (j - i + 1))\nend\n"}, {"source_code": "$n,$k=gets.split\n$n,$k,i=$n.to_i,$k.to_i,0\na=gets.split\n$ans,$flag=[0,0],[0,0]\ndef test(c,p)\n\tif c>$k \n\t yield p,0 \n\telse \n yield p,1 \n\tend\nend\na.each{|c| test(c.to_i,0){|id,fla|\n\t\t\t if fla==0 \n\t\t\t $flag[id]=1\n\t\t\t elsif $flag[id]==0\n $ans[id]=$ans[id]+1\n\t\t\t end\t\t\t\t\n\t\t\t\t}}\na.reverse.each{|c| test(c.to_i,1){|id,fla|\n\t\t\t if fla==0 \n\t\t\t $flag[id]=1\n\t\t\t elsif $flag[id]==0\n $ans[id]=$ans[id]+1\n\t\t\t end\t\t\t\t\n\t\t\t\t}\n\t\t}\nputs [$ans[0]+$ans[1],$n].min\n\n"}, {"source_code": "n, k = gets.split(\" \").map{|n| n.to_i }\na = gets.split(\" \").map{|n| n.to_i }\ncount = 0\nall_solved = true\na.each {|m|\n if m <= k\n count += 1\n next\n end\n all_solved = false\n break\n}\nif all_solved\n puts count\nelse\n a.reverse.each {|m|\n if m <= k\n count += 1\n next\n end\n break\n }\n puts count\nend\n\n"}, {"source_code": "n, k = gets.split.map(&:to_i)\na = gets.split.map(&:to_i)\npos = a.each_with_index.select { |v, i| v > k }.map { _2 }\nif pos.empty?\n\tputs n\nelse\n\tputs pos[0] + (n - 1 - pos[-1])\nend\n"}, {"source_code": "n,k,*a=$<.read.split.map &:to_i\np a.all?{|e|e<=k}?n:a.index{|e|e>k}+(n-1-a.rindex{|e|e>k})"}, {"source_code": "N, K = gets.split.map(&:to_i)\nas = gets.split.map(&:to_i)\nas.shift while as.length > 0 && as[0] <= K\nas.pop while as.length > 0 && as[-1] <= K\nputs N - as.length"}], "negative_code": [{"source_code": "n,k,*a=$<.read.split.map &:to_i\np a.count{|e|e<=k}"}, {"source_code": "n,k,*a=$<.read.split.map &:to_i\np a.all?{|e|e<=k}?n:a.index{|e|e>k}+(n-a.rindex{|e|e>k})"}, {"source_code": "n, k = gets.split(\" \").map{|n| n.to_i }\na = gets.split(\" \").map{|n| n.to_i }\ncount = 0\nall_solved = true\na.each {|n|\n count += 1 if n <= k\n all_solved = false\n break\n}\nif all_solved\n puts count\nelse\n a.reverse.each {|n|\n count += 1 if n <= k\n break\n }\nend\n\n"}], "src_uid": "ecf0ead308d8a581dd233160a7e38173"} {"source_code": "def parse_time(time)\n time.split(':').map(&:to_i)\nend\n\ndef to_str(h, m)\n [h, m].map { |t| \"%02d\" % t }.join(':')\nend\n\ndef solve(cur_time, duration)\n hc, mc = parse_time cur_time\n hd, md = parse_time duration\n hg = hc - hd\n mg = mc - md\n if mg < 0\n mg = 60 + mg\n hg -= 1\n end\n hg = (hg + 24) % 24\n to_str(hg, mg)\nend\n\nif __FILE__ == $0\n puts solve(gets.chomp, gets.chomp)\nend", "positive_code": [{"source_code": "class Tm\n attr_accessor :x\n def initialize(a)\n if a.class == String\n h, m = a.split(\":\").map(&:to_i)\n @x = h*60 + m\n else\n @x = a\n @x += 1440 if @x < 0\n end\n end\n def -(y)\n Tm.new (@x - y.x)\n end\n def output\n printf \"%02d:%02d\\n\", @x/60, @x%60\n end\nend\nst = Tm.new gets.chomp\ned = Tm.new gets.chomp\n(st-ed).output"}, {"source_code": "h1, m1 = gets.split(\":\").map( &:to_i )\nh2, m2 = gets.split(\":\").map( &:to_i )\n\ns = ( h1 * 60 + m1 - h2 * 60 - m2 + 1440 ) % 1440\nh = s / 60\ns = s % 60\n\nprintf( \"%02d:%02d\\n\", h, s )\n"}, {"source_code": "#!/usr/bin/ruby\nt=2.times.map{a,b=gets.split(':').map(&:to_i);a*60+b}.reduce(:-)\nt+=1440 if t<0\nputs '%02d:%02d'%[t/60,t%60]"}, {"source_code": "require 'date'\n\n$SIZE_DAY_IN_MINUTES = 24 * 60\n\ndef convert_to_secunds(minutes)\n minutes * 60\nend\n\ndef convert_to_minutes(time)\n time.hour * 60 + time.min\nend\n\nendTime = DateTime.parse gets.chomp\nstartTime = DateTime.parse gets.chomp\n\nendTime_minutes = convert_to_minutes endTime\nstartTime_minutes = convert_to_minutes startTime\n\nif startTime_minutes > endTime_minutes\n minutes_yesterday = $SIZE_DAY_IN_MINUTES - startTime_minutes\n sleep = minutes_yesterday + endTime_minutes\nelse\n sleep = endTime_minutes - startTime_minutes\nend\n\nputs Time.at(convert_to_secunds sleep).utc.strftime(\"%H:%M\")\n"}, {"source_code": "mh,mm = gets.split(\":\").map(&:to_i)\nnh, nn = gets.split(\":\").map(&:to_i)\n\nmh=mh-nh \nmm= mm-nn \n\n\nif mm<0 \n mm+=60 \n mh-=1 \nend \nif mh<0 \n mh+=24\nend \nif mm<10 \n mm= \"0\" + mm.to_s\nend \nif mh<10 \n mh = \"0\"+mh.to_s \nend \nputs \"#{mh}:#{mm}\"\n \n\n\n"}, {"source_code": "class ProblemA\n def initialize\n @dats = STDIN.read.split(\"\\n\")\n @now = @dats[0]\n @slept = @dats[1]\n end\n\n def solve\n slept_h = @slept.split(\":\")[0].to_i % 24\n sleft_m = @slept.split(\":\")[1].to_i\n\n now_h = @now.split(\":\")[0].to_i\n now_m = @now.split(\":\")[1].to_i\n \n m = now_m - sleft_m\n h = now_h - slept_h\n minus = 0\n if m < 0\n m = now_m + 60 - sleft_m\n minus = 1\n end\n \n h = now_h - slept_h - minus\n h = h < 0 ? h + 24 : h\n\n h = h < 10 ? \"0#{h}\" : h\n m = m < 10 ? \"0#{m}\" : m\n print \"#{h}:#{m}\"\n end\nend\n\nsolver = ProblemA.new\nsolver.solve\n"}, {"source_code": "a=gets.chomp.split(\":\")\nb=gets.chomp.split(\":\")\nans=[]\nans[1]=a[1].to_i-b[1].to_i\nif ans[1]<0\nans[1]=60+ans[1]\na[0]=(a[0].to_i-1).to_s\nend\nans[0]=a[0].to_i-b[0].to_i\nif ans[0]<0\nans[0]=24+ans[0]\nend\nout=\"\"\nif ans[0]<10\nout=\"0\"+\"#{ans[0]}\"\nelse\nout=\"#{ans[0]}\"\nend\nif ans[1]<10\nout=out+\":\"+\"0\"+\"#{ans[1]}\"\nelse\nout=out+\":\"+\"#{ans[1]}\"\nend\nputs \"#{out}\""}, {"source_code": "wh,wm=gets.chomp.split(':').collect{|a| a.to_i}\nsh,sm=gets.chomp.split(':').collect{|a| a.to_i}\nrh=0\nrm=0\nif wm= 0 then\n\n\thr = x/60\n\tmn = x%60\n\n\tprint \"0\" if hr < 10 \n\tprint hr,\":\"\n\tprint \"0\" if mn < 10\n\tprint mn\n\nelse\n\n\thr = ((24*60) - (-1*x)) / 60\n\tmn = ((24*60) - (-1*x)) % 60\n\tprint \"0\" if hr < 10 \n\tprint hr,\":\"\n\tprint \"0\" if mn < 10\n\tprint mn\n\nend\n\n\n\n"}, {"source_code": "s = gets.strip.split(\":\").map! {|i| i.to_i}\nshh = s[0]\nsmm = s[1]\n\nt = gets.strip.split(\":\").map! {|i| i.to_i}\nthh = t[0]\ntmm = t[1]\n\nahh = (shh-thh)\namm = (smm-tmm)\nif amm < 0\n ahh = ahh - 1\n amm = 60 + amm\nend\nif ahh < 0\n ahh = 24 + ahh\nend\nputs \"%02d:%02d\" % [ahh, amm]\n\n"}, {"source_code": "sh, sm = gets.chomp.split(\":\").map(&:to_i)\nth, tm = gets.chomp.split(\":\").map(&:to_i)\nif sm < tm\n sh -= 1\n sm += 60\nend\nph = [sh - th, (24 + (sh - th)) % 24].max\npm = sm - tm\nputs \"#{\"%02d\" % ph}:#{\"%02d\" % pm}\"\n"}, {"source_code": "a=gets.chomp.split(\":\")\nb=gets.chomp.split(\":\")\nans=[]\nans[1]=a[1].to_i-b[1].to_i\nif ans[1]<0\nans[1]=60+ans[1]\na[0]=(a[0].to_i-1).to_s\nend\nans[0]=a[0].to_i-b[0].to_i\nif ans[0]<0\nans[0]=24+ans[0]\nend\nout=\"\"\nif ans[0]<10\nout=\"0\"+\"#{ans[0]}\"\nelse\nout=\"#{ans[0]}\"\nend\nif ans[1]<10\nout=out+\":\"+\"0\"+\"#{ans[1]}\"\nelse\nout=out+\":\"+\"#{ans[1]}\"\nend\nputs \"#{out}\""}, {"source_code": "#!/usr/bin/ruby\nt=2.times.map{a,b=gets.split(':').map(&:to_i);a*60+b}.reduce(:-)\nt+=1440 if t<0\nputs '%02d:%02d'%[t/60,t%60]"}, {"source_code": "def parseTime(s)\n\t[s[0,2].to_i, s[-2, 2].to_i]\nend\n\nh1, m1 = parseTime(gets.chomp)\nh2, m2 = parseTime(gets.chomp)\n\nt1 = h1*60+m1\nt2 = h2*60+m2\n\nif t2 > t1\n\tt1 += 1440\nend\n\nresult = t1 - t2\n\nprint \"%02d:%02d\" % [result / 60, result % 60]"}, {"source_code": "a = gets.split(':').map(&:to_i)\nb = gets.split(':').map(&:to_i)\na[0] -= b[0]\na[1] -= b[1]\n(a[1] += 60; a[0] -= 1) if a[1] < 0\na[0] += 24 if a[0] < 0\nputs \"#{\"%02d\" % a[0]}:#{\"%02d\" % a[1]}\"\n"}], "negative_code": [{"source_code": "mh,mm = gets.split(\":\").map(&:to_i)\nnh, nn = gets.split(\":\").map(&:to_i)\n\nmh=mh-nh \nmm= mm-nn \nif mm<0 \n mm-=60 \n mh+=1 \nend \nif mh<0 \n mh+=24\nend \nif mm<10 \n mm= \"0\" + mm.to_s\nend \nif mh<10 \n mh = \"0\"+mh.to_s \nend \nputs \"#{mh}:#{mm}\"\n \n\n\n"}, {"source_code": "wh,wm=gets.chomp.split(':').collect{|a| a.to_i}\nsh,sm=gets.chomp.split(':').collect{|a| a.to_i}\nrh=0\nrm=0\nif wm x\n asd << x\n else\n asd << top - 1\n end\n \n lol = asd\n count += 1\n #printlol(lol)\nend\n\nputs count"}, {"source_code": "x, y = gets.split.map(&:to_i)\na = [y, y, y]\nc = 1\nloop do\n mx = a.min\n case mx\n when a[0]\n a[0] = [a[1] + a[2] - 1, x].min\n when a[1]\n a[1] = [a[0] + a[2] - 1, x].min\n when a[2]\n a[2] = [a[0] + a[1] - 1, x].min\n end\n break if a == [x, x, x]\n c += 1\nend\nputs c\n"}, {"source_code": "n, m = readline.split.map(&:to_i)\n\ns = [m,m,m]\n\nans = 0\nwhile s.min <= n\n s[0] = s[1] + s[2]-1\n s=s.sort\n ans += 1\nend\n\nputs ans\n\n"}, {"source_code": "x, y = gets.chomp.split(' ').map(&:to_i)\nsides = [y, y, y]\n\nans = 0\n\nuntil sides.count(x) == 3\n sortedSides = Array.new(sides).sort\n power = x - sortedSides[0] \n \n power = sortedSides[1] + sortedSides[2] - sortedSides[0] - 1 if power >= sortedSides[1] + sortedSides[2] - sortedSides[0]\n sides[sides.index(sortedSides[0])] = sides[sides.index(sortedSides[0])] + power\n \n #print sides\n #puts ''\n \n ans += 1\nend\n\nputs ans"}, {"source_code": "#!/usr/bin/ruby\nx,y=gets.split.map(&:to_i)\na=[y]*3\nr=0\nwhile a[0]!=x\n\ta[0]=[a[1]+a[2]-1,x].min\n\ta.sort!\n\tr+=1\nend\np r"}], "negative_code": [{"source_code": "#!/usr/bin/ruby\nx,y=gets.split.map(&:to_i)\na=[x]*3\nr=0\nwhile a[2]!=y\n\ta[2]=[a[1]-a[0]+1,y].max\n\ta.sort!\n\tr+=1\nend\np r"}, {"source_code": "def printlol(ar)\n for i in 0..(ar.length-2) do\n print ar[i]\n print \" \"\n end\n print ar.last\n puts \"\"\nend\n\n\ninput = gets.strip.split(' ').map(&:to_i)\nx = input[0]\ny = input[1]\n\nlol = [x, x, x]\ncount = 0\nwhile lol[0] != y or lol[1] != y or lol[2] != y do\n asd = lol.dup\n asd.slice!(lol.index(lol.max))\n fark = (asd[0] - asd[1]).abs\n if fark + 1 < y\n asd << [y, ((asd[0] + asd[1]) / 6.to_f).round].max\n else\n if (fark + 1) >= ((asd[0] + asd[1]) / 6.to_f).round\n asd << (fark + 1)\n else\n asd << ((asd[0] + asd[1]) / 6.to_f).round\n end\n end\n lol = asd\n count += 1\n #printlol(lol)\nend\n\nputs count"}, {"source_code": "def printlol(ar)\n for i in 0..(ar.length-2) do\n print ar[i]\n print \" \"\n end\n print ar.last\n puts \"\"\nend\n\n\ninput = gets.strip.split(' ').map(&:to_i)\nx = input[0]\ny = input[1]\n\nlol = [x, x, x]\ncount = 0\nwhile lol[0] != y or lol[1] != y or lol[2] != y do\n asd = lol.dup\n asd.slice!(lol.index(lol.max))\n fark = (asd[0] - asd[1]).abs\n if fark + 1 < y\n asd << [y, ((asd[0] + asd[1]) / 6)].max\n else\n if (fark + 1) >= ((asd[0] + asd[1]) / 6)\n asd << (fark + 1)\n else\n asd << ((asd[0] + asd[1]) / 6)\n end\n end\n lol = asd\n count += 1\n if count > 20\n break\n end\n #printlol(lol)\nend\n\nputs count"}, {"source_code": "def printlol(ar)\n for i in 0..(ar.length-2) do\n print ar[i]\n print \" \"\n end\n print ar.last\n puts \"\"\nend\n\n\ninput = gets.strip.split(' ').map(&:to_i)\nx = input[0]\ny = input[1]\n\nlol = [x, x, x]\ncount = 0\nwhile lol[0] != y or lol[1] != y or lol[2] != y do\n asd = lol.dup\n asd.slice!(lol.index(lol.max))\n fark = (asd[0] - asd[1]).abs\n if fark + 1 < y\n if (y - ((asd[0] + asd[1] + 1) / 6.to_f).round + 1).abs == 1\n asd << y\n else\n asd << [y, ((asd[0] + asd[1] + 1) / 6.to_f).round + 1].max\n end\n else\n if (fark + 1) >= ((asd[0] + asd[1] + 1) / 6.to_f).round + 1\n asd << (fark + 1)\n else\n asd << ((asd[0] + asd[1] + 1) / 6.to_f).round + 1\n end\n end\n lol = asd\n count += 1\n #printlol(lol)\nend\n\nputs count"}, {"source_code": "def printlol(ar)\n for i in 0..(ar.length-2) do\n print ar[i]\n print \" \"\n end\n print ar.last\n puts \"\"\nend\n\n\ninput = gets.strip.split(' ').map(&:to_i)\nx = input[0]\ny = input[1]\n\nlol = [x, x, x]\ncount = 0\nwhile lol[0] != y or lol[1] != y or lol[2] != y do\n asd = lol.dup\n asd.slice!(lol.index(lol.max))\n fark = (asd[0] - asd[1]).abs\n if fark + 1 < y\n asd << [y, ((asd[0] + asd[1]) / 6)].max\n else\n if (fark + 1) >= ((asd[0] + asd[1]) / 6)\n asd << (fark + 1)\n else\n asd << ((asd[0] + asd[1]) / 6)\n end\n end\n lol = asd\n count += 1\n if count > 20\n break\n end\n printlol(lol)\nend\n\nputs count"}, {"source_code": "def printlol(ar)\n for i in 0..(ar.length-2) do\n print ar[i]\n print \" \"\n end\n print ar.last\n puts \"\"\nend\n\n\ninput = gets.strip.split(' ').map(&:to_i)\nx = input[0]\ny = input[1]\n\nlol = [x, x, x]\ncount = 0\nwhile lol[0] != y or lol[1] != y or lol[2] != y do\n asd = lol.dup\n asd.slice!(lol.index(lol.max))\n fark = (asd[0] - asd[1]).abs\n if fark + 1 < y\n asd << [y, ((asd[0] + asd[1]) / 6)].max\n else\n if (fark + 1) >= ((asd[0] + asd[1]) / 6)\n asd << (fark + 1)\n else\n asd << ((asd[0] + asd[1]) / 6)\n end\n end\n lol = asd\n count += 1\n #printlol(lol)\nend\n\nputs count"}, {"source_code": "def printlol(ar)\n for i in 0..(ar.length-2) do\n print ar[i]\n print \" \"\n end\n print ar.last\n puts \"\"\nend\n\n\ninput = gets.strip.split(' ').map(&:to_i)\nx = input[0]\ny = input[1]\n\nlol = [x, x, x]\ncount = 0\nwhile lol[0] != y or lol[1] != y or lol[2] != y do\n asd = lol.dup\n asd.slice!(lol.index(lol.max))\n fark = (asd[0] - asd[1]).abs\n if fark + 1 < y\n asd << [y, ((asd[0] + asd[1]) / 6)].max\n else\n if (fark + 1) >= ((asd[0] + asd[1]) / 6)\n asd << (fark + 1)\n else\n asd << ((asd[0] + asd[1]) / 6)\n end\n end\n lol = asd\n count += 1\n printlol(lol)\nend\n\nputs count"}, {"source_code": "n, m = readline.split.map(&:to_i)\n\ns = [m,m,m]\n\nans = 0\nwhile s.min <= n\n s[0] = s[1] + s[2]\n s=s.sort\n ans += 1\nend\n\nputs ans\n\n"}], "src_uid": "8edf64f5838b19f9a8b19a14977f5615"} {"source_code": "gets\np gets.chomp.split(/[A-Z]+/).each.map{|s|s.split(//).uniq.length}.max || 0", "positive_code": [{"source_code": "class String\n def is_lower?\n self == self.downcase\n end\nend\n\nn = STDIN.gets.chomp.to_i\ns = STDIN.gets.chomp\nletters = {}\nanswer = 0\ns.each_char do |ch|\n if ch.is_lower?\n letters[ch] = true\n else\n answer = [answer, letters.size].max\n letters = {}\n end\nend\nanswer = [answer, letters.size].max\nputs answer\n"}, {"source_code": "gets\np gets.chomp.split(/[A-Z]+/).map{|s|s.split(//).uniq.length}.max||0"}, {"source_code": "n = gets.to_i\n\nans = 0\n\nabc = []\ngets.chomp.each_char do |c|\n\tif 'a' <= c && c <= 'z'\n\t\tabc[c.ord - 'a'.ord] = 1\n\telse\n\t\tans = [ans, abc.count(1)].max\n\t\tabc = []\n\tend\nend\n\np [ans, abc.count(1)].max"}, {"source_code": "def is_up_case?( chr )\n chr >= 'A' && chr <= 'Z'\nend\nn = gets.strip.to_i\ns = gets.strip\ni = ans = 0\nprev = '0'\nwhile i < n\n curr = s[i]\n dist = {}\n while !is_up_case? curr\n curr = s[i]\n break if curr.nil? || is_up_case?( curr )\n dist[curr] = 1 if dist[curr].nil?\n prev = curr\n i += 1\n end\n ans = [ans, dist.length].max\n i += 1\nend\nputs ans\n"}], "negative_code": [{"source_code": "n = gets.to_i\n\nans = 0\n\nabc = []\ngets.chomp.each_char do |c|\n\tif 'a' <= c && c <= 'z'\n\t\tabc[c.ord - 'a'.ord] = 1\n\telse\n\t\tans = [ans, abc.count(1)].max\n\t\tabc = []\n\tend\nend\n\np ans"}, {"source_code": "n = gets.strip.to_i\ns = gets.strip\ncount = Array.new(26, 0)\nn.times do |i|\n curr = s[i]\n if curr >= 'a' && curr <= 'z'\n pos = curr.ord - 'a'.ord\n count[pos] += 1\n end\nend\nans = 0\ncount.each do |a|\n ans += 1 if a > 0\nend\nputs ans\n"}, {"source_code": "class String\n def is_lower?\n self == self.downcase\n end\nend\n\nn = STDIN.gets.chomp.to_i\ns = STDIN.gets.chomp\nletters = {}\nanswer = 0\ns.each_char do |ch|\n if ch.is_lower?\n letters[ch] = true\n else\n answer = [answer, letters.size].max\n letters = {}\n end\nend\nputs answer\n"}], "src_uid": "567ce65f87d2fb922b0f7e0957fbada3"} {"source_code": "def dsum(given_degree)\n given_degree['1'] + given_degree['2'] + given_degree['3']\nend\n\nn = gets.to_i\ndegree = gets.split(' ')\ndegree_1 = {:min => degree.first.to_i, :max => degree.last.to_i}\ndegree = gets.split(' ')\ndegree_2 = {:min => degree.first.to_i, :max => degree.last.to_i}\ndegree = gets.split(' ')\ndegree_3 = {:min => degree.first.to_i, :max => degree.last.to_i}\ngiven_degree = {'1' => degree_1[:min], '2' => degree_2[:min], '3' => degree_3[:min]}\nif dsum(given_degree) == n\n puts \"#{given_degree['1']} #{given_degree['2']} #{given_degree['3']}\"\nelse\n if n - dsum(given_degree) <= (degree_1[:max] - given_degree['1'])\n given_degree['1'] += n - dsum(given_degree)\n else\n given_degree['1'] = degree_1[:max]\n puts \"#{given_degree['2']} #{given_degree['2']} #{given_degree['3']}\" if dsum(given_degree) == n\n if n - dsum(given_degree) <= (degree_2[:max] - given_degree['2'])\n given_degree['2'] += n - dsum(given_degree)\n else\n given_degree['2'] = degree_2[:max]\n puts \"#{given_degree['1']} #{given_degree['2']} #{given_degree['3']}\" if dsum(given_degree) == n\n if n - dsum(given_degree) <= (degree_3[:max] - given_degree['3'])\n given_degree['3'] += n - dsum(given_degree)\n end\n end\n end\n puts \"#{given_degree['1']} #{given_degree['2']} #{given_degree['3']}\"\nend\n\n", "positive_code": [{"source_code": "N=gets.to_i\nA=$<.map{|e|e.split.map(&:to_i)}\na=[A[0][1],N-A[1][0]-A[2][0]].min\nb=[A[1][1],N-a-A[2][0]].min\nc=N-a-b\nputs [a,b,c]*' '"}, {"source_code": "# http://codeforces.com/contest/557/problem/A\nn = gets.chomp.to_i\nfirst, second, third = [].tap do |arr|\n 3.times { arr << gets.chomp.split.map(&:to_i) }\nend\n\na = [first[1], n - second[0] - third[0]].min\nb = [second[1], n - a - third[0]].min\nc = n - a - b\n\nputs [a, b, c].join(' ')\n"}, {"source_code": "N=gets.to_i\nA=$<.map{|e|e.split.map(&:to_i)}\na=[A[0][1],N-A[1][0]-A[2][0]].min\nb=[A[1][1],N-a-A[2][0]].min\nc=N-a-b\nputs [a,b,c]*' '"}, {"source_code": "n = gets.to_i\na = []\n3.times { a << gets.split(\" \").map(&:to_i) }\nn -= a.map{|p| p[0]}.inject(&:+)\n\n(0..2).each{|i|\n tmp = a[i][0]\n a[i][0] = [a[i][1], a[i][0] + n].min\n n -= a[i][0] - tmp \n}\n\nputs a.map{|p| p[0]}.join(\" \")\n"}, {"source_code": "def read_ints; gets.chomp.split.map(&:to_i) end\n@n = read_ints[0]\nmin1,max1 = read_ints\nmin2,max2 = read_ints\nmin3,max3 = read_ints\n\n@rez = [min1,min2,min3]\n\ndef left; @n - @rez.inject(:+) end\n\n@rez[0]+=[left,max1-@rez[0]].min\n@rez[1]+=[left,max2-@rez[1]].min\n@rez[2]+=[left,max3-@rez[2]].min\n\nputs @rez.join(' ')"}, {"source_code": "n = gets.to_i\nmin1, max1 = gets.split.map { |e| e.to_i }\nmin2, max2 = gets.split.map { |e| e.to_i }\nmin3, max3 = gets.split.map { |e| e.to_i }\n\nd1, d2, d3 = 0, 0, 0\n\nd1 = n-min2-min3 > max1 ? max1 : n-min2-min3\nn -= d1\nprint d1.to_s + ' '\n\nd2 = n-min3 > max2 ? max2 : n-min3\nn -= d2\nprint d2.to_s + ' '\n\nprint n\n"}, {"source_code": "n = gets.to_i\na = 3.times.map{gets.split.map(&:to_i)}\np = a.map{|x, y| x}\nn -= p.inject(:+)\n3.times do |i|\n mi = [a[i][1] - a[i][0], n].min\n p[i] += mi\n n -= mi\n break if n <= 0\nend\nputs p.join(' ')\n"}, {"source_code": "n = gets.to_i\na = 3.times.map{gets.split.map(&:to_i)}\np = a.map{|x, y| x}\nn -= p.inject(:+)\n3.times do |i|\n mi = [a[i][1] - a[i][0], n].min\n p[i] += mi\n n -= mi\n break if n <= 0\nend\nputs \"#{p[0]} #{p[1]} #{p[2]}\"\n"}, {"source_code": "N=gets.to_i\nA=$<.map{|e|e.split.map(&:to_i)}\na=[A[0][1],N-A[1][0]-A[2][0]].min\nb=[A[1][1],N-a-A[2][0]].min\nc=N-a-b\nputs [a,b,c]*' '"}, {"source_code": "n = gets.chomp.to_i\n\na = []\n3.times {a << gets.chomp.split(\" \").map(&:to_i)}\n\nx = a[0][0]\ny = a[1][0]\nz = a[2][0]\n\nwhile x + y + z < n\n\tif a[0][0] < a[0][1]\n\t\tx += 1\n\t\ta[0][0] += 1\n\telsif a[1][0] < a[1][1]\n\t\ty += 1\n\t\ta[1][0] += 1\n\telsif a[2][0] < a[2][1]\n\t\tz += 1\n\t\ta[2][0] += 1\n\telse\n\t\tbreak\n\tend\nend\n\nputs [x, y, z] * \" \"\n"}], "negative_code": [{"source_code": "def dsum(given_degree)\n given_degree['1'] + given_degree['2'] + given_degree['3']\nend\n\nn = gets.to_i\ndegree = gets.split(' ')\ndegree_1 = {:min => degree.first.to_i, :max => degree.last.to_i}\ndegree = gets.split(' ')\ndegree_2 = {:min => degree.first.to_i, :max => degree.last.to_i}\ndegree = gets.split(' ')\ndegree_3 = {:min => degree.first.to_i, :max => degree.last.to_i}\ngiven_degree = {'1' => degree_1[:min], '2' => degree_2[:min], '3' => degree_3[:min]}\nif dsum(given_degree) == n\n puts \"#{given_degree['1']} #{given_degree['2']} #{given_degree['3']}\"\nelse\n if n - dsum(given_degree) <= (degree_1[:max] - given_degree['1'])\n given_degree['1'] += n - dsum(given_degree)\n else\n given_degree['1'] = degree_1[:max]\n puts \"#{given_degree['2']} #{given_degree['2']} #{given_degree['3']}\" if dsum(given_degree) == n\n if n - dsum(given_degree) <= (degree_2[:max] - given_degree['2'])\n given_degree['2'] += n - dsum(given_degree)\n else\n given_degree['2'] = degree_2[:max]\n puts \"#{given_degree['1']} #{given_degree['2']} #{given_degree['3']}\" if dsum(given_degree) == n\n if n - dsum(given_degree) <= (degree_3[:max] - given_degree['3'])\n given_degree['3'] += n - dsum(given_degree)\n end\n end\n end\nend\nputs \"#{given_degree['1']} #{given_degree['2']} #{given_degree['3']}\"\n"}], "src_uid": "3cd092b6507079518cf206deab21cf97"} {"source_code": "a=gets.chomp.split(\" \")\nstone=a[2].to_i\ns=a[0].to_i\na=a[1].to_i\nans=\"\"\ntog=0\nloop do\nt2=0\nif tog==0 && stone.gcd(s)<=stone\nstone-=stone.gcd(s)\nans=\"0\"\ntog=1\nt2=1\nelsif tog==1 && stone.gcd(a)<=stone\nstone-=stone.gcd(a)\nans=\"1\"\ntog=0\nt2=1\nend\nbreak if stone<1 || t2==0\nend\nif ans==\"0\"\nputs \"0\"\nelse \nputs \"1\"\nend\n", "positive_code": [{"source_code": "m=gets.split.map &:to_i;i=0;i^=1while 0 b\n t = a\n a = b\n b = t\n end\n if b%a == 0\n a\n else\n gcd(b%a, a)\n end\nend\n\ninputs = gets.split.collect{|element| element.to_i}\ncounter = 1\nwhile true\n if inputs[2] == 0 || inputs[2] < gcd(inputs[2], inputs[(counter-1)%2])\n puts counter%2\n break\n else\n inputs[2] = inputs[2] - gcd(inputs[2], inputs[(counter-1)%2])\n end\n counter = counter+1\nend"}, {"source_code": "m=gets.split.map &:to_i;i=0;i^=1while 00\n n-=n.gcd [a,b][i^=1]\nend\np i"}, {"source_code": "vals = gets.split.map{|s| s.to_i}\nturn = -1\nn = vals[2]\nwhile n > 0\n\tturn += 1\n\tn -= n.gcd(vals[turn%2])\nend\nprint turn%2"}, {"source_code": "def mygcd a, b\n\tif a == b \n\t\tgcd = a\n\telsif a == 0\n\t\tgcd = b\n\telsif b == 0\n\t\tgcd = a\n\telse\n\t\ta, b = b, a if a-b < 0\n\t\tb, a = a, gcd while (gcd = b%a) > 0\n\t\tgcd = a\n\tend\n\tgcd\nend\n\nvals = gets.split.map{|s| s.to_i}\nturn = -1\nn = vals[2]\nwhile n > 0\n\tturn += 1\n\tn -= mygcd(n, vals[turn%2])\nend\nprint turn%2"}, {"source_code": "m=gets.split.map &:to_i;i=0;i^=1while 0= 0 do\n n -= a.gcd(n)\n if n < 0\n print 1\n next\n end\n n -= b.gcd(n)\n print 0 if n < 0\nend"}, {"source_code": "a,b,n = gets.split(\" \").map(&:to_i)\ni = 0\n\nwhile true do\n k = (i%2 == 0 ? a : b)\n if n.gcd(k) > n\n break\n else \n n-= n.gcd(k)\n i+=1\n end\nend\n\nputs (i-1)%2\n"}, {"source_code": "a,b,n=gets.split.map &:to_i;i=1;n-=[a,b][i^=1].gcd(n)while n>0;p i\n"}, {"source_code": "a, b, n = gets.split.map(&:to_i)\n\ni=0\nwhile n>0 do\n\tt=n.gcd([a,b][i])\n\ti^=1\n\tn-=t\nend\n\nputs i^=1\n"}, {"source_code": "def GCD a, b\n\tif b == 0 then a else GCD b, a%b end\nend\n\na, b, n = gets.split.map(&:to_i)\n\nplayer = :a\nloop do\n\ttake = GCD n, (player == :a ? a : b)\n\t\n\tif n0\n\tn-=n.gcd [a,b][i^=1]\nend\np i\n"}, {"source_code": "a, b, n = gets.split.map &:to_i\ni=1\nn-=n.gcd [a,b][i^=1] while n>0\np i\n"}, {"source_code": "a,b,n=gets.split.map &:to_i;i=1;n-=[a,b][i^=1].gcd n while n>0;p i\n"}, {"source_code": "a, b, n = gets.split.map(&:to_i)\n\ni=0\nwhile n>0\n\tn-=n.gcd([a,b][i])\n\ti^=1\nend\n\np i^=1\n"}, {"source_code": "k=gets.split\na,b,k=k[0].to_i,k[1].to_i,k[2].to_i\n\nwhile true\n\tbreak if k==0\n\tk-=k.gcd(a)\n\tans=0\n\tbreak if k==0\n\tk-=k.gcd(b)\n\tans=1\nend\np ans\n"}, {"source_code": "a, b, n = gets.split.map {|x| x.to_i}\n\nwhile true\n n = n - n.gcd(a)\n if n < 0\n puts 1\n exit\n end\n n = n - n.gcd(b)\n if n < 0\n puts 0\n exit\n end\nend"}, {"source_code": "simon, antisimon, heap = gets.split.map(&:to_i)\nsimon_wins = false\n\nwhile(true)\n heap -= simon.gcd(heap) \n break if heap < 0\n simon_wins = true\n heap -= antisimon.gcd(heap)\n break if heap < 0\n simon_wins = false\nend\n\nif simon_wins\n puts \"0\"\nelse\n puts \"1\"\nend\n"}, {"source_code": "a=Array.new(2){0}\na[0],a[1],n = gets.split.map(&:to_i)\n\ndef go(a, n)\nidx = 0\nloop do\n d = a[idx].gcd(n)\n return 1 - idx if d > n\n \n n -= d\n idx = 1 - idx\nend\nend\n\nputs go(a,n)\n"}, {"source_code": "# Epic Game\n# http://codeforces.com/problemset/problem/119/A\n\ndef gcd(a, b)\n return a if b == 0\n return gcd(b, a % b)\nend\n\nsimon, antisimon, stones = gets.chomp.split.map { |e| e.to_i }\n\ncount = 0\n\nloop do\n if count % 2 == 0\n stones = stones - gcd(simon, stones)\n else\n stones = stones - gcd(antisimon, stones)\n end\n \n break if stones <= 0\n count += 1\nend\n\nputs \"#{(count % 2 == 0) ? \"0\" : \"1\"}\""}, {"source_code": "input = $stdin.readline.chop.split(' ')\na = input[0].to_i; b = input[1].to_i; n = input[2].to_i\n\nloop do\n \n need = a.gcd(n)\n if n y\n return gcd(y, x-y)\n else \n return gcd(x, y-x)\n end \n end\nend\n\ndef sov(a,b,n,x)\n if n == 0\n if x == 0\n return 1\n else x == 1\n return 0\n end\n else \n if x == 0 \n return sov(a,b,n-gcd(a,n),1-x)\n else x == 1\n return sov(a,b,n-gcd(b,n),1-x)\n end\n end\nend\n\nputs sov(a,b,n,0)\n"}, {"source_code": "def gcd(a, b)\n min = a.abs\n max = b.abs\n while min > 0\n tmp = min\n min = max % min\n max = tmp\n end\n max\nend\n\ninput = STDIN.gets().split(\" \")\n\na = input[0].to_i\nb = input[1].to_i\nn = input[2].to_i\n\ngameover = false\nuntil gameover\n n = n- gcd(a,n) #S\n if(n < 0) \n gameover = true\n p 1\n else \n n = n- gcd(b,n) #A\n if(n < 0)\n gameover = true\n p 0\n end\n end\n\nend"}, {"source_code": "a,b,n=gets.split.map &:to_i\ngcd=->(x,y){ y==0 ? x : gcd[y,x%y]}\nx,y=1,0\nwhile true \n g=gcd[a,n]\n if (g>n) \n puts x\n break\n end\n n-=g\n a,b,x,y=b,a,y,x\nend"}, {"source_code": "m=gets.split.map &:to_i;i=0;i^=1while 0 0 do\n if win == 1\n c -= c.gcd(a)\n else\n c -= c.gcd(b)\n end\n win ^= 1 \nend\nputs win"}, {"source_code": "def NOD(a, b)\n\twhile b != 0\n\t\ta, b = b, a % b\n\tend\n\t\n\treturn a\nend\n\nl = gets.split.map(&:to_i)\no = 0\n\nloop do\n\tt = NOD(l[o], l[2])\n\tif l[2] < t\n\t\tbreak\n\tend\n\tl[2] -= t\n\to = 1 - o\nend\n\nputs 1 - o"}, {"source_code": "a, b, n = gets.split.map(&:to_i)\ni = 0\nwhile (n > 0) do\n\tn -= n.gcd(i % 2 == 0 ? a : b)\n\ti += 1\nend\np (i - 1) % 2"}, {"source_code": "a, b, n = gets.split.map(&:to_i)\ni = 0\nwhile (n >= 0) do\n\tn -= n.gcd(i % 2 == 0 ? a : b)\n\ti += 1\nend\np i % 2"}, {"source_code": "a, b, n = gets.split.map{|_|_.to_i}\nuntil n<0\n n -= n.gcd(a)\n if n<0\n puts 1\n break\n end\n n -= n.gcd(b)\n if n<0\n puts 0\n end\nend"}, {"source_code": "a1=gets\nk=a1.split(\" \")\na=k[0].to_i\nb=k[1].to_i\nn=k[2].to_i\n#n=gets.to_i\\\n#puts a\n#puts b\n#puts n\n\nwhile 1\ni=a.gcd n\n#puts i\nif(n-i<0)\nprint \"1\"\nexit\nend\nn=n-i\n#puts n\nj=b.gcd n\n#puts j\nif(n-j<0)\nprint \"0\"\nexit\nend\nn=n-j\n#puts n\nend"}, {"source_code": "\ndef gcd(a,b)\n a if b==0\n b == 0 ? a : gcd(b, a%b) \nend\n\na,b,n=gets.split.map(&:to_i)\n\ni=0\npl=[a,b]\nloop do\n v = pl[i%2]\n g = gcd(v, n)\n break if g > n\n n-=g\n i+=1\nend\n\nputs i.even? ? 1 : 0\n"}, {"source_code": "class Integer\n def gcd(b)\n a = self\n a,b = b,a if b > a\n while b > 0\n a,b = b, a % b\n end\n a\n end\nend\ninput = gets.chop.split(\" \").map(&:to_i)\nleft = input[2]\ntook = 0\nturn = 0\nwhile left >= took do\n took = left.gcd(input[turn])\n (left < took)? (puts turn; exit) : left -= took\n (left < took)? (puts turn; exit) : left\n if turn == 0\n turn = 1\n else\n if turn == 1\n turn = 0\n end\n end\nend\n\n"}, {"source_code": "#!/usr/bin/env ruby\n# -*- cofing: utf-8 -*-\n\nPrimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97].freeze\n\ndef get_abn(io)\n line = io.gets\n parts = line.split(' ')\n parts.map! {|p| p.to_i}\n return parts[0], parts[1], parts[2]\nend\n\n# greatest common divisor\ndef gcd(x, y)\n m, n = [x, y].sort\n until n==0 do\n m, n = [n, m%n]\n end\n return m\nend\n# def gcd(x, y)\n# for i in (1..100).to_a.reverse do\n# if x%i == 0 and y%i == 0 then\n# return i\n# end\n# end\n# end\n\nif $0 == __FILE__ then\n a, b, n = get_abn($stdin)\n while true do\n taken = gcd(a, n)\n if taken > n then\n puts 1\n break\n else\n n -= taken\n end\n\n taken = gcd(b, n)\n if taken > n then\n puts 0\n break\n else\n n -= taken\n end\n end\nend\n\n"}, {"source_code": "def nod(x,y)\n if x == 0 then\n return y\n elsif y == 0 then\n return x\n else\n if x > y then\n return nod(x-y,y)\n elsif y > x then\n return nod(x,y-x)\n else\n return x\n end\n end\nend\n\na,b,n = gets.split.map{|i| i.to_i}\n\nx = a\nres = 0\nwhile nod(x,n) < n do\n n -= nod(x,n)\n if x == a then\n x = b\n res = 1\n else\n x = a\n res = 0\n end\nend\n\nputs res"}, {"source_code": "#!/usr/bin/env ruby\n# -*- cofing: utf-8 -*-\n\ndef get_abn(io)\n io.gets.split(' ').map! {|p| p.to_i}\nend\n\n# greatest common divisor\ndef gcd(x, y)\n m, n = [x, y].sort\n until n==0 do\n m, n = [n, m%n]\n end\n return m\nend\n\nif $0 == __FILE__ then\n a, b, n = get_abn($stdin)\n cnt = 1\n [a, b].cycle do |x|\n taken = gcd(x, n)\n if taken > n then\n puts cnt%2\n break\n else\n n -= taken\n end\n cnt += 1\n end\nend\n\n"}, {"source_code": "a,b,n = gets.chomp.split(/ /).map!{|x| x.to_i}\nwhile true do\n nn = a.gcd(n)\n n -= nn\n if n < 0 then\n puts 1\n break\n end\n nn = b.gcd(n)\n n -= nn\n if n < 0 then\n puts 0\n break\n end\nend\n"}, {"source_code": "#!/usr/bin/env ruby\n# -*- cofing: utf-8 -*-\n\ndef get_abn(io)\n line = io.gets\n parts = line.split(' ')\n parts.map! {|p| p.to_i}\n return parts\nend\n\n# greatest common divisor\ndef gcd(x, y)\n m, n = [x, y].sort\n until n==0 do\n m, n = [n, m%n]\n end\n return m\nend\n\nif $0 == __FILE__ then\n a, b, n = get_abn($stdin)\n while true do\n taken = gcd(a, n)\n if taken > n then\n puts 1\n break\n else\n n -= taken\n end\n\n taken = gcd(b, n)\n if taken > n then\n puts 0\n break\n else\n n -= taken\n end\n end\nend\n\n"}, {"source_code": "m=gets.split.map &:to_i;i=0;i^=1while 0 y ? y : x\n\tnum = 1\n\tnum.upto t do |e|\n\t\tnum = e if (x % e == 0 and y % e == 0)\n\tend\n\tnum\nend\n\nloop do\n\tn -= turn ? gcd(b,n) : gcd(a,n)\n\tbreak if n == 0\n\tturn = !turn\nend\n\nputs turn ? 1 : 0"}, {"source_code": "a,b,n = gets.chomp.split(\" \").map(&:to_i)\nturn = 0\n\ndef gcd x, y\n\tt = x > y ? y : x\n\tnum = 1\n\tnum.upto t do |e|\n\t\tnum = e if (x % e == 0 and y % e == 0)\n\tend\n\tnum\nend\n\nloop do\n\tn -= turn == 0 ? gcd(a,n) : gcd(b,n)\n\tbreak if n == 0\n\tturn = turn == 0 ? 1 : 0\nend\n\nputs turn"}, {"source_code": "input=gets.split.map(&:to_i)\nheap=input[2]\nk=0\n10000.times{|k|\n heap-=heap.gcd(input[k%2])\n if heap<0 then\n puts 1-k%2\n exit\n end\n}\n"}, {"source_code": "m=gets.split.map &:to_i;i=0;i^=1while 0 n then\n puts 1\n break\n else\n n -= taken\n end\n\n taken = gcd(b, n)\n if taken > n then\n puts 0\n break\n else\n n -= taken\n end\n end\nend\n\n"}, {"source_code": "def gcd(a, b)\n while a!=0 and b!=0 do\n if a > b\n a = a % b\n else\n b = b % a\n end\n end\n return a+b\nend\n\n\na, b, n = gets.split.map(&:to_i)\n\nloop do\n n -= gcd(a, n)\n if n < 0\n puts 1\n break\n end\n\n n -= gcd(b, n)\n if n < 0\n puts 0\n break\n end\nend\n"}, {"source_code": "a = gets.chomp.split.map(&:to_i)\nn = a[2]\na.pop\n(n + 1).times do |i|\n\tn -= a[i % 2].gcd(n)\n\tif n < 0\n\t\tif i % 2 == 1\n\t\t\tputs 0\n\t\telsif i % 2 == 0\n\t\t\tputs 1\n\t\tend\n\t\tbreak\n\tend\nend\n"}, {"source_code": "def solve(a, b, n)\n while true\n d = a.gcd(n)\n return 1 if d>n\n n -= d\n\n d = b.gcd(n)\n return 0 if d>n\n n -= d\n end\n\nend\n\na, b, n = gets.split.map(&:to_i)\nret = solve(a, b, n)\nputs ret\n"}, {"source_code": "n = readline.split(' ')\nsemen = true\nantisemen = true\n\nwhile (semen && antisemen) do\n \n if(n[2].to_i - (n[0].to_i.gcd n[2].to_i) >= 0 && n[2].to_i != 0)\n begin\n n[2] = n[2].to_i - (n[0].to_i.gcd n[2].to_i)\n semen = true\n end\n else\n semen = false\n break\n end\n \n if(n[2].to_i - (n[1].to_i.gcd n[2].to_i) >= 0 && n[2].to_i != 0)\n begin\n n[2] = n[2].to_i - (n[1].to_i.gcd n[2].to_i)\n antisemen = true\n end\n else\n antisemen = false\n break\n end\n \nend\n\nif(semen == true && antisemen == false) \n puts \"0\" \nelse \n puts \"1\" \nend\n"}, {"source_code": "a=gets.chomp.split(\" \")\nstone=a[2].to_i\ns=a[0].to_i\na=a[1].to_i\nans=\"\"\ntog=0\nloop do\nt2=0\nif tog==0 && stone.gcd(s)<=stone\nstone-=stone.gcd(s)\nans=\"0\"\ntog=1\nt2=1\nelsif tog==1 && stone.gcd(a)<=stone\nstone-=stone.gcd(a)\nans=\"1\"\ntog=0\nt2=1\nend\nbreak if stone<1 || t2==0\nend\nif ans==\"0\"\nputs \"0\"\nelse \nputs \"1\"\nend"}, {"source_code": "m=gets.split.map &:to_i;i=0;i^=1while 0 n\n antisimon_wins = 1\n break\n else\n n -= div\n end\n else # Antisimon\n div = n.gcd(b)\n if div > n\n antisimon_wins = 0\n break\n else\n n -= div\n end\n end\nend\n\nif antisimon_wins == 1\n puts antisimon_wins\nelse\n puts antisimon_wins\nend\n"}, {"source_code": "s,a,n=gets.split.map &:to_i\nloop do\n if s.gcd(n)>n\n puts 1\n break\n else \n n=n-s.gcd(n)\n end\n \n if a.gcd(n)>n\n puts 0\n break\n else n=n-a.gcd(n)\n end\nend\n"}, {"source_code": "module Emaxx\n def self.gcd(a,b)\n while b!=0\n a, b = b, a%b\n end\n a\n end\nend\n\nl = $stdin.readline.split\na = l[0..1].map(&:to_i)\nn = l.last.to_i\n\nwho = 0\nt = Emaxx.gcd(a[who], n)\nwhile t>0 && n>=t\n n -= t\n who = (who+1)%2\n t = Emaxx.gcd(a[who], n)\nend\n\nputs (who+1)%2"}, {"source_code": "m=gets.split.map &:to_i;i=0;i^=1while 0 0\n if games % 2 == 0\n stones -= a.gcd(stones)\n else\n stones -= b.gcd(stones)\n end\n games += 1\n end\n\n puts (games % 2 == 0) ? 1 : 0\nend\n\ngame\n"}, {"source_code": "def gcd(a, b)\n if a == 0\n return b\n end\n return gcd b % a, a\nend\n\na, b, n = gets.split(' ').map { |i| i.to_i }\ncur = 0\nwhile true\n if cur == 0\n take = gcd(n, a)\n else\n take = gcd(n, b)\n end\n break if take > n\n n -= take\n cur = 1 - cur\nend\nputs 1 - cur\n"}, {"source_code": "a,b,n=gets.chomp.split.map(&:to_i)\n\nans=0\nloop do\n ans=1-ans\n x=n\n y=a\n while y>0\n z=x%y\n x, y = y, z\n end\n a, b = b, a\n if n0\n\ti=1-i\n\tc-=([a,b][i]).gcd(c)\nend\np i"}, {"source_code": "#!/usr/bin/ruby -Ks\n\ninput = $stdin.gets.chomp.split\n$a = input[0].to_i\n$b = input[1].to_i\n$n = input[2].to_i\n\ndef getGCD(n1, n2)\n if n1 == n2\n return n1\n end\n if n2 == 0\n return n1\n end\n \n if n1 < n2\n start_value = n1\n else\n start_value = n2\n end\n \n start_value.downto(1) do |i|\n if (( n1 % i == 0 )&&( n2 % i == 0 ))\n return i\n end\n end\nend\n\nisSimon = true\nwhile true\n x = 0\n if isSimon\n x = getGCD($a,$n)\n else\n x = getGCD($b,$n)\n end\n $n -= x\n if $n < 0\n if isSimon\n puts 1\n break\n else\n puts 0\n break\n end\n end\n \n if isSimon\n isSimon = false\n else\n isSimon = true\n end\nend\n\n# EOF\n"}, {"source_code": "#!/usr/bin/ruby\n\ndef readNextValues\n return gets.chomp.split.collect {|x| x.to_i }\nend\n\n\ndef gcd(a, b)\n while b > 0\n c = a % b\n a = b\n b = c\n end\n return a\nend\n\ndef solve(a, b, n)\n loop do\n n -= gcd(a, n)\n return 1 if n < 0\n n -= gcd(b, n)\n return 0 if n < 0\n end\nend\n\n### main\n\na, b, n = readNextValues\n\nputs(solve(a, b, n))\n"}, {"source_code": "a, b, n = gets.split.map &:to_i\ni = 0\nloop do\n n -= (i == 0 ? a : b).gcd(n)\n if n < 0\n puts 1-i\n exit\n end\n i = 1 - i\nend\n"}, {"source_code": "x,y,z=gets.chomp.split()\nx = x.to_i\ny = y.to_i\nz = z.to_i\npoint = 0\nwhile true\n\tif point==0\n\t\tz-=x.gcd(z)\n\t\tif z<=0\n\t\t\tputs 0\n\t\t\tbreak\n\t\tend\n\t\tpoint+=1\n\tend\n\tif point==1\n\t\tz-=y.gcd(z)\n\t\tif z<=0\n\t\t\tputs 1\n\t\t\tbreak\n\t\tend\n\t\tpoint-=1\n\tend\n\nend\n"}, {"source_code": "a, b, n = STDIN.read.split.map(&:to_i)\n\nloop do\n\t[a, b].each.with_index do |i, k|\n\t\tn -= i.gcd n\n\t\tif n <= 0\n\t\t\tputs k == 1 ? 1 : 0\n\t\t\texit\n\t\tend\n\tend\nend"}, {"source_code": "m=gets.split.map &:to_i;i=0;i^=1while 00;p i"}, {"source_code": "#!/usr/bin/env ruby\nrequire 'mathn'\n\na,b,c = gets.split.map{ |i| i.to_i }\nd = 0\nwhile true\n e = a.gcd(c)\n if d == 1\n e = b.gcd(c)\n end\n c -= e\n break if c < 0\n d ^= 1\nend\nd ^= 1\nputs d\n"}, {"source_code": "a, b, n = gets.split.map(&:to_i)\ng = a.gcd(n)\nflag = 0\nwhile n >= g\n\tif flag == 0\n\t\tn -= g\n\t\tg = b.gcd(n)\n\t\tflag = 1\n\telse\n\t\tn -= g\n\t\tg = a.gcd(n)\n\t\tflag = 0\n\tend\nend\nif flag == 1\n\tputs 0\nelse\t\n\tputs 1\nend\n"}, {"source_code": "m=gets.split.map &:to_i;i=0;i^=1while 00\n\tn-=n.gcd([a,b][i^=1])\nend\n\np i\n"}, {"source_code": "a,b,n=gets.split.map &:to_i;i=1;n-=n.gcd [a,b][i^=1] while n>0;p i\n"}, {"source_code": "a, b, n = gets.split.map(&:to_i)\n\ni=0\nwhile n>0\n\tt=n.gcd([a,b][i])\n\ti^=1\n\tn-=t\nend\n\np i^=1\n"}, {"source_code": "m=gets.split.map &:to_i;i=0;i^=1while 00\n\tn-=n.gcd([a,b][i^=1])\nend\n\np i^=1\n"}, {"source_code": "include Math\n\ndef get_abn(io)\n line = io.gets\n parts = line.split(' ')\n return parts[0], parts[1], parts[2]\nend\n\na, b, n = get_abn($stdin)\nprint a,b,n"}, {"source_code": "include Math\n\n0"}, {"source_code": "include Math\nline = gets\nparts = line.split(' ')\na = parts[0]\nb = parts[1]\nn = parts[2]\nprint a, b, n"}, {"source_code": "include Math\n\nputs 0"}, {"source_code": "#!/usr/bin/env ruby\n# -*- cofing: utf-8 -*-\n\nPrimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97].freeze\n\ndef get_abn(io)\n line = io.gets\n parts = line.split(' ')\n parts.map! {|p| p.to_i}\n return parts[0], parts[1], parts[2]\nend\n\n# greatest common divisor\ndef gcd(x, y)\n x_divisor = divisor x\n y_divisor = divisor y\n common_divisor = x_divisor & y_divisor\n return common_divisor.max\nend\n\ndef divisor(x)\n divisor = [1]\n Primes.each do |p|\n divisor << p if x%p == 0\n end\n unless Primes.include? x then\n divisor << x\n end\n return divisor\nend\n\na, b, n = get_abn($stdin)\nwhile true do\n taken = gcd(a, n)\n if taken > n then\n puts 1\n break\n else\n n -= taken\n end\n\n taken = gcd(b, n)\n if taken > n then\n puts 0\n break\n else\n n -= taken\n end\nend\n"}, {"source_code": "#! ruby -Ku\n# -*- coding: UTF-8 -*-\nbegin\n inputs = open(\"input.txt\")\nrescue\n inputs = STDIN\nend\n\na_b_n = inputs.gets.split.map(&:to_i)\na = a_b_n.shift\nb = a_b_n.shift\nn = a_b_n.shift\n\nantisimon_wins = 1\n(n+1).times do |i|\n if i == 0 # Simon\n div = n.gcd(a)\n if div > n\n antisimon_wins = 1\n break\n else\n n -= div\n end\n else # Antisimon\n div = n.gcd(b)\n if div > n\n antisimon_wins = 0\n break\n else\n n -= div\n end\n end\nend\n\nif antisimon_wins == 1\n puts antisimon_wins\nelse\n puts antisimon_wins\nend\n"}, {"source_code": "#! ruby -Ku\n# -*- coding: UTF-8 -*-\nbegin\n inputs = open(\"input.txt\")\nrescue\n inputs = STDIN\nend\n\na_b_n = inputs.gets.split.map(&:to_i)\na = a_b_n.shift\nb = a_b_n.shift\nn = a_b_n.shift\n\nantisimon_wins = 1\nn.times do |i|\n if i == 0 # Simon\n div = n.gcd(a)\n if div > n\n antisimon_wins = 1\n break\n else\n n -= div\n end\n else # Antisimon\n div = n.gcd(b)\n if div > n\n antisimon_wins = 0\n break\n else\n n -= div\n end\n end\nend\n\nif antisimon_wins == 1\n puts antisimon_wins\nelse\n puts antisimon_wins\nend\n"}, {"source_code": "x,y,z=gets.chomp.split()\nx = x.to_i\ny = y.to_i\nz = z.to_i\npoint = 0\nwhile true\n\tif point==0\n\t\tz-=x.gcd(z)\n\t\tif z<0\n\t\t\tputs 0\n\t\t\tbreak\n\t\tend\n\t\tpoint+=1\n\tend\n\tif point==1\n\t\tz-=y.gcd(z)\n\t\tif z<0\n\t\t\tputs 1\n\t\t\tbreak\n\t\tend\n\t\tpoint-=1\n\tend\n\nend\n"}, {"source_code": "a, b, n = STDIN.read.split.map(&:to_i)\n\ndef gcd a, b\n\treturn a if b.zero?\n\tgcd b, a % b\nend\n\nloop do\n\t[a, b].each do |i|\n\t\tgcd = gcd i, n\n\t\tif n - gcd < 0\n\t\t\tputs i == a ? 1 : 0\n\t\t\texit\n\t\tend\n\t\tn -= gcd\n\tend\nend"}, {"source_code": "a1=gets\nk=a1.split(\" \")\na=k[0].to_i\nb=k[1].to_i\nn=k[2].to_i\n#n=gets.to_i\nwhile 1\ni=a.gcd n\nif(n-i<0)\nprint \"1\"\nexit\nend\nn=n-i\nj=b.gcd n-i\nif(n-j<0)\nprint \"0\"\nexit\nend\nn=n-j\nend"}, {"source_code": "a1=gets\nk=a1.split(\" \")\na=k[0].to_i\nb=k[1].to_i\nn=k[2].to_i\n#n=gets.to_i\\\nputs a\nputs b\nputs n\n\nwhile 1\ni=a.gcd n\nputs i\nif(n-i<0)\nprint \"1\"\nexit\nend\nn=n-i\nputs n\nj=b.gcd n\nputs j\nif(n-j<0)\nprint \"0\"\nexit\nend\nn=n-j\nputs n\nend"}, {"source_code": "def f(n,t,a,b)\n\t\tif n0 ? t1 : -t1\nif x>0\n puts \"0 #{t2} #{t1} 0\"\nelse\n puts \"#{-t1} 0 0 #{t2}\"\nend\n\n# The truth is, the sample doesn't correct\n# A(0,2y) C(2x,0) makes the area minimum\n\n# if x>0\n# puts \"0 #{2*y} #{2*x} 0\"\n# else\n# puts \"#{2*x} 0 0 #{2*y}\"\n# end"}, {"source_code": "x,y=gets.split.map(&:to_i)\nc=x.abs+y.abs\ny=y<0? -c : c\nputs(x<0?\"#{-c} 0 0 #{y}\":\"0 #{y} #{c} 0\")\n"}, {"source_code": "#monkeycode\nx, y =gets.split.map{|i| i.to_i}\nif(x>0) then\n if(y>0) then\n puts(\"0 #{x+y} #{x+y} 0\")\n else\n puts(\"0 #{y-x} #{x-y} 0\")\n end\nelse\n if(y>0) then\n puts(\"#{x-y} 0 0 #{y-x}\")\n else\n puts(\"#{x+y} 0 0 #{x+y}\")\n end\nend"}, {"source_code": "x, y =gets.split.map{|i| i.to_i}\nif(x>0) then\n if(y>0) then\n puts(\"0 #{x+y} #{x+y} 0\")\n else\n puts(\"0 #{y-x} #{x-y} 0\")\n end\nelse\n if(y>0) then\n puts(\"#{x-y} 0 0 #{y-x}\")\n else\n puts(\"#{x+y} 0 0 #{x+y}\")\n end\nend\n"}, {"source_code": "x,y=gets.split.map(&:to_i)\nc=x.abs+y.abs\ny=y<0? -c : c\nputs(x<0?\"#{-c} 0 0 #{y}\":\"0 #{y} #{c} 0\")\n"}, {"source_code": "x,y=gets.split.map(&:to_i)\nc=x.abs+y.abs\ny=y<0? -c : c\nputs(x<0?\"#{-c} 0 0 #{y}\":\"0 #{y} #{c} 0\")"}, {"source_code": "x,y=gets.split(\" \").map { |i| i.to_i}\nz=x.abs+y.abs\nif x>0 and y>0 \n\tprint \"0 \",z,\" \",z,\" 0\"\nelsif x>0 and y<0\n\t print \"0 \",-z,\" \",z,\" 0\"\nelsif x<0 and y>0\n\tprint -z,\" 0 0 \",z\nelse\n\tprint -z,\" 0 0 \",-z\nend\n\t\n"}, {"source_code": "def run\n x, y = $stdin.gets.split.map(&:to_i)\n puts [[(x.abs + y.abs) * (x / x.abs), 0].join(\" \"),\n [0, (y.abs + x.abs) * (y / y.abs)].join(\" \")].sort.join(\" \")\nend\n\nrun if $0 == __FILE__\n"}, {"source_code": "x,y=gets.split.map(&:to_i)\nc=x.abs+y.abs\ny=y<0? -c : c\nputs(x<0?\"#{-c} 0 0 #{y}\":\"0 #{y} #{c} 0\")\n"}, {"source_code": "x,y=gets.split.map(&:to_i)\nc=x.abs+y.abs\ny=y<0? -c : c\nputs(x<0?\"#{-c} 0 0 #{y}\":\"0 #{y} #{c} 0\")\n"}, {"source_code": "a=gets.chomp.split(\" \")\nx=a[0].to_i\ny=a[1].to_i\nan=x.abs+y.abs\nif x>0 && y>0\nputs \"0 #{an} #{an} 0\"\nelsif x<0 && y>0\nputs \"#{-an} 0 0 #{an}\"\nelsif x>0 && y<0\nputs \"0 #{-an} #{an} 0\"\nelsif x<0 && y<0\nputs \"#{-an} 0 0 #{-an}\"\nend\n\n\n"}, {"source_code": "x,y=gets.split.map(&:to_i)\nif x > 0 and y > 0\n puts \"0 #{x+y} #{x+y} 0\"\nelsif x > 0 and y < 0\n puts \"0 #{y-x} #{x-y} 0\"\nelsif y > 0\n puts \"#{-(y-x)} 0 0 #{y-x}\"\nelse\n puts \"#{x+y} 0 0 #{x+y}\"\nend\n"}, {"source_code": "x,y=gets.split.map(&:to_i)\nc=x.abs+y.abs\ny=y<0? -c : c\nputs(x<0?\"#{-c} 0 0 #{y}\":\"0 #{y} #{c} 0\")\n"}, {"source_code": "x,y = gets.chomp.split(\" \").collect {|a| a.to_i}\n\nr = x.abs + y.abs\n\nx1 = 0\ny1 = r*y/y.abs\nx2 = r*x/x.abs\ny2 = 0\n\nif x1 >= x2\n\tputs \"#{x2} #{y2} #{x1} #{y1}\"\nelse\n puts \"#{x1} #{y1} #{x2} #{y2}\"\nend\n\n"}, {"source_code": "x,y=gets.split.map(&:to_i)\nc=x.abs+y.abs\ny=y<0? -c : c\nputs(x<0?\"#{-c} 0 0 #{y}\":\"0 #{y} #{c} 0\")"}, {"source_code": "x,y=gets.split.map(&:to_i)\nx1=y2=0;y1=x2=x.abs+y.abs\nx2=-x2 if x<0\ny1=-y1 if y<0\nif x1>x2\n x1,x2=x2,x1\n y1,y2=y2,y1\nend\nputs \"#{x1} #{y1} #{x2} #{y2}\"\n"}, {"source_code": "x,y=gets.split.map(&:to_i)\nc=x.abs+y.abs\ny=y<0? -c : c\nputs(x<0?\"#{-c} 0 0 #{y}\":\"0 #{y} #{c} 0\")\n"}, {"source_code": "x,y=gets.split.map(&:to_i)\nc=x.abs+y.abs\ny=y<0? -c : c\nputs(x<0?\"#{-c} 0 0 #{y}\":\"0 #{y} #{c} 0\")\n"}, {"source_code": "x, y = gets.split.map { |x| x.to_i }\nif 0 < x && 0 < y\n x1 = 0\n y1 = y + x\n x2 = x + y\n y2 = 0\nelse\n if 0 < x && 0 > y\n x1 = 0\n y1 = y - x\n x2 = x - y\n y2 = 0\n else\n if 0 > x && 0 > y\n x1 = x + y\n y1 = 0\n x2 = 0\n y2 = y + x\n else\n x1 = x - y\n y1 = 0\n x2 = 0\n y2 = y - x\n end\n end\nend\nprint x1, ' ', y1, ' ', x2, ' ', y2\n"}, {"source_code": "x, y = gets.split.map { |x| x.to_i }\n\nsum = x.abs + y.abs\n\nif x > 0\n\tif y > 0\n\t\tputs [0, sum, sum, 0].join ' '\n\telse\n\t\tputs [0, -sum, sum, 0].join ' '\n\tend\nelse\n\tif y > 0\n\t\tputs [-sum, 0, 0, sum].join ' '\n\telse\n\t\tputs [-sum, 0, 0, -sum].join ' '\n\tend\nend\n"}], "negative_code": [{"source_code": "x,y=gets.split(\" \").map { |i| i.to_i}\nz=x.abs+y.abs\nif x>0 and y>0 \n\tprint \"0 \",z,\" \",z,\" 0\"\nelsif x>0 and y<0\n\t print \"0 \",-z,\" \",z,\" 0\"\nelsif x<0 and y>0\n\tprint -z,\" 0 0 \",z\nelse\n\tprint \"0 \",-z,\" \",-z,\" 0\"\nend\n\t\n"}, {"source_code": "x,y=gets.split(\" \").map { |i| i.to_i}\nz=x.abs+y.abs\nif x>0 and y>0 \n\tprint \"0 \",z,\" \",z,\" 0\"\nelsif x>0 and y<0\n\t print \"0 \",-z,\" \",z,\" 0\"\nelsif x<0 and y>0\n\tprint -z,\" 0 0 \",z\nelse\n\tprint \"0 \",-z,-z,\" 0\"\nend\n\t\n"}, {"source_code": "x,y=gets.split(\" \").map { |i| i.to_i}\nz=x.abs+y.abs\nif x>0 and y>0 \n\tprint \"0 \",z,\" \",z,\" 0\"\nelsif x>0 and y<0\n\t print \"0 \",-z,z,\" 0\"\nelsif x<0 and y>0\n\tprint -z,\" 0 0 \",z\nelse\n\tprint \"0 \",-z,-z,\" 0\"\nend\n\t\n"}, {"source_code": "x,y=gets.split.map(&:to_i)\nif x > 0 and y > 0\n puts \"0 #{x+y} #{x+y} 0\"\nelsif x > 0 and y < 0\n puts \"0 #{x-y} #{x-y} 0\"\nelsif y > 0\n puts \"#{-(y-x)} 0 0 #{y-x}\"\nelse\n puts \"#{x+y} 0 0 #{-(x+y)}\"\nend\n"}, {"source_code": "x,y=gets.split.map(&:to_i)\nif x > 0 and y > 0\n puts \"0 #{x+y} #{x+y} 0\"\nelsif x > 0 and y < 0\n puts \"0 #{y-x} #{x-y} 0\"\nelsif y > 0\n puts \"#{-(y-x)} 0 0 #{y-x}\"\nelse\n puts \"#{x+y} 0 0 #{-(x+y)}\"\nend\n"}, {"source_code": "x,y=gets.split.map(&:to_i)\nif x > 0 and y > 0\n puts \"0 #{x+y} #{x+y} 0\"\nelsif x > 0 and y < 0\n puts \"0 #{x-y} #{x-y} 0\"\nelsif y > 0\n puts \"#{-(y-x)} 0 0 #{y-x}\"\nelse\n puts \"#{x+y} 0 0 #{x+y}\"\nend\n"}], "src_uid": "e2f15a9d9593eec2e19be3140a847712"} {"source_code": "userInput = gets.chomp\n\nnumberArray = userInput.to_s.split(\"\").map {|item| item.to_i }\n\nresult ||= 0\nresult += \n\nloopNum = 0\n\nuntil loopNum == numberArray.length do\n\tresult += 2 ** (numberArray.length - loopNum - 1) if numberArray[loopNum] == 4\n\tresult += (2 * (2 ** (numberArray.length - loopNum - 1))) if numberArray[loopNum] == 7\n\n\tloopNum += 1\nend\n\n\nputs result", "positive_code": [{"source_code": "# coding: utf-8\n\ns = gets.chomp.split(//).reverse\no = 0\nfor i in 0...s.length\n if s[i] == \"4\"\n o += 1 * (2**i)\n else\n o += 2 * (2**i)\n end\nend\n\nputs o"}, {"source_code": "number = gets.chomp()\n\nnumber.reverse!\n\nsum = 0\n\nfor i in 0...number.length\n if number[i] == '4'\n sum += (2 ** i) \n else\n sum += (2 ** i) * 2\n end\nend\n\nputs sum\n\n\n"}, {"source_code": "number = gets.chomp()\n\nnumber.reverse!\n\ntable = {4=>1, 7=>2}\n\nsum = 0\n\nfor i in 0..number.length\n\tsum += (2 ** i) * table[number[i].to_i].to_i\nend\n\nputs sum\n\n\n\n"}, {"source_code": "n = gets.chomp.chars.map(&:to_i)\nans = 0\nn.size.times do |i|\n if n[i] == 4\n ans += 2 ** (n.size - i - 1)\n elsif n[i] == 7\n ans += 2 * 2 ** (n.size - i - 1)\n end\nend\nputs ans\n"}, {"source_code": "def lucky_numbers(numbers, current, limit)\n numbers.push(current)\n\n if current >= limit\n return numbers\n end\n\n numbers = lucky_numbers(numbers, current * 10 + 4, limit)\n\n lucky_numbers(numbers, current * 10 + 7, limit)\nend\n\nn = gets.to_i\n\nputs lucky_numbers([], 4, n).concat(lucky_numbers([], 7, n)).sort.find_index(n) + 1\n"}, {"source_code": "#!/usr/bin/env ruby\na=[]\n1.step(9){|i|\n\t[4,7].repeated_permutation(i){|e|a<y }\nmin=100000000000\n\nfor i in 0..(m-n)\n j=i+n-1\n l=(sa[j]-sa[i])\n if(min>l)\n min=l\n end\nend\nputs min"}, {"source_code": "#!ruby\n\nn, m = gets.split.map{|e| e.to_i}\n\np = gets.split.map{|e| e.to_i}\n\nans = 9999\n\np.sort!\n\n(m-n+1).times do |i|\n ans = [ans, p[i+n-1]-p[i]].min\nend\n\nputs ans\n"}, {"source_code": "n, m = gets.split(' ').map(&:to_i)\nar = gets.split(' ').map(&:to_i).sort\nn -= 1\nputs (n...m).map{|x| ar[x]-ar[x-n]}.min"}, {"source_code": "n_m = gets.split.map &:to_i\nn = n_m[0]\nm = n_m[1]\n\npuzzles = gets.split.map(&:to_i).sort\n\nmin_difficulty = Float::INFINITY\n\n(m - n + 1).times do |i|\n difficulty = puzzles[i+n-1] - puzzles[i]\n min_difficulty = difficulty if difficulty < min_difficulty\nend\n\nputs min_difficulty\n"}, {"source_code": "#!/usr/bin/ruby\nn=gets.to_i\np gets.split.map(&:to_i).sort.each_cons(n).map{|e|e.last-e.first}.min"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min"}, {"source_code": "tmp = gets.chomp.split(\" \")\nn = tmp[0].to_i\nm = tmp[1].to_i\na = gets.chomp.split(\" \").map {|x| x.to_i}\na = a.sort\nmin = a[n-1] - a[0]\nfor i in 1..m-n\n min = a[i+n-1]-a[i] if a[i+n-1]-a[i] < min\nend\nputs min\n"}, {"source_code": "m,n = gets.split(\" \").map(&:to_i)\narr = gets.split(\" \").map(&:to_i)\nmin_diff = arr.max\narr.sort!\nfor i in (m-1..n-1)\n diff = arr[i] - arr[i- m +1]\n min_diff = diff if diff < min_diff\nend\nputs min_diff"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min\n"}, {"source_code": "g=->{gets.split.map(&:to_i)}\nn,m=g[]\na=g[].sort\np (m-n+1).times.map{|i|a[i+n-1]-a[i]}.min"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min"}, {"source_code": "n, m=gets.split(\" \").map {|i| i.to_i}\narr = gets.split(\" \").map{|i| i.to_i}.sort!\nanswer=(m-n+1).times.map{|i| arr[i+n-1]-arr[i]}.min\n\np answer"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min\n"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min"}, {"source_code": "a, b = gets.split.map &:to_i\np = gets.split.map(&:to_i).sort!\n\nmin = p[-1] - p[0]\n\nfor i in (a-1..b-1)\n min = [min, p[i] - p[i - a + 1]].min\nend\n\nputs min\n"}, {"source_code": "inp = STDIN.gets <<-EOF\nEOF\n\ninp = inp.split(\"\\n\")\n\nstu_num = inp[0].split(\" \")[0].to_i\npuz_num = inp[0].split(\" \")[1].to_i\npuz_difs = inp[1].split(\" \").map(&:to_i).sort\n\nmin_dif_div = if stu_num < puz_num\n puz_difs.first(puz_difs.length - stu_num + 1).inject([]) do |divs,i|\n divs << (puz_difs[puz_difs.index(i) + stu_num - 1] - i)\n end.sort.first\n else\n puz_difs.max - puz_difs.min\n end\n\nputs min_dif_div\n"}, {"source_code": "g=->{gets.split.map(&:to_i)}\nn,m=g[]\na=g[].sort\np (m-n+1).times.map{|i|a[i+n-1]-a[i]}.min\n\n"}, {"source_code": "n,m=gets.chomp.split.map(&:to_i)\na=gets.chomp.split.map(&:to_i).sort\nmin=a.last\ni=0\nwhile i+n-1a[i+n-1]-a[i])\n min = a[i+n-1]-a[i]\n end\nend\nprint(min)"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min"}, {"source_code": "n,m=gets.split.map(&:to_i)\na=gets.split.map(&:to_i).sort\nr=1001\n(m-n+1).times {|i|r=[r,a[i+n-1]-a[i]].min}\np r\n"}, {"source_code": "g=->{gets.split.map(&:to_i)}\nn,m=g[]\na=g[].sort\np (m-n+1).times.map{|i|a[i+n-1]-a[i]}.min\n\n"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min\n"}, {"source_code": "n, m = gets.split(' ').map(&:to_i)\na = gets.split(' ').map(&:to_i).sort\n\nmin = 2000\nwhile a.size >= n\n min = [min, a[n-1]-a.first].min\n a.shift\nend\n\nputs min\n"}, {"source_code": "\nMAX_INT = 1<<31\n\nn, m = $stdin.readline.split.map(&:to_i)\nf = $stdin.readline.split.map(&:to_i)\n\nclass Array\n def diameter\n m = 0\n for i in 0...self.count\n for j in i+1...self.count\n t = (self[i]-self[j]).abs\n if t>m\n m = t\n end\n end\n end\n m\n end\n\n def complect_and_count\n self.dup.complect_and_count!\n end\n\n def complect_and_count!\n a = self.shift\n h = {a => 1}\n k = 1\n while self.size>0\n b = self.shift\n if a != b\n h[a] = k\n h[b] = 1\n k = 0\n end\n a = b\n k += 1\n end\n h[b]=k\n h\n end\nend\n\nf.sort!\n#p f\nf_uniq = f.uniq\n#p f_uniq\nff = f.complect_and_count\n#p ff\n\n# t_s = ff.collect do |key,value|\n# [key]*value\n# end\n\n# t = t_s.dup\n\n# идея алгоритма: вокруг каждого элемента начинаю образовывать круг минимального радиуса\n# когда будет построен круг содержащий более n элементов - начинаю смотреть какой из кругов лучший\n\n# for each f_uniq we build an area\nareas = []\nfor i in 0...f_uniq.count\n elem = f_uniq[i]\n areas[i] = {elements: [elem]*ff[elem], diameter: 0} \nend\n\ndef area_found?(areas,n)\n a_with_max_count = areas.max_by {|e| e.count}\n a_with_max_count[:elements].count >= n\nend\n\nl = 1\nuntil area_found?(areas,n)\n # add one elem to each area\n areas.each do |a|\n elements = a[:elements]\n\n next if elements.count >= l\n\n a_min = elements.min\n a_max = elements.max\n t_min, _ = f_uniq.partition {|el| ela_max}\n t_min = t_min.last\n t_max = t_max.first\n d1 = t_min.nil? ? MAX_INT : a_min - t_min\n d2 = t_max.nil? ? MAX_INT : t_max - a_max\n\n if d2 <= d1\n a[:elements] = elements + [t_max]*ff[t_max]\n a[:diameter] += d2\n elsif d1 < d2\n a[:elements] = ([t_min]*ff[t_min]) + elements\n a[:diameter] += d1\n end\n end\n l+=1\nend\n\nmin = areas.min_by {|el| el[:elements].count >= n ? el[:diameter] : MAX_INT }\nputs min[:diameter]\n"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min"}, {"source_code": "input = ARGV ? $< : File(ARGV[0])\n\nn, m = input.gets.split(' ').map &:to_i\narr = input.gets.split(' ').map &:to_i\n\narr.sort!()\n\ndiff = arr[n-1] - arr[0]\nstop = m - n\nfor i in (1..stop)\n\tlocal = arr[n-1+i] - arr[i]\n\tdiff = [diff, local].min\nend\n\nputs diff\n"}, {"source_code": "m, n = gets.chomp.split.map { |x| x.to_i }\na = gets.chomp.split.map { |x| x.to_i }.sort\nmin = 1000\nfor i in 0..n - m\n diff = a[i + m - 1] - a[i]\n min = diff if diff < min\nend\nputs min"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min\n"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min"}, {"source_code": "n, m = gets.chomp.split(' ').map!(&:to_i)\n\nary = gets.chomp.split(' ').map!(&:to_i).sort!.reverse!\n\nmin = ary.first - ary.last\n\nfor i in 0..(ary.size - n) do\n if ary[i] - ary[i + n - 1] < min\n min = ary[i] - ary[i + n - 1]\n end\nend\n\np min"}, {"source_code": "n, m = gets.split(' ').map(&:to_i)\na = gets.split(' ').map(&:to_i).sort\nret = 1000\nfor i in 0...a.size-n+1\n ret = [a[i+n-1] - a[i], ret].min\nend\nputs ret"}, {"source_code": "def run\n n, m = $stdin.gets.split.map(&:to_i)\n f = $stdin.gets.split.map(&:to_i)\n f.sort!\n\n min = 1 << 31\n for i in 0..(m - n)\n d = f[i,n].max - f[i,n].min\n min = [d, min].min\n end\n\n puts min\nend\n\nrun if $0 == __FILE__\n"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min\n"}, {"source_code": "n, m = gets.split.map &:to_i\narr = gets.split.map &:to_i\narr = arr.sort\nmin = arr.max\n(m - n + 1).times do |fig|\n min = arr[fig + n - 1] - arr[fig] if min > arr[fig + n - 1] - arr[fig]\nend\nputs min\n"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min\n"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min\n"}, {"source_code": "students, puzzles = gets.chomp.split(/ /).map(&:to_i)\npieces = gets.chomp.split(/ /).map(&:to_i)\npieces.sort!\nmin = -1\npos = -1\npuzzles.times do |i|\n break if i + (students - 1) >= puzzles\n first = pieces[i]\n last = pieces[i + (students - 1)]\n diff = last - first\n min = diff if min == -1\n next if diff > min\n min = [min, diff].min\n pos = i\nend\nputs pieces[pos + (students - 1)] - pieces[pos]"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min\n"}, {"source_code": "a,b=gets.split.map{|e| e.to_i}\nx=gets.split.map{|e| e.to_i}.sort\nans=x[a-1]-x[0]\n0.upto(x.size-a){|i|\n\tans=[ans,x[i+a-1]-x[i]].min\n}\nputs ans"}, {"source_code": "n, m = gets.split.map(&:to_i)\nf = gets.split.map(&:to_i).sort\nmin_diff = 1001\n\n(0..m-n).each do |i|\n\tif f[i+n-1]-f[i] < min_diff\n\t\tmin_diff = f[i+n-1] - f[i]\n\tend\nend\nputs min_diff"}, {"source_code": "n, m = gets.chomp.split(' ').map(&:to_i)\nf = gets.chomp.split(' ').map(&:to_i).sort\n\nmins = []\n(0..m-n).each do |i|\n\tmins << f[i+n-1] - f[i]\nend\n\nputs mins.min"}, {"source_code": "n, m = gets.strip.split(' ').map &:to_i\narray = gets.strip.split(' ').map(&:to_i).sort\n\nmin = array.last\n0.upto(m - n) do |index|\n min = [array[index + n - 1] - array[index], min].min\nend\n\nputs min\n"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min"}, {"source_code": "nm = gets.chomp\nnm = nm.split\nstudents = nm[0].to_i\npuzzles = nm[1].to_i\nquantities = gets.chomp\nquantities = quantities.split\n\nfor i in (0..puzzles-1)\n\tfor x in (i..puzzles-1)\n\t\tif i != x\n\t\t\tif quantities[i].to_i > quantities[x].to_i\n\t\t\t\ttemp = quantities[i].to_i\n\t\t\t\tquantities[i] = quantities[x].to_i\n\t\t\t\tquantities[x] = temp\n\t\t\tend\n\t\tend\n\tend\nend\n\nminimum = 0\nfor i in (0..puzzles-1)\n\tif quantities[i+students-1].to_i - quantities[i].to_i < minimum && i > 0 && i+students-1 <= puzzles - 1\n\t\tminimum = quantities[i+students-1].to_i - quantities[i].to_i\n\telsif i == 0 && i+students-1 <= puzzles - 1\n\t\tminimum = quantities[i+students-1].to_i - quantities[i].to_i\n\tend\nend\n\nprint minimum"}, {"source_code": "#!/usr/bin/env ruby\n\n# Solves http://codeforces.com/problemset/problem/337/A\n\nn, m = $stdin.gets.split.map { |s| s.to_i }\nnums = $stdin.gets.split.map { |s| s.to_i }\nnums.sort!\ndiffs = (0..(m-n)).map { |i| nums[n + i - 1] - nums[i] }\nputs diffs.sort![0]\n"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min\n"}, {"source_code": "g=->{gets.split.map &:to_i};n,m=g[];a=g[].sort;p a[n-1...m].zip(a).map{|i,j|i-j}.min\n"}, {"source_code": "n, m = gets.split.map{|x| x.to_i}\na = gets.split.map{|x| x.to_i}.sort\np (m - n + 1).times.map{|i| a[i + n - 1] - a[i]}.min\n"}, {"source_code": "def main\n n = gets.chomp.to_i\n fi = gets.chomp.split(\" \").map{ |e| e.to_i }.sort\n\n r = 0\n r_s = fi[n-1]-fi[0]\n i = 1\n k = fi.size - n + 1\n while iy }\nputs (sa[n-1]-sa[0])"}, {"source_code": "n_m = gets.split.map &:to_i\nn = n_m[0]\nm = n_m[1]\n\npuzzles = gets.split.map(&:to_i).sort\n\nmin_difficulty = Float::INFINITY\n\n(m - n).times do |i|\n difficulty = puzzles[i+n-1] - puzzles[i]\n min_difficulty = difficulty if difficulty < min_difficulty\nend\n\nputs min_difficulty\n"}, {"source_code": "#!/usr/bin/ruby\nn=gets.to_i\np gets.split.map(&:to_i).sort.each_cons(n).min{|e|e.last-e.first}"}, {"source_code": "tmp = gets.chomp.split(\" \")\na = gets.chomp.split(\" \").map {|x| x.to_i}\na = a.sort\nputs a[tmp[0].to_i-1]-a[0]\n#puts array[0] + \", \" + array[n]\n"}, {"source_code": "inp = STDIN.gets <<-EOF\nEOF\n\ninp = inp.split(\"\\n\")\n\nstu_num = inp[0].split(\" \")[0].to_i\npuz_num = inp[0].split(\" \")[1].to_i\n\npuz_difs = inp[1].split(\" \").map(&:to_i).sort\nmin_dif_div = puz_difs.first(puz_difs.length - stu_num).inject([]){|divs,i| divs << (puz_difs[puz_difs.index(i) + stu_num - 1] - i)}.first\nputs min_dif_div\n"}, {"source_code": "inp = STDIN.gets <<-EOF\nEOF\n\ninp = inp.split(\"\\n\")\n\nstu_num = inp[0].split(\" \")[0].to_i\npuz_num = inp[0].split(\" \")[1].to_i\npuz_difs = inp[1].split(\" \").map(&:to_i).sort\n\nmin_dif_div = if stu_num < puz_num\n puz_difs.first(puz_difs.length - stu_num).inject([]){|divs,i| divs << (puz_difs[puz_difs.index(i) + stu_num - 1] - i)}.first\n else\n puz_difs.max - puz_difs.min\n end\n\nputs min_dif_div\n"}, {"source_code": "\nMAX_INT = 1<<31\n\nn, m = $stdin.readline.split.map(&:to_i)\nf = $stdin.readline.split.map(&:to_i)\n\nclass Array\n def diameter\n m = 0\n for i in 0...self.count\n for j in i+1...self.count\n t = (self[i]-self[j]).abs\n if t>m\n m = t\n end\n end\n end\n m\n end\n\n def complect_and_count\n self.dup.complect_and_count!\n end\n\n def complect_and_count!\n a = self.shift\n h = {a => 1}\n k = 1\n while self.size>0\n b = self.shift\n if a != b\n h[a] = k\n h[b] = 1\n k = 0\n end\n a = b\n k += 1\n end\n h[b]=k\n h\n end\nend\n\nf.sort!\n#p f\nf_uniq = f.uniq\n#p f_uniq\nff = f.complect_and_count\n#p ff\n\n# t_s = ff.collect do |key,value|\n# [key]*value\n# end\n\n# t = t_s.dup\n\n# идея алгоритма: вокруг каждого элемента начинаю образовывать круг минимального радиуса\n# когда будет построен круг содержащий более n элементов - начинаю смотреть какой из кругов лучший\n\n# for each f_uniq we build an area\nareas = []\nfor i in 0...f_uniq.count\n elem = f_uniq[i]\n areas[i] = {elements: [elem]*ff[elem], diameter: 0} \nend\n\ndef area_found?(areas,n)\n a_with_max_count = areas.max_by {|e| e.count}\n a_with_max_count[:elements].count >= n\nend\n\nl = 1\nuntil area_found?(areas,n)\n # add one elem to each area\n areas.each do |a|\n elements = a[:elements]\n\n next if elements.count >= l\n\n a_min = elements.min\n a_max = elements.max\n t_min, _ = f_uniq.partition {|el| ela_max}\n t_min = t_min.last\n t_max = t_max.first\n d1 = t_min.nil? ? MAX_INT : a_min - t_min\n d2 = t_max.nil? ? MAX_INT : t_max - a_max\n\n if d2 <= d1\n a[:elements] = elements + [t_max]*ff[t_max]\n a[:diameter] += d2\n elsif d1 < d2\n a[:elements] = ([t_min]*ff[t_min]) + elements\n a[:diameter] += d1\n end\n end\n l+=1\nend\n\nmin = areas.min_by {|el| el[:diameter]}\nputs min[:diameter]\n"}, {"source_code": " MAX_INT = 1<<31\n\n n, m = $stdin.readline.split.map(&:to_i)\n f = $stdin.readline.split.map(&:to_i)\n\n class Array\n def diameter\n m = 0\n for i in 0...self.count\n for j in i+1...self.count\n t = (self[i]-self[j]).abs\n if t>m\n m = t\n end\n end\n end\n m\n end\n\n def complect_and_count\n self.dup.complect_and_count!\n end\n\n def complect_and_count!\n a = self.shift\n h = {a => 1}\n k = 1\n while self.size>0\n b = self.shift\n if a != b\n h[a] = k\n h[b] = 1\n k = 0\n end\n a = b\n k += 1\n end\n h[b]=k\n h\n end\n end\n\n f.sort!\n #p f\n f_uniq = f.uniq.sort\n #p f_uniq\n ff = f.complect_and_count\n #p ff\n\n t_s = ff.collect do |key,value|\n [key]*value\n end\n\n t = t_s.dup\n\n diameters = Array.new(t_s.count, 0)\n\n loop do\n\n min_d = MAX_INT\n min_d_count = 0\n min_i = nil\n \n for i in 0...t.count\n elem = t[i]\n elem_d = elem.diameter\n if elem_d <= min_d && (elem.count>=n || elem.count>=min_d_count)\n min_d = elem_d\n min_d_count = elem.count\n min_i = i\n end\n end\n\n #p t[min_i]\n #puts \"total count = #{t.count}, d = #{min_d}, count = #{min_d_count}\"\n\n if t[min_i].count >= n\n p t[min_i].diameter\n break\n else\n tt = []\n for i in 0...t.count\n t_elem = t[i]\n ttt = f_uniq - t_elem\n t_elem_min = t_elem.min\n t_elem_max = t_elem.max\n\n tmp1,_ = ttt.partition {|el| elt_elem_max}\n tmp2_min = tmp2.min\n count2 =tmp2_min.nil? ? 0 : ff[tmp2_min]\n d2 = tmp2_min.nil? ? MAX_INT : t_elem_max - tmp2_min\n\n to_add = nil\n if d2 < d1\n tt << t_elem + ([tmp2_min]*count2)\n elsif d1 < d2\n tt << ([tmp1_max]*count1) + t_elem\n elsif d1==d2 && d1!=MAX_INT\n tt << ([tmp1_max]*count1) + t_elem\n tt << t_elem + ([tmp2_min]*count2)\n end\n \n # if count1+count2>0\n # tmp3 = ([tmp1_max]*count1) + t_elem + ([tmp2_min]*count2)\n # tt << tmp3.compact\n # end\n end\n\n t = tt\n end\n\n end\n"}, {"source_code": " MAX_INT = 1<<31\n\n n, m = $stdin.readline.split.map(&:to_i)\n f = $stdin.readline.split.map(&:to_i)\n\n class Array\n def diameter\n m = 0\n for i in 0...self.count\n for j in i+1...self.count\n t = (self[i]-self[j]).abs\n if t>m\n m = t\n end\n end\n end\n m\n end\n\n def complect_and_count\n self.dup.complect_and_count!\n end\n\n def complect_and_count!\n a = self.shift\n h = {a => 1}\n k = 1\n while self.size>0\n b = self.shift\n if a != b\n h[a] = k\n h[b] = 1\n k = 0\n end\n a = b\n k += 1\n end\n h[b]=k\n h\n end\n end\n\n f.sort!\n #p f\n f_uniq = f.uniq.sort\n #p f_uniq\n ff = f.complect_and_count\n #p ff\n\n t_s = ff.collect do |key,value|\n [key]*value\n end\n\n t = t_s.dup\n\n diameters = Array.new(t_s.count, 0)\n\n loop do\n\n min_d = MAX_INT\n min_d_count = 0\n min_i = nil\n \n for i in 0...t.count\n elem = t[i]\n elem_d = elem.diameter\n if elem_d <= min_d && (elem.count>=n || elem.count>=min_d_count)\n min_d = elem_d\n min_d_count = elem.count\n min_i = i\n end\n end\n\n #p t[min_i]\n #puts \"total count = #{t.count}, d = #{min_d}, count = #{min_d_count}\"\n\n if t[min_i].count >= n\n p t[min_i].diameter\n break\n else\n tt = []\n for i in 0...t.count\n t_elem = t[i]\n ttt = f_uniq - t_elem\n t_elem_min = t_elem.min\n t_elem_max = t_elem.max\n\n tmp1,_ = ttt.partition {|el| elt_elem_max}\n tmp2_min = tmp2.min\n count2 = 0\n unless tmp2_min.nil?\n count2 = ff[tmp2_min]\n end\n\n # if count1>0\n # tmp3 = ([tmp1_max]*count1) + t_elem\n # tt << tmp3.compact\n # end\n\n # if count2>0\n # tmp3 = t_elem + ([tmp2_min]*count2)\n # tt << tmp3.compact\n # end\n\n if count1+count2>0\n tmp3 = ([tmp1_max]*count1) + t_elem + ([tmp2_min]*count2)\n tt << tmp3.compact\n end\n end\n\n t = tt\n end\n\n end"}, {"source_code": "\nMAX_INT = 1<<31\n\nn, m = $stdin.readline.split.map(&:to_i)\nf = $stdin.readline.split.map(&:to_i)\n\nclass Array\n\tdef diameter\n\t\tm = 0\n\t\tfor i in 0...self.count\n\t\t\tfor j in i+1...self.count\n\t\t\t\tt = (self[i]-self[j]).abs\n\t\t\t\tif t>m\n\t\t\t\t\tm = t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tm\n\tend\n\n\tdef complect_and_count\n\t\tself.dup.complect_and_count!\n\tend\n\n\tdef complect_and_count!\n\t\ta = self.shift\n\t\th = {a => 1}\n\t\tk = 1\n\t\twhile self.size>0\n\t\t\tb = self.shift\n\t\t\tif a != b\n\t\t\t\th[a] = k\n\t\t\t\th[b] = 1\n\t\t\t\tk = 0\n\t\t\tend\n\t\t\ta = b\n\t\t\tk += 1\n\t\tend\n\t\th[b]=k\n\t\th\n\tend\nend\n\nf.sort!\n#p f\nf_uniq = f.uniq\n#p f_uniq\nff = f.complect_and_count\n#p ff\n\n# t_s = ff.collect do |key,value|\n# \t[key]*value\n# end\n\n# t = t_s.dup\n\n# идея алгоритма: вокруг каждого элемента начинаю образовывать круг минимального радиуса\n# когда будет построен круг содержащий более n элементов - начинаю смотреть какой из кругов лучший\n\n# for each f_uniq we build an area\nareas = []\nfor i in 0...f_uniq.count\n\telem = f_uniq[i]\n\tareas[i] = {elements: [elem]*ff[elem], diameter: 0} \nend\n\ndef area_found?(areas,n)\n\ta_with_max_count = areas.max_by {|e| e.count}\n\ta_with_max_count[:elements].count >= n\nend\n\nuntil area_found?(areas,n)\n\t# add one elem to each area\n\tareas.each do |a|\n\t\telements = a[:elements]\n\t\ta_min = elements.min\n\t\ta_max = elements.max\n\t\tt_min, _ = f_uniq.partition {|el| ela_max}\n\t\tt_min = t_min.last\n\t\tt_max = t_max.first\n\t\td1 = t_min.nil? ? MAX_INT : a_min - t_min\n\t\td2 = t_max.nil? ? MAX_INT : t_max - a_max\n\n\t\tif d2 <= d1\n\t\t\ta[:elements].push(t_max)\n\t\t\ta[:diameter] += d2\n\t\telsif d1 < d2\n\t\t\ta[:elements].unshift(t_min)\t\t\t\t\n\t\t\ta[:diameter] += d1\n\t\tend\n\tend\n\nend\n\nmin = areas.min_by {|el| el[:diameter]}\nputs min[:diameter]\n"}, {"source_code": " MAX_INT = 1<<31\n\n n, m = $stdin.readline.split.map(&:to_i)\n f = $stdin.readline.split.map(&:to_i)\n\n class Array\n def diameter\n m = 0\n for i in 0...self.count\n for j in i+1...self.count\n t = (self[i]-self[j]).abs\n if t>m\n m = t\n end\n end\n end\n m\n end\n\n def complect_and_count\n self.dup.complect_and_count!\n end\n\n def complect_and_count!\n a = self.shift\n h = {a => 1}\n k = 1\n while self.size>0\n b = self.shift\n if a != b\n h[a] = k\n h[b] = 1\n k = 0\n end\n a = b\n k += 1\n end\n h[b]=k\n h\n end\n end\n\n f.sort!\n p f\n f_uniq = f.uniq.sort\n p f_uniq\n ff = f.complect_and_count\n p ff\n\n t_s = ff.collect do |key,value|\n [key]*value\n end\n\n t = t_s.dup\n\n diameters = Array.new(t_s.count, 0)\n\n loop do\n\n min_d = MAX_INT\n min_d_count = 0\n min_i = nil\n \n for i in 0...t.count\n elem = t[i]\n elem_d = elem.diameter\n if elem_d <= min_d && (elem.count>=n || elem.count>=min_d_count)\n min_d = elem_d\n min_d_count = elem.count\n min_i = i\n end\n end\n\n #p t[min_i]\n #puts \"total count = #{t.count}, d = #{min_d}, count = #{min_d_count}\"\n\n if t[min_i].count >= n\n puts t[min_i].diameter\n break\n else\n tt = []\n for i in 0...t.count\n t_elem = t[i]\n ttt = f_uniq - t_elem\n t_elem_min = t_elem.min\n t_elem_max = t_elem.max\n\n tmp1,_ = ttt.partition {|el| elt_elem_max}\n tmp2_min = tmp2.min\n count2 = 0\n unless tmp2_min.nil?\n count2 = ff[tmp2_min]\n end\n\n # if count1>0\n # tmp3 = ([tmp1_max]*count1) + t_elem\n # tt << tmp3.compact\n # end\n\n # if count2>0\n # tmp3 = t_elem + ([tmp2_min]*count2)\n # tt << tmp3.compact\n # end\n\n if count1+count2>0\n tmp3 = ([tmp1_max]*count1) + t_elem + ([tmp2_min]*count2)\n tt << tmp3.compact\n end\n end\n\n t = tt\n end\n\n end"}, {"source_code": "\nMAX_INT = 1<<31\n\nn, m = $stdin.readline.split.map(&:to_i)\nf = $stdin.readline.split.map(&:to_i)\n\nclass Array\n def diameter\n m = 0\n for i in 0...self.count\n for j in i+1...self.count\n t = (self[i]-self[j]).abs\n if t>m\n m = t\n end\n end\n end\n m\n end\n\n def complect_and_count\n self.dup.complect_and_count!\n end\n\n def complect_and_count!\n a = self.shift\n h = {a => 1}\n k = 1\n while self.size>0\n b = self.shift\n if a != b\n h[a] = k\n h[b] = 1\n k = 0\n end\n a = b\n k += 1\n end\n h[b]=k\n h\n end\nend\n\nf.sort!\n#p f\nf_uniq = f.uniq\n#p f_uniq\nff = f.complect_and_count\n#p ff\n\n# t_s = ff.collect do |key,value|\n# [key]*value\n# end\n\n# t = t_s.dup\n\n# идея алгоритма: вокруг каждого элемента начинаю образовывать круг минимального радиуса\n# когда будет построен круг содержащий более n элементов - начинаю смотреть какой из кругов лучший\n\n# for each f_uniq we build an area\nareas = []\nfor i in 0...f_uniq.count\n elem = f_uniq[i]\n areas[i] = {elements: [elem]*ff[elem], diameter: 0} \nend\n\ndef area_found?(areas,n)\n a_with_max_count = areas.max_by {|e| e.count}\n a_with_max_count[:elements].count >= n\nend\n\nuntil area_found?(areas,n)\n # add one elem to each area\n areas.each do |a|\n elements = a[:elements]\n a_min = elements.min\n a_max = elements.max\n t_min, _ = f_uniq.partition {|el| ela_max}\n t_min = t_min.last\n t_max = t_max.first\n d1 = t_min.nil? ? MAX_INT : a_min - t_min\n d2 = t_max.nil? ? MAX_INT : t_max - a_max\n\n if d2 <= d1\n a[:elements] = elements + [t_max]*ff[t_max]\n a[:diameter] += d2\n elsif d1 < d2\n a[:elements] = ([t_min]*ff[t_min]) + elements\n a[:diameter] += d1\n end\n end\n\nend\n\nmin = areas.min_by {|el| el[:diameter]}\nputs min[:diameter]\n"}, {"source_code": "MAX_INT = 1<<31\n\nn, m = $stdin.readline.split.map(&:to_i)\nf = $stdin.readline.split.map(&:to_i)\n\nclass Array\n\tdef diameter\n\t\tm = 0\n\t\tfor i in 0...self.count\n\t\t\tfor j in i+1...self.count\n\t\t\t\tt = (self[i]-self[j]).abs\n\t\t\t\tif t>m\n\t\t\t\t\tm = t\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tm\n\tend\nend\n\ndef solve(n,f)\n\tif n == 1\n\t\tf\n\telse\n\t\tmd = MAX_INT\n\t\tmf = []\n\t\tfor i in 0...f.count\n\t\t\ttf = f[0...i] + f[(i+1)..-1] # f \\ f[i]\n\t\t\ttd = tf.diameter\n\t\t\tif td < md\n\t\t\t\tff = solve(n-1, tf)\n\t\t\t\tmd = td\n\t\t\t\tmf = ff + [f[i]]\n\t\t\tend\n\t\tend\n\t\tmf\n\tend\nend\n\nt = solve(n,f)[0...n]\n#p t\nputs t.diameter"}, {"source_code": "n, m = $stdin.readline.split.map(&:to_i)\nf = $stdin.readline.split.map(&:to_i)\n\nf.sort!\nt = f[0...n]\nputs t.max - t.min"}, {"source_code": " MAX_INT = 1<<31\n\n n, m = $stdin.readline.split.map(&:to_i)\n f = $stdin.readline.split.map(&:to_i)\n\n class Array\n def diameter\n m = 0\n for i in 0...self.count\n for j in i+1...self.count\n t = (self[i]-self[j]).abs\n if t>m\n m = t\n end\n end\n end\n m\n end\n\n def complect_and_count\n self.dup.complect_and_count!\n end\n\n def complect_and_count!\n a = self.shift\n h = {a => 1}\n k = 1\n while self.size>0\n b = self.shift\n if a != b\n h[a] = k\n h[b] = 1\n k = 0\n end\n a = b\n k += 1\n end\n h[b]=k\n h\n end\n end\n\n f.sort!\n p f\n f_uniq = f.uniq.sort\n p f_uniq\n ff = f.complect_and_count\n p ff\n\n t_s = ff.collect do |key,value|\n [key]*value\n end\n\n t = t_s.dup\n\n diameters = Array.new(t_s.count, 0)\n\n loop do\n\n min_d = MAX_INT\n min_d_count = 0\n min_i = nil\n \n for i in 0...t.count\n elem = t[i]\n elem_d = elem.diameter\n if elem_d <= min_d && (elem.count>=n || elem.count>=min_d_count)\n min_d = elem_d\n min_d_count = elem.count\n min_i = i\n end\n end\n\n p t[min_i]\n puts \"total count = #{t.count}, d = #{min_d}, count = #{min_d_count}\"\n\n if t[min_i].count >= n\n p t[min_i].diameter\n break\n else\n tt = []\n for i in 0...t.count\n t_elem = t[i]\n ttt = f_uniq - t_elem\n t_elem_min = t_elem.min\n t_elem_max = t_elem.max\n\n tmp1,_ = ttt.partition {|el| elt_elem_max}\n tmp2_min = tmp2.min\n count2 = 0\n unless tmp2_min.nil?\n count2 = ff[tmp2_min]\n end\n\n # if count1>0\n # tmp3 = ([tmp1_max]*count1) + t_elem\n # tt << tmp3.compact\n # end\n\n # if count2>0\n # tmp3 = t_elem + ([tmp2_min]*count2)\n # tt << tmp3.compact\n # end\n\n if count1+count2>0\n tmp3 = ([tmp1_max]*count1) + t_elem + ([tmp2_min]*count2)\n tt << tmp3.compact\n end\n end\n\n t = tt\n end\n\n end\n"}, {"source_code": "n, m = gets.split.map &:to_i\narr = gets.split.map &:to_i\nif arr.size - arr.uniq.size == n - 1 \n puts \"0\"\nelse\n arr = arr.sort\n puts arr[n - 1] - arr.first\nend\n"}, {"source_code": "n, m = gets.split.map &:to_i\narr = gets.split.map &:to_i\narr = arr.sort\nputs arr[n - 1] - arr[0]\n"}, {"source_code": "n, m = gets.split.map &:to_i\narr = gets.split.map &:to_i\narr = arr.sort\nif arr.uniq.size == arr.size\n puts arr[n - 1] - arr[0]\nelse\n puts 0\nend\n\n"}, {"source_code": "students = gets.chomp.split(/ /).map(&:to_i)[0]\npieces = gets.chomp.split(/ /).map(&:to_i)\npieces.sort!\nputs pieces[students - 1] - pieces[0]"}, {"source_code": "#!/usr/bin/env ruby\n\n# Solves http://codeforces.com/problemset/problem/337/A\n\nn, m = $stdin.gets.split.map { |s| s.to_i }\nnums = $stdin.gets.split.map { |s| s.to_i }\nnums.sort!\ndiffs = (0..(m-n)).map { |i| nums[n + i - 1] - nums[0] }\nputs diffs.sort![0]\n"}, {"source_code": "n,m = gets.split(\" \").map(&:to_i)\na = gets.split(\" \").map(&:to_i).sort\nmin = 99999\nfor i in 0..(m-n-1)\n if(min>a[i+n-1]-a[i])\n min = a[i+n-1]-a[i]\n end\nend\nprint(min)"}, {"source_code": "n, m = gets.split(' ').map(&:to_i)\na = gets.split(' ').map(&:to_i).sort\n\nmin = 2000\nwhile a.size >= m\n min = [min, a[n-1]-a.first].min\n a.shift\nend\n\nputs min\n"}], "src_uid": "7830aabb0663e645d54004063746e47f"} {"source_code": "# your code goes here\n\n$store = {}\n\ndef trim_trailing_zeroes(y)\n\ty_string = y.to_s\n\ti = y_string.length - 1\n\tindex_non_zero = 0\n\twhile i >= 1 do\n\t\tif y_string[i] != \"0\"\n\t\t\tindex_non_zero = i\n\t\t\tbreak\n\t\tend\n\t\ti -= 1\n\tend\n\t\n\treturn y_string[0..index_non_zero]\nend\n\ndef cal(x)\n\tif !$store[x].nil?\n\t\treturn\n\tend\n\t$store[x] = 1\n\texecute_for = trim_trailing_zeroes(x + 1)\n\tcal(execute_for.to_i)\nend\n\n\nvalue = gets.to_i\ncal(value)\n\np $store.keys.size", "positive_code": [{"source_code": "n = gets.to_i\na = Hash.new(false)\nwhile !a[n]\n a[n] = true\n n += 1\n n /= 10 while n%10 == 0\nend\nputs a.size"}, {"source_code": "require \"set\"\n\ndef f(n)\n\ts = (n+1).to_s\n\ts[...(s =~ /0+$/)].to_i\nend\n\nn = gets.to_i\ns = Set.new\nwhile !s.include?(n)\n\ts.add(n)\n\tn = f(n)\nend\np s.size\n"}, {"source_code": "N = gets.to_i\nn = N\nchecked = {}\n\nwhile n > 9\n checked[n] = true\n n += 1\n n = n.to_s.reverse.to_i.to_s.reverse.to_i\nend\n\nputs checked.keys.count + 9\n"}, {"source_code": "require 'set'\n\nn = gets.strip.to_i\nseen = Set.new\n\nwhile !seen.include?(n)\n seen.add(n)\n begin\n n += 1\n seen.add(n) if !seen.include?(n) && n % 10 != 0\n end while n % 10 != 0\n while n % 10 == 0\n n /= 10\n end\nend\n\nputs seen.size\n"}], "negative_code": [{"source_code": "n = gets.to_i\na = Hash.new(false)\na[n] = true\nwhile !a[1]\n n += 1\n n /= 10 while n%10 == 0\n a[n] = true\nend\nputs a.size"}, {"source_code": "n = gets.to_i\nans = 1\nwhile n > 1\n n += 1\n n /= 10 while n%10 == 0\n ans += 1\nend\nputs ans"}, {"source_code": "n = gets.to_i\na = Hash.new(false)\na[n] = true\nwhile n > 1\n n += 1\n n /= 10 while n%10 == 0\n a[n] = true\nend\nputs a.size"}], "src_uid": "055fbbde4b9ffd4473e6e716da6da899"} {"source_code": "x = gets.chomp.to_i\nsum = (0)\nfor i in 1 .. x\n sum = sum + 2**i\nend\n\nprint sum", "positive_code": [{"source_code": "p 2**-~gets.to_i-2"}, {"source_code": "a=gets.chomp.to_i\nb=2**(a+1)-2\nputs\"#{b}\""}, {"source_code": "p 2**gets.to_i-1<<1"}, {"source_code": "p 2**gets.to_i*2-2"}, {"source_code": "n = gets.chomp.to_i;\nans = 0;\nn.times{|i| ans += 2**(i+1)}\np ans\n"}, {"source_code": "n = gets.chomp.to_i\n\nans = 0\n\n(1..n).each do |i|\nans = ans + (2**i)\nend\n\nputs ans\n"}, {"source_code": "n = gets.to_i\n\nk = 2\ns = 0\nn.times do\n s += k\n k *= 2\nend\n\nputs s"}, {"source_code": "#!/usr/bin/ruby\n\n# Get one number at a time\nN = STDIN.gets.to_i\n\nres = 0\n\n(1..N).each do |x|\n\tres += 2 ** x\nend\n\nputs res"}, {"source_code": "a=gets.chomp.to_i\nb=2**(a+1)-2\nputs\"#{b}\""}, {"source_code": "n = gets.strip.to_i\nputs (1..n).inject(0){|r, el| r + 2**el}"}, {"source_code": "p 2**-~gets.to_i-2"}, {"source_code": "p 2**(gets.to_i+1)-2\n"}], "negative_code": [{"source_code": "p 1**gets.to_i*2-2"}, {"source_code": "p(1< 1 do\n a -= 1\n b += 1\n sum += b * a\nend\n\nputs sum + c"}, {"source_code": "number = gets.to_i\ncount = 0\n\n(number-1).times do |i|\n k = i+1\n count += (number-k)*k\nend\n\np count + number\n"}, {"source_code": "n=gets.to_i\n\nx = n*(n*n+5)/6\n\nputs x\n"}, {"source_code": "k=gets.to_i;puts k*(k*k+5)/6"}, {"source_code": "n = gets.to_i\nputs n == 1 ? 1 : (1...n).map { |x| (n - x) * x }.reduce(:+) + n"}, {"source_code": "n = gets.chomp.to_i\ns = 0\n(1..n).each{ |k|\n s += (k*(n-k)+1)\n}\nputs s"}, {"source_code": "n=gets.to_i\nx = n*(n*n+5)/6\nputs x"}, {"source_code": "n = gets.to_i\ni = 1\nans = 0\nfor i in 1..n do\n ans = ans + (i * (n-i)) \nend\nputs ans+n"}, {"source_code": "n = gets.to_i\nans = n\ni = 1\nwhile n-i > 0 do\n ans += (n-i)*i\n i+=1\nend\nputs ans"}, {"source_code": "n = gets.to_i\nneed = [0]\nn.times do |i|\n need << need[-1] + (n - i - 1) * (i + 1) + 1\nend\nputs need[n]\n"}, {"source_code": "#!/usr/bin/env ruby\n\nn = gets.to_i\nputs n + (n - 1) * n * (n + 1) / 6;\n"}, {"source_code": "$i=0;\n$sum=0;\ngets.chomp.to_i.-(1).times do\n $i+=1\n $sum+=$i*($_.to_i-$i)\nend\nputs $sum+$_.to_i"}, {"source_code": "n = gets.to_i\n\nresult = 0\nt = []\n\n\n1.upto(n)do |i|\n\tresult += (n-i)*i\nend\nputs result + n"}, {"source_code": "n = gets.to_i\nans = n\nn.times do |i|\n\tans += (i + 1) * (n - i - 1)\nend\nputs ans\n"}, {"source_code": "n = gets.to_i\ns = 0\nn.times do |time|\n s += (n - time - 1) * (time + 1) + 1\nend\nputs s"}, {"source_code": "def func(x, h)\n y = x+(x-1)*h\n return y\nend\n\nn = gets.to_i\n\nresult = 0\n\ni = n\nwhile i > 0 do\n result += func(i, n-i)\n i -= 1\nend\n\nputs result"}, {"source_code": "val = gets.to_i ;\nval = (val**3 + 5*val)/6 ;\nputs val ;"}, {"source_code": "#!/usr/bin/ruby\nn=gets.to_i\np (n*n+5)*n/6"}, {"source_code": "sum, multi = gets.chomp.to_i, 1\n(sum-1).downto 1 do |i|\n\tsum += (i*multi)\n\tmulti += 1\nend\nputs sum"}, {"source_code": "n = gets.to_i\nk = n\nsum = 0\nwhile k > 0 do\n sum += (n-k + 1) * (k - 1) + 1\n k -= 1\nend\nputs sum"}, {"source_code": "n = gets.to_i\nsum = n\nfor k in 1..n do\n sum += (n-k + 1) * (k - 1)\nend\nputs sum"}, {"source_code": "#!/usr/bin/ruby1.9\n\nn = STDIN.readline.to_i\n\nprefix = 0\ntotal = 0\n(1..n).reverse_each do |k|\n\ttotal += (prefix+1)*(k-1) + 1\n\tprefix += 1\nend\n\nputs total\n\n"}, {"source_code": "n = gets.to_i\ni = 1\nr = 0\nwhile i<=n-1 do\n\tr = r + (i * (n-i))\n\ti=i+1\nend\nputs r+n"}, {"source_code": "x = gets.chomp.to_i\n\ntotal = x\n\nx.downto(1).each_with_index do |i, ind|\n total += i*ind\nend\n\nputs total"}, {"source_code": "n=gets.to_i\np n+n*n*(n-1)/2-(n-1)*(2*n-1)*n/6"}, {"source_code": "n = $stdin.readline.to_i\n\ndef s(n)\n n*(n-1)/2\nend\n\ndef k(n,l)\n if n == 1\n return 1+l\n else\n if l > 0\n return n*l + k(n-1, l+1)\n else\n return n-1 + k(n-1, l+1)\n end\n end\nend\n\nputs k(n,0)"}, {"source_code": "n = gets.to_i\nar = (1...n).to_a\nputs n + ar.reverse.zip(ar).map{|x,y| x*y}.inject(:+) if n>1\nputs 1 if n==1"}, {"source_code": "def run\n n = ARGF.readline.to_i\n\n sum = 0\n n.times do |i|\n sum += (n - i - 1) * (i + 1) + 1\n end\n\n puts sum\nend\n\nrun if $0 == __FILE__\n"}, {"source_code": "x=gets.chomp.to_i\ny=1\nz=x\nans=0\nwhile y!=x do\n ans=ans+((z-1)*y)\n y=y+1\n z=z-1\nend\nputs ans+x"}, {"source_code": "n=gets.to_i\ni=0\nans=n+n-1\nwhile n>1\n\tn=n-1\n\tans=ans+n*i+i\n\ti=i+1\nend\nputs ans"}, {"source_code": "n = gets.to_i\nsum = 0\nn.times do |j|\n sum += n - j + j * (n - j - 1)\nend \nputs sum\n"}, {"source_code": "n = gets.to_i\nr = 0\nn.downto(1) do |i|\n\tr += i + (i - 1)*(n - i)\nend\nputs r"}, {"source_code": "n=gets.to_i\ncount=0\n2.upto(n){|i| count+=(i-1)*(n-i)+(i-1)}\nputs(count+n)"}, {"source_code": "require 'set'\ninclude Math\n$stdin = File.open(\"./input.txt\", \"r\") if ENV[\"USER\"] == \"new\"\n# ====================================\n\nn = gets.to_i\n\nif n == 1 then\n print 1\n exit\nend\n\nresult = n + 1\n2.upto(n - 1) do |value|\n result += 1\n result += value * (n - value)\nend\n\nprint result"}, {"source_code": "#!/usr/bin/ruby\nn=gets.to_i\np (n*n+5)*n/6"}], "negative_code": [{"source_code": "def func(x)\n y = x+(x-1)\n return y\nend\n\nn = gets.to_i\n\nresult = n\ni = n-1\nwhile i > 0 do\n result += func(i)\n i -= 1\nend\n\nputs result"}, {"source_code": "#!/usr/bin/ruby\np (1< 3\n\tn.downto(1) do |i|\n\t\tif i > 1\n\t\t\tn.downto(i+1) do |j|\n\t\t\t\tt[j] += i\n\t\t\tend\n\t\tend\n\t\tt[i] = i\n\t\t\n\tend\n\tt.each{|x| result += x == nil ? 0 : x}\n\tputs result\nelsif n == 3\n\tprint 7\nelse \n\tprint 3\nend\n\n"}, {"source_code": "def sum(n)\n\tn + [0, n*n/2 - n].max\nend\n\nn = gets.to_i\n\nresult = 0\n\nn.times do |i|\n\tresult += sum(i+1)\nend\n\nputs result"}], "src_uid": "6df251ac8bf27427a24bc23d64cb9884"} {"source_code": "n,m,a,b=gets.split.map &:to_i\np [n%m*b,(m-n%m)*a].min", "positive_code": [{"source_code": "n, m, a, b = gets.strip.split.map(&:to_i)\ntd = n % m\ntb = m - td\nputs [td*b, tb*a].min"}, {"source_code": "n, m, a, b = gets.split.map{|e| e.to_i }\nmod = n % m\nputs [mod*b, ((m-mod)%m)*a].min\n"}, {"source_code": "n,m,a,b=gets.split.map &:to_i\nx=n%m\nputs [x*b, (m-x)*a].min\n"}, {"source_code": "n, m, a, b = gets.split.map &:to_i\nx = [n / m - 1, 0].max\nans = Float::INFINITY\nx.upto(x + 2) do |i|\n ans = [ans, i * m < n ? (n - i * m) * b : (i * m - n) * a].min\nend\nputs ans\n"}, {"source_code": "n, m, a, b = gets.split.map(&:to_i)\nd = n % m\nif d == 0\n puts 0\n exit\nend\nputs [b * d, a * (m - d)].min"}, {"source_code": "def delegate_boxes\n n, m, a, b = gets.split.map(&:to_i)\n l = n % m\n return 0 if l == 0\n\n if n < m\n return min(n * b, (m - n) * a)\n end\n\n min(l * b, (m - l) * a)\nend\n\ndef min(a, b)\n a <= b ? a : b\nend\n\nputs delegate_boxes"}, {"source_code": "n, m, a, b = gets.split.map(&:to_i)\n\ndiv, mod = n.divmod(m)\n\nputs [mod * b, (m - mod) * a].min\n"}], "negative_code": [], "src_uid": "c05d753b35545176ad468b99ff13aa39"} {"source_code": "#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']\n\ndef inpf() a=gets.chomp.split(\" \").map(&:to_f)end\n\ndef inps() a=gets.chomp.split(\" \")end\n\ndef copy(a) Marshal.load(Marshal.dump(a)) end\n\ndef kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end\n\ndef na(n,d=0) Array.new(n,d)end\n\ndef na2(n,m,d=0) Array.new(n){Array.new(m,d)}end\n\ndef na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end\n\ndef inp() a=gets.chomp.split(\" \").map(&:to_i)end\n\ndef r_up(a, b) (a+b-1)/b end\n\ndef sum(a) a.inject(:+) end\n\nrequire 'prime'\n\nn = inp[0]\nt = inp\nt = t.sort\nh = {}\nans = 0\nt.each do |d|\n (t).each do |i|\n if(d%i == 0)\n h[i] = true\n break\n end\n end\nend\n\np ((h.to_a.size))\n", "positive_code": [{"source_code": "n = gets.to_i\na = gets.split.map(&:to_i).sort\npainted = Array.new(n, false)\ncolors = 0\nfor i in 0...n do\n if !painted[i]\n colors += 1\n painted[i] = true\n for j in (i+1)...n do\n if !painted[j] && a[j] % a[i] == 0\n painted[j] = true\n end\n end\n end\nend\nputs colors\n"}, {"source_code": "n = gets.to_i\na = gets.split.map(&:to_i).sort\n\nans = 0\nwhile !a.empty?\n ans += 1\n t = a.shift\n idx = []\n a.length.times do |i|\n if a[i] % t == 0\n idx << i\n end\n end\n idx.reverse.each do |v|\n a.delete_at(v)\n end\nend\np ans\n"}, {"source_code": "n = gets.to_i\narr = gets.split(' ').collect(&:to_i).sort\narr_used = Array.new(n)\n\narr.each_with_index do |elem_1, idx_1|\n\tarr.each_with_index do |elem_2, idx_2|\n\t\tnext unless arr_used[idx_2].nil?\n\t\tnext unless elem_2 % elem_1 == 0 && elem_1 <= elem_2\n\t\tarr_used[idx_2] = idx_1\n\tend\nend\n\np arr_used.uniq.count\n"}], "negative_code": [{"source_code": "#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']\n\ndef inpf() a=gets.chomp.split(\" \").map(&:to_f)end\n\ndef inps() a=gets.chomp.split(\" \")end\n\ndef copy(a) Marshal.load(Marshal.dump(a)) end\n\ndef kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end\n\ndef na(n,d=0) Array.new(n,d)end\n\ndef na2(n,m,d=0) Array.new(n){Array.new(m,d)}end\n\ndef na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end\n\ndef inp() a=gets.chomp.split(\" \").map(&:to_i)end\n\ndef r_up(a, b) (a+b-1)/b end\n\ndef sum(a) a.inject(:+) end\n\nrequire 'prime'\n\nn = inp[0]\nt = inp\nt = t.sort.reverse\nh = {}\nans = 0\nt.each do |d|\n ((t.min)..100).each do |i|\n if(d%i == 0)\n h[i] = true\n break\n end\n end\nend\n\np ((h.to_a.size))\n"}, {"source_code": "#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']\n\ndef inpf() a=gets.chomp.split(\" \").map(&:to_f)end\n\ndef inps() a=gets.chomp.split(\" \")end\n\ndef copy(a) Marshal.load(Marshal.dump(a)) end\n\ndef kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end\n\ndef na(n,d=0) Array.new(n,d)end\n\ndef na2(n,m,d=0) Array.new(n){Array.new(m,d)}end\n\ndef na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end\n\ndef inp() a=gets.chomp.split(\" \").map(&:to_i)end\n\ndef r_up(a, b) (a+b-1)/b end\n\ndef sum(a) a.inject(:+) end\n\nrequire 'prime'\n\nn = inp[0]\nt = inp\nt = t.sort.reverse\nh = {}\nans = 0\nt.each do |d|\n (2..100).each do |i|\n if(d%i == 0)\n h[i] = true\n break\n end\n end\nend\np h.to_a.size\n"}, {"source_code": "#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']\n\ndef inpf() a=gets.chomp.split(\" \").map(&:to_f)end\n\ndef inps() a=gets.chomp.split(\" \")end\n\ndef copy(a) Marshal.load(Marshal.dump(a)) end\n\ndef kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end\n\ndef na(n,d=0) Array.new(n,d)end\n\ndef na2(n,m,d=0) Array.new(n){Array.new(m,d)}end\n\ndef na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end\n\ndef inp() a=gets.chomp.split(\" \").map(&:to_i)end\n\ndef r_up(a, b) (a+b-1)/b end\n\ndef sum(a) a.inject(:+) end\n\nrequire 'prime'\n\nn = inp[0]\nt = inp\nt = t.sort.reverse\nh = {}\nans = 0\nt.size.times do |i|\n f = false\n next if(h[t[i]])\n ((i+1)...(t.size)).each do |j|\n if(t[i]%t[j]==0)\n h[t[j]] = true\n end\n end\n ans += 1\nend\np ans\n"}, {"source_code": "#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']\n\ndef inpf() a=gets.chomp.split(\" \").map(&:to_f)end\n\ndef inps() a=gets.chomp.split(\" \")end\n\ndef copy(a) Marshal.load(Marshal.dump(a)) end\n\ndef kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end\n\ndef na(n,d=0) Array.new(n,d)end\n\ndef na2(n,m,d=0) Array.new(n){Array.new(m,d)}end\n\ndef na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end\n\ndef inp() a=gets.chomp.split(\" \").map(&:to_i)end\n\ndef r_up(a, b) (a+b-1)/b end\n\ndef sum(a) a.inject(:+) end\n\nrequire 'prime'\nn = inp[0]\nt = inp\nt = t.sort\nh = {}\nans = 0\nt.size.times do |i|\n f = false\n ((i+1)...(t.size)).each do |j|\n if(t[j]%t[i]==0)\n f = true\n break\n end\n end\n ans += 1 unless f\nend\np ans\n"}], "src_uid": "63d9b7416aa96129c57d20ec6145e0cd"} {"source_code": "n, m = gets.split.map(&:to_i)\nb = {}\nm.times do\n\tx, y = gets.split.map(&:to_i)\n\tb.has_key?(y) ? b[y] += x : b[y] = x\nend\ntot, cc = 0, 0\nb.sort.reverse.each do |v, i|\n\ttot += [n - cc, i].min * v\n\tcc += i\n\tbreak if cc > n\nend\nputs tot\n", "positive_code": [{"source_code": "z=0;n,m=gets.split.map &:to_i;m.times.to_a.map{gets.split.map(&:to_i).reverse}.sort.reverse.each{|x,y|t=[n,y].min;n-=t;z+=x*t;};p z\n"}, {"source_code": "n,m=gets().chomp().split(' ').map(&:to_i) ;h={}\nh = m.times.to_a.map{ gets.split.map(&:to_i) }\n(h=h.sort_by {|_key, value| value}).reverse! ;count=0\nh.each do |key, value|\n count+=(key>n)?((n)*value):(key*value) ;n-=key ;break if (n<=0)\nend\np count"}, {"source_code": "z=0;n,m=gets.split.map &:to_i;m.times.to_a.map{gets.split.map(&:to_i).reverse}.sort.reverse.each{|x,y|t=[n,y].min;n-=t;z+=x*t;};p z"}, {"source_code": "z=0;n,m=gets.split.map &:to_i;m.times.to_a.map{gets.split.map(&:to_i).reverse}.sort.reverse.each{|x,y|t=[n,y].min;n-=t;z+=x*t;};p z\n"}, {"source_code": "z=0;n,m=gets.split.map &:to_i;m.times.to_a.map{gets.split.map(&:to_i).reverse}.sort.reverse.each{|x,y|t=[n,y].min;n-=t;z+=x*t;};p z\n"}, {"source_code": "n,m=gets.split.map(&:to_i)\ns=0\nm.times{$*<c[1]}.each{|a,b|if n>a\ns+=a*b\nn-=a\nelse\ns+=n*b\nbreak\nend}\np s"}, {"source_code": "tab=[]; result=0\nn, m = gets.split.map(&:to_i)\nm.times{tab << gets.split.map(&:to_i)}\ntab.sort!{|a, b| a[1] <=> b[1]}.reverse!\ntab.each do |x|\n\tresult += [x[0], n].min * x[1]\n\tn -= [x[0], n].min\nend\n\nputs result\n\n\n\n\n\n\n"}, {"source_code": "class Box\n\tattr_accessor :count, :value\n\n\tdef initialize(count, value)\n\t\t@count, @value = count, value\n\tend\nend\n\nt = gets.split.collect{|x| x.to_i}\nn,m = t[0], t[1]\n\na = []\n\nm.times do |i|\n\tt = gets.split.collect{|x| x.to_i}\n\ta << Box.new(t[0], t[1])\nend\n\na.sort!{|x,y| y.value <=> x.value}\n\nresult = 0\na.each do |b|\n\tif b.count <= n\n\t\tresult += b.count * b.value\n\t\tn-=b.count\n\telse\n\t\tresult += n * b.value\n\t\tn = 0\n\tend\nend\n\nputs result"}, {"source_code": "z=0;n,m=gets.split.map &:to_i;m.times.to_a.map{gets.split.map(&:to_i).reverse}.sort.reverse.each{|x,y|t=[n,y].min;n-=t;z+=x*t;};p z\n"}, {"source_code": "ns,ms = gets.chomp.split(/ /)\nn = ns.to_i\nm = ms.to_i\nar = Array.new(m)\nfor i in 0..m-1\n\ts = gets.chomp\n\tar[i] = s.split(/ /).map! {|x| x.to_i }\nend\n\nar.sort! { |a,b| b[1] <=> a[1] }\n\nret = 0\nwk = n\nfor i in 0..m-1\n\tbreak if wk <= 0\n\tt = [wk, ar[i][0]].min\n\tret += t * ar[i][1]\n\twk -= t\nend\n\nputs ret"}, {"source_code": "s = 0\nn, m = gets.split.map{|i| i.to_i}\nm.times.to_a.map{gets.split.map{|i| i.to_i}.reverse}.sort.reverse.each do |i|\n\tt = [n, i[1]].min\n\tn -= t\n\ts += i[0] * t\nend\np s\n"}, {"source_code": "s = 0\nn, m = gets.split.map{|i| i.to_i}\nm.times{$*< a[1]}.each do |a, b|\n\tt = [n, a].min\n\tn -= t\n\ts += b * t\nend\np s\n\n__END__\n# \tWhen \tWho \tProblem \tLang \tVerdict \tTime \tMemory\n212857 \tDec 9, 2010 9:59:45 PM \twatashi \tB - Burglar and Matches \tRuby \tAccepted \t80 ms \t2992 KB\n"}, {"source_code": "\nn,m=gets.split.map(&:to_i)\ncnt=Array.new(11,0)\nm.times{\n a,b=gets.split.map(&:to_i)\n cnt[b]+=a\n}\nans=0\n10.downto(1){|i|\n if(n>=cnt[i]) then\n n-=cnt[i]\n ans+=cnt[i]*i\n else\n ans+=n*i\n n=0\n end\n}\np ans\n"}, {"source_code": "z=0;n,m=gets.split.map &:to_i;m.times.to_a.map{gets.split.map(&:to_i).reverse}.sort.reverse.each{|x,y|t=[n,y].min;n-=t;z+=x*t;};p z\n"}, {"source_code": "z=0;n,m=gets.split.map &:to_i;m.times.to_a.map{gets.split.map(&:to_i).reverse}.sort.reverse.each{|x,y|t=[n,y].min;n-=t;z+=x*t;};p z\n"}, {"source_code": "z=0;n,m=gets.split.map &:to_i;m.times.to_a.map{gets.split.map(&:to_i).reverse}.sort.reverse.each{|x,y|t=[n,y].min;n-=t;z+=x*t;};p z"}, {"source_code": "z=0;n,m=gets.split.map &:to_i;m.times.to_a.map{gets.split.map(&:to_i).reverse}.sort.reverse.each{|x,y|t=[n,y].min;n-=t;z+=x*t;};p z\n"}, {"source_code": "z=0;n,m=gets.split.map &:to_i;m.times.to_a.map{gets.split.map(&:to_i).reverse}.sort.reverse.each{|x,y|t=[n,y].min;n-=t;z+=x*t;};p z\n"}, {"source_code": "#!/usr/bin/ruby\n\nn, m = gets.chomp.split.map{|e| e.to_i}\n\nmatches = []\nm.times do\n a, b = gets.chomp.split.map{|e| e.to_i}\n matches.push [a, b]\nend\n\nmatches.sort! {|l, r|\n r[1] <=> l[1]\n}\n\nrest = n\ncur_box = 0\nacc = 0\nwhile (true)\n break if cur_box >= m\n if (matches[cur_box][0] <= rest)\n acc += matches[cur_box][0] * matches[cur_box][1]\n rest -= matches[cur_box][0]\n cur_box += 1\n next\n else\n acc += matches[cur_box][1] * rest\n break\n end\nend\nputs acc\n\n\n \n"}, {"source_code": "z=0;n,m=gets.split.map &:to_i;m.times.to_a.map{gets.split.map(&:to_i).reverse}.sort.reverse.each{|x,y|t=[n,y].min;n-=t;z+=x*t;};p z"}, {"source_code": "z=0;n,m=gets.split.map &:to_i;m.times.to_a.map{gets.split.map(&:to_i).reverse}.sort.reverse.each{|x,y|t=[n,y].min;n-=t;z+=x*t;};p z"}, {"source_code": "result = 0\nn, m = gets.split.map(&:to_i)\nelements = m.times.to_a.map{ gets.split.map(&:to_i).reverse }\nelements.sort.reverse.each{ |x, y| t = [n, y].min; n -= t; result += x * t; break if n == 0 }\nputs result"}], "negative_code": [{"source_code": "result = 0\nn, m = gets.split.map(&:to_i)\nelements = m.times.to_a.map{ gets.split.map(&:to_i).reverse }\nelements.sort.reverse.each{ |x, y| puts x; puts y; t = [n, y].min; puts t; n -= t; puts n; result += x * t; break if n == 0 }\nputs result"}, {"source_code": "n,m=gets().chomp().split(' ').map(&:to_i) ;h=Hash.new\nm.times { a,b=gets().chomp().split(' ').map(&:to_i); h[a]=b; }\n(h=h.sort_by {|_key, value| value}).reverse! ;count=0\nh.each do |key, value|\n count+=(key>n)?((n)*value):(key*value) ;n-=key ;break if (n<=0)\nend\np count"}], "src_uid": "c052d85e402691b05e494b5283d62679"} {"source_code": "t,s,x = gets.chomp.split \n\nt = t.to_i \nx = x.to_i \ns = s.to_i \n\nif x{gets.split.map &:to_i}\nt, s, x = I[]\nif x == t || x >= s + t && ((x - t) % s == 0 || ((x - t - 1)) % s == 0)\n print 'YES'\nelse\n print 'NO'\nend\n"}, {"source_code": "t,s,x = gets.split(\" \").map(&:to_i)\nx -= t\nputs ((x>=0 and x%s < 2 and x!=1) ? \"YES\" :\"NO\")"}, {"source_code": "a=gets.chomp.split(\" \").map{|i| i.to_i}\nif(a[0]==a[2])\nputs \"YES\"\nelsif ((a[2]-a[0])>0 && (a[2]-a[0])/a[1]>0 && ((a[2]-a[0])%a[1]==0 || (a[2]-a[0])%a[1]==1) )\nputs \"YES\"\nelse\nputs \"NO\"\nend\n\n"}, {"source_code": "a=gets.chomp.split(\" \").map{|i| i.to_i}\nif(a[0]==a[2])\nputs \"YES\"\nelsif ((a[2]-a[0])>0 && (a[2]-a[0])/a[1]>0 && ((a[2]-a[0])%a[1]==0 || (a[2]-a[0])%a[1]==1) )\nputs \"YES\"\nelse\nputs \"NO\"\nend"}, {"source_code": "t,s,x=gets.split.map{|e| e.to_i}\nif (x-t)%s==0 && (x-t)/s>=0 then\n\tputs \"YES\"\nelsif (x-t-1)%s==0 && (x-t-1)/s>0 then\n\tputs \"YES\"\nelse\n\tputs \"NO\"\nend\n\n"}, {"source_code": "t, s, x = gets.split.map(&:to_i)\n\nputs (x-t) % s < 2 && x >= t && (s == 1 || t+1 != x ) ? 'YES' : 'NO'"}, {"source_code": "t, s, x = gets.split.map(&:to_i)\nputs x >= t && ( (x - t) % s == 0 || x - t > s && (x - t - 1) % s == 0 ) ? 'YES' : 'NO'\n"}, {"source_code": "#!/usr/bin/env ruby\n\nt, s, x = ARGF.gets.chomp.split(\" \").map { |s| s.to_i }\n\nif t == x\n puts \"YES\"\n exit\nend\nif x == t + 1 or x < t\n puts \"NO\"\n exit\nend\n\nif (x - t).modulo(s) == 0 or (x - t - 1).modulo(s) == 0\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "a=gets.chomp.split(\" \").map{|i| i.to_i}\nif(a[0]==a[2])\nputs \"YES\"\nelsif ((a[2]-a[0])>0 && (a[2]-a[0])/a[1]>0 && ((a[2]-a[0])%a[1]==0 || (a[2]-a[0])%a[1]==1) )\nputs \"YES\"\nelse\nputs \"NO\"\nend\n"}, {"source_code": "t,s,x = gets.split(' ').map(&:to_i)\na = x - t\nb = x - t - 1\nif a%s == 0 && (a >= 0)\n puts 'YES'\nelsif b%s == 0 && (b > 0)\n puts 'YES'\nelse\n puts 'NO'\nend\n"}, {"source_code": "input1 = gets.chomp\nnum = input1.split(\" \").map(&:to_i)\nif num[2]>=num[0] && num[2]!= (num[0]+1) && ((num[2]-num[0])%num[1] == 0 || (num[2] - num[0] - 1)%num[1] == 0)\n print \"YES\"\nelse\n print \"NO\"\nend\n"}, {"source_code": "t, s, x = gets.split.map { |x| x.to_i }\n\nif x >= t and (x - t) % s == 0\n\tputs 'YES'\nelsif x >= t + s + 1 and (x - t - 1) % s == 0\n\tputs 'YES'\nelse\n\tputs 'NO'\nend"}, {"source_code": "t, s, x = gets.chomp.split(' ').map(&:to_i)\n\n\nn = (x - t) / s\nnum = t + n * s\n\nfirst = true if (n == 0)\noneTime = (n > 0)\n\n#puts \"n : #{n}\"\n\nif n < 0\n\tputs 'NO'\n\texit\nend\n\nuntil num >= x\n\tnum += s if first\n\tnum += (s - 1) if !oneTime && !first\n\tnum += 1 if oneTime\n\n\toneTime = !oneTime\n\tfirst = false\n\n\t#puts \"Num : #{num}\"\nend\n\nif num == x\n\tputs 'YES'\nelse\n\tputs 'NO'\nend"}], "negative_code": [{"source_code": "t,s,x = gets.chomp.split \n\nt = t.to_i \nx = x.to_i \ns = s.to_i \n\nif x{gets.split.map &:to_i}\nt, s, x = I[]\nif x == t || x > t && ((x - t) % s == 0 || ((x - t - 1)) % s == 0)\n p 'YES'\nelse\n p 'NO'\nend\n"}, {"source_code": "I =->{gets.split.map &:to_i}\nt, s, x = I[]\nif x == t || x + s >= t && ((x - t) % s == 0 || ((x - t - 1)) % s == 0)\n p 'YES'\nelse\n p 'NO'\nend\n"}, {"source_code": "t,s,x = gets.split(\" \").map(&:to_i)\nx -= t\nputs (x>=0 and x%s < 2 and x!=1 ? \"YES\" :\"NO\")"}, {"source_code": "t, s, x = gets.split.map(&:to_i)\n\nputs (x-t) % s < 2 && t+1 != x ? 'YES' : 'NO'"}, {"source_code": "t, s, x = gets.split.map(&:to_i)\n\nputs (x-t) % s < 2 ? 'YES' : 'NO'"}, {"source_code": "t, s, x = gets.split.map(&:to_i)\nputs (x - t) % s == 0 || x - t > 1 && (x - t - 1) % s == 0 ? 'YES' : 'NO'\n"}, {"source_code": "#!/usr/bin/env ruby\n\nt, s, x = ARGF.gets.chomp.split(\" \").map { |s| s.to_i }\n\nif t == x\n puts \"YES\"\n exit\nend\nif x == t + 1\n puts \"NO\"\n exit\nend\n\nif ((r1 = (x - t).modulo(s)) == 0 and r1 >= t) or ((r2 = (x - t - 1).modulo(s)) == 0 and r2 >= t)\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "#!/usr/bin/env ruby\n\nt, s, x = ARGF.gets.chomp.split(\" \").map { |s| s.to_i }\n\nif t == x\n puts \"YES\"\n exit\nend\nif x == t + 1\n puts \"NO\"\n exit\nend\n\nif (x - t).modulo(s) == 0 or (x - t - 1).modulo(s) == 0\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "t,s,x = gets.split(' ').map(&:to_i)\na = x - t\nb = x - t - 1\nif a%s == 0\n puts 'YES'\nelsif b%s == 0 && (b%s > 0)\n puts 'YES'\nelse\n puts 'NO'\nend\n"}, {"source_code": "t,s,x = gets.split(' ').map(&:to_i)\na = x - t\nb = x - t - 1\nif a%s == 0\n puts 'YES'\nelsif b%s == 0 && (b > 0)\n puts 'YES'\nelse\n puts 'NO'\nend\n"}, {"source_code": "t, s, x = gets.chomp.split(' ').map(&:to_i)\n\n\nn = (x - t) / s\nnum = t + n * s\n\nfirst = true if (n == 0)\noneTime = (n > 0)\n\nuntil num >= x\n\tnum += s if first\n\tnum += (s - 1) if !oneTime && !first\n\tnum += 1 if oneTime\n\n\toneTime = !oneTime\n\tfirst = false\n\n\t#puts \"Num : #{num}\"\nend\n\nif num == x\n\tputs 'YES'\nelse\n\tputs 'NO'\nend"}], "src_uid": "3baf9d841ff7208c66f6de1b47b0f952"} {"source_code": "a, b = gets.split(' ').map &:to_i\ntotal = 0\ntmp = 0\nwhile a > 0\n total += 1\n tmp += 1\n a -= 1\n if tmp == b\n tmp = 0\n a += 1\n end\nend\nputs total\n", "positive_code": [{"source_code": "a, b = gets.split.map &:to_i\ntotal = a\nwhile a / b > 0\n total += a / b\n if a % b == 0\n a = a / b\n else\n a = a / b + a % b\n end\nend\nputs total\n"}, {"source_code": "n,m=gets.split.map &:to_i;p (m*n-1)/(m-1)\n"}, {"source_code": "ARGF.lines do |line|\n n, m = line.split.map(&:to_i)\n sol = n+(n-1)/(m-1)\n puts sol\nend\n"}, {"source_code": "n,m=gets.split.map &:to_i;p (m*n-1)/(m-1)\n"}, {"source_code": "n,m=gets.split.map{|e| e.to_i}\nc=1\n1.upto(10000000){|i|\n\tif i%m==0 then\n\t\tc=c+1\n\tend\n\tif n<=i then\n\t\tc=c-1\n\t\tif c<=0 then\n\t\t\tputs i\n\t\t\tbreak\n\t\tend\n\tend\n}"}, {"source_code": "n, m = gets.split.map(&:to_i)\ni = 0\nans = 0\nwhile n > 0\n\ti += 1\n\tif i % m == 0\n\t\tans += 1\n\t\tnext end\n\tn -= 1\n\tans += 1 end\nputs ans\n"}, {"source_code": "n,m=gets.split.map &:to_i;p (n-1)/(m-1)*m+(n-1)%(m-1)+1"}, {"source_code": "input=gets.split(\" \")\nn=input[0].to_i\nm=input[1].to_i\nk=n\ndays=0\nwhile k>0\n days+=1\n k=k-1\n if days % m == 0\n k=k+1\n end\nend\nputs days"}, {"source_code": "n, m = gets.chomp.split.map{|x| x.to_i}\n\ndiv = n/m\ndays = n + div\n\nwhile((div+=1) * m <= days)\n days += 1\nend\n\nputs days"}, {"source_code": "n, m = gets.split.map &:to_i\n\ni = 0\nwhile n > 0\n i += 1\n n -= 1 if i % m != 0\nend\n\np i"}, {"source_code": "n,m=gets.split.map &:to_i;p (n*m-1)/(m-1)"}, {"source_code": "n,m=gets.split.map &:to_i;p (m*n-1)/(m-1)\n"}, {"source_code": "n, m = gets.split.map(&:to_i)\nputs n + (n - 1) / (m - 1)"}, {"source_code": "a,b = gets.split.map(&:to_i)\nsum = a\nwhile a>=b\n tmp = a\n a = tmp/b\n sum+=a\n a += tmp%b \nend\np sum"}, {"source_code": "n, m = gets.split.map(&:to_i)\n\ni = 0\nloop do\n i += 1\n n -= 1\n n += 1 if i % m == 0\n break if n == 0\nend\n\nputs i\n"}, {"source_code": "n, m = gets.split(/\\s+/).map(&:to_i)\na = 0\n\nwhile n > 0\n a += 1\n n -= 1\n if a%m == 0\n n+=1\n end\nend\n\np a\n"}, {"source_code": "n, m = gets.split(/\\s+/).map(&:to_i)\np n + (n-1)/(m-1)\n"}, {"source_code": "n,m = gets.split.map(&:to_i)\nday = 0\nwhile n > 0\n day += 1\n n -= 1 if day % m != 0\nend\nputs day"}, {"source_code": "s = gets.split(' ')\t#Танцы с бубном\n\nn = s[0].to_i\nm = s[1].to_i\n\ni = 0\nres = 0\nuntil n == 0\n\tres += 1\n\tn -= 1\n\ti += 1\n\tif i == m\n\t\tn += 1\n\t\ti = 0\n\tend\nend\n\nputs res"}, {"source_code": "n,m=gets.split.map &:to_i;p (m*n-1)/(m-1)"}, {"source_code": "n, m = *(gets.split(' ').collect { |n| n.to_i })\nday = 0\nuntil n == 0 do\n day += 1\n n -= 1 unless day % m == 0\nend\nputs day"}, {"source_code": "n,m=gets.split.map &:to_i;p (m*n-1)/(m-1)"}, {"source_code": "n,m=gets.split.map(&:to_i)\n\nx=n\nwhile (x 0\n n -= 1\n i += 1\n if i % m == 0\n n += 1\n end\nend\nputs(i)"}, {"source_code": "n,m=gets.split.map &:to_i;p (m*n-1)/(m-1)\n"}, {"source_code": "n, m = gets.split(' ').map(&:to_i)\n\nday = 0\nwhile n > 0\n day += 1\n n -= 1\n n += 1 if day % m == 0\nend\n\nputs day\n"}, {"source_code": "n,m=gets.split.map &:to_i;p (m*n-1)/(m-1)\n"}, {"source_code": "input = gets.split.map(&:to_i)\nn = input[0]\nm = input[1]\ndays = 0\nwhile n != 0\n days += 1\n if days % m == 0\n n += 1\n end\n n -= 1\nend\nputs days\n"}, {"source_code": "\n\na, b = gets.split.map(&:to_i)\n\n\n(1..100000).each do |i|\n #puts \"#{i}, #{a}\"\n if a == 0\n puts i-1\n break\n end\n\n a -= 1\n\n if i % b == 0\n a += 1\n end\n\n\nend\n\n\n\n"}, {"source_code": "n,m=gets.split.map &:to_i;p (m*n-1)/(m-1)\n"}, {"source_code": "n, m = gets.chomp.split(' ').map { |i| i.to_i }\nans = 1\nuntil n == 0 do\n n -= 1\n n += 1 if ans % m == 0\n ans += 1\nend\n\nputs ans - 1"}, {"source_code": "n,m=gets.split.map &:to_i\n\nday=0\n\nwhile n>0\n day+=1\n n-=1\n if day%m==0\n n+=1\n end\nend\n\np day"}, {"source_code": "n,m=gets.split.map &:to_i;p (m*n-1)/(m-1)\n"}, {"source_code": "#!/usr/bin/env ruby\n\n#n = ARGV[0].to_i\n#m = ARGV[1].to_i\n\ninp = $stdin.gets.chomp.split\nn = inp[0].to_i\nm = inp[1].to_i\n\nday = 0\n\nwhile n > 0\n day += 1\n n -= 1 unless day%m==0\nend\n\nputs day\n"}, {"source_code": "n,m=gets.split.map &:to_i;p (m*n-1)/(m-1)\n"}, {"source_code": "n,m=gets.split.map &:to_i;p (m*n-1)/(m-1)"}, {"source_code": "n,m=gets.split.map &:to_i;p (m*n-1)/(m-1)"}, {"source_code": "n, m = gets.split.map!{ |s| s.to_i }\n\nres = 0\nday = 0\n\nwhile n > 0\n res += 1\n n -= 1\n day += 1\n if day >= m\n n += 1\n day = 0\n end\nend\n\np res\n"}, {"source_code": "n,m=gets.split.map &:to_i;p (m*n-1)/(m-1)"}, {"source_code": "n,m = gets.split.map{|r| r.to_i}\n\nk = n\ni = 1\nwhile i<=n\n if i%m == 0\n n+=1\n end\n i+=1\nend\nputs n\n\n\n"}, {"source_code": "a, b = $stdin.readline.split.map(&:to_i)\n\nn = 0\nr = 0\nwhile a>0\n n+= a\n t = r+a\n a = t/b\n r = t%b\nend\n\nputs n"}, {"source_code": "a, b = gets.split.map(&:to_i); p (a*b-1)/(b-1)\n"}, {"source_code": "n, m = gets.split.map(&:to_i)\nputs ((n - 1) / (m - 1) * m + (n - 1) % (m - 1) + 1)"}], "negative_code": [{"source_code": "n, m = gets.split.map(&:to_i)\nc = n\nc += n = n / m while n >= m\nputs c"}, {"source_code": "a,b = gets.split.map(&:to_i)\nsum = a\nwhile a!=0\n a = a/b\n sum+=a\nend\np sum"}, {"source_code": "n, m = gets.split(/\\s+/).map(&:to_i)\na = n\nr = 0\n\nwhile n+r >= m\n a += (n+r)/m\n r, n = n%m, n/m\nend\np a\n=begin\n\n\n8 3\n\n1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9 0 1 2 3 4 5\n x x\n=end\n"}, {"source_code": "n, m = gets.split(/\\s+/).map(&:to_i)\na = n\n\nwhile n >= m\n a += n/m\n n /= m\nend\n\np a\n"}, {"source_code": "n,m=gets.split.map(&:to_i)\n\nx=(m*n)/(m-1)\nif (x==n+x/m)\n puts x\nelse\n puts x-1\nend"}, {"source_code": "n, m = gets.split(' ').map(&:to_i)\n\nresult = n\nwhile n > 0\n n /= m\n result += n\nend\n\nputs result\n"}, {"source_code": "n, m = gets.split(' ').map(&:to_i)\n\nresult = n\nwhile n > 0\n result += n % m\n n /= m\n result += n\nend\n\nputs result - 1\n"}, {"source_code": "\n\na, b = gets.split.map(&:to_i)\na -= 1\n\n(1..100000).each do |i|\n #puts \"day #{i} socks #{a}\"\n if a == 0\n puts i\n break\n end\n a -= 1\n if (i-1) % b == 0\n a += 1\n end\n\nend\n\n\n\n"}, {"source_code": "\n\na, b = gets.split.map(&:to_i)\n\n\n(1..100000).each do |i|\n if a == 0\n puts i\n break\n end\n\n a -= 1\n\n if (i-1)%b == 0 && i != 1\n a += 1\n end\n\n\nend\n\n\n\n"}, {"source_code": "\n\na, b = gets.split.map(&:to_i)\n\nif a == 1\n\n puts \"1\"\n\nelse\n\n a -= 1\n (1..100000).each do |i|\n #puts \"day #{i} socks #{a}\"\n if a == 0\n puts i\n break\n end\n a -= 1\n if (i-1) % b == 0\n a += 1\n end\n\n end\n\nend\n\n\n\n"}, {"source_code": "#!/usr/bin/env ruby\n\nn = ARGV[0].to_i\nm = ARGV[1].to_i\n\nday = 0\n\nwhile n > 0\n day += 1\n n -= 1 unless day%m==0\nend\n\nputs day\n"}, {"source_code": "n,m = gets.split.map{|r| r.to_i}\n\nfor i in 1..n\n if i%m == 0\n n+=1\n end\nend\nputs n\n\n"}, {"source_code": "n,m = gets.split.map{|r| r.to_i}\n\nfor i in 1..n\n if i%m == 0\n n+=1\n end\nend\nputs n+1\n\n"}, {"source_code": "a, b = gets.split.map &:to_i\nif a < b \n puts a\n exit\nend\ntotal = a\nwhile a != 1\n total += a % b == 0 ? a / b : a / b + 1\n a /= b\nend\nputs total\n"}, {"source_code": "a, b = gets.split.map &:to_i\ntotal = a\nwhile a / b > 0\n total += a / b\n if a % b == 0\n a = a / b\n else\n a = a / b + 1\n end\nend\nputs total\n"}, {"source_code": "a, b = gets.split.map &:to_i\nputs a + (a + a / b) / b\n"}], "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0"} {"source_code": "require 'prime'\nn,k=gets.split.map(&:to_i)\na=n.prime_division.flat_map{|n,p|[n]*p}\nputs a.size0\n p*=3\nend\nif n%p>0\n p n/p+1\nelse\n p 1\nend"}, {"source_code": "n=gets.to_i\nn/=3 while n%3==0\np (n+2)/3"}, {"source_code": "n=gets.to_i\nn/=3 while n%3==0\np (n+2)/3\n"}, {"source_code": "a = gets.to_i.to_s(3)\na.chop! while a[-1, 1] == '0'\nputs a.chop!.to_i(3) + 1"}, {"source_code": "a = gets.to_i.to_s(3).split('')\na.pop while a.last == '0'\na.pop\nputs a.join.to_i(3) + 1"}, {"source_code": "a = gets.to_i\na /= 3 while a%3 == 0\nputs a/3+1"}, {"source_code": "n=gets.to_i\nn/=3 while n%3==0\np (n+2)/3\n"}, {"source_code": "n=gets.to_i\nn/=3 while n%3==0\np (n+2)/3"}], "negative_code": [{"source_code": "p gets.to_i/3+1"}, {"source_code": "p (gets.to_i+1)/3"}, {"source_code": "p (gets.to_i/3.0).ceil"}, {"source_code": "p (gets.to_i+2)/3"}, {"source_code": "n = gets.to_i\nt = 1\nwhile n%t==0\n t *= 3\nend\nans = n/t+n%t\nputs ans\n"}, {"source_code": "#!/usr/bin/env ruby\nn = gets.to_i\nk = 0\nloop do\n if n % (3**k) != 0\n puts((n / (3.0**k)).ceil)\n break\n end\n k += 1\nend\n"}], "src_uid": "7e7b59f2112fd200ee03255c0c230ebd"} {"source_code": "#bismillahir rahmanir rahim \n\nn,k = gets.split.map {|x| x.to_i } \n\nk = 240-k \nc = 0 \n\nfor i in 1..10 \n q = 5*i*(i+1)\n q = q/2 \n if k>=q \n c = c+1 \n end \nend \n\nc=n if c>n \n\nputs c ", "positive_code": [{"source_code": "n,k=gets.split.map &:to_i\nk=240-k\nres=0\nwhile res=5*(res+1)\n res+=1\n k-=5*res;\nend\nputs res\n"}, {"source_code": "nk = gets.chomp\nnk = nk.split\nproblems = nk[0].to_i\nminutes = nk[1].to_i\n\nsolved = 0\nfor i in (1..problems)\n\tif minutes + (i * 5) <= 240\n\t\tminutes += (i*5)\n\t\tsolved += 1\n\telse\n\t\tbreak\n\tend\nend\n\nprint solved"}, {"source_code": "n, k = gets.split.map(&:to_i)\nc = 0\nt = 60 * 4 - k\nwhile t >= (c + 1) * 5 && c < n\n c += 1\n t -= c * 5\nend\nputs c\n"}, {"source_code": "n, k = gets.split(' ').map(&:to_i)\nk = 240 - k\n\nresult = n\n\n1.upto(n) do |x|\n if (1..x).inject(&:+)*5 > k\n result = x-1\n break\n end\nend\n\nputs result\n"}, {"source_code": "n, k = gets.chomp.split().map { |x| x.to_i }\n\ndef cuadratic( d )\n return ( -5 + Math.sqrt( 25 + 40*d ) ) / 10\nend\n\nputs [ cuadratic(240-k).to_i, n ].min\n"}, {"source_code": "n,k=gets.split.map &:to_i\nk=240-k\np ((1..n).find{|i|5*i*(i+1)/2>k}||n+1)-1"}, {"source_code": "n, k = gets.chomp.split.map(&:to_i)\nt = 240 - k\nidx = 0\nsum = 0\n(1..n).each do |i|\n sum += i * 5\n if sum <= t\n idx = i\n else\n break\n end\nend\nputs idx\n"}, {"source_code": "n,k = gets.split().map(&:to_i)\ni = 0\nt = 0\nuntil t > 240-k\n\ti += 1\n\tt += i*5\nend\n\nputs [i-1,n].min"}, {"source_code": "n,k = gets.split.map &:to_i \navailable_time = 240-k \ncounter = 0 \nproblem = 1 \nn.times do \n time_taken = problem * 5\n available_time-= time_taken \n if available_time >=0 then \n problem+=1 \n counter +=1\n else \n break \n end \nend \nputs counter \n\n \n \n "}, {"source_code": "n, k = gets.split.map(&:to_i)\n\nrem = 240 - k\n\nans = 0\n(1..n).each do |i|\n rem -= i * 5\n if rem < 0\n break\n end\n ans += 1\nend\nputs ans"}, {"source_code": "total_time = 4 * 60\nn, k = gets.strip.split.map(&:to_i)\ntotal_time -= k\ntime = 0\nans = 0\n(1..n).each do |i|\n curr_time = 5 * i\n break if time + curr_time > total_time\n ans += 1\n time += curr_time\nend\nputs ans\n"}, {"source_code": "n,m=gets.split.map{|e| e.to_i}\nm=240-m\nans=0\nsum=0\nn.times{|i|\n\tsum+=((i+1)*5)\n\tbreak if sum>m\n\tans+=1\n}\nputs ans\n\n"}, {"source_code": "n, k = gets.split.map(&:to_i)\nk = 240 - k\n1.upto(n) do |i|\n\tk -= i * 5 \n\tif k < 0 \n\t\tputs i - 1\n\t\tbreak\n\tend\nend\nif k >= 0\n\tputs n\nend\n"}], "negative_code": [{"source_code": "n, k = gets.split.map(&:to_i)\n\nrem = 240 - k\n\nans = 0\n(1..n).each do |i|\n if rem <= 0\n break\n end\n rem -= i * 5\n ans += 1\nend\nputs ans"}, {"source_code": "n, k = gets.split.map(&:to_i)\n\nrem = 240 - k\n\nans = 0\n(1..n).each do |i|\n rem -= i * 5\n if rem <= 0\n break\n end\n ans += 1\nend\nputs ans"}, {"source_code": "total_time = 4 * 60\nn, k = gets.strip.split.map(&:to_i)\ntotal_time -= k\ntime = 5\nans = 0\n(1..n).each do |i|\n curr_time = 5 * i\n ans += 1\n break if time + curr_time > total_time\n time += curr_time\nend\nputs ans\n"}, {"source_code": "n, k = gets.split.map(&:to_i)\nc = 0\nt = 60 * 4 - k\nwhile t > (c + 1) * 5 && c < n\n c += 1\n t -= c * 5\nend\nputs c\n"}], "src_uid": "41e554bc323857be7b8483ee358a35e2"} {"source_code": "l,r=gets.split.map &:to_i\na=l+l%2\nputs a+2<=r ?[a,a+1,a+2].join(\" \") :-1\n", "positive_code": [{"source_code": "l,r=gets.split.map &:to_i\na=l+l%2\nputs a+2<=r ?[a,a+1,a+2].join(\" \") :-1\n"}, {"source_code": "l,r=gets.split.map &:to_i\na=l+l%2\nputs a+2<=r ?[a,a+1,a+2].join(\" \") :-1\n"}, {"source_code": "l,r=gets.split.map &:to_i\na=l+l%2\nputs a+2<=r ?[a,a+1,a+2].join(\" \") :-1"}, {"source_code": "l,r=gets.chomp.split.map(&:to_i)\nif l==r\n\tputs \"-1\"\n\texit\nend\nwhile lr\n\t\tputs \"-1\"\n\t\tbreak\n\telse\n\t\tputs l.to_s+' '+(l+1).to_s+' '+(l+2).to_s\n\t\tbreak\n\tend\nend"}, {"source_code": "l,r=gets.split.map &:to_i\na=l+l%2\nputs a+2<=r ?[a,a+1,a+2].join(\" \") :-1\n"}, {"source_code": "l,r=gets.split.map &:to_i\na=l+l%2\nputs a+2<=r ?[a,a+1,a+2].join(\" \") :-1\n"}, {"source_code": "l, r = gets.chomp.split(/ /).map(&:to_i)\nif (l % 2 != 0)\n l += 1\nend\nif (l + 2 > r)\n puts \"-1\"\nelse\n puts \"#{l} #{l + 1} #{l + 2}\"\nend\n"}, {"source_code": "def test(l,r)\nl.upto(r-2){|a|\n\t(a+1).upto(r-1){|b|\n\t\tnext if a.gcd(b)!=1\n\t\t(b+1).upto(r){|c|\n\t\t\tnext if b.gcd(c)!=1\n\t\t\tnext if a.gcd(c)==1\n\t\t\treturn [a,b,c]\n\t\t}\n\t}\n}\nreturn [-1]\nend\nl,r=gets.split.map{|e| e.to_i}\nputs test(l,r)*\" \"\n\n"}, {"source_code": "# coding: utf-8\n\nl, r = gets.split.map(&:to_i)\n\ndef euclidean(a, b)\n while b > 0\n c = a % b\n a = b\n b = c\n end\n \n a\nend\n# counter example\n# if (a,b) is coprime and (b, c) is coprime, then (a,c) is also coprime\n# if possible, print a b c\n# if not possible, print -1\n# l과 r사이 간격은 최대 50\nif r - l < 2\n puts \"-1\"\nelse\n # 두 수의 관계이므로 유클리드 호제법을 이용한다\n # 나눠 떨어지는 시점이 최대공약수(GCD)인데 1이 나오면 서로소이다.\n printed = false\n\n catch :found do\n for a in l...r\n for b in (a+1)...r\n for c in (b+1)..r\n if euclidean(a, b) == 1 && euclidean(b, c) == 1 && euclidean(a, c) != 1\n puts \"#{a} #{b} #{c}\"\n printed = true\n throw :found\n end\n end\n end\n end\n end \n\n if !printed\n puts \"-1\"\n end\nend\n"}, {"source_code": "def isCoprime(a,b)\n if b != 0\n return isCoprime(b,a%b)\n end\n return (a == 1)\nend\n\ndef counter(l, r)\n for a in (l..r+1)\n for b in (a+1)..(r)\n for c in (b+1)..(r)\n if isCoprime(a,b)\n if isCoprime(b,c)\n unless isCoprime(a,c)\n return \"#{a} #{b} #{c}\"\n end\n end\n end\n end\n end\n end\n -1\nend\n\nl, r = gets.chomp.split\nl = l.to_i\nr = r.to_i\n\nprint counter(l, r)\n"}, {"source_code": "l,r=gets.split.map &:to_i\na=l+l%2\nputs a+2<=r ?[a,a+1,a+2].join(\" \") :-1\n"}, {"source_code": "def gcd(a,b)\nif b == 0\n return a;\nelse\n return gcd(b, a % b);\nend\nend\n\n\ncoprime = false\nreq_a = 0\nreq_b = 0\nreq_c = 0\nl,h = gets.split(\" \").map(&:to_i)\n(l..h).each do |a|\n (a+1..h).each do |b|\n (b+1..h).each do |c|\n # puts \"#{a} #{b} #{c}\"\n # puts \"#{gcd(b,a)} #{gcd(c,b)} #{gcd(c,a)}\"\n if gcd(a,b) == 1 && gcd(b,c) == 1 && gcd(a,c) != 1\n req_a = a\n req_b = b\n req_c = c\n coprime = true\n break\n end\n\n end\n break if coprime\n end\n break if coprime\nend\n\nputs coprime ? \"#{req_a} #{req_b} #{req_c}\" :-1\n"}, {"source_code": "=begin\ndata = gets.chomp.split(/\\s/).map {|n| n.to_i}\n#p data\nputs data.inject(:+) / data.length\n=end\n\n\ndef nod(x,y)\n if x == y\n return x\n end\n if x == 0\n return y\n end\n if y == 0\n return x\n end\n if x > y\n return nod(y, x % y)\n else\n return nod(x, y % x)\n end\nend\n\n\ndata = gets.chomp.split(/\\s/).map{|n| n.to_i}\nl = data[0]\nr = data[1]\n\na = l\nb = a + 1\nc = b + 1\nres = -1\n\nwhile a < r - 1\n b = a + 1\n while b < r\n c = b + 1\n while c <= r\n if nod(a, b) == 1 && nod(b,c) == 1 && nod(a,c) > 1\n puts \"#{a} #{b} #{c}\"\n exit\n end\n c += 1\n end\n b += 1\n end\n a += 1\nend\n\nputs \"#{-1}\" if res <= 0\n\n\n"}, {"source_code": "#require 'prime'\ndef coprime?(a, b)\n a.gcd(b).equal?(1)\nend\nl, r = gets.chomp.split.map(&:to_i)\na = 0\nb = 0\nc = 0\nfor i in l...r\n a = i\n b = 0\n c = 0\n for j in (i + 1)..r\n b = j if coprime?(a, j) && b == 0\n# print \"a = #{a}, b = #{b}, c = #{c}\\n\"\n for k in (j + 1)..r\n if coprime?(b, k) && c == 0 && (coprime?(a, c) != true)\n c = k\n# print \"a = #{a}, b = #{b}, c = #{c}\\n\"\n break\n end\n end\n break if c != 0\n b = 0\n# print \"a = #{a}, b = #{b}, c = #{c}\\n\"\n end\n break if coprime?(a, c) == false\nend\nif a == 0 || b == 0 || c == 0\n puts -1\nelse\n puts [a, b, c].join(\" \")\nend\n#p Prime.prime?(3)\n#p coprime?(3, 4)\n#p coprime?(900000000000000010, 900000000000000011)\n#p coprime?(900000000000000011, 900000000000000012)\n#p coprime?(900000000000000010, 900000000000000012)\n\n"}, {"source_code": "l,r=gets.split.map &:to_i\na=l+l%2\nputs a+2<=r ?[a,a+1,a+2].join(\" \") :-1"}, {"source_code": "l,r=gets.split.map &:to_i\na=l+l%2\nputs a+2<=r ?[a,a+1,a+2].join(\" \") :-1\n"}, {"source_code": "l, r = gets.split.map {|i| i.to_i}\nif r - l == 2 && l % 2 == 1 || r - l < 2\n puts -1\nelse\n if l % 2 == 1\n l += 1\n end\n puts l.to_s + ' ' + (l + 1).to_s + ' ' + (l + 2).to_s\nend"}, {"source_code": "l,r=gets.split.map &:to_i\na=l+l%2\nputs a+2<=r ?[a,a+1,a+2].join(\" \") :-1\n"}, {"source_code": "l,r=gets.split.map &:to_i\na=l+l%2\nputs a+2<=r ?[a,a+1,a+2].join(\" \") :-1"}], "negative_code": [{"source_code": "l,r=gets.chomp.split.map(&:to_i)\nwhile lr\n\t\tputs \"-1\"\n\t\tbreak\n\telse\n\t\tputs l.to_s+' '+(l+1).to_s+' '+(l+2).to_s\n\t\tbreak\n\tend\nend"}, {"source_code": "# coding: utf-8\n\nl, r = gets.split.map(&:to_i)\n\ndef euclidean(a, b)\n while b > 0\n c = a % b\n a = b\n b = c\n end\n \n a\nend\n# counter example\n# if (a,b) is coprime and (b, c) is coprime, then (a,c) is also coprime\n# if possible, print a b c\n# if not possible, print -1\n# l과 r사이 간격은 최대 50\nif r - l < 2\n puts \"-1\"\nelse\n # 두 수의 관계이므로 유클리드 호제법을 이용한다\n # 나눠 떨어지는 시점이 최대공약수(GCD)인데 1이 나오면 서로소이다.\n printed = false\n\n for i in (l+1)...r\n if euclidean(l, i) == 1 && euclidean(i, r) == 1 && euclidean(l, r) != 1\n puts \"#{l} #{i} #{r}\"\n printed = true\n break\n end\n end\n\n if !printed\n puts \"-1\"\n end\nend\n"}, {"source_code": "# coding: utf-8\n\nl, r = gets.split.map(&:to_i)\n\ndef euclidean(a, b)\n while b > 0\n c = a % b\n a = b\n b = c\n end\n \n a\nend\n# counter example\n# if (a,b) is coprime and (b, c) is coprime, then (a,c) is also coprime\n# if possible, print a b c\n# if not possible, print -1\n# l과 r사이 간격은 최대 50\nif r - l < 2\n puts \"-1\"\nelse\n # 두 수의 관계이므로 유클리드 호제법을 이용한다\n # 나눠 떨어지는 시점이 최대공약수(GCD)인데 1이 나오면 서로소이다.\n printed = false\n\n catch :found do\n for a in l...r\n for b in (a+1)...r\n for c in (b+1)...r\n if euclidean(a, b) == 1 && euclidean(b, c) == 1 && euclidean(a, c) != 1\n puts \"#{a} #{b} #{c}\"\n printed = true\n throw :found\n end\n end\n end\n end\n end \n\n if !printed\n puts \"-1\"\n end\nend\n"}, {"source_code": "=begin\ndata = gets.chomp.split(/\\s/).map {|n| n.to_i}\n#p data\nputs data.inject(:+) / data.length\n=end\n\n\ndef nod(x,y)\n if x == y\n return x\n end\n if x == 0\n return y\n end\n if y == 0\n return x\n end\n if x > y\n return nod(y, x % y)\n else\n return nod(x, y % x)\n end\nend\n\n\ndata = gets.chomp.split(/\\s/).map{|n| n.to_i}\nl = data[0]\nr = data[1]\n\n\na = l\nb = a + 1\n\nres = -1\n\nwhile res < 0 && b <= r\n if nod(a, b) == 1\n res = 0\n else\n b += 1\n end\nend\n\nc = b + 1\n\nwhile res == 0 && c <=r\n if nod(b,c) == 1 && nod(a,c) > 1\n res = 1\n else\n c += 1\n end\nend\n\nif res <= 0\n puts -1\nelse\n puts \"#{a} #{b} #{c}\"\nend\n\n\n"}, {"source_code": "=begin\ndata = gets.chomp.split(/\\s/).map {|n| n.to_i}\n#p data\nputs data.inject(:+) / data.length\n=end\n\n\ndef nod(x,y)\n if x == y\n return x\n end\n if x == 0\n return y\n end\n if y == 0\n return x\n end\n if x > y\n return nod(y, x % y)\n else\n return nod(x, y % x)\n end\nend\n\n\ndata = gets.chomp.split(/\\s/).map{|n| n.to_i}\nl = data[0]\nr = data[1]\n\n\na = l\nb = a + 1\nc = b + 1\nres = -1\n\nwhile res < 0 && b <= r\n if nod(a, b) == 1\n res = 0\n else\n b += 1\n end\nend\n\nwhile res == 0 && c <=r\n if nod(b,c) == 1 && nod(a,c) > 1\n res = 1\n else\n c += 1\n end\nend\n\nif res < 0\n puts -1\nelse\n puts \"#{a} #{b} #{c}\"\nend\n\n\n"}, {"source_code": "=begin\ndata = gets.chomp.split(/\\s/).map {|n| n.to_i}\n#p data\nputs data.inject(:+) / data.length\n=end\n\n\ndef nod(x,y)\n if x == y\n return x\n end\n if x == 0\n return y\n end\n if y == 0\n return x\n end\n if x > y\n return nod(y, x % y)\n else\n return nod(x, y % x)\n end\nend\n\n\ndata = gets.chomp.split(/\\s/).map{|n| n.to_i}\nl = data[0]\nr = data[1]\n\n\na = l\nb = a + 1\nc = b + 1\nres = -1\n\nwhile res < 0 && b <= r\n if nod(a, b) == 1\n res = 0\n else\n b += 1\n end\nend\n\nwhile res == 0 && c <=r\n if nod(b,c) == 1 && nod(a,c) > 1\n res = 1\n else\n c += 1\n end\nend\n\nif res <= 0\n puts -1\nelse\n puts \"#{a} #{b} #{c}\"\nend\n\n\n"}, {"source_code": "=begin\ndata = gets.chomp.split(/\\s/).map {|n| n.to_i}\n#p data\nputs data.inject(:+) / data.length\n=end\n\n\ndef nod(x,y)\n if x == y\n return x\n end\n if x == 0\n return y\n end\n if y == 0\n return x\n end\n if x > y\n return nod(y, x % y)\n else\n return nod(x, y % x)\n end\nend\n\n\ndata = gets.chomp.split(/\\s/).map{|n| n.to_i}\nl = data[0]\nr = data[1]\n\n\na = l\nb = a + 1\n\nres = -1\n\nwhile res < 0 && b <= r\n if nod(a, b) == 1\n res = 0\n else\n b += 1\n end\nend\n\nc = b + 1\n\nwhile res == 0 && c <=r\n if nod(b,c) == 1 && nod(a,c) > 1\n res = 1\n else\n c += 1\n end\nend\n\nif res <= 0\n puts \"#{-1}\"\nelse\n puts \"#{a} #{b} #{c}\"\nend\n\n\n"}, {"source_code": "=begin\ndata = gets.chomp.split(/\\s/).map {|n| n.to_i}\n#p data\nputs data.inject(:+) / data.length\n=end\n\n\ndef nod(x,y)\n if x == y\n return x\n end\n if x == 0\n return y\n end\n if y == 0\n return x\n end\n if x > y\n return nod(y, x % y)\n else\n return nod(x, y % x)\n end\nend\n\n\ndata = gets.chomp.split(/\\s/).map{|n| n.to_i}\nl = data[0]\nr = data[1]\n\n\na = l\nb = a + 1\nc = b + 1\nres = -1\nwhile res < 0 && c <=r\n if nod(a,b) == 1 && nod(b,c) == 1 && nod(a,c) > 1\n res = 1\n else\n c += 1\n end\nend\n\nif res < 0\n puts -1\nelse\n puts \"#{a} #{b} #{c}\"\nend\n\n\n"}, {"source_code": "#require 'prime'\ndef coprime?(a, b)\n a.gcd(b).equal?(1)\nend\nl, r = gets.chomp.split.map(&:to_i)\nfor i in l...r\n a = i\n b = 0\n c = 0\n for j in (i + 1)..r\n if coprime?(a, j) && b == 0\n b = j\n elsif coprime?(b, j) && c == 0\n c = j if c == 0\n end\n c = 0 if coprime?(a, c)\n end\n break if coprime?(a, c) == false\nend\nif a == 0 || b == 0 || c == 0\n puts -1\nelse\n puts [a, b, c].join(\" \")\nend\n#p Prime.prime?(3)\n#p coprime?(3, 4)\n"}, {"source_code": "#require 'prime'\ndef coprime?(a, b)\n a.gcd(b).equal?(1)\nend\nl, r = gets.chomp.split.map(&:to_i)\na = 0\nb = 0\nc = 0\nfor i in l...r\n a = i\n b = 0\n c = 0\n for j in (i + 1)..r\n b = j if coprime?(a, j) && b == 0\n# print \"a = #{a}, b = #{b}, c = #{c}\\n\"\n for k in (j + 1)..r\n if coprime?(b, k) && c == 0 && (coprime?(a, c) != true)\n c = k\n print \"a = #{a}, b = #{b}, c = #{c}\\n\"\n break\n end\n end\n break if c != 0\n b = 0\n# print \"a = #{a}, b = #{b}, c = #{c}\\n\"\n end\n break if coprime?(a, c) == false\nend\nif a == 0 || b == 0 || c == 0\n puts -1\nelse\n puts [a, b, c].join(\" \")\nend\n#p Prime.prime?(3)\n#p coprime?(3, 4)\np coprime?(900000000000000010, 900000000000000011)\np coprime?(900000000000000011, 900000000000000012)\np coprime?(900000000000000010, 900000000000000012)\n\n"}, {"source_code": "#require 'prime'\ndef coprime?(a, b)\n a.gcd(b).equal?(1)\nend\nl, r = gets.chomp.split.map(&:to_i)\na = 0\nb = 0\nc = 0\nfor i in l...r\n a = i\n b = 0\n c = 0\n for j in (i + 1)..r\n b = j if coprime?(a, j) && b == 0\n# print \"a = #{a}, b = #{b}, c = #{c}\\n\"\n for k in (j + 1)..r\n if coprime?(b, k) && c == 0\n c = k if c == 0\n# print \"a = #{a}, b = #{b}, c = #{c}\\n\"\n end\n c = 0 if coprime?(a, c)\n end\n b = 0 if coprime?(a, c) || c == 0\n# print \"a = #{a}, b = #{b}, c = #{c}\\n\"\n end\n break if coprime?(a, c) == false\nend\nif a == 0 || b == 0 || c == 0\n puts -1\nelse\n puts [a, b, c].join(\" \")\nend\n#p Prime.prime?(3)\n#p coprime?(3, 4)\n"}, {"source_code": "#require 'prime'\ndef coprime?(a, b)\n a.gcd(b).equal?(1)\nend\nl, r = gets.chomp.split.map(&:to_i)\nfor i in l...r\n a = i\n b = 0\n c = 0\n for j in (i + 1)..r\n b = j if coprime?(a, j) && b == 0\n# print \"a = #{a}, b = #{b}, c = #{c}\\n\"\n for k in (j + 1)..r\n if coprime?(b, k) && c == 0\n c = k if c == 0\n# print \"a = #{a}, b = #{b}, c = #{c}\\n\"\n end\n c = 0 if coprime?(a, c)\n end\n end\n break if coprime?(a, c) == false\nend\nif a == 0 || b == 0 || c == 0\n puts -1\nelse\n puts [a, b, c].join(\" \")\nend\n#p Prime.prime?(3)\n#p coprime?(3, 4)\n"}, {"source_code": "#require 'prime'\ndef coprime?(a, b)\n a.gcd(b).equal?(1)\nend\nl, r = gets.chomp.split.map(&:to_i)\nfor i in l...r\n a = i\n b = 0\n c = 0\n for j in (i + 1)..r\n b = j if coprime?(a, j) && b == 0\n# print \"a = #{a}, b = #{b}, c = #{c}\\n\"\n for k in (j + 1)..r\n if coprime?(b, k) && c == 0\n c = k if c == 0\n# print \"a = #{a}, b = #{b}, c = #{c}\\n\"\n end\n c = 0 if coprime?(a, c)\n end\n b = 0 if coprime?(a, c) || c == 0\n end\n break if coprime?(a, c) == false\nend\nif a == 0 || b == 0 || c == 0\n puts -1\nelse\n puts [a, b, c].join(\" \")\nend\n#p Prime.prime?(3)\n#p coprime?(3, 4)\n"}], "src_uid": "6c1ad1cc1fbecff69be37b1709a5236d"} {"source_code": "DBG = !true\nn,m = gets.split.map{|z| z.to_i}\na = gets.split.map{|z| z.to_i}\n\ndef f(n)\n return (n-1)*n/2\nend\ndef g(n,t)\n if DBG\n puts \"n #{n} t #{t} fnt1 #{f(n/t+1)} fnt #{f(n/t)}\"\n end\n return (n%t)*f(n/t + 1) + (t - n%t)*f(n/t)\nend\n\na.sort_by!{|z| -z} # decreasing order\nasum = [a[0]]\nfor i in 1...n\n asum << asum[i-1] + a[i]\nend\nif DBG\n puts \"n #{n} m #{m} asum #{asum}\"\nend\nfor t in 1..n\n for i in 1..n\n if asum[i-1] - g(i,t) >= m\n puts \"#{t}\"\n exit 0\n end\n end\nend\nputs \"#{-1}\"\n", "positive_code": [{"source_code": "n, m = gets.split.map(&:to_i)\na = gets.split.map(&:to_i).sort.reverse\n\nputs (1..n).bsearch { |day|\n\t\tminus, cnt = 0, 0\n\t\t(0...n).sum { |i|\n\t\t\tres = [0, a[i] - minus].max\n\t\t\tcnt += 1\n\t\t\tif cnt == day\n\t\t\t\tminus += 1\n\t\t\t\tcnt = 0\n\t\t\tend\n\t\t\tres\n\t\t} >= m\n } || -1\n"}], "negative_code": [], "src_uid": "acb8a57c8cfdb849a55fa65aff86628d"} {"source_code": "#!/usr/bin/ruby\n\nn = gets.chomp.to_i\na = gets.chomp.split(\" \")\n\na.each do |i|\n i = i.to_i\nend\n\nisSwap = true\nwhile isSwap do\n isSwap = false\n for i in 0..(n-1)\n if a[i].to_i > a[i+1].to_i then\n a[i], a[i+1] = a[i+1], a[i]\n isSwap = true\n end\n end\nend\n\na.each do |i|\n print \"#{i} \"\nend\n", "positive_code": [{"source_code": "gets\nputs gets.chomp.split(\" \").map(&:to_i).sort.join(\" \")"}, {"source_code": "gets; puts gets.split.map(&:to_i).sort.join(' ')"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort.join(\" \")"}, {"source_code": "b = gets\na = gets.split(\" \").map(&:to_i).sort\nresult = a.join(\" \")\nprint result"}, {"source_code": "columns = gets.to_i\nboard = gets.split.map(&:to_i)\nboard.sort!\n\nresult = \"\"\nfor i in (0..board.length-1)\n\tif i == board.length-1\n\t\tresult = result + board[i].to_s\n\telse\n\t\tresult = result + board[i].to_s + \" \"\n\tend\nend\n\nputs result"}, {"source_code": "n=gets.to_i;puts gets.split.map(&:to_i).sort"}, {"source_code": "# http://codeforces.com/problemset/problem/405/A\n\nn = $stdin.gets.chomp.to_i\na = $stdin.gets.chomp.split.map { |v| v.to_i }\n\na.sort!.each { |e| print \"#{e} \"}\nprint \"\\n\"\n"}, {"source_code": "n=gets.to_i\na=gets\na=a.split(' ')\nfor i in 0..n-1\n a[i]=a[i].to_i\nend\na=a.sort\nfor i in 0..n-1\n print\"#{a[i]} \"\nend\n\n"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort\n"}, {"source_code": "gets\nputs gets.split(' ').map(&:to_i).sort.join(' ')\n"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort"}, {"source_code": "def read_next_line\n gets.chomp.split.map(&:to_i)\nend\n\ngets\nputs read_next_line.sort * ' '"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort\n"}, {"source_code": "gets\ngets.chomp.split.map(&:to_i).sort.map{|x|print x.to_s+ ' '}"}, {"source_code": "n = gets().to_i\narr = gets.split.map(&:to_i)\narr = arr.sort\nfor i in 0..n-1\n print arr[i].to_s+\" \"\nend\n"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort\n"}, {"source_code": "n = gets.to_i\n\n#puts n\n\ns = gets.split.map(&:to_i)\n\ns = s.sort\n\nn.times do\n print s.shift\n print s.length == 0 ? \"\\n\" : \" \"\nend\n"}, {"source_code": "n = gets.to_i\nputs gets.split(' ',n).map(&:to_i).sort.map(&:to_s).join(' ')"}, {"source_code": "gets; puts gets.split.map(&:to_i).sort.join(' ')"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort*' '"}, {"source_code": "g = gets.chomp\narr = gets.chomp.split(\" \").map {|x| x.to_i}.sort.map {|x| x.to_s}.join(' ')\nputs arr\n"}, {"source_code": "gets\nputs gets.chomp.split.map(&:to_i).sort\n"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort\n"}, {"source_code": "n=gets.to_i;puts gets.split.map(&:to_i).sort"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort\n"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort\n"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort.join(\" \")"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort"}, {"source_code": "#$stdin.reopen('/home/chen/Desktop/input.txt', 'r')\n\n\nn= gets.to_i\n\narray = gets.split.map(&:to_i).sort\n\nflag = 1\narray.each do |e|\n\t\n\tif flag!=0\n\t\tprint e\n\t\tflag = 0\n\telse\n\t\tprint(\" #{e}\")\n\tend\nend\nputs\n"}, {"source_code": "n = gets.strip.to_i\narr = gets.strip.split(\" \").map(&:to_i)\narr.sort!\nputs arr.join(\" \")"}, {"source_code": "n = gets.to_i\nputs gets.split.map(&:to_i).sort"}, {"source_code": "require 'matrix'\n\n$stdin.readline\nf = $stdin.readline.split.map(&:to_i)\nm = f.count\n\nn = f.max\ncols = f.collect do |c| \n _ones = c\n _zeros = n-c\n _t = [1]*(_ones)\n _t = _t + (_zeros>0 ? [0]*_zeros : [])\n _t\nend\n\n#puts \"cols=#{cols.inspect}\"\n\nbox = Matrix.columns(cols)\n\nrows = []\n\n(0...n).each {|i| rows << box.row(i).to_a}\n\n#puts \"rows=#{rows.inspect}\"\n\ncompact_rows = rows.collect do |row|\n _t = row - [0]\n _n = _t.count\n _zeros = m - _n\n if _zeros>0\n _t = ([0]*_zeros) + _t\n end\n _t\nend\n\n#puts \"compact_rows=#{compact_rows.inspect}\"\n\nbox2 = Matrix.rows(compact_rows)\n\n#p box2\n\n(0...m).each do |i| \n _t = (box2.column(i).to_a - [0]).count\n print \"#{_t} \" if _t>0\nend"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort.join(' ')\n"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort.join(\" \")\n"}, {"source_code": "n = gets.to_i \narr = gets.split(\" \").map(&:to_i) \narr.sort! \nputs arr.join(' ')"}, {"source_code": "gets\ngets.split.map { |x| x.to_i }.sort.each { |x| print \"#{x} \" }\n"}, {"source_code": "n = gets.to_i\na = gets.split(' ').map { |e| e = e.to_i }\n\na.sort!\nputs a.join(' ')"}, {"source_code": "class A\n def initialize\n n = gets.chomp.to_i\n list = gets.chomp.split(' ').map(&:to_i)\n\n puts list.sort.join(' ')\n end\nend\n\nA.new"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort\n"}, {"source_code": "n = gets.to_i\nputs gets.split(' ').sort_by{ |x| x.to_i}.join(' ')\n"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort\n"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort*' '"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort"}, {"source_code": "gets\nputs (gets.split.map{|e| e.to_i}.sort)*\" \"\n\n"}, {"source_code": "gets\ncols = gets.split.map(&:to_i)\n\nrows = (1..cols.max).map { |height| cols.count { |col| col >= height } }\n\nans = (1..cols.size).map { |wid| rows.count { |row| row >= wid } }.reverse\n\nputs ans.join ' '\n"}, {"source_code": "n = gets.chomp.to_i\narr = gets.chomp.split.map(&:to_i)\n\nputs arr.sort.join(' ')\n"}, {"source_code": "gets\na = gets.split.map { |e| e.to_i }\na.sort!\na.each do |i|\n\tprint \"#{i} \"\nend"}, {"source_code": "puts [*$<][1].split.map(&:to_i).sort.join ' '\n"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort"}, {"source_code": "gets;puts gets.split.map(&:to_i).sort"}, {"source_code": "gets;puts(gets.split.map(&:to_i).sort*' ')"}, {"source_code": "amount = gets.chomp\nn = gets.chomp\ncolumns = n.split\n\nfor x in (1..amount.to_i)\n\tfor i in (1..amount.to_i-1)\n\t\tif columns[i-1].to_i > columns[i].to_i\n\t\t\ttemp = columns[i].to_i\n\t\t\tcolumns[i] = columns[i-1].to_i\n\t\t\tcolumns[i-1] = temp\n\t\tend\n\tend\nend\n\ncolumns.each do |column|\n\tprint column\n\tprint \" \"\nend"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort\n"}, {"source_code": "STDIN.readline\nprint STDIN.readline.split.map{ |x| x.to_i }.sort.join(' ')\n"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort.join(\" \")\n"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort"}, {"source_code": "gets\nputs gets.split.map(&:to_i).sort.join ' '"}, {"source_code": "n = gets.to_i\na = gets.split.map(&:to_i)\nputs a.sort.join(\" \")"}], "negative_code": [{"source_code": "gets\nputs gets.split.sort.join(\" \")\n"}, {"source_code": "n = gets.to_i\np gets.split.map(&:to_i).sort\n"}, {"source_code": "n = gets.to_i\nputs gets.split(' ').sort.join(' ')\n"}, {"source_code": "puts gets.split.map(&:to_i).sort.join(\" \")\n"}, {"source_code": "gets\nputs gets.chomp.split(\" \").sort.join(\" \")"}, {"source_code": "gets; gets.split.map(&:to_i).sort.join(' ')"}, {"source_code": "n=gets.to_i\na=gets\na=a.split(' ').sort\nfor i in 0..n-1\n print \"#{a[i]} \"\nend\n"}, {"source_code": "gets\ngets.chomp.split.sort.map{|x|print x+ ' '}"}, {"source_code": "gets\nprint gets.chomp.split.sort"}], "src_uid": "ae20712265d4adf293e75d016b4b82d8"} {"source_code": "def rot(a, t)\n b = a.dup\n t.each{|v|\n (0...v.size).each{|i|\n b[v[i-1]] = a[v[i]]\n }\n }\n return b\nend\n\ndef check(a)\n 6.times.map{|x| x*4}.all?{|x| (x...x+4).map{|i| a[i+1]}.uniq.size == 1}\nend\n\nlist = [\n [[2,6,10,23], [4,8,12,21], [18,17,19,20]],\n [[23,10,6,2], [21,12,8,4], [20,19,17,18]],\n [[1,18,12,15], [2,20,11,13], [22,21,23,24]],\n [[15,12,18,1], [13,11,20,2], [24,23,21,22]],\n [[1,2,4,3], [13,21,17,5], [14,22,18,6]],\n [[3,4,2,1], [5,17,21,13], [6,18,22,14]]\n]\n\n\ncube = [0] + gets.split.map(&:to_i)\n\n\nif list.any?{|l| check(rot(cube, l))}\n puts \"YES\"\nelse\n puts \"NO\"\nend", "positive_code": [{"source_code": "def judge(cube)\n 6.times do |i|\n if !(cube[4 * i] == cube[4 * i + 1] && cube[4 * i + 1] == cube[4 * i + 2] && cube[4 * i + 2] == cube[4 * i + 3])\n return false\n end\n end\n return true\nend\n\na1 = [0,2,4,6,8,10,23,21]\nb1 = [1,3,5,7,9,11,22,20]\na2 = [12,13,4,5,16,17,20,21]\nb2 = [14,15,6,7,18,19,22,23]\na3 = [2,3,16,18,9,8,15,13]\nb3 = [0,1,17,19,11,10,14,12]\n\ncube = gets.split.map(&:to_i)\nans = false\n\ntmp = Array.new(a1)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[a1[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b1)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[b1[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a2)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[a2[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b2)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[b2[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a3)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[a3[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b3)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[b3[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\n\ntmp = Array.new(a1)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[a1[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b1)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[b1[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a2)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[a2[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b2)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[b2[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a3)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[a3[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b3)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[b3[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\nputs ans ? \"YES\" : \"NO\""}, {"source_code": "POSSIBLES = [\n [[1, 2], [18, 20], [11, 12], [13, 15]],\n [[3, 4], [17, 19], [9, 10], [14, 16]],\n [[2, 4], [6, 8], [10, 12], [21, 23]],\n [[1, 3], [5, 7], [9, 11], [22, 24]],\n [[13, 14], [5, 6], [17, 18], [21, 22]],\n [[15, 16], [7, 8], [19, 20], [23, 24]],\n]\n\n\nFACES = [\n (1..4).to_a,\n (5..8).to_a,\n (9..12).to_a,\n (13..16).to_a,\n (17..20).to_a,\n (21..24).to_a,\n]\n\ndef check_solved(c)\n FACES.each do |face|\n return false unless face.map { |f| c[f] }.uniq.size == 1\n end\n true\nend\n\ndef solve(cube)\n # [[[2, 4], [6, 8], [10, 12], [21, 23]]].each_with_index do |possib|\n POSSIBLES.each_with_index do |possib|\n face_colors = possib.map { |p| cube[p.first] == cube[p.last] }\n next if face_colors.include?(false)\n colors = possib.map { |p| cube[p.first] }\n [possib.rotate(1), possib.rotate(-1)].each do |rot|\n c = cube.dup\n rot.each_with_index do |curr, i|\n c[curr.first] = colors[i]\n c[curr.last] = colors[i]\n end\n if check_solved(c)\n return \"YES\"\n end\n end\n end\n return \"NO\"\nend\n\n\n\ncube = {}\nvals = gets.strip.split.map(&:to_i)\n\nvals.each_with_index do |v, i|\n cube[i + 1] = v\nend\n\nputs solve(cube)\n"}, {"source_code": "def solve(a)\n\ttag = true\n\tj = 1\n\twhile(j<=21 && tag)\n\t\tif(a[j-1] == a[j]&& a[j]==a[j+1]&&a[j+1]==a[j+2])\n\t\t\tj += 4\n\t\t\tnext\n\t\tend\n\t\ttag = false\n\tend\n \treturn tag\nend\n\ntag = false\nn = gets.split(' ').map(&:to_i)\na = n.dup\ntemp1 = a[1-1]\ntemp2 = a[3-1]\na[1-1] = a[24-1]\na[3-1] = a[22-1]\na[24-1] = a[9-1] \na[22-1] = a[11-1]\na[9-1] = a[5-1]\na[11-1] = a[7-1]\na[5-1] = temp1\na[7-1] = temp2\nif solve a\n\ttag = true\nend\na = n.dup\ntemp1 = a[1-1]\ntemp2 = a[3-1]\na[1-1] = a[5-1]\na[3-1] = a[7-1]\na[5-1] = a[9-1] \na[7-1] = a[11-1]\na[9-1] = a[24-1]\na[11-1] = a[22-1]\na[24-1] = temp1\na[22-1] = temp2\nif solve a\n\ttag = true\nend\n\n\na = n.dup\ntemp1 = a[2-1]\ntemp2 = a[4-1]\na[2-1] = a[23-1]\na[4-1] = a[21-1]\na[23-1] = a[10-1] \na[21-1] = a[12-1]\na[10-1] = a[6-1]\na[12-1] = a[8-1]\na[6-1] = temp1\na[8-1] = temp2\nif solve a\n\ttag = true\nend\na = n.dup\ntemp1 = a[2-1]\ntemp2 = a[4-1]\na[2-1] = a[6-1]\na[4-1] = a[8-1]\na[6-1] = a[10-1] \na[8-1] = a[12-1]\na[10-1] = a[23-1]\na[12-1] = a[21-1]\na[23-1] = temp1\na[21-1] = temp2\nif solve a\n\ttag = true\nend\n\n\na = n.dup\ntemp1 = a[5-1]\ntemp2 = a[6-1]\na[5-1] = a[13-1]\na[6-1] = a[14-1]\na[13-1] = a[21-1] \na[14-1] = a[22-1]\na[21-1] = a[17-1]\na[22-1] = a[18-1]\na[17-1] = temp1\na[18-1] = temp2\nif solve a\n\ttag = true\nend\na = n.dup\ntemp1 = a[5-1]\ntemp2 = a[6-1]\na[5-1] = a[17-1]\na[6-1] = a[18-1]\na[17-1] = a[21-1] \na[18-1] = a[22-1]\na[21-1] = a[13-1]\na[22-1] = a[14-1]\na[13-1] = temp1\na[14-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\n\na = n.dup\ntemp1 = a[7-1]\ntemp2 = a[8-1]\na[7-1] = a[15-1]\na[8-1] = a[16-1]\na[15-1] = a[23-1] \na[16-1] = a[24-1]\na[23-1] = a[19-1]\na[24-1] = a[20-1]\na[19-1] = temp1\na[20-1] = temp2\nif solve a\n\ttag = true\nend\na = n.dup\ntemp1 = a[7-1]\ntemp2 = a[8-1]\na[7-1] = a[19-1]\na[8-1] = a[20-1]\na[19-1] = a[23-1] \na[20-1] = a[24-1]\na[23-1] = a[15-1]\na[24-1] = a[16-1]\na[15-1] = temp1\na[16-1] = temp2\nif solve a\n\ttag = true\nend\n\n\na = n.dup\ntemp1 = a[18-1]\ntemp2 = a[20-1]\na[18-1] = a[1-1]\na[20-1] = a[2-1]\na[1-1] = a[15-1] \na[2-1] = a[13-1]\na[13-1] = a[11-1]\na[15-1] = a[12-1]\na[12-1] = temp1\na[11-1] = temp2\nif solve a\n\ttag = true\nend\na = n.dup\ntemp1 = a[18-1]\ntemp2 = a[20-1]\na[18-1] = a[12-1]\na[20-1] = a[11-1]\na[11-1] = a[13-1] \na[12-1] = a[15-1]\na[15-1] = a[1-1]\na[13-1] = a[2-1]\na[1-1] = temp1\na[2-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\n\n\na = n.dup\ntemp1 = a[17-1]\ntemp2 = a[19-1]\na[17-1] = a[10-1]\na[19-1] = a[9-1]\na[9-1] = a[14-1] \na[10-1] = a[16-1]\na[16-1] = a[3-1]\na[14-1] = a[4-1]\na[3-1] = temp1\na[4-1] = temp2\nif solve a\n\ttag = true\nend\na = n.dup\ntemp1 = a[17-1]\ntemp2 = a[19-1]\na[17-1] = a[3-1]\na[19-1] = a[4-1]\na[3-1] = a[16-1] \na[4-1] = a[14-1] \na[14-1] = a[9-1]\na[16-1] = a[10-1] \na[10-1] = temp1\na[9-1] = temp2\nif solve a\n\ttag = true\nend\nif tag\n\tprint('YES')\nelse\n\tprint('NO')\nend\n"}], "negative_code": [{"source_code": "\nPOSSIBLES = [\n [[1, 2], [18, 20], [11, 12], [13, 15]],\n [[3, 4], [17, 19], [9, 10], [14, 16]],\n [[2, 4], [6, 8], [10, 12], [21, 23]],\n [[1, 3], [5, 7], [9, 11], [22, 24]],\n]\n\ndef check_solved(c)\n POSSIBLES.each do |pp|\n face_colors = pp.map { |p| c[p.first] == c[p.last] }\n return false if face_colors.include?(false)\n end\n true\nend\n\ndef solve(cube)\n # [[[2, 4], [6, 8], [10, 12], [21, 23]]].each_with_index do |possib|\n POSSIBLES.each_with_index do |possib|\n face_colors = possib.map { |p| cube[p.first] == cube[p.last] }\n next if face_colors.include?(false)\n colors = possib.map { |p| cube[p.first] }\n [possib.rotate(1), possib.rotate(-1)].each do |rot|\n c = cube.dup\n rot.each_with_index do |curr, i|\n c[curr.first] = colors[i]\n c[curr.last] = colors[i]\n # c[curr.last] = colors[next_val.last]\n end\n if check_solved(c)\n return \"YES\"\n end\n end\n end\n return \"NO\"\nend\n\n\n\ncube = {}\nvals = gets.strip.split.map(&:to_i)\n\nvals.each_with_index do |v, i|\n cube[i + 1] = v\nend\n\nputs solve(cube)\n"}, {"source_code": "\nPOSSIBLES = [\n [[1, 2], [18, 20], [11, 12], [13, 15]],\n [[3, 4], [17, 19], [9, 10], [14, 16]],\n [[2, 4], [6, 8], [10, 12], [21, 23]],\n [[1, 3], [5, 7], [9, 11], [22, 24]],\n]\n\n\nFACES = [\n (1..4).to_a,\n (5..8).to_a,\n (9..12).to_a,\n (13..16).to_a,\n (17..20).to_a,\n (21..24).to_a,\n]\n\ndef check_solved(c)\n FACES.each do |face|\n return false unless face.map { |f| c[f] }.uniq.size == 1\n end\n true\nend\n\ndef solve(cube)\n # [[[2, 4], [6, 8], [10, 12], [21, 23]]].each_with_index do |possib|\n POSSIBLES.each_with_index do |possib|\n face_colors = possib.map { |p| cube[p.first] == cube[p.last] }\n next if face_colors.include?(false)\n colors = possib.map { |p| cube[p.first] }\n [possib.rotate(1), possib.rotate(-1)].each do |rot|\n c = cube.dup\n rot.each_with_index do |curr, i|\n c[curr.first] = colors[i]\n c[curr.last] = colors[i]\n end\n if check_solved(c)\n return \"YES\"\n end\n end\n end\n return \"NO\"\nend\n\n\n\ncube = {}\nvals = gets.strip.split.map(&:to_i)\n\nvals.each_with_index do |v, i|\n cube[i + 1] = v\nend\n\nputs solve(cube)\n"}, {"source_code": "def rot(a, t)\n b = a.dup\n t.each{|v|\n tmp = a[v[0]]\n (1...v.size).each{|i|\n a[v[i-1]] = a[v[i]]\n }\n a[v[-1]] = tmp\n }\n return b\nend\n\ndef check(a)\n 6.times.map{|x| x*4}.all?{|x| (x...x+4).map{|i| a[i+1]}.uniq.size == 1}\nend\n\nlist = [\n [[2,6,10,23], [4,8,12,21], [18,17,19,20]],\n [[23,10,6,2], [21,12,8,4], [20,19,17,18]],\n [[1,18,12,15], [2,20,11,13], [22,21,23,24]],\n [[15,12,18,1], [13,11,20,2], [24,23,21,22]],\n [[1,2,4,3], [13,21,17,5], [14,22,18,6]],\n [[3,4,2,1], [5,17,21,13], [6,18,22,14]]\n]\n\n\ncube = [0] + gets.split.map(&:to_i)\n\n\n\n\nif list.any?{|l| check(rot(cube, l))}\n puts \"YES\"\nelse\n puts \"NO\"\nend"}, {"source_code": "def judge(cube)\n 6.times do |i|\n if !(cube[4 * i] == cube[4 * i + 1] && cube[4 * i + 1] == cube[4 * i + 2] && cube[4 * i + 2] == cube[4 * i + 3])\n return false\n end\n end\n return true\nend\n\na1 = [0,2,4,6,8,10,23,21]\nb1 = [1,3,5,7,9,11,22,20]\na2 = [12,13,4,5,16,17,20,21]\nb2 = [14,15,6,7,18,19,22,23]\na3 = [2,3,16,18,9,8,15,13]\nb3 = [0,1,17,19,11,10,14,12]\n\ncube = gets.split.map(&:to_i)\nans = judge(cube)\ntmp = Array.new(a1)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a1[i]]\nend\nans |= judge(cube2)\ntmp = Array.new(b1)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b1[i]]\nend\nans |= judge(cube2)\ntmp = Array.new(a2)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a2[i]]\nend\nans |= judge(cube2)\ntmp = Array.new(b2)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b2[i]]\nend\nans |= judge(cube2)\ntmp = Array.new(a3)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a3[i]]\nend\nans |= judge(cube2)\ntmp = Array.new(b3)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b3[i]]\nend\nans |= judge(cube2)\nputs ans ? \"YES\" : \"NO\""}, {"source_code": "def judge(cube)\n 6.times do |i|\n if !(cube[4 * i] == cube[4 * i + 1] && cube[4 * i + 1] == cube[4 * i + 2] && cube[4 * i + 2] == cube[4 * i + 3])\n return false\n end\n end\n return true\nend\n\na1 = [0,2,4,6,8,10,23,21]\nb1 = [1,3,5,7,9,11,22,20]\na2 = [12,13,4,5,16,17,20,21]\nb2 = [14,15,6,7,18,19,22,23]\n\ncube = gets.split.map(&:to_i)\nans = judge(cube)\ntmp = Array.new(a1)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a1[i]]\nend\nans |= judge(cube2)\ntmp = Array.new(b1)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b1[i]]\nend\nans |= judge(cube2)\ntmp = Array.new(a2)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a2[i]]\nend\nans |= judge(cube2)\ntmp = Array.new(b2)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b2[i]]\nend\nans |= judge(cube2)\nputs ans ? \"YES\" : \"NO\""}, {"source_code": "def judge(cube)\n 6.times do |i|\n if !(cube[4 * i] == cube[4 * i + 1] && cube[4 * i + 1] == cube[4 * i + 2] && cube[4 * i + 2] == cube[4 * i + 3])\n return false\n end\n end\n return true\nend\n\na1 = [0,2,4,6,8,10,23,21]\nb1 = [1,3,5,7,9,11,22,20]\na2 = [12,13,4,5,16,17,20,21]\nb2 = [14,15,6,7,18,19,22,23]\na3 = [2,3,16,18,9,8,15,13]\nb3 = [0,1,17,19,11,10,14,12]\n\ncube = gets.split.map(&:to_i)\nans = judge(cube)\n\ntmp = Array.new(a1)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a1[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b1)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b1[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a2)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a2[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b2)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b2[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a3)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a3[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b3)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b3[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a1)\ntmp.rotate!(4)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a1[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b1)\ntmp.rotate!(4)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b1[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a2)\ntmp.rotate!(4)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a2[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b2)\ntmp.rotate!(4)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b2[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a3)\ntmp.rotate!(4)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a3[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b3)\ntmp.rotate!(4)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b3[i]]\nend\nans |= judge(cube2)\n\nputs ans ? \"YES\" : \"NO\""}, {"source_code": "def judge(cube)\n 6.times do |i|\n if !(cube[4 * i] == cube[4 * i + 1] && cube[4 * i + 1] == cube[4 * i + 2] && cube[4 * i + 2] == cube[4 * i + 3])\n return false\n end\n end\n return true\nend\n\na1 = [0,2,4,6,8,10,23,21]\nb1 = [1,3,5,7,9,11,22,20]\na2 = [12,13,4,5,16,17,20,21]\nb2 = [14,15,6,7,18,19,22,23]\na3 = [2,3,16,18,9,8,15,13]\nb3 = [0,1,17,19,11,10,14,12]\n\ncube = gets.split.map(&:to_i)\nans = judge(cube)\n\ntmp = Array.new(a1)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[a1[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b1)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[b1[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a2)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[a2[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b2)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[b2[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a3)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[a3[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b3)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[b3[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\n\ntmp = Array.new(a1)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[a1[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b1)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[b1[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a2)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[a2[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b2)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[b2[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a3)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[a3[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b3)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[b3[i]] = cube[tmp[i]]\nend\nans |= judge(cube2)\n\nputs ans ? \"YES\" : \"NO\""}, {"source_code": "def judge(cube)\n 6.times do |i|\n if !(cube[4 * i] == cube[4 * i + 1] && cube[4 * i + 1] == cube[4 * i + 2] && cube[4 * i + 2] == cube[4 * i + 3])\n return false\n end\n end\n return true\nend\n\na1 = [0,2,4,6,8,10,23,21]\nb1 = [1,3,5,7,9,11,22,20]\na2 = [12,13,4,5,16,17,20,21]\nb2 = [14,15,6,7,18,19,22,23]\na3 = [2,3,16,18,9,8,15,13]\nb3 = [0,1,17,19,11,10,14,12]\n\ncube = gets.split.map(&:to_i)\nans = judge(cube)\n\ntmp = Array.new(a1)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a1[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b1)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b1[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a2)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a2[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b2)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b2[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a3)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a3[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b3)\ntmp.rotate!(2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b3[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a1)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a1[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b1)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b1[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a2)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a2[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b2)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b2[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(a3)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[a3[i]]\nend\nans |= judge(cube2)\n\ntmp = Array.new(b3)\ntmp.rotate!(-2)\ncube2 = Array.new(cube)\n8.times do |i|\n cube2[tmp[i]] = cube[b3[i]]\nend\nans |= judge(cube2)\n\nputs ans ? \"YES\" : \"NO\""}, {"source_code": "def solve(a)\n\ttag = true\n\tj = 1\n\twhile(j<=21 && tag)\n\t\tif(a[j-1] == a[j]&& a[j]==a[j+1]&&a[j+1]==a[j+2])\n\t\t\tj += 4\n\t\t\tnext\n\t\tend\n\t\ttag = false\n\tend\n \treturn tag\nend\n\ntag = false\na = gets.split(' ').map(&:to_i)\ntemp1 = a[1-1]\ntemp2 = a[3-1]\na[1-1] = a[22-1]\na[3-1] = a[24-1]\na[22-1] = a[9-1] \na[24-1] = a[11-1]\na[9-1] = a[5-1]\na[11-1] = a[7-1]\na[5-1] = temp1\na[7-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[1-1]\ntemp2 = a[3-1]\na[1-1] = a[5-1]\na[3-1] = a[7-1]\na[5-1] = a[9-1] \na[7-1] = a[11-1]\na[9-1] = a[22-1]\na[11-1] = a[24-1]\na[22-1] = temp1\na[24-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\ntemp1 = a[2-1]\ntemp2 = a[4-1]\na[2-1] = a[21-1]\na[4-1] = a[23-1]\na[21-1] = a[10-1] \na[23-1] = a[12-1]\na[10-1] = a[6-1]\na[12-1] = a[8-1]\na[6-1] = temp1\na[8-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[2-1]\ntemp2 = a[4-1]\na[2-1] = a[6-1]\na[4-1] = a[8-1]\na[6-1] = a[10-1] \na[8-1] = a[12-1]\na[10-1] = a[21-1]\na[12-1] = a[23-1]\na[21-1] = temp1\na[23-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\ntemp1 = a[5-1]\ntemp2 = a[6-1]\na[5-1] = a[13-1]\na[6-1] = a[14-1]\na[13-1] = a[21-1] \na[14-1] = a[22-1]\na[21-1] = a[17-1]\na[22-1] = a[18-1]\na[17-1] = temp1\na[18-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[5-1]\ntemp2 = a[6-1]\na[5-1] = a[17-1]\na[6-1] = a[18-1]\na[17-1] = a[21-1] \na[18-1] = a[22-1]\na[21-1] = a[13-1]\na[22-1] = a[14-1]\na[13-1] = temp1\na[14-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\n\n\ntemp1 = a[7-1]\ntemp2 = a[8-1]\na[7-1] = a[15-1]\na[8-1] = a[16-1]\na[15-1] = a[23-1] \na[16-1] = a[24-1]\na[23-1] = a[19-1]\na[24-1] = a[20-1]\na[19-1] = temp1\na[20-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[7-1]\ntemp2 = a[8-1]\na[7-1] = a[19-1]\na[8-1] = a[20-1]\na[19-1] = a[23-1] \na[20-1] = a[24-1]\na[23-1] = a[15-1]\na[24-1] = a[16-1]\na[15-1] = temp1\na[16-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\n\n\n\n\ntemp1 = a[18-1]\ntemp2 = a[20-1]\na[18-1] = a[1-1]\na[20-1] = a[2-1]\na[1-1] = a[13-1] \na[2-1] = a[15-1]\na[13-1] = a[11-1]\na[15-1] = a[12-1]\na[11-1] = temp1\na[12-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[18-1]\ntemp2 = a[20-1]\na[18-1] = a[11-1]\na[20-1] = a[12-1]\na[11-1] = a[13-1] \na[12-1] = a[15-1]\na[13-1] = a[1-1]\na[15-1] = a[2-1]\na[1-1] = temp1\na[2-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\n\n\n\ntemp1 = a[17-1]\ntemp2 = a[19-1]\na[17-1] = a[9-1]\na[19-1] = a[10-1]\na[9-1] = a[14-1] \na[10-1] = a[16-1]\na[14-1] = a[3-1]\na[16-1] = a[4-1]\na[3-1] = temp1\na[4-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[17-1]\ntemp2 = a[19-1]\na[17-1] = a[3-1]\na[19-1] = a[4-1]\na[3-1] = a[14-1] \na[4-1] = a[16-1] \na[14-1] = a[9-1]\na[16-1] = a[10-1] \na[9-1] = temp1\na[10-1] = temp2\nif solve a\n\ttag = true\nend\nif tag\n\tprint('YES')\nelse\n\tprint('NO')\nend\n"}, {"source_code": "def solve(a)\n\ttag = true\n\tj = 1\n\twhile(j<=21 && tag)\n\t\tif(a[j-1] == a[j]&& a[j]==a[j+1]&&a[j+1]==a[j+2])\n\t\t\tj += 4\n\t\t\tnext\n\t\tend\n\t\ttag = false\n\tend\n \treturn tag\nend\n\ntag = false\na = gets.split(' ').map(&:to_i)\ntemp1 = a[1-1]\ntemp2 = a[3-1]\na[1-1] = a[22-1]\na[3-1] = a[24-1]\na[22-1] = a[9-1] \na[24-1] = a[11-1]\na[9-1] = a[5-1]\na[11-1] = a[7-1]\na[5-1] = temp1\na[7-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[2-1]\ntemp2 = a[4-1]\na[2-1] = a[21-1]\na[4-1] = a[23-1]\na[21-1] = a[10-1] \na[23-1] = a[12-1]\na[10-1] = a[6-1]\na[12-1] = a[8-1]\na[6-1] = temp1\na[8-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[5-1]\ntemp2 = a[6-1]\na[5-1] = a[13-1]\na[6-1] = a[14-1]\na[13-1] = a[21-1] \na[14-1] = a[22-1]\na[21-1] = a[17-1]\na[22-1] = a[18-1]\na[17-1] = temp1\na[18-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[7-1]\ntemp2 = a[8-1]\na[7-1] = a[15-1]\na[8-1] = a[16-1]\na[15-1] = a[23-1] \na[16-1] = a[24-1]\na[23-1] = a[19-1]\na[24-1] = a[20-1]\na[19-1] = temp1\na[20-1] = temp2\nif solve a\n\ttag = true\nend\nif tag\n\tprint('YES')\nelse\n\tprint('NO')\nend\n"}, {"source_code": "def solve(a)\n\ttag = true\n\tj = 1\n\twhile(j<=21 && tag)\n\t\tif(a[j-1] == a[j]&& a[j]==a[j+1]&&a[j+1]==a[j+2])\n\t\t\tj += 4\n\t\t\tnext\n\t\tend\n\t\ttag = false\n\tend\n \treturn tag\nend\n\ntag = false\na = gets.split(' ').map(&:to_i)\ntemp1 = a[1-1]\ntemp2 = a[3-1]\na[1-1] = a[24-1]\na[3-1] = a[22-1]\na[24-1] = a[9-1] \na[22-1] = a[11-1]\na[9-1] = a[5-1]\na[11-1] = a[7-1]\na[5-1] = temp1\na[7-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[1-1]\ntemp2 = a[3-1]\na[1-1] = a[5-1]\na[3-1] = a[7-1]\na[5-1] = a[9-1] \na[7-1] = a[11-1]\na[9-1] = a[24-1]\na[11-1] = a[22-1]\na[24-1] = temp1\na[22-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\ntemp1 = a[2-1]\ntemp2 = a[4-1]\na[2-1] = a[23-1]\na[4-1] = a[21-1]\na[23-1] = a[10-1] \na[21-1] = a[12-1]\na[10-1] = a[6-1]\na[12-1] = a[8-1]\na[6-1] = temp1\na[8-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[2-1]\ntemp2 = a[4-1]\na[2-1] = a[6-1]\na[4-1] = a[8-1]\na[6-1] = a[10-1] \na[8-1] = a[12-1]\na[10-1] = a[23-1]\na[12-1] = a[21-1]\na[23-1] = temp1\na[21-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\ntemp1 = a[5-1]\ntemp2 = a[6-1]\na[5-1] = a[13-1]\na[6-1] = a[14-1]\na[13-1] = a[21-1] \na[14-1] = a[22-1]\na[21-1] = a[17-1]\na[22-1] = a[18-1]\na[17-1] = temp1\na[18-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[5-1]\ntemp2 = a[6-1]\na[5-1] = a[17-1]\na[6-1] = a[18-1]\na[17-1] = a[21-1] \na[18-1] = a[22-1]\na[21-1] = a[13-1]\na[22-1] = a[14-1]\na[13-1] = temp1\na[14-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\n\n\ntemp1 = a[7-1]\ntemp2 = a[8-1]\na[7-1] = a[15-1]\na[8-1] = a[16-1]\na[15-1] = a[23-1] \na[16-1] = a[24-1]\na[23-1] = a[19-1]\na[24-1] = a[20-1]\na[19-1] = temp1\na[20-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[7-1]\ntemp2 = a[8-1]\na[7-1] = a[19-1]\na[8-1] = a[20-1]\na[19-1] = a[23-1] \na[20-1] = a[24-1]\na[23-1] = a[15-1]\na[24-1] = a[16-1]\na[15-1] = temp1\na[16-1] = temp2\nif solve a\n\ttag = true\nend\n\n\ntemp1 = a[18-1]\ntemp2 = a[20-1]\na[18-1] = a[1-1]\na[20-1] = a[2-1]\na[1-1] = a[15-1] \na[2-1] = a[13-1]\na[13-1] = a[11-1]\na[15-1] = a[12-1]\na[12-1] = temp1\na[11-1] = temp2\nif solve a\n\ttag = true\nend\n\ntemp1 = a[18-1]\ntemp2 = a[20-1]\na[18-1] = a[12-1]\na[20-1] = a[11-1]\na[11-1] = a[13-1] \na[12-1] = a[15-1]\na[15-1] = a[1-1]\na[13-1] = a[2-1]\na[1-1] = temp1\na[2-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\n\n\n\ntemp1 = a[17-1]\ntemp2 = a[19-1]\na[17-1] = a[10-1]\na[19-1] = a[9-1]\na[9-1] = a[14-1] \na[10-1] = a[16-1]\na[16-1] = a[3-1]\na[14-1] = a[4-1]\na[3-1] = temp1\na[4-1] = temp2\nif solve a\n\ttag = true\nend\n\ntemp1 = a[17-1]\ntemp2 = a[19-1]\na[17-1] = a[3-1]\na[19-1] = a[4-1]\na[3-1] = a[16-1] \na[4-1] = a[14-1] \na[14-1] = a[9-1]\na[16-1] = a[10-1] \na[10-1] = temp1\na[9-1] = temp2\nif solve a\n\ttag = true\nend\nif tag\n\tprint('YES')\nelse\n\tprint('NO')\nend\n"}, {"source_code": "def solve(a)\n\ttag = true\n\tj = 1\n\twhile(j<=21 && tag)\n\t\tif(a[j-1] == a[j]&& a[j]==a[j+1]&&a[j+1]==a[j+2])\n\t\t\tj += 4\n\t\t\tnext\n\t\tend\n\t\ttag = false\n\tend\n \treturn tag\nend\n\ntag = false\na = gets.split(' ').map(&:to_i)\ntemp1 = a[1-1]\ntemp2 = a[3-1]\na[1-1] = a[22-1]\na[3-1] = a[24-1]\na[22-1] = a[9-1] \na[24-1] = a[11-1]\na[9-1] = a[5-1]\na[11-1] = a[7-1]\na[5-1] = temp1\na[7-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[1-1]\ntemp2 = a[3-1]\na[1-1] = a[5-1]\na[3-1] = a[7-1]\na[5-1] = a[9-1] \na[7-1] = a[11-1]\na[9-1] = a[22-1]\na[11-1] = a[24-1]\na[22-1] = temp1\na[24-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\ntemp1 = a[2-1]\ntemp2 = a[4-1]\na[2-1] = a[21-1]\na[4-1] = a[23-1]\na[21-1] = a[10-1] \na[23-1] = a[12-1]\na[10-1] = a[6-1]\na[12-1] = a[8-1]\na[6-1] = temp1\na[8-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[2-1]\ntemp2 = a[4-1]\na[2-1] = a[6-1]\na[4-1] = a[8-1]\na[6-1] = a[10-1] \na[8-1] = a[12-1]\na[10-1] = a[21-1]\na[12-1] = a[23-1]\na[21-1] = temp1\na[23-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\ntemp1 = a[5-1]\ntemp2 = a[6-1]\na[5-1] = a[13-1]\na[6-1] = a[14-1]\na[13-1] = a[21-1] \na[14-1] = a[22-1]\na[21-1] = a[17-1]\na[22-1] = a[18-1]\na[17-1] = temp1\na[18-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[5-1]\ntemp2 = a[6-1]\na[5-1] = a[17-1]\na[6-1] = a[18-1]\na[17-1] = a[21-1] \na[18-1] = a[22-1]\na[21-1] = a[13-1]\na[22-1] = a[14-1]\na[13-1] = temp1\na[14-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\n\n\ntemp1 = a[7-1]\ntemp2 = a[8-1]\na[7-1] = a[15-1]\na[8-1] = a[16-1]\na[15-1] = a[23-1] \na[16-1] = a[24-1]\na[23-1] = a[19-1]\na[24-1] = a[20-1]\na[19-1] = temp1\na[20-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[7-1]\ntemp2 = a[8-1]\na[7-1] = a[19-1]\na[8-1] = a[20-1]\na[19-1] = a[23-1] \na[20-1] = a[24-1]\na[23-1] = a[15-1]\na[24-1] = a[16-1]\na[15-1] = temp1\na[16-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\n\n\n\n\ntemp1 = a[18-1]\ntemp2 = a[20-1]\na[18-1] = a[1-1]\na[20-1] = a[2-1]\na[1-1] = a[13-1] \na[2-1] = a[14-1]\na[13-1] = a[11-1]\na[14-1] = a[12-1]\na[11-1] = temp1\na[12-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[18-1]\ntemp2 = a[20-1]\na[18-1] = a[11-1]\na[20-1] = a[12-1]\na[11-1] = a[13-1] \na[12-1] = a[14-1]\na[13-1] = a[1-1]\na[14-1] = a[2-1]\na[1-1] = temp1\na[2-1] = temp2\nif solve a\n\ttag = true\nend\n\n\n\n\n\n\ntemp1 = a[17-1]\ntemp2 = a[19-1]\na[17-1] = a[9-1]\na[19-1] = a[10-1]\na[9-1] = a[15-1] \na[10-1] = a[16-1]\na[15-1] = a[3-1]\na[16-1] = a[4-1]\na[3-1] = temp1\na[4-1] = temp2\nif solve a\n\ttag = true\nend\ntemp1 = a[17-1]\ntemp2 = a[19-1]\na[17-1] = a[3-1]\na[19-1] = a[4-1]\na[3-1] = a[15-1] \na[4-1] = a[16-1] \na[15-1] = a[9-1]\na[16-1] = a[10-1] \na[9-1] = temp1\na[10-1] = temp2\nif solve a\n\ttag = true\nend\nif tag\n\tprint('YES')\nelse\n\tprint('NO')\nend\n"}], "src_uid": "881a820aa8184d9553278a0002a3b7c4"} {"source_code": "# coding: utf-8\n\n# if __FILE__ == $0\n# end\n\nn, a, b = gets.split.map(&:to_i)\n\n# 앞엔 a명 이상, 뒤엔 b명 이하로 서있음\n# n에는 Petr 자신을 포함함\nd = n - (a + b)\n\nif d > 0\n puts b + 1\nelsif d == 0\n if a == n\n puts 1\n else\n puts b\n end\nelse\n puts (n - a)\nend", "positive_code": [{"source_code": "f=->{gets(\" \").to_i};p [f[]-f[],f[]+1].min\n"}, {"source_code": "f=->{gets(\" \").to_i};p [f[]-f[],f[]+1].min"}, {"source_code": "s = gets.split\nn = s[0].to_i\na = s[1].to_i\nb = s[2].to_i\np = 0\ni = a\nwhile i=a then\n if n-i<=b then\n ans+=1\n end\n end\nend\np ans\n"}, {"source_code": "f=->{gets(\" \").to_i};p [f[]-f[],f[]+1].min\n"}, {"source_code": "n,a,b=gets.split.map(&:to_i)\nprint [b+1,n-a].min,\"\\n\"\n"}, {"source_code": "n, a, b = gets.split(\" \").map{|x| x.to_i}\nputs [n - a, b + 1].min"}, {"source_code": "n, a, b = gets.split(\" \").map{|x| x.to_i}\nif n - a > b + 1\n puts b + 1\nelse\n puts n - a\nend"}, {"source_code": "n, a, b = gets.split.map(&:to_i)\nprint [n-a, b+1].min"}, {"source_code": "f=->{gets(\" \").to_i};p [f[]-f[],f[]+1].min\n"}, {"source_code": " n,a,b=gets.split.map &:to_i;p [n-a,b+1].min\n\n"}, {"source_code": "n,a,b=gets.split.collect{|i| i.to_i}\nputs [n-a,b+1].min"}, {"source_code": "f=->{gets(\" \").to_i};p [f[]-f[],f[]+1].min"}, {"source_code": "n,a,b=gets.chomp.split(' ').map(&:to_i)\nwhile a>=n-b\n\tb-=1\nend\nputs b+1"}, {"source_code": "n, a, b = gets.split.map(&:to_i)\nputs [n-a, b+1].min"}, {"source_code": "n,a,b = gets.split(' ').map(&:to_i)\n\nputs (n-a)-1 > b ? b+1 : n-a\n"}, {"source_code": "n,a,b = gets.split.map(&:to_i)\n \nif a+b == n \n puts b\nelsif a+b > n\n puts n-a\nelse\n counter = 0\n for i in n-b..n\n counter+=1\n end\n puts counter\nend\n"}, {"source_code": "#!/usr/bin/ruby\n\ndef readNextValues\n return gets.chomp.split.collect {|x| x.to_i }\nend\n\nn, a, b = readNextValues\n\npos = n - b\npos = a + 1 if pos < a + 1\nnum = n - pos + 1\nif num > 0\n puts num\nelse\n puts 0\nend"}, {"source_code": "n, a, b = gets.split.map &:to_i\np [n - a, b + 1].min\n"}, {"source_code": "f=->{gets(\" \").to_i};p [f[]-f[],f[]+1].min\n"}, {"source_code": "f=->{gets(\" \").to_i};p [f[]-f[],f[]+1].min\n"}, {"source_code": "n,a,b=gets.split.map{|e| e.to_i}\nputs [n-a,b+1].min\n\n"}, {"source_code": "n,a,b=gets.split.map &:to_i;p [n-a,b+1].min"}, {"source_code": "n,a,b = gets.split.map(&:to_i)\n\nn -= a\n\nif n > b + 1\n n = b + 1\nend\nputs n\n"}, {"source_code": "f=->{gets(\" \").to_i};p [f[]-f[],f[]+1].min"}, {"source_code": "n,a,b=gets.split.map(&:to_i)\np [n-a,b+1].min\n"}, {"source_code": "n,a,b=gets.split.map &:to_i;p [n-a,b+1].min\n"}, {"source_code": "n,a,b=gets.split.map(&:to_i)\nans=0\n(1..n).each{|_| ans+=1 if (_-1)>=a && (n-_)<=b}\nputs ans\n"}, {"source_code": "n,a,b=gets.split.map(&:to_i)\np [*1..n].keep_if{|_|_>a && n-_<=b}.size\n"}, {"source_code": "a=gets.split.collect {|i|i.to_i}\np [a[0]-a[1],a[2]+1].min\n"}, {"source_code": "n, a, b = gets.split.map{ |e| e.to_i}\n\nputs a+b >= n ? n-a : b+1"}, {"source_code": "n, a, b = gets.split.map(&:to_i)\n\np [n - a, b + 1].min"}, {"source_code": "n,a,b=gets.split.map &:to_i;p [n-a,b+1].min\n"}, {"source_code": "f=->{gets(\" \").to_i};p [f[]-f[],f[]+1].min\n"}, {"source_code": "n,a,b=gets.split.map(&:to_i)\nputs [b+1,n-a].min\n"}, {"source_code": "n,a,b=gets.split.map &:to_i\nputs [n-a,b+1].min"}, {"source_code": "k=gets.split(\" \"); \nn=k[0].to_i\na=k[1].to_i\nb=k[2].to_i\nputs n - [a+1, n-b].max + 1\n"}, {"source_code": "f=->{gets(\" \").to_i};p [f[]-f[],f[]+1].min\n"}, {"source_code": "n, a, b = gets.split(' ').map(&:to_i)\n\nputs [n-a, b+1].min"}, {"source_code": "n, a, b = gets.split.map(&:to_i)\np [[n-a, b+1].min, 0].max"}, {"source_code": "f=->{gets(\" \").to_i};p [f[]-f[],f[]+1].min\n"}, {"source_code": "n,a,b=gets.split.map(&:to_i)\np [n-a,b+1].min"}, {"source_code": "n, a, b = gets.split(' ').map(&:to_i)\nputs [n-a, b+1].min"}, {"source_code": "n, a, b = gets.split.map(&:to_i)\np (((a+1)..n).to_a & ((n-b)..n).to_a).size\n"}, {"source_code": "#!/usr/bin/ruby -Ks\n\ninput = $stdin.gets.chomp.split\n$n = input[0].to_i\n$a = input[1].to_i\n$b = input[2].to_i\n\nans = 0\n1.upto($n) do |i|\n if (i>=$a+1) and ($n-i<=$b)\n ans+=1\n end\nend\nputs ans\n\n# EOF\n"}, {"source_code": "n,a,b = gets.chomp.split \n\na = a.to_i \nb = b.to_i \nn = n.to_i \n\na = n-a \nb = b+1 \n\nif a= a and n - i <= b\nend\nputs ans\n"}], "negative_code": [{"source_code": "puts gets.chomp.split(\" \")[1].to_i+1\n"}, {"source_code": "t = gets.chomp.split(\" \")\nn = t[0].to_i\na = t[1].to_i\nb = t[2].to_i\nif a+1 < n-a\n puts a+1\nelse\n puts n-a\nend\n"}, {"source_code": "n, a, b = gets.split(\" \").map{|x| x.to_i}\nif n - a > b\n puts b\nelse\n puts n - a\nend"}, {"source_code": "n, a, b = gets.split(\" \").map{|x| x.to_i}\nputs n - a"}, {"source_code": "n, a, b = gets.split(\" \").map{|x| x.to_i}\nif n == 9 && a == 4 && b == 3\n puts 4\nelse\n puts n - a\nend"}, {"source_code": "n,a,b=gets.split.collect{|i| i.to_i}\nputs [n-1,b+1].min"}, {"source_code": "n,a,b = gets.split(' ').map(&:to_i)\n\nputs (n-a)-1 > b ? b : n-a"}, {"source_code": "n,a,b = gets.split.map(&:to_i)\n counter = 0\nfor i in n-a..n\n counter+=1\nend\nputs counter"}, {"source_code": "n,a,b = gets.split.map(&:to_i)\n counter = 0\nfor i in a+1..n\n counter+=1\nend\nputs counter"}, {"source_code": "n,a,b = gets.split.map(&:to_i)\n counter = 0\nfor i in n-b+1..n\n counter+=1\nend\nputs counter"}, {"source_code": "n,a,b = gets.split.map(&:to_i)\n \nif a+b == n \n puts b\nelse\n counter = 0\n for i in n-b..n\n counter+=1\n end\nend\n\nputs counter"}, {"source_code": "n, a, b = gets.split.map &:to_i\nputs b > a ? b : a == b ? 1 + a : 0\n"}, {"source_code": "n, a, b = gets.split.map &:to_i\nputs a == b ? n - 1 : n - a\n"}, {"source_code": "n,a,b = gets.split.map(&:to_i)\n\nif n-a > b+1\n puts 0\nelse\n puts n-a\nend\n"}, {"source_code": "n,a,b = gets.split.map(&:to_i)\n\nif n >= a+b\n puts n-a\nelse\n puts n-a- b\nend\n\n"}, {"source_code": "n,a,b = gets.split.map(&:to_i)\n\nputs n-a\n"}, {"source_code": "n,a,b = gets.split.map(&:to_i)\n\nif n-a > b\n puts b\nelse\n puts n-a\nend\n"}, {"source_code": "n,a,b=gets.split.map(&:to_i)\nans=0\n(1..n).each{|_| ans+=1 if (_-1)>=a && (n-_)<=b}\n"}, {"source_code": "n,a,b=gets.split.map(&:to_i);p [n-a,b].max\n"}, {"source_code": "n,a,b=gets.split.map(&:to_i)\nans=1\n(1..n).each{|_| ans+=1 if _>=a && _<=b}\nputs ans\n"}, {"source_code": "n=gets.split.collect! {|i| i.to_i}\na=n[1]\nn=n[0]\n\np n-a\n"}, {"source_code": "n=gets.split.collect! {|i| i.to_i}\na=n[1] #4\nb=n[2] #3\nn=n[0] #9\n\np n-a\n"}, {"source_code": "# coding: utf-8\n\n# if __FILE__ == $0\n# end\n\nn, a, b = gets.split.map(&:to_i)\n\n# 앞엔 a명 이상, 뒤엔 b명 이하로 서있음\n# n에는 Petr 자신을 포함함\nd = n - (a + b)\n\nif d > 0\n puts b + 1\nelsif d == 0\n if a == n\n puts 1\n else\n puts b\n end\nelse\n puts (n - a) + 1\nend"}, {"source_code": "# coding: utf-8\n\n# if __FILE__ == $0\n# end\n\nn, a, b = gets.split.map(&:to_i)\n\n# 앞엔 a명 이상, 뒤엔 b명 이하로 서있다고 그르네요\n# a: from a, up to a + (n - a - b) = n - b\n# n - a - b = movable size\n# b: from b up to 0\nputs (n - a - b + 1) * (b)"}, {"source_code": "n,a,b=gets.split.map(&:to_i)\nputs [b,n-a].max\n"}, {"source_code": "a=0;\nn=gets.split(\" \");\nif (n[1].to_i>1)\n a+=n[1].to_i-1;\nelse\n a+=1;\nend\nif (n[2].to_i>1)\n a+=n[2].to_i-1;\nelse\n a+=1;\nend\nputs a"}, {"source_code": "n, a, b = gets.split.map(&:to_i)\np [[n-a, n-b].min, 0].max"}, {"source_code": "n,a,b=gets.split.map(&:to_i)\np [n-a,b].min"}, {"source_code": "n,a,b=gets.split.map(&:to_i)\np n-a"}, {"source_code": "#!/usr/bin/ruby -Ks\n\ninput = $stdin.gets.chomp.split\n$n = input[0].to_i\n$a = input[1].to_i\n$b = input[2].to_i\n\n($n-$a) < $b ? ans = $n-$a : ans = $b\nputs ans\n\n# EOF\n"}, {"source_code": "#!/usr/bin/ruby -Ks\n\ninput = $stdin.gets.chomp.split\n$n = input[0].to_i\n$a = input[1].to_i\n$b = input[2].to_i\n\nif $n - $a < $b\n ans = $b\nelse\n ans = $n - $a\nend\nputs ans\n\n# EOF\n"}, {"source_code": "#!/usr/bin/ruby -Ks\n\ninput = $stdin.gets.chomp.split\n$n = input[0].to_i\n$a = input[1].to_i\n$b = input[2].to_i\n\nans = 0\nc = $a + 1\n(c..$n).each do |i|\n if $n - c <= $b\n ans += 1\n end\nend\nputs ans\n\n# EOF\n"}, {"source_code": "f=->{gets(\" \").to_i};p f[]-[f[],f[]-1].max"}, {"source_code": "f=->{gets(\" \").to_i};p f[]-[f[],f[]+1].min"}, {"source_code": "f=->{gets(\" \").to_i};p f[]-[f[],f[]].min"}], "src_uid": "51a072916bff600922a77da0c4582180"} {"source_code": "n = gets.to_i\na = gets.chomp.chars.map(&:to_i)\nputs a[0...n / 2].inject(:+) == a[n / 2...n].inject(:+) && n == a.count(4) + a.count(7) ?\n \"YES\" : \"NO\"\n", "positive_code": [{"source_code": "input = STDIN.read.split(\"\\n\")\n\nnum = input[1]\n\nif num.length != num.count('47')\n\tSTDOUT.puts :NO\n\texit\nend\n\nn = input[0].to_i / 2\nnum1, num2 = input[1][0..n-1], input[1][n..-1]\n\nsum1 = num1.split(//).map(&:to_i).inject(0){|sum, x| sum += x}\nsum2 = num2.split(//).map(&:to_i).inject(0){|sum, x| sum += x}\n\nSTDOUT.puts sum1 == sum2 ? :YES : :NO"}, {"source_code": "gets\nlucky_numbers = [4, 7]\ndigits = gets.strip.split(//).map do |str|\n i = str.to_i\n unless lucky_numbers.include?(i)\n puts \"NO\"\n exit\n end\n i\nend\n\nif digits[0, digits.size/2].inject(:+) == digits[digits.size/2, digits.size/2].inject(:+)\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "n=gets.to_i\nputs gets=~/^[47]+$/ && $_[0..n/2-1].sum==$_[n/2..n-1].sum ? \"YES\" : \"NO\"\n\n"}, {"source_code": "n=gets.to_i/2;s=gets.split'';puts (s-['4','7']==[\"\\n\"]&&s[0,n].sort==s[n,n].sort)?\"YES\":\"NO\""}, {"source_code": "n=gets.to_i\nputs gets=~/^[47]+$/ && $_[0..n/2-1].sum==$_[n/2..n-1].sum ? \"YES\" : \"NO\"\n\n"}, {"source_code": "length = gets.to_i\nnumber = gets.chomp.to_s\nnum_7 = number.count('7')\nnum_4 = number.count('4')\nif num_7 + num_4 == length\n sum_half1 = 0\n sum_half2 = 0\n (0...length/2).each do |i|\n sum_half1 += number[i].to_i\n end\n (length/2...length).each do |j|\n sum_half2 += number[j].to_i\n end\n if sum_half1 == sum_half2\n puts \"YES\"\n else\n puts \"NO\"\n end\nelse\n puts \"NO\"\nend"}, {"source_code": "def checkLucky str1\n return str1 =~ /[^47]/\nend\n\nn = gets.to_i\nstr = gets.chomp\nar = []\nar = str.split('').map &:to_i\nlen = ar.size/2\n#puts ar.join(' ')\nif !checkLucky str\n if ar[0,len].inject{|a,b| a+b} == ar[len,2*len].inject{|c,d| c+d}\n puts \"YES\"\n else\n puts \"NO\"\n end\n else\n puts \"NO\"\nend"}, {"source_code": "number_length = gets.to_i\nnumber = gets.to_i\ndigits = [4,7]\nleft_part = 0\nright_part = 0\n\ni = 1\nresult = true\nwhile i <= number_length do\n digit = number % 10\n number = number / 10\n left_part += digit if (i-1) < number_length / 2\n right_part += digit if (i-1) >= number_length / 2\n result = false if !digits.include?(digit)\n i+=1\nend\n\nif(result)\n result = false if left_part != right_part\nend\n\nputs result ? \"YES\" : \"NO\""}, {"source_code": "n = gets.to_i\na = gets.chomp.chars.map(&:to_i)\nif a[0...n / 2].inject(:+) == a[n / 2...n].inject(:+) && n == a.count(4) + a.count(7)\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "n = gets.to_i\nt = gets.chomp\ns = t.split('').map(&:to_i)\nputs (t=~/^(4|7)+$/ && s[0...n/2].sort == s[n/2...n].sort)?'YES':'NO'\n"}, {"source_code": "n = gets.to_i / 2\nar = gets.scan(/[47]/).map(&:to_i)\nif ar.length != n * 2\n puts \"NO\"\nelsif ar[0...n].inject(:+)==ar[n..-1].inject(:+)\n puts \"YES\"\nelse\n puts \"NO\"\nend\n "}, {"source_code": "def isLucky(s)\n s.each_byte{|sb|\n return false if sb.chr != \"4\" && sb.chr != \"7\"\n }\n return true\nend\n\ndef sumstr(s)\n sum = 0\n s.each_byte{|sb|\n sum += sb.chr.to_i\n }\n return sum\nend\n\nret = \"NO\"\n$n = gets.chomp.to_i\n$s = gets.chomp\nif isLucky($s)\n s1 = $s.slice(0,$n/2)\n s2 = $s.slice($n/2,$n/2)\n if sumstr(s1) == sumstr(s2)\n ret = \"YES\"\n end\nend\nputs ret\n\n"}, {"source_code": "#!/usr/bin/ruby\nn=gets.to_i\ns=gets.chomp\nputs s=~/^[47]{#{n}}$/ && s[0,n/2].split('').map(&:to_i).reduce(:+)==s[n/2..-1].split('').map(&:to_i).reduce(:+) ? 'YES' : 'NO'"}, {"source_code": "\nn,a=gets.to_i,gets\nif /[01235689]/=~a then\n puts \"NO\"\n exit\nend\nsum=0\nn.times{|i|\n if i0, \"b\"=>1, \"c\"=>2, \"d\"=>3, \"e\"=>4, \"f\"=>5, \"g\"=>6, \"h\"=>7, \"i\"=>8, \"j\"=>9, \"k\"=>10, \"l\"=>11, \"m\"=>12, \"n\"=>13, \"o\"=>14, \"p\"=>15, \"q\"=>16, \"r\"=>17, \"s\"=>18, \"t\"=>19, \"u\"=>20, \"v\"=>21, \"w\"=>22, \"x\"=>23, \"y\"=>24, \"z\"=>25} \ns = gets.chomp\ninit = 'a'\nans = 0\ns.each_char do |c|\n d = (h[c] - h[init]).abs\n ans += [d, (d - 26).abs].min\n init = c\nend\np ans\n"}, {"source_code": "c = 'a'.ord\nm = 'z'.ord - 'a'.ord + 1\nputs(gets.strip.split('').map{|x| x.ord}.inject(0){|s, x| t = s + [[x, c].max - [x, c].min, ([x, c].min - [x, c].max)%m].min; c = x; t})\n"}, {"source_code": "string = gets.chomp\nvessel = string.scan(/./).map(&:ord)\nchar = 'a'.ord\nsum = 0\nvessel.each do |c|\n d = (char - c).abs\n if d < 13\n sum += d\n else\n sum += (26 - d)\n end\n char = c\nend\nputs sum"}, {"source_code": "word = gets.chop!\nlast_char = 'a'\nsum = 0\nword.each_char do |char|\n diff = char.ord > last_char.ord ? char.ord - last_char.ord : last_char.ord - char.ord\n sum += diff < 13 ? diff : 26 - diff\n last_char = char\nend\nputs sum"}, {"source_code": "prev = 'a'.ord\n\nputs(\n gets.chomp.chars.inject(0) do |sum, c|\n diff = (prev - c.ord).abs\n prev = c.ord\n sum + [diff, 26 - diff].min\n end\n)\n"}, {"source_code": "s = gets.strip\n\nmp = {}\n(0..25).each do |i|\n mp[('a'.ord + i).chr] = i\nend\n\ncnt = 0\ncurr = 'a'\ns.split('').each do |l|\n i = mp[curr]\n j = mp[curr]\n while(1)\n if i == mp[l] || j == mp[l]\n break\n end\n i -= 1\n j += 1\n j = 0 if j >= 26\n i = 25 if i < 0\n end\n if (mp[curr] - i).abs < (mp[curr] - j).abs\n cnt += (mp[curr] - i).abs \n else\n cnt += (mp[curr] - j).abs\n end\n\n curr = l\n\nend\n\nprintf(\"%d\\n\", cnt)\n"}, {"source_code": "require 'set'\n\nparse_int = lambda {gets.split.map{|x| x.to_i}}\n\ndef turn(a,b)\n a, b = [a,b].min, [a,b].max\n \n v1 = b.ord-a.ord\n v2 = 'z'.ord-b.ord + 1 + (a.ord-'a'.ord)\n \n #p [v1,v2].min\n [v1,v2].min\nend\n\n#puts turn 'a','z'\n#puts turn 'z','a'\n\nst = 'a'+gets.chomp\n\nans = 0\nfor i in (0...st.length-1)\n ans += turn st[i], st[i+1]\nend\nputs ans"}, {"source_code": "n = gets\nr = 0\ni = 0\nn = n[0..( n.size - 2)]\nn.each_byte {|c|\n c = c - 97\n r = [ ( c - i ).abs, ( ( i - c ).abs - 26 ).abs ].min + r\n i = c\n}\nputs r"}, {"source_code": "def execute(input)\n # special case\n pointer = 'a'\n if input == pointer\n puts 0\n return\n end\n\n if input.length == 1\n puts count_min_step(pointer, input)\n return\n end\n\n @count = 0\n input.split('').each_with_index do |char, index|\n if index == 0\n @count += count_min_step(pointer, char)\n else\n @count += count_min_step(input[index - 1], char)\n end\n end\n puts @count\nend\n\ndef count_min_step(char1, char2)\n step = (origin_anphabet.index(char1) - origin_anphabet.index(char2)).abs\n if step > (origin_anphabet.size / 2)\n return origin_anphabet.size - step\n else\n return step\n end\nend\n\ndef origin_anphabet\n @origin_anphabet ||= ('a'..'z').to_a\nend\n\ninput = gets.chomp\n\nexecute(input)\n"}, {"source_code": "r=0\n[0,*gets.chomp.bytes.map{|b|b-97}].each_cons(2){|x,y|r+=[(y-x)%26,(x-y)%26].min}\np r"}, {"source_code": "\ndef museum(input)\n rt = {}\n index = 0\n rt.tap do |r|\n rotations = ('a'..'z').to_a.each do |ro|\n r[ro] = index\n index += 1\n end\n end\n\n inputs = input.split('')\n inputs_size = inputs.size\n ch = rt['a']\n step = 0\n i = 0\n inputs.each do |s|\n d = (ch - rt[inputs[i]]).abs\n if d < 13\n step = step + d\n else\n step = step + (26 - d)\n end\n ch = rt[inputs[i]]\n i += 1\n end\n\n puts step\nend\n\nmuseum(gets.chomp)\n"}, {"source_code": "s = gets.chomp.split('')\nx = 'a'\nc = 0\ns.each do |y|\n v = (y.ord - x.ord).abs\n v = 26 - v if v > 13\n c += v\n x = y\nend\nputs c\n"}, {"source_code": "name = gets.strip.bytes\n# name = 'zeus'.bytes\n\ndef calculate(name)\n result = 0\n current_ascii = 'a'.bytes[0]\n name.each do |char_ascii|\n dist = (current_ascii - char_ascii).abs\n current_ascii = char_ascii\n result += [dist, 26 - dist].min\n end\n result\nend\n\nputs calculate(name)\n"}, {"source_code": "def get_code(c)\n c.upcase.ord - 'A'.ord\nend\n\nresult = 0\npos = 0\n\nls = gets.chomp()\n\nls.split(\"\").each do |v|\n if pos == 0\n if get_code(v) - pos <= 13\n result += get_code(v)\n else\n result += 26 - get_code(v)\n end\n else\n if (get_code(v) - pos).abs <= 13\n result += (get_code(v) - pos).abs\n else\n result += 26 - (pos - get_code(v)).abs\n end\n end\n pos = get_code(v)\nend\n\nputs result\n"}, {"source_code": "s = gets.chomp.chars\n\narr = ('a'..'z').to_a\n# puts arr.index('c') - arr.index('a')\n\nans = 0\ncur = 'a'\ns.each do |c|\n ans += [(arr.index(cur) - arr.index(c)).abs, ((arr.index(cur) - arr.index(c)).abs - 26).abs].min\n cur = c\nend\nputs ans"}, {"source_code": "s = gets.strip\ncount = 0\ncurrent = 'a'\n(0...s.length).each do |i|\n clockwise = current.ord - s[i].ord\n counterclock = s[i].ord - current.ord\n clockwise = 26 + clockwise if clockwise < 0\n counterclock = 26 + counterclock if counterclock < 0\n min_count = [clockwise, counterclock].min\n count += min_count\n current = s[i]\nend\nputs count\n"}, {"source_code": "exhibit = gets.rstrip\n\narr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\n\ncount = 0\ncurrent_index = 0\nexhibit.split('').each do |char|\n index = arr.find_index do |l|\n l == char\n end\n\n distance_index = (index - current_index).abs\n\n if distance_index > 13\n if index < current_index\n count += index + 26 - current_index\n else\n count += current_index + 26 - index\n end\n else\n count += distance_index\n end\n current_index = index\nend\n\nputs count\n"}, {"source_code": "t=gets.chomp\nt=\"a\"+t\ns=t.chars\nans=0\nwhile s.size>1\n\tc1=s[0].ord\n\tc2=s[1].ord\n\td1=[c1,c2].min\n\td2=[c1,c2].max\n\tans+=[d2-d1,d1+26-d2].min\n\ts.shift\nend\nputs ans\n\n"}, {"source_code": "string = gets.to_s.chomp; sum =0 ;string.insert(0,\"a\")\nfor i in 0..string.length-2\n a = string[i+1].ord - string[i].ord\n a = a >13? 26-a : a<0? a<-13? 26+a : -a : a\n sum += a\nend\nputs sum\n"}, {"source_code": "s=gets.chomp\nres=0\na=?a\ns.chars{|e|\n\tc=e.dup\n\tx=0\n\twhile c[-1]!=a\n\t\tc.next!\n\t\tx+=1\n\tend\n\n\tb=a.dup\n\ty=0\n\twhile b[-1]!=e\n\t\tb.next!\n\t\ty+=1\n\tend\n\tres+=x>y ? y : x\n\ta=e\n}\nputs res\n"}, {"source_code": "t=0;('a'+gets).strip.split('').inject{|pr,i|td=((pr||'a').ord-i.ord).abs;t+=[td,26-td].min;i};puts t"}, {"source_code": "t=0;('a'+gets).strip.split('').inject{|pr,i|td=pr.ord-i.ord;t+=[td%26,(-td)%26].min;i};puts t"}, {"source_code": "s='a'+gets;revs=0\n(s.size-2).times{|i|\n clockwise=(s[i+1].ord-s[i].ord).abs;\n revs += [clockwise, (clockwise-26).abs].min\n}\nputs revs\n"}, {"source_code": "# coding: utf-8\n\n# if __FILE__ == $0\n# end\nword = gets.chomp.split(//).map { |i|\n i.ord - \"a\".ord\n}\n\nc = 0\nrev = 0\nword.each { |i|\n l = 0\n r = 0\n\n if c < i # 'a' .... \"b\"\n l, r = i - c, c + (26 - i)\n elsif c == i # 'a' .... \"a\"\n l, r = 0, 0\n else # 'b' .... \"a\"\n l, r = (26 - c) + i , c - i\n end\n\n if l < r\n rev += l\n else\n rev += r\n end\n\n c = i\n}\n\nputs rev\n"}, {"source_code": "word = gets.chomp.split(\"\")\nalphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\nsum = 0\npos = 0\nfor i in (0..word.size-1)\n\tif i == 0\n\t\tif alphabet.find_index(word[i]) >= 13\n\t\t\tsum += 26 - alphabet.find_index(word[i])\n\t\telse\n\t\t\tsum += alphabet.find_index(word[i])\n\t\tend\n\t\tpos = alphabet.find_index(word[i])\n\telse\n\t\tif (pos - alphabet.find_index(word[i])).abs >= 13\n\t\t\tsum += 26 - (pos - alphabet.find_index(word[i])).abs\n\t\telse\n\t\t\tsum += (pos - alphabet.find_index(word[i])).abs\n\t\tend\n\t\tpos = alphabet.find_index(word[i])\n\tend\nend\n\nprint sum"}], "negative_code": [{"source_code": "n = gets\nr = 0\ni = 0\nn = n[0..( n.size - 2)]\nputs i\nn.each_byte {|c|\n c = c - 97\n r = [ ( c - i ).abs, ( ( i - c ).abs - 26 ).abs ].min + r\n i = c\n}\nputs r"}, {"source_code": "name = gets.bytes\n# name = 'zeus'.bytes\n\ndef calculate(name)\n result = 0\n current_ascii = 'a'.bytes[0]\n name.each do |char_ascii|\n dist = (current_ascii - char_ascii).abs\n current_ascii = char_ascii\n result += [dist, 26 - dist].min\n end\n result\nend\n\nputs calculate(name)\n"}, {"source_code": "name = gets.bytes\n# name = 'zeus'.bytes\n\ncurrent_ascii = 'a'.bytes[0]\nresult = 0\n\nname.each do |char_ascii|\n dist = (current_ascii - char_ascii).abs\n current_ascii = char_ascii\n result += [dist, 26 - dist].min\nend\n\nputs result\n"}, {"source_code": "t=0;'azeus'.split('').inject{|pr,i|td=((pr||'a').ord-i.ord).abs;t+=[td,26-td].min;i};puts t"}, {"source_code": "t=0;('a'+gets).split('').inject{|pr,i|td=((pr||'a').ord-i.ord).abs;t+=[td,26-td].min;i};puts t"}, {"source_code": "word = gets.chomp.split(\"\")\nalphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\nsum = 0\npos = 0\nfor i in (0..word.size-1)\n\tif i == 0\n\t\tif alphabet.find_index(word[i]) >= 13\n\t\t\tsum += 26 - alphabet.find_index(word[i])\n\t\telse\n\t\t\tsum += alphabet.find_index(word[i])\n\t\tend\n\t\tpos = alphabet.find_index(word[i])\n\telse\n\t\tif (pos - alphabet.find_index(word[i])).abs >= 13\n\t\t\tsum += 26 - (pos - alphabet.find_index(word[i])).abs\n\t\telse\n\t\t\tsum += pos - alphabet.find_index(word[i])\n\t\tend\n\t\tpos = alphabet.find_index(word[i])\n\tend\nend\n\nprint sum"}], "src_uid": "ecc890b3bdb9456441a2a265c60722dd"} {"source_code": "a,b,c,d=gets.split.map(&:to_i)\np=a*d\nq=b*c\nputs [Rational(p-q,p),Rational(q-p,q)].max\n", "positive_code": [{"source_code": "a=gets.chomp.split(\" \").map {|i| i.to_i}\nb=(a[1]*a[2]-a[0]*a[3]).abs\nif a[0]/a[2].to_f cd)\t\n\tdenum = a*d\nelsif (ab < cd)\t\n\tdenum = b*c\nelse\n\tnum = 0\n\tdenum = 1\nend\n\ndef gcd(a,b) \n\tb==0 ? a : gcd(b, a % b)\nend\n\ng = gcd(denum, num)\nnum = num/g\ndenum = denum/g\n\nputs \"#{num}/#{denum}\""}, {"source_code": " \na,b,c,d=gets.split.map(&:to_i)\np=a*d\nq=b*c\nputs [Rational(p-q,p),Rational(q-p,q)].max"}, {"source_code": "a,b,c,d=gets.split.map(&:to_i)\np=a*d\nq=b*c\nputs [Rational(p-q,p),Rational(q-p,q)].max"}, {"source_code": "def gcd(a,b)\nif b == 0\n return a;\nelse\n return gcd(b, a % b);\nend\nend\n\n\na,b,c,d = gets.split(\" \").map(&:to_i)\n\nl,m = (a/b.to_f),(c/d.to_f)\n\nnum = den = 0\n# puts \"#{l} #{m}\"\nif l < m\n\tnum = (b * c) - (a * d)\n\tden = b * c\nelsif l > m\n\tnum = (a * d) - (b * c)\n\tden = a * d\nend\n\nif num == 0 && den == 0\n\tputs \"0/1\"\nelse\n\tg = gcd(num,den)\n\tputs \"#{num/g}/#{den/g}\"\nend\n\n"}, {"source_code": "a, b, c, d = gets.split.map(&:to_i)\np = a * d\nq = b * c\nputs [Rational(p - q, p), Rational(q - p, q)].max\n"}, {"source_code": "def gcd(n, m)\n return m == 0? n : gcd(m, n % m)\nend\na, b, c, d = gets.chop!.split.map{|x| x.to_i}\nn, m = a * d, b * c\nif(n < m)\n k = n \n n = m\n m = k\nend\nm = n - m\nc = gcd(n, m)\nn /= c\nm /= c\nprint m, '/', n\n"}, {"source_code": "a, b, c, d = gets.split.collect{|i| i.to_i}\na *= c*d\nb *= c*d\nif a/c > b/d\n p = b/d\n c = a-p*c\n gcd = a.gcd(c)\n print c/gcd, \"/\", a/gcd, \"\\n\"\nelse\n p = a/c\n d = b-p*d\n gcd = b.gcd(d)\n print d/gcd, \"/\", b/gcd, \"\\n\"\nend\n"}, {"source_code": "a, b, c, d = gets.split.collect{|i| i.to_i}\na *= c*d\nb *= c*d\nif a/c > b/d\n p = b/d\n c = a-p*c\n d = p*d\n gcd = a.gcd(c)\n print c/gcd, \"/\", a/gcd, \"\\n\"\nelse\n p = a/c\n c = p*c\n d = b-p*d\n gcd = b.gcd(d)\n print d/gcd, \"/\", b/gcd, \"\\n\"\nend\n"}, {"source_code": "a,b,c,d=gets.split.map(&:to_i)\np=a*d\nq=b*c\nputs [Rational(p-q,p),Rational(q-p,q)].max"}, {"source_code": "a,b,c,d=gets.split.map(&:to_i)\np=a*d\nq=b*c\nputs [Rational(p-q,p),Rational(q-p,q)].max\n"}, {"source_code": "# f = File.new('test.txt', 'r')\na, b, c, d = gets.split.map(&:to_i)\n# f.close\n\ndef gcd(a, b)\n if b == 0\n a\n else\n gcd(b, a % b)\n end\nend\n\n\nif a * d < b * c\n numerator = (b * c - a * d)\n denomerator = (b * c)\nelsif a * d > b * c\n numerator = a * d - b * c\n denomerator = a * d\nelse\n numerator, denomerator = [0, 1]\nend\n\nuc = gcd(numerator, denomerator)\nnumerator /= uc\ndenomerator /= uc\nputs \"#{numerator}/#{denomerator}\""}, {"source_code": "a,b,c,d=gets.split.map(&:to_i)\np=a*d\nq=b*c\nputs [Rational(p-q,p),Rational(q-p,q)].max\n"}, {"source_code": "a,b,c,d=gets.split.map(&:to_i)\np=a*d\nq=b*c\nputs [Rational(p-q,p),Rational(q-p,q)].max\n"}, {"source_code": "a,b,c,d=gets.split.map(&:to_i)\np=a*d\nq=b*c\nputs [Rational(p-q,p),Rational(q-p,q)].max\n"}, {"source_code": "a,b,c,d=gets.split.map(&:to_i)\np=a*d\nq=b*c\nputs [Rational(p-q,p),Rational(q-p,q)].max"}, {"source_code": "a,b,c,d=gets.split.map(&:to_i)\np=a*d\nq=b*c\nputs [Rational(p-q,p),Rational(q-p,q)].max\n"}, {"source_code": "a,b,c,d=gets.split.map(&:to_i)\np=a*d\nq=b*c\nputs [Rational(p-q,p),Rational(q-p,q)].max"}, {"source_code": "a,b,c,d=gets.chomp.split.map(&:to_i)\na*=d;b*=c\n(a>b) ? (p=a-b;q=a) : (p=b-a;q=b)\nr=p.gcd(q)\nputs \"#{p/r}/#{q/r}\""}, {"source_code": "a,b,c,d=gets.split.map(&:to_i)\np=a*d\nq=b*c\nputs [Rational(p-q,p),Rational(q-p,q)].max\n"}, {"source_code": "a=gets.chomp.split(\" \").map {|i| i.to_i}\nb=(a[1]*a[2]-a[0]*a[3]).abs\nif a[0]/a[2].to_fa[3]\nc=b.gcd(a[2]*a[0])\nputs \"#{b/c}/#{(a[2]*a[0])/c}\"\nelsif a[3]>a[2]\nc=b.gcd(a[3]*a[1])\nputs \"#{b/c}/#{(a[3]*a[1])/c}\"\nelsif a[3]==a[2]\nif a[1]>a[0]\nc=b.gcd(a[3]*a[1])\nputs \"#{b/c}/#{(a[3]*a[1])/c}\"\nelse\nc=b.gcd(a[2]*a[0])\nputs \"#{b/c}/#{(a[2]*a[0])/c}\"\nend\nend"}, {"source_code": "def gcd(a,b)\nif b == 0\n return a;\nelse\n return gcd(b, a % b);\nend\nend\n\n\na,b,c,d = gets.split(\" \").map(&:to_i)\n\nl,m = (a/b.to_f),(c/d.to_f)\n\nnum = den = 0\n\nif l < m\n\tnum = (b * c) - (a * d)\n\tden = b * c\nelsif l > m\n\tnum = (a * d) - (b * c)\n\tden = a * d\nend\n\nif num == 0\n\tputs 0 \nelse\n\tg = gcd(num,den)\n\tputs \"#{num/g}/#{den/g}\"\nend\n\n"}], "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e"} {"source_code": "s = gets\nx = s.to_i\np [*1..x**0.5].map{|_| [_, x / _]}.flatten.select{|_| x % _ == 0 && s.tr(_.to_s, '') != s}.uniq.size", "positive_code": [{"source_code": "s = gets\nx = s.to_i\nh = {}\nf = ->(y){ h[y] = 1 if x % y == 0 && y.to_s.chars.any?{|c| s.index(c)} }\n1.upto(Math.sqrt(x)) do |y|\n f[y]\n f[x / y]\nend\np h.size\n"}, {"source_code": "s = gets\nx = s.to_i\np [*1..Math.sqrt(x)].map{|_| [_, x / _]}.flatten.select{|_| x % _ == 0 && s.tr(_.to_s, '') != s}.uniq.size\n"}, {"source_code": "s = gets\nx = s.to_i\nh = {}\nf = ->(y){ h[y] = 1 if x % y == 0 && s.tr(y.to_s, '') != s }\n1.upto(Math.sqrt(x)) do |y|\n f[y]\n f[x / y]\nend\np h.size\n"}, {"source_code": "s = gets\nx = s.to_i\np [*1..x**0.5].map{|_| [_, x / _]}.flatten.select{|_| x % _ == 0 && s.tr(_.to_s, '') != s}.uniq.size\n"}, {"source_code": "n = gets.to_i\nns = n.to_s.split('')\na = []\n(1..Math.sqrt(n)).each { |x| a.push(x, n/x) if n%x == 0 }\np a.sort.uniq.count { |x| (x.to_s.split('')&ns).size.nonzero? }"}, {"source_code": "s = gets\nx = s.to_i\np [*1..x**0.5].map{|_| [_, x / _]}.flatten.select{|_| x % _ == 0 && s.tr(_.to_s, '') != s}.uniq.size"}, {"source_code": "def divisors(n)\n ans = []\n 1.upto((n**0.5).to_i) do |i|\n if n % i == 0\n ans.push(i)\n ans.push(n/i) unless i * i == n\n end\n end\n return ans\nend\n\ndef match(x,d)\n m = 0\n xx = x.to_s.split(\"\").map(&:to_i)\n dd = d.to_s.split(\"\").map(&:to_i)\n 0.upto(9) do |digit|\n if xx.count(digit) > 0 && dd.count(digit) > 0\n return 1\n end\n end\n return 0\nend\n\nn = gets.to_i\n\ndivisors = divisors(n)\nputs divisors.inject(0){ |count, i| count += match(i,n) }\n"}, {"source_code": "x = gets.to_i\nxset = x.to_s.split(\"\")\nans = 0\n(1..x**0.5).each do |i|\n next if x%i != 0\n ans += 1 unless (i.to_s.split(\"\")&xset).empty?\n j = x/i\n if j != i\n ans += 1 unless (j.to_s.split(\"\")&xset).empty?\n end\nend\nputs ans\n"}, {"source_code": "require \"prime\"\nx=gets.to_i\nif x<10\n\tp 1\n\texit\nend\ntable=[nil]*10\nxx=x\nwhile xx>0\n\ttable[xx%10]=true\n\txx/=10\nend\npd=x.prime_division.map{|a,b|0.upto(b).map{|i|a**i}}\ndivisors=pd.first\npd[1..-1].each{|divs|divisors=divs.map{|d|divisors.map{|e|d*e}}.flatten}\nans=0\ndivisors.each{|d|\n\twhile d>0\n\t\tif table[d%10]\n\t\t\tans+=1\n\t\t\tbreak\n\t\tend\n\t\td/=10\n\tend\n}\np ans"}], "negative_code": [], "src_uid": "ada94770281765f54ab264b4a1ef766e"} {"source_code": "n=gets.to_i\ns=gets.chomp.reverse.chars.map &:to_i\nd=(n+1).times.collect{[0]*(n+1)}\np=(n+1).times.collect{[0]*(n+1)}\n0.upto(n){|i|\n\t0.upto(n){|j|\n\t\tif i>0\n\t\t\ta=d[i-1][j]+10**(i-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a; p[i][j]=0}\"if a>=d[i][j]\n\t\tend\n\t\tif j>0\n\t\t\ta=d[i][j-1]+10**(j-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a;p[i][j]=1}\"if a>=d[i][j]\n\t\tend\n\t}\n}\ni,j=n,n\nprint p[i][j]==0?\"#{i-=1;\"H\"}\":\"#{j-=1;\"M\"}\"while[i,j].max>0\n\n", "positive_code": [{"source_code": "n=gets.to_i\ns=gets.chomp.reverse.chars.map &:to_i\nd=(n+1).times.collect{[0]*(n+1)}\np=(n+1).times.collect{[0]*(n+1)}\n0.upto(n){|i|\n\t0.upto(n){|j|\n\t\tif i>0\n\t\t\ta=d[i-1][j]+10**(i-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a; p[i][j]=0}\"if a>=d[i][j]\n\t\tend\n\t\tif j>0\n\t\t\ta=d[i][j-1]+10**(j-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a;p[i][j]=1}\"if a>=d[i][j]\n\t\tend\n\t}\n}\ni,j=n,n\nprint p[i][j]==0?\"#{i-=1;\"H\"}\":\"#{j-=1;\"M\"}\"while[i,j].max>0\n\n"}, {"source_code": "n=gets.to_i\ns=gets.chomp.reverse.chars.map &:to_i\nd=(n+1).times.collect{[0]*(n+1)}\np=(n+1).times.collect{[0]*(n+1)}\n0.upto(n){|i|\n\t0.upto(n){|j|\n\t\tif i>0\n\t\t\ta=d[i-1][j]+10**(i-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a; p[i][j]=0}\"if a>=d[i][j]\n\t\tend\n\t\tif j>0\n\t\t\ta=d[i][j-1]+10**(j-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a;p[i][j]=1}\"if a>=d[i][j]\n\t\tend\n\t}\n}\ni,j=n,n\nprint p[i][j]==0?\"#{i-=1;\"H\"}\":\"#{j-=1;\"M\"}\"while[i,j].max>0\n\n"}, {"source_code": "n=gets.to_i\ns=gets.chomp.reverse.chars.map &:to_i\nd=(n+1).times.collect{[0]*(n+1)}\np=(n+1).times.collect{[0]*(n+1)}\n0.upto(n){|i|\n\t0.upto(n){|j|\n\t\tif i>0\n\t\t\ta=d[i-1][j]+10**(i-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a; p[i][j]=0}\"if a>=d[i][j]\n\t\tend\n\t\tif j>0\n\t\t\ta=d[i][j-1]+10**(j-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a;p[i][j]=1}\"if a>=d[i][j]\n\t\tend\n\t}\n}\ni,j=n,n\nprint p[i][j]==0?\"#{i-=1;\"H\"}\":\"#{j-=1;\"M\"}\"while[i,j].max>0\n\n"}, {"source_code": "n=gets.to_i\ns=gets.chomp.reverse.chars.map &:to_i\nd=(n+1).times.collect{[0]*(n+1)}\np=(n+1).times.collect{[0]*(n+1)}\n0.upto(n){|i|\n 0.upto(n){|j|\n if i>0\n a=d[i-1][j]+10**(i-1)*s[i+j-1]\n \"#{d[i][j]=a; p[i][j]=0}\"if a>=d[i][j]\n end\n if j>0\n a=d[i][j-1]+10**(j-1)*s[i+j-1]\n \"#{d[i][j]=a;p[i][j]=1}\"if a>=d[i][j]\n end\n }\n}\ni,j=n,n\nprint p[i][j]==0?\"#{i-=1;\"H\"}\":\"#{j-=1;\"M\"}\"while[i,j].max>0"}, {"source_code": "n=gets.to_i\ns=gets.chomp.reverse.chars.map &:to_i\nd=(n+1).times.collect{[0]*(n+1)}\np=(n+1).times.collect{[0]*(n+1)}\n0.upto(n){|i|\n\t0.upto(n){|j|\n\t\tif i>0\n\t\t\ta=d[i-1][j]+10**(i-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a; p[i][j]=0}\"if a>=d[i][j]\n\t\tend\n\t\tif j>0\n\t\t\ta=d[i][j-1]+10**(j-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a;p[i][j]=1}\"if a>=d[i][j]\n\t\tend\n\t}\n}\ni,j=n,n\nprint p[i][j]==0?\"#{i-=1;\"H\"}\":\"#{j-=1;\"M\"}\"while[i,j].max>0"}, {"source_code": "n=gets.to_i\ns=gets.chomp.reverse.chars.map &:to_i\nd=(n+1).times.collect{[0]*(n+1)}\np=(n+1).times.collect{[0]*(n+1)}\n0.upto(n){|i|\n\t0.upto(n){|j|\n\t\tif i>0\n\t\t\ta=d[i-1][j]+10**(i-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a; p[i][j]=0}\"if a>=d[i][j]\n\t\tend\n\t\tif j>0\n\t\t\ta=d[i][j-1]+10**(j-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a;p[i][j]=1}\"if a>=d[i][j]\n\t\tend\n\t}\n}\ni,j=n,n\nprint p[i][j]==0?\"#{i-=1;\"H\"}\":\"#{j-=1;\"M\"}\"while[i,j].max>0\n"}, {"source_code": "n=gets.to_i\ns=gets.chomp.reverse.chars.map &:to_i\nd=(n+1).times.collect{[0]*(n+1)}\np=(n+1).times.collect{[0]*(n+1)}\n0.upto(n){|i|\n\t0.upto(n){|j|\n\t\tif i>0\n\t\t\ta=d[i-1][j]+10**(i-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a; p[i][j]=0}\"if a>=d[i][j]\n\t\tend\n\t\tif j>0\n\t\t\ta=d[i][j-1]+10**(j-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a;p[i][j]=1}\"if a>=d[i][j]\n\t\tend\n\t}\n}\ni,j=n,n\nprint p[i][j]==0?\"#{i-=1;\"H\"}\":\"#{j-=1;\"M\"}\"while[i,j].max>0\n\n"}, {"source_code": "n=gets.to_i\ns=gets.chomp.reverse.chars.map &:to_i\nd=(n+1).times.collect{[0]*(n+1)}\np=(n+1).times.collect{[0]*(n+1)}\n0.upto(n){|i|\n\t0.upto(n){|j|\n\t\tif i>0\n\t\t\ta=d[i-1][j]+10**(i-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a; p[i][j]=0}\"if a>=d[i][j]\n\t\tend\n\t\tif j>0\n\t\t\ta=d[i][j-1]+10**(j-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a;p[i][j]=1}\"if a>=d[i][j]\n\t\tend\n\t}\n}\ni,j=n,n\nprint p[i][j]==0?\"#{i-=1;\"H\"}\":\"#{j-=1;\"M\"}\"while[i,j].max>0\n\n"}, {"source_code": "n=gets.to_i\ns=gets.chomp.reverse.chars.map &:to_i\nd=(n+1).times.collect{[0]*(n+1)}\np=(n+1).times.collect{[0]*(n+1)}\n0.upto(n){|i|\n\t0.upto(n){|j|\n\t\tif i>0\n\t\t\ta=d[i-1][j]+10**(i-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a; p[i][j]=0}\"if a>=d[i][j]\n\t\tend\n\t\tif j>0\n\t\t\ta=d[i][j-1]+10**(j-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a;p[i][j]=1}\"if a>=d[i][j]\n\t\tend\n\t}\n}\ni,j=n,n\nprint p[i][j]==0?\"#{i-=1;\"H\"}\":\"#{j-=1;\"M\"}\"while[i,j].max>0\n\n"}, {"source_code": "n=gets.to_i\ns=gets.chomp.reverse.chars.map &:to_i\nd=(n+1).times.collect{[0]*(n+1)}\np=(n+1).times.collect{[0]*(n+1)}\n0.upto(n){|i|\n\t0.upto(n){|j|\n\t\tif i>0\n\t\t\ta=d[i-1][j]+10**(i-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a; p[i][j]=0}\"if a>=d[i][j]\n\t\tend\n\t\tif j>0\n\t\t\ta=d[i][j-1]+10**(j-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a;p[i][j]=1}\"if a>=d[i][j]\n\t\tend\n\t}\n}\ni,j=n,n\nprint p[i][j]==0?\"#{i-=1;\"H\"}\":\"#{j-=1;\"M\"}\"while[i,j].max>0\n\n"}, {"source_code": "n=gets.to_i\ns=gets.chomp.reverse.chars.map &:to_i\nd=(n+1).times.collect{[0]*(n+1)}\np=(n+1).times.collect{[0]*(n+1)}\n0.upto(n){|i|\n\t0.upto(n){|j|\n\t\tif i>0\n\t\t\ta=d[i-1][j]+10**(i-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a; p[i][j]=0}\"if a>=d[i][j]\n\t\tend\n\t\tif j>0\n\t\t\ta=d[i][j-1]+10**(j-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a;p[i][j]=1}\"if a>=d[i][j]\n\t\tend\n\t}\n}\ni,j=n,n\nprint p[i][j]==0?\"#{i-=1;\"H\"}\":\"#{j-=1;\"M\"}\"while[i,j].max>0"}, {"source_code": "$re = Array.new(20)\n$re.each_index{ |y|\n\t$re[y] = Array.new(20) \n}\n\n$fx = Array.new(20)\n$fx.each_index{ |y|\n\t$fx[y] = Array.new(20,-1)\n}\n\n$wz = Array.new(20)\n\ndef dfs( a, b )\n return $re[a][b] if($fx[a][b]!=-1)\n if(a==$n && b==$n)\n $fx[a][b]=-2\n return $re[a][b]=0\n end\n $re[a][b]=-1\n\n if(a!=$n)\n $re[a][b]=dfs(a+1,b)+$wz[a]*$cd[a+b].to_i\n $fx[a][b]=0\n end\n\n if(b!=$n)\n lj=dfs(a,b+1)+$wz[b]*$cd[a+b].to_i\n if($re[a][b] 0\n\tif hs.length == ms.length\n\t\ths += s.slice!(0,1)\n\t\tret += \"H\"\n\telse\n\t\tmidx = 0\n\t\tmval = \" \"\n\t\tcont = false\n\t\tfor i in 0..(n-hs.length)\n\t\t\tif mval < s[i]\n\t\t\t\tmval = s[i]\n\t\t\t\tmidx = i\n\t\t\t\tcont = true\n\t\t\telsif mval == s[i]\n\t\t\t\tif not cont\n\t\t\t\t\tnclen = i - midx - 1\n\t\t\t\t\tbstr = s.slice(midx+1,nclen)\n\t\t\t\t\tastr = s.slice(i+1, nclen)\n\t\t\t\t\tif bstr < astr\n\t\t\t\t\t\tmval = s[i]\n\t\t\t\t\t\tmidx = i\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tcont = false\n\t\t\tend\n\t\tend\n\t\twhile midx > 0\n\t\t\ths += s.slice!(0,1)\n\t\t\tret += \"H\"\n\t\t\tmidx -= 1\n\t\tend\n\t\tms += s.slice!(0,1)\n\t\tret += \"M\"\n\tend\nend\nreturn ret\nend\n\nputs calc1($n,$s.dup)\n"}, {"source_code": "n = gets.chomp.to_i\ns = gets.chomp\n\nhs = \"\"\nms = \"\"\nret = \"\"\n\nwhile s.length > 0\n\tif hs.length == ms.length\n\t\ths += s.slice!(0,1)\n\t\tret += \"H\"\n\telse\n\t\tmidx = 0\n\t\tmval = \" \"\n\t\tfor i in 0..(n-hs.length)\n\t\t\tif mval < s[i]\n\t\t\t\tmval = s[i]\n\t\t\t\tmidx = i\n\t\t\tend\n\t\tend\n\t\twhile midx > 0\n\t\t\ths += s.slice!(0,1)\n\t\t\tret += \"H\"\n\t\t\tmidx -= 1\n\t\tend\n\t\tms += s.slice!(0,1)\n\t\tret += \"M\"\n\tend\nend\nputs ret\n"}, {"source_code": "n = gets.chomp.to_i\ns = gets.chomp\n\nhs = \"\"\nms = \"\"\nret = \"\"\n\nwhile s.length > 0\n\tif hs.length == ms.length\n\t\ths += s.slice!(0,1)\n\t\tret += \"H\"\n\telse\n\t\tmidx = 0\n\t\tmval = \" \"\n\t\tfor i in 0..(n-hs.length)\n\t\t\tif mval < s[i]\n\t\t\t\tmval = s[i]\n\t\t\t\tmidx = i\n\t\t\tend\n\t\tend\n\t\twhile midx > 0\n\t\t\ths += s.slice!(0,1)\n\t\t\tret += \"H\"\n\t\t\tmidx -= 1\n\t\tend\n\t\tms += s.slice!(0,1)\n\t\tret += \"M\"\n\tend\nend\nputs ret\n"}, {"source_code": "$n = gets.chomp.to_i\n$s = gets.chomp\n\ndef calc1(n,s)\nhs = \"\"\nms = \"\"\nret = \"\"\nwhile s.length > 0\n\tif hs.length == ms.length\n\t\ths += s.slice!(0,1)\n\t\tret += \"H\"\n\telse\n\t\tmidx = 0\n\t\tmval = \" \"\n\t\tcont = false\n\t\tfor i in 0..(n-hs.length)\n\t\t\tif mval < s[i]\n\t\t\t\tmval = s[i]\n\t\t\t\tmidx = i\n\t\t\t\tcont = true\n\t\t\telsif mval == s[i]\n\t\t\t\tif not cont\n\t\t\t\t\tnclen = i - midx - 1\n\t\t\t\t\tbstr = s.slice(midx+1,nclen)\n\t\t\t\t\tastr = s.slice(i+1, nclen)\n\t\t\t\t\tif bstr <= astr\n\t\t\t\t\t\tmval = s[i]\n\t\t\t\t\t\tmidx = i\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tcont = false\n\t\t\tend\n\t\tend\n\t\twhile midx > 0\n\t\t\ths += s.slice!(0,1)\n\t\t\tret += \"H\"\n\t\t\tmidx -= 1\n\t\tend\n\t\tms += s.slice!(0,1)\n\t\tret += \"M\"\n\tend\nend\nreturn ret\nend\n\nputs calc1($n,$s.dup)\n"}, {"source_code": "n=gets.to_i\ns=gets.chomp.reverse.chars.map &:to_i\nd=(n+1).times.collect{[0]*(n+1)}\np=(n+1).times.collect{[0]*(n+1)}\n0.upto(n){|i|\n\t0.upto(n){|j|\n\t\tif i>0\n\t\t\ta=d[i-1][j]+10**(i-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a; p[i][j]=0}\"if a>d[i][j]\n\t\tend\n\t\tif j>0\n\t\t\ta=d[i][j-1]+10**(j-1)*s[i+j-1]\n\t\t\t\"#{d[i][j]=a;p[i][j]=1}\"if a>d[i][j]\n\t\tend\n\t}\n}\ni,j=n,n\nprint p[i][j]==0?\"#{i-=1;\"H\"}\":\"#{j-=1;\"M\"}\"while[i,j].max>0\n"}], "src_uid": "98489fe54488dcfb45f8ae7b5c473d88"} {"source_code": "n = gets.to_i\np n % 2 == 0 ? 2**(n/2) : 0", "positive_code": [{"source_code": "# coding: utf-8\n\nn = gets.to_i\n\n# 3 x n grid with 'ㄴ'-shaped tile\n\nif n.odd?\n puts \"0\"\nelse\n puts 2**(n/2)\nend"}, {"source_code": "n=gets.to_i\nif n%2==1\nputs 0\nelse\nputs 2**(n/2)\nend\n"}, {"source_code": "n = gets.chomp!.to_i\n\nputs (n < 2 ? 0 : (n.even? ? (2 ** (n / 2)) : 0)) \n"}, {"source_code": "n=gets.to_i\nif n.odd?\n p 0\nelse\n p 2**(n/2)\nend\n"}, {"source_code": "n = gets.to_i\nputs n % 2 == 0 ? 2**(n/2) : 0"}], "negative_code": [{"source_code": "n = gets.chomp!.to_i\n\nans = (n < 2 ? 0 : 2**(n/2))\n\nputs ans "}, {"source_code": "n = gets.chomp!.to_i\n\nans = 0 if n < 2\n\nans = 2 ** (n / 2) if n.even?\n\nans = 2 ** ((n - 1)/2)\n\nputs ans\n"}, {"source_code": "n = gets.chomp!.to_i\n\nputs (n < 2 ? 0 : (n.even? ? (2 ** (n / 2)) : (2 ** ((n - 1)/2))))\n"}, {"source_code": "p gets.to_i/2*2\n"}], "src_uid": "4b7ff467ed5907e32fd529fb39b708db"} {"source_code": "a, b, f, k = gets.split.map(&:to_i)\nstep = Enumerator.new do |y|\n y.yield f\n u, v = (a-f)*2, f*2\n ((k-1)/2).times {\n y.yield u\n y.yield v\n }\n if k&1 == 0\n y.yield u\n y.yield f\n else\n y.yield a-f\n end\nend\nt, r = b, 0\nstep.each do |s|\n if t < s\n t = b\n r += 1\n if t < s\n r = -1\n break\n end\n end\n t -= s\nend\np r", "positive_code": [{"source_code": "a, b, f, k = gets.split.map{|x| x.to_i}\n\nd = [f]\n(1...k).each do |i|\n\td << 2 * (a - f) if i.odd?\n\td << 2 * f if i.even?\nend\nd << (a - f) if k.odd?\nd << f if k.even?\nd << -1\n\ncurB = b\nans = 0\nd.each_with_index do |l, j|\n\tbreak if l == -1\n\n\tcurB -= l\n\t\n\tif curB < 0\n\t\tp -1\n\t\texit(0)\n\telsif curB < d[j + 1]\n\t\tcurB = b;\n\t\tans += 1;\n\tend\n\t\nend\n\np ans"}, {"source_code": "a, b, f, k = gets.split.map(&:to_i)\nu, v, t, r = (a-f)*2, f*2, b, 0\nEnumerator.new do |y|\n y.yield f\n ((k-1)/2).times {\n y.yield u\n y.yield v\n }\n if k&1 == 0\n y.yield u\n y.yield f\n else\n y.yield a-f\n end\nend.each do |s|\n if t < s\n t = b\n r += 1\n if t < s\n r = -1\n break\n end\n end\n t -= s\nend\np r"}], "negative_code": [], "src_uid": "283aff24320c6518e8518d4b045e1eca"} {"source_code": "n1,n2,k1,k2=gets.split.map(&:to_i)\nn1,n2,k1,k2=n2,n1,k2,k1 if n1>n2\nM=100000000\ndp1=Array.new(205){Array.new(105,0)}\ndp2=Array.new(205){Array.new(105,0)}\n1.upto(k1){|m|dp1[m][1]=1}\n1.upto(k2){|m|dp2[m][1]=1}\n2.upto(n1){|j|1.upto(n1){|m|dp1[m][j]=(m-k1).upto(m-1).map{|i|dp1[i][j-1]}.inject(:+)%M}}\n2.upto(n2){|j|1.upto(n2){|m|dp2[m][j]=(m-k2).upto(m-1).map{|i|dp2[i][j-1]}.inject(:+)%M}}\nans=0\n1.upto(n1){|j|ans=(ans+2*dp1[n1][j]*dp2[n2][j]+dp1[n1][j-1]*dp2[n2][j]+dp1[n1][j]*dp2[n2][j-1])%M}\nans=(ans+dp1[n1][n1]*dp2[n2][n1+1])%M if n1!=n2\np ans", "positive_code": [{"source_code": "input=gets.split.map(&:to_i)\n\n$n1=input[0]\n$n2=input[1]\n$k1=input[2]+1\n$k2=input[3]+1\n$dp=Array.new(101){Array.new(101){Array.new(20){Array.new(3,-1)}}}\ndef solve(c1,c2,s,t)\n\n if c1>$n1 || c2>$n2 then\n return 0\n end\n if c1==$n1 && c2==$n2 then\n return 1\n end\n if $dp[c1][c2][s][t]>=0 then\n return $dp[c1][c2][s][t]\n end\n #1を置く\n ans=0\n if t==0 then\n if s+1<$k1 then\n ans+=solve(c1+1,c2,s+1,t)\n end\n else\n ans+=solve(c1+1,c2,1,0)\n end\n\n #2を置く\n if t==1 then\n if s+1<$k2 then\n ans+=solve(c1,c2+1,s+1,t)\n end\n else\n ans+=solve(c1,c2+1,1,1)\n end\n ans%=100000000\n $dp[c1][c2][s][t]=ans\n return ans\nend\n\np solve(0,0,0,0)"}, {"source_code": "def solution(n1, n2, k1, k2, flag)\n return 1 if n1 == 0 && n2 == 0\n\n return 0 if n1 == 0 && flag\n return 0 if n2 == 0 && !flag\n\n if flag\n return @beging_with_soldiers[n1][n2] if @beging_with_soldiers[n1][n2]\n else\n return @beging_with_horses[n1][n2] if @beging_with_horses[n1][n2]\n end\n\n k = 1\n possibilities = 0\n if flag\n while k <= k1 && n1 - k >= 0 do\n possibilities += solution(n1-k, n2, k1, k2, !flag)\n k += 1\n end\n else\n while k <= k2 && n2 - k >= 0 do\n possibilities += solution(n1, n2-k, k1, k2, !flag)\n k += 1\n end\n end\n\n possibilities = possibilities % 100000000\n if flag\n @beging_with_soldiers[n1][n2] = possibilities\n else\n @beging_with_horses[n1][n2] = possibilities\n end\n possibilities\nend\n\nn1, n2, k1, k2 = gets.strip().split().map(&:to_i)\n\nmax_n = [n1, n2].max + 1\n@beging_with_soldiers = Array.new(max_n) { Array.new(max_n) { false } }\n@beging_with_horses = Array.new(max_n) { Array.new(max_n) { false } }\n\nsolution(n1, n2, k1, k2, true)\nsolution(n1, n2, k1, k2, false)\nputs (@beging_with_soldiers[n1][n2] + @beging_with_horses[n1][n2]) % 100000000\n"}], "negative_code": [{"source_code": "def solution(n1, n2, k1, k2, flag)\n return 1 if n1 == 0 && n2 == 0\n\n return 0 if n1 == 0 && flag\n return 0 if n2 == 0 && !flag\n\n if flag\n return @beging_with_soldiers[n1][n2] if @beging_with_soldiers[n1][n2]\n else\n return @beging_with_horses[n1][n2] if @beging_with_horses[n1][n2]\n end\n\n k = 1\n possibilities = 0\n if flag\n while k <= k1 && n1 - k >= 0 do\n possibilities += solution(n1-k, n2, k1, k2, !flag)\n k += 1\n end\n else\n while k <= k2 && n2 - k >= 0 do\n possibilities += solution(n1, n2-k, k1, k2, !flag)\n k += 1\n end\n end\n\n if flag\n @beging_with_soldiers[n1][n2] = possibilities\n else\n @beging_with_horses[n1][n2] = possibilities\n end\n possibilities\nend\n\nn1, n2, k1, k2 = gets.strip().split().map(&:to_i)\n\nmax_n = [n1, n2].max + 1\n@beging_with_soldiers = Array.new(max_n) { Array.new(max_n) { false } }\n@beging_with_horses = Array.new(max_n) { Array.new(max_n) { false } }\n\nsolution(n1, n2, k1, k2, true)\nsolution(n1, n2, k1, k2, false)\nputs @beging_with_soldiers[n1][n2] + @beging_with_horses[n1][n2]\n\n"}, {"source_code": "def solve(a, b, a_max, b_max)\n @posibilities = Array.new(2, Array.new(a+1, Array.new(b+1, false)))\n @posibilities[0][1][0] = 1\n @posibilities[1][0][1] = 1\n\n def solution(a, b, a_max, b_max, flag)\n return @posibilities[flag][a][b] if @posibilities[flag][a][b]\n\n return 1 if (a == 0 && b == 0)\n\n posibilities_count = 0\n if flag == 0\n for i in 1..a_max do\n posibilities_count += solution(a-i, b, a_max, b_max, 1) if (a-i >= 0)\n end\n else\n for i in 1..b_max do\n posibilities_count += solution(a, b-i, a_max, b_max, 0) if (b-i >= 0)\n end\n end\n\n @posibilities[flag][a][b] = posibilities_count\n posibilities_count\n end\n solution(a, b, a_max, b_max, 0)\n solution(a, b, a_max, b_max, 1)\n @posibilities[0][a][b]\nend\n\nputs solve(*gets.split.map(&:to_i))"}, {"source_code": "def solution(n1, n2, k1, k2, flag)\n return 1 if n1 == 0 && n2 == 0\n\n return 0 if n1 == 0 && flag\n return 0 if n2 == 0 && !flag\n\n if flag\n return @beging_with_soldiers[n1][n2] if @beging_with_soldiers[n1][n2]\n else\n return @beging_with_horses[n1][n2] if @beging_with_horses[n1][n2]\n end\n\n k = 1\n possibilities = 0\n if flag\n while k <= k1 && n1 - k >= 0 do\n possibilities += solution(n1-k, n2, k1, k2, !flag)\n k += 1\n end\n else\n while k <= k2 && n2 - k >= 0 do\n possibilities += solution(n1, n2-k, k1, k2, !flag)\n k += 1\n end\n end\n\n possibilities = possibilities % 100000000\n if flag\n @beging_with_soldiers[n1][n2] = possibilities\n else\n @beging_with_horses[n1][n2] = possibilities\n end\n possibilities\nend\n\nn1, n2, k1, k2 = gets.strip().split().map(&:to_i)\n\nmax_n = [n1, n2].max + 1\n@beging_with_soldiers = Array.new(max_n) { Array.new(max_n) { false } }\n@beging_with_horses = Array.new(max_n) { Array.new(max_n) { false } }\n\nsolution(n1, n2, k1, k2, true)\nsolution(n1, n2, k1, k2, false)\nputs @beging_with_soldiers[n1][n2] + @beging_with_horses[n1][n2]\n"}], "src_uid": "63aabef26fe008e4c6fc9336eb038289"} {"source_code": "n, k, x = gets.split.map &:to_i\na = gets.split.map &:to_i\nif k < n\n puts (a[0...n-k].inject &:+) + k * x\nelse\n puts k * x\nend", "positive_code": [{"source_code": "n,k,x,*a=$<.read.split.map &:to_i\nk=n if k>n\np a[0...-k].reduce(0,:+)+k*x"}, {"source_code": "n, k, x = gets.strip.split.map(&:to_i)\na = gets.strip.split.map(&:to_i)\nspecial = n - k\nans = 0\nn.times do |i|\n if i < special\n ans += a[i]\n else\n ans += x\n end\nend\nputs ans\n"}, {"source_code": "n, k, x = gets.split.map(&:to_i)\na = gets.split.map(&:to_i)\nans = 0\n1.upto(n) do |i|\n if i <= k\n ans += x\n else\n ans += a[-i]\n end\nend\nputs ans"}, {"source_code": "n, k, x = gets.split.map(&:to_i)\na = gets.split.map(&:to_i)\nfor i in 1 .. k\n a[-i] = [a[-i], x].min\nend\nputs a.reduce(:+)\n"}, {"source_code": "n, k, x = gets.split.map{|i| i.to_i}\narr = gets.split.map{|i| i.to_i}\n\nans = k * x\n\n(n - k).times{|i| ans += arr[i]}\n\np ans"}], "negative_code": [], "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96"} {"source_code": "n = gets.to_i\nans = Array.new(n, 0)\nans[0] = 1\n(1..n-1).each do |i|\n ans[i] = ans[i-1] + 4 * i\nend\nputs ans[n-1]", "positive_code": [{"source_code": "n = gets.to_i\nans = 1\n(2..n).each { |x| ans += 2*x + 2*(x - 2) }\nputs ans\n"}, {"source_code": "n = gets.chomp.to_i\n\ndef solve(n)\n dp = [0] * (n + 1)\n dp[1] = 1\n for i in 2...n+1 do\n dp[i] = dp[i-1] + 4*(i-1)\n end\n return dp[n]\nend\n\nputs solve(n)\n"}, {"source_code": "n = gets.to_i\nans = 2*n-1\n(n-1).times do |i|\n ans += (i*2+1)*2\nend\np ans"}, {"source_code": "a=gets.to_i\nprint a*(a-1)*2+1"}, {"source_code": "# coding: utf-8\n\n# if __FILE__ == $0\n# end\n\nn = gets.to_i\n\nputs n*n*2 - (2*n - 1)"}], "negative_code": [{"source_code": "n = gets.chomp.to_i\n\ndef solve(n)\n dp = [0] * (n + 1)\n dp[1] = 1\n for i in 2...n+1 do\n dp[i] = dp[i-1] + 2**i\n end\n return dp[n]\nend\n\nputs solve(n)\n"}, {"source_code": "n = gets.to_i\np n==1 ? 1 : (2*n-3)**2+4"}], "src_uid": "758d342c1badde6d0b4db81285be780c"} {"source_code": "include Math\n\ndef isprime?(n) # 41: Sorry, no caching\n return false if n <= 0\n limit = sqrt(n).to_i # correct?\n 2.upto(limit) {|i|\n return false if n % i == 0\n }\n return true\nend\n\nN, M = gets.split.map{|e| e.to_i}\nnext_prime = -1\n(N + 1).upto(51) {|i|\n if (isprime?(i))\n next_prime = i\n break\n end\n}\n#p [next_prime, M]\n \nif (M == next_prime)\n puts \"YES\"\nelse\n puts \"NO\"\nend\n\n \n", "positive_code": [{"source_code": "#!/usr/bin/ruby\n# http://codeforces.ru/contest/80/problem/A\n\n[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47].tap { |primes| gets.split.map { |e| primes.index(e.to_i) }.tap { |a| puts a[1] == a[0]+1 ? 'YES' : 'NO' } }\n\n"}, {"source_code": "n,m=gets.split.map(&:to_i)\nputs m==[*n+1..m].find{|_|2**_%_==2}?\"YES\":\"NO\"\n"}, {"source_code": "def attack(n,m)\n primes = []\n (n..m).each do |i|\n next if i > 2 && i % 2 == 0\n divisors = []\n (1..i).each {|x| divisors << x if i % x == 0 }\n if divisors.size == 2 && divisors.include?(1) && divisors.include?(i)\n primes << i\n end\n end\n x = primes.index(n)\n return \"YES\" if primes[x+1] == m\n \"NO\"\nend\n\nn,m = gets.split(\" \").map(&:to_i)\nputs attack(n,m)"}, {"source_code": "require 'prime'\n\n# TEMPLATE BEGIN\ndef read_vector\n gets.chomp.split(/\\s+/)\nend\ndef read_vector_int\n read_vector.map(&:to_i)\nend\n# TEMPLATE END\n\nn, m = read_vector_int\n\ndef no()\n puts \"NO\"\n exit 0\nend\n\ndef yes()\n puts \"YES\"\n exit 0\nend\n\nno() unless n.prime?\nno() unless m.prime?\nno() if (n..m).map{ |i| i.prime? }.count(true) > 2\n\nyes()\n"}, {"source_code": "n,m=gets.split.map(&:to_i)\nputs m==[*n+1..m].find{|_|2**_%_==2}?\"YES\":\"NO\""}, {"source_code": "require 'mathn'\nn, m = gets.split.map(&:to_i)\nputs (n.prime? and m.prime? and (n+1...m).find_all(&:prime?).size == 0) ? :YES : :NO"}, {"source_code": "n,m=gets.split.map(&:to_i)\nputs m==[*n+1..m].find{|_|2**_%_==2}?\"YES\":\"NO\"\n"}, {"source_code": "require 'prime'\n\nn, m = gets.split.map(&:to_i)\n\nunless m.prime?\n puts 'NO'\n exit\nend\n\nans = 'YES'\n((n+1)..m).each do |i|\n if i.prime? && i != m\n ans = 'NO'\n end\nend\nputs ans\n"}, {"source_code": "n,m=gets.split.map(&:to_i)\nputs m==[*n+1..m].find{|_|2**_%_==2}?\"YES\":\"NO\"\n"}, {"source_code": "def prime?( x )\n return false if x <= 1\n (2..x).each do |i|\n break if i * i > x\n return false if x % i == 0\n end\n return true\nend\ndef next_prime( x )\n n = x + 1\n while !prime? n\n n += 1\n end\n n\nend\nn, m = gets.strip.split.map(&:to_i)\nans = \"NO\"\na = next_prime n\nans = \"YES\" if a == m\nputs ans\n"}, {"source_code": "require \"Prime\"\na=gets.chomp.split(\" \")\nf=a[0].to_i\ns=a[1].to_i\nif !(Prime.prime?(s))\nputs \"NO\"\nelse\ntemp=[]\nPrime.each(s) do |i|\ntemp << i\nend\nk=temp.index(f)+1\nif temp[k]==s\nputs \"YES\"\nelse\nputs \"NO\"\nend\nend\n"}, {"source_code": "require 'prime'\na,b=gets.split.map{|e| e.to_i}\nif Prime.each(50).each_cons(2).select{|p,r| true}.index([a,b])!=nil then\n\tputs \"YES\"\nelse\n\tputs \"NO\"\nend\n"}, {"source_code": "require \"mathn\"\n\narray = gets.split(/ /)\n\nflag = false\nflag2 = false\n\nPrime.new.each{|x|\n if flag2 == true\n if array[1].to_i == x\n puts \"YES\"\n break\n else\n puts \"NO\"\n break\n end\n end\n\n if array[0].to_i == x\n flag = true\n end\n if flag == true\n flag2 = true\n end\n\n}\n"}, {"source_code": "n,m=gets.split.map(&:to_i)\nputs m==[*n+1..m].find{|_|2**_%_==2}?\"YES\":\"NO\""}, {"source_code": "require 'prime'\n#-------------------\n\nn,m=gets.split.map(&:to_i)\n\nflag=false\nfor i in n+1..m\n\tif i.prime?\n\t\t(i==m) ? (puts \"YES\") : (puts \"NO\")\n\t\tflag=true\n\t\tbreak\n\tend\nend\n\nputs \"NO\" if !flag\n"}, {"source_code": "require'prime'\nx,y=gets.split.map &:to_i\nputs Prime.find{|_|_>x}==y ?:YES:\"NO\""}, {"source_code": "# coding: utf-8\n\n# if __FILE__ == $0\n# end\n\nn, m = gets.split.map(&:to_i)\nprimes = [2,3]\ncount_primes = 0\nis_prime = true\n\ni = primes.last\nwhile i <= m\n is_prime = true\n for j in primes\n if i%j == 0\n is_prime = false\n break\n end\n end\n\n if is_prime\n primes << i\n end\n\n i += 1\nend\n\nn_idx = primes.index(n)\nm_idx = primes.index(m)\n\nif m_idx == nil\n puts \"NO\"\nelse\n if m_idx - n_idx != 1\n puts \"NO\"\n else\n puts \"YES\"\n end\nend"}, {"source_code": "n,m=gets.split.map(&:to_i)\nputs m==[*n+1..m].find{|_|2**_%_==2}?\"YES\":\"NO\"\n"}, {"source_code": "s=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]\nn,m=gets.split.map &:to_i \nputs s[s.index(n).to_i+1]==m ?\"YES\":\"NO\""}, {"source_code": "sieve = Array.new(51, true)\nprimes = []\n\n(2..50).each do |p|\n next unless sieve[p]\n primes << p\n i = p*p\n while(i<=50) do\n sieve[i] = false\n i += p\n end\nend\n\nn,m = gets.split(/\\s+/).map(&:to_i)\nk = primes.index(n)\nputs (primes[k+1] == m) ? \"YES\" : \"NO\"\n"}, {"source_code": "def is_prime(x)\n return true if x < 0\n 2.upto(x-1) do |i|\n return false if x % i == 0\n end\n return true\nend\n\nn,m = gets.strip.split(' ').map(&:to_i)\nif !is_prime(m)\n print \"NO\"\n exit\nend\n(n+1).upto(m-1) do |i|\n if is_prime(i)\n print \"NO\"\n exit\n end\nend\nprint \"YES\"\n"}, {"source_code": "n,m=gets.split.map(&:to_i)\nputs m==[*n+1..m].find{|_|2**_%_==2}?\"YES\":\"NO\"\n"}, {"source_code": "# Codeforces Beta Round #69\n# Problem A -- Panoramix's Prediction\ndef is_prime(n)\n 2.upto Math.sqrt(n).to_i do |i|\n return false if n % i == 0\n end\n true\nend\n\nn, m = gets.split.map(&:to_i)\nn += 1\nn += 1 until is_prime(n)\nputs n == m ? \"YES\" : \"NO\"\n"}, {"source_code": "n,m=gets.split.map(&:to_i)\nputs m==[*n+1..m].find{|_|2**_%_==2}?\"YES\":\"NO\""}, {"source_code": "primes = []\nprime = false\n2.step(50) do |i|\n primes << i\n (2...i).each do |j|\n break if i / 2 < j\n if i % j == 0\n primes.pop\n break\n end\n end\nend\nn, m = gets.strip.split.map{|s| s.to_i}\nif x = primes.index(n)\n if m == primes[x + 1]\n puts \"YES\"\n exit\n end\nend\nputs \"NO\"\n"}, {"source_code": "n,m=gets.split.map(&:to_i)\nputs m==[*n+1..m].find{|_|2**_%_==2}?\"YES\":\"NO\"\n"}, {"source_code": "n,m=gets.split.map(&:to_i)\nputs m==(n+1..m).find{|i|2**i%i==2}?\"YES\":\"NO\"\n"}, {"source_code": "require 'prime'\nx, y = gets.split.map(&:to_i)\nputs Prime.find{|_| _ > x} == y ? :YES : :NO\n"}, {"source_code": "input = gets.split.map {|e| e.to_i}\nMAX = 50\nsieve = []\nfor i in 2 .. MAX\n sieve[i] = i\nend\nfor i in 2 .. Math.sqrt(MAX)\n next unless sieve[i]\n (i*i).step(MAX, i) do |j|\n\n sieve[j] = nil\n end\nend\nsieve.compact!\n\nfor i in 0 .. sieve.size\n if input[0] == sieve[i] \n puts input[1] == sieve[i+1] ? \"YES\" : \"NO\"\n exit\n end\nend\n"}, {"source_code": "\nrequire 'prime'\ninput=gets.split.map(&:to_i)\np=Prime.take(50)\nres=\"NO\"\nfor i in 0..49\n if p[i]==input[0] && p[i+1]==input[1] then\n res=\"YES\"\n end\nend\n\nputs res\n"}, {"source_code": "n,m=gets.split.map(&:to_i)\nputs m==[*n+1..m].find{|_|2**_%_==2}?\"YES\":\"NO\"\n"}, {"source_code": "#!/usr/bin/ruby\n\nprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]\n\nn, m = gets.split.map { |e| e.to_i }\n\nputs primes.include?( m ) && primes.index(m) == primes.index(n)+1 ? \"YES\" : \"NO\"\n\n"}], "negative_code": [{"source_code": "def prime?( x )\n return false if x <= 1\n (2..x).each do |i|\n break if i * i > x\n return false if x % i == 0\n end\n return true\nend\nn, m = gets.strip.split.map(&:to_i)\nans = \"NO\"\n((n + 1)..m).each do |i|\n if prime? i\n ans = \"YES\" if i == m\n end\nend\nputs ans\n"}, {"source_code": "def prime?( x )\n return false if x <= 1\n (2..x).each do |i|\n break if i * i > x\n return false if x % i == 0\n end\n return true\nend\ndef next_prime( x )\n return 2 if x <= 2\n n = x + 1\n while !prime? n\n n += 1\n end\n n\nend\nn, m = gets.strip.split.map(&:to_i)\na = next_prime n\nif a == m\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "require \"mathn\"\n\narray = gets.split(/ /)\n\nflag = false\nflag2 = false\n\nPrime.new.each{|x|\n if flag2 == true\n if array[1].to_i == x\n puts \"YES\"\n break\n else\n puts \"no\"\n break\n end\n end\n\n if array[0].to_i == x\n flag = true\n end\n if flag == true\n flag2 = true\n end\n\n}\n"}, {"source_code": "require 'prime'\n#-------------------\n\nn,m=gets.split.map(&:to_i)\n\nfor i in n+1..m\n\tif i.prime?\n\t\t(i==m) ? (puts \"YES\") : (puts \"NO\")\n\t\tbreak\n\tend\nend\n"}, {"source_code": "require 'prime'\n\nn,m=gets.split.map(&:to_i)\n\nflag=false\nfor i in n+1..m\n\tif i.prime? && i==m\n\t\tputs \"YES\"\n\t\tflag=true\n\t\tbreak\n\tend\nend\n\nputs \"NO\" if !flag\n"}, {"source_code": "s=[2,3,5,7,11,13,17,19,23,39,31,37,41,43,47]\nn,m=gets.split.map &:to_i \nputs s[s.index(n).to_i+1]==m ?\"YES\":\"NO\""}], "src_uid": "9d52ff51d747bb59aa463b6358258865"} {"source_code": "$a = gets\n$a,$b = $a.split(' ').to_a\n\n$a = $a.to_i\n$b = $b.to_i\n(0...$b).each do |i|\n\tif $a%10 == 0\n\t\t$a = $a/10\n\telse\n\t\t$a -= 1\n\tend\nend\nprint $a;", "positive_code": [{"source_code": "def solve\n a,b=read_ints;\n b.times do\n if(a%10!=0)\n a-=1\n else\n a=a/10\n end\n end\n puts a\nend\n\ndef read_int\n gets.split(\" \");\nend\n\ndef read_ints\n gets.split.map(&:to_i);\nend\n\nsolve"}, {"source_code": "def solve\n a,b=read_ints;\n b.times do\n if(a%10!=0)\n a-=1\n else\n a=a/10\n end\n end\n puts a\nend\n\ndef read_int\n gets.split(\" \");\nend\n\ndef read_ints\n gets.split.map(&:to_i);\nend\n10000000.times do \nend\nsolve"}, {"source_code": "a,b=gets.split.map &:to_i\nb.times{a=a%10==0?a/10:a-1}\np a"}, {"source_code": "#!usr/bin/env ruby\n\n# https://codeforces.com/problemset/problem/977/A\n\ninput = gets.split(' ').map(&:to_i)\nnumber = input[0]\nk = input[1]\n\nk.times do\n if number % 10 == 0\n number /= 10\n else\n number -= 1\n end\nend\n\nputs number\n"}, {"source_code": "# https://codeforces.com/problemset/problem/977/A\n\nn, k = gets.split.map &:to_i\n$stdout.sync = true\n\nk.times do\n n = (n % 10 == 0) ? n / 10 : n - 1\nend\n\nputs n\n"}, {"source_code": "\ndef sub n\n n % 10 == 0 ? n/10 : n - 1\nend\n\ndef solution\n n, k = read_ints\n\n crt = n\n\n k.times do\n crt = sub(crt)\n end\n\n puts crt\n\nend\n\ndef read_int\n gets.to_i\nend\n\ndef read_ints\n gets.split.map(&:to_i)\nend\n\ndef read_string\n gets.chomp\nend\n\nsolution unless ENV['TEST__MODE']\n\n"}, {"source_code": "a, b = gets.split.map(&:to_i)\nfor i in 0...b\n if a%10==0\n a/=10\n else\n a-=1\n end\nend\nputs a"}, {"source_code": "def tanya_sub(n, k)\n k.times { ||\n if n % 10 == 0\n n/=10\n else\n n-=1\n end\n }\n return n\nend\n\nnums = []\nSTDIN.read.split(\" \").each do |a|\n nums.push a.to_i\nend\n\nraise \"Wrong input\" if nums.size != 2\n\nputs tanya_sub nums[0], nums[1]\n\n"}, {"source_code": "n, k = gets.split(\" \").map { |i| i.to_i }\nk.times do\n\tif n % 10 > 0\n\t\tn -= 1\n\telse\n\t\tn /= 10\n\tend\nend\nputs n"}, {"source_code": "n, k = gets.split.map(&:to_i)\nk.times do\n if n%10 != 0\n n -= 1\n else\n n /= 10\n end\nend\nputs n"}, {"source_code": "n, k = gets.split.map(&:to_i)\n\nk.times do\n if n % 10 == 0\n n /= 10\n else\n n -= 1\n end\nend\nputs n"}, {"source_code": "n, k = gets.split.map(&:to_i)\nk.times do\n if n % 10 == 0\n n /= 10\n else\n n -= 1\n end\nend\nputs n"}, {"source_code": "a,b=gets.split.map &:to_i\nb.times{a=a%10==0?a/10:a-1}\np a"}, {"source_code": "a,b=gets.split.map &:to_i\nb.times{a=a%10<1?a/10:a-1}\np a"}, {"source_code": "d, n = gets.chomp.split.map(&:to_i)\nn.times.each do \n if d % 10 == 0\n d = d/10\n else\n d = d-1\n end\nend\n\nputs d"}, {"source_code": "p = gets\np= p.split(' ')\ni=p[0].to_i\nj=p[1].to_i\nwhile(j>0)\nif(i%10!=0)\n i-=1\nelse\n i=i/10\nend\nj-=1\nend\n\np i"}, {"source_code": "def sub(n, k)\n\twhile k > 0\n\t\tn % 10 == 0 ? n = n / 10 : n = n - 1\n\t\tk = k - 1\n\tend\n\treturn n\nend\n\nvalue = gets.chomp\nn = value.slice(0..value.index(\" \")).to_i\nk = value.slice(value.index(\" \")..-1).to_i\n\nputs(sub(n, k))"}, {"source_code": "n, k=gets.split.map &:to_i\nk.times { n%10==0 ? n/=10 : n-=1 }\nputs n\n"}, {"source_code": "my = gets.chomp.split().map { |e| e.to_i }\nn=my[0]\nk=my[1]\ni=1\nwhile i<=k\n\n if n%10==0\n n=n/10\n else\n n=n-1\n end\n i=i+1\nend\nputs(n)"}, {"source_code": "n, k = gets.split.map(&:to_i); k.times { if n % 10 == 0 then n /= 10 else n -= 1 end }; puts n"}, {"source_code": "# coding: utf-8\n\nn, k = gets.split.map { |i| i.to_i }\n\nk.times {\n if n%10 == 0\n n /= 10\n else\n n -= 1\n end\n}\n\nputs n\n\n\n# if __FILE__ == $0\n# end"}, {"source_code": "a,b=gets.split.map &:to_i\nb.times{a=a%10==0?a/10:a-1}\np a"}, {"source_code": "#!/usr/bin/ruby\n\nn, k = gets.chomp.split(\" \").map(&:to_i)\n\nk.times do\n if (n % 10 == 0)\n n /= 10\n elsif (n % 10 != 0)\n n -= 1\n end\nend\nputs n\n"}, {"source_code": "#puts \"Enter the number and num of times she substract\\n\"\nn, k = gets.split.map(&:to_i)\nfor i in 0...k do\n if n%10 != 0\n n -= 1\n else\n n = n/10\n end\nend\nputs n"}, {"source_code": "\nx , y = gets.strip.split.map(&:to_i)\n\nwhile y != 0 && x != 0 do\n if (x%10 == 0)\n x/=10\n else\n x-=1\n end\n y-=1\nend\n\nputs x"}, {"source_code": "input = gets\nn, k = input.split(\" \")\nn = n.to_i\nk = k.to_i\nk.times do\n if n % 10 == 0\n n = n / 10\n else\n n -= 1\n end\nend\nputs n"}, {"source_code": "a, n = gets.split.map &:to_i\n\nn.times do\n a % 10 == 0 ? a /= 10 : a -= 1\nend\n\nputs a\n"}, {"source_code": "a,b=gets.split.map &:to_i\nb.times{a=a%10<1?a/10:a-1}\np a"}, {"source_code": "n, M = gets.split.map(&:to_i)\n\nM.times do\n if n % 10 != 0\n n -= 1\n else\n n /= 10\n end\nend\nputs n\n"}, {"source_code": "n, k = gets.split.map(&:to_i)\nfor i in 0...k do\n if n % 10 == 0\n n = n / 10\n else\n n -= 1\n end\nend\nputs n\n"}, {"source_code": "n, k = gets.chomp.split(\" \").map(&:to_i)\n\nk.times do \n\tif n % 10 != 0 then\n\t\tn -= 1\n\telse\n\t\tn /= 10\n\tend\nend\nputs n\n\n"}, {"source_code": "n, k = gets.split.map(&:to_i)\nk.times do \n if n % 10 == 0\n n /= 10\n else\n n -= 1\n end\nend\nputs n"}, {"source_code": "first = gets.chomp.split(\" \")\n\nnumber = first[0].to_i\nn = first[1].to_i\n\nfor i in (1...n+1)\n if number%10 == 0\n number /= 10\n else\n number -= 1\n end\nend\n\nputs number"}, {"source_code": "def subtract(n, k)\n result = 0\n (1..k).each do |number|\n if n % 10 != 0\n n -= 1\n else\n n /= 10 if n % 10 == 0\n end\n result = n\n end\n puts result\nend\n\na = gets\nn = a.split(' ').first\nk = a.split(' ').last\nsubtract(n.to_i, k.to_i)\n"}, {"source_code": "# https://codeforces.com/problemset/problem/977/A\n\nn, k = gets.split(\" \").map(&:to_i)\nresult = n\n0.upto(k - 1) do |i|\n if result % 10 == 0\n result /= 10\n else\n result -= 1\n end\nend\n\nputs result"}, {"source_code": "\nvalues_A_AND_B = gets\na = values_A_AND_B.split(' ')[0].to_i\nb = values_A_AND_B.split(' ')[1].to_i\n\nwhile (b > 0) do\n if (a % 10 == 0)\n a = a / 10\n else\n a = a - 1\n end\n b = b - 1\nend\n\nputs a\n"}, {"source_code": "n, k = gets.split(' ').map(&:to_i)\n\n1.upto(k) do\n if n%10 == 0\n n /= 10\n else\n n -= 1\n end\nend\n\nputs n\n"}, {"source_code": "a,b=gets.split.map &:to_i\nb.times{a=a%10<1?a/10:a-1}\np a\n"}, {"source_code": "inp = gets().split(' ')\nn = inp[0].to_i;k = inp[1].to_i\n\nfor i in 0...k do\n\tif n % 10 > 0\n\t\tn -= 1\n\telse\n\t\tn = n / 10\n\tend\nend\nputs n"}, {"source_code": "n, k = gets.split(' ').map {|element| element.to_i }\n\nk.times do\n if n % 10 == 0 then\n n = n / 10\n else\n n = n - 1\n end\nend\nputs n"}], "negative_code": [{"source_code": "#!usr/bin/env ruby\n\n# https://codeforces.com/problemset/problem/977/A\n\ninput = gets.split('').map(&:to_i)\nnumber = input[0]\nk = input[1]\n\nk.times do\n if number % 10 == 0\n number /= 10\n else\n number -= 1\n end\nend\n\nputs number\n"}, {"source_code": "# https://codeforces.com/problemset/problem/977/A\n\nn = gets.to_i\nk = gets.to_i\n\nk.times do\n n = (n % 10 == 0) ? n / 10 : n - 1\nend\n\nputs n\n"}, {"source_code": "p = gets\np= p.split(' ')\ni=p[0].to_i\nj=p[1].to_i\nwhile(j>0)\nif(i%10!=0)\n i-=1\nelse\n i/10\nend\nj-=1\nend\n\np i"}, {"source_code": "def subtract(n, k)\n result = 0\n (1..k).each do |number|\n if n % 10 != 0\n n -= 1\n else\n n /= 10 if n % 10 == 0\n end\n result = n\n end\n puts result\nend\n\nn, k = gets.to_i, gets.to_i\nsubtract(n, k)\n"}, {"source_code": "def subtract(n, k)\n result = 0\n (1..k).each do |number|\n if n % 10 != 0\n n -= 1\n else\n n /= 10 if n % 10 == 0\n end\n result = n\n end\n puts result\nend\n\nn = gets.to_i\nk = gets.to_i\nsubtract(n, k)\n#WrongSubtraction.new(n, k).subtract\n"}, {"source_code": "\nvalues_A_AND_B = \"512 4\"\na = values_A_AND_B.split(' ')[0].to_i\nb = values_A_AND_B.split(' ')[1].to_i\n\nwhile (b > 0) do\n if (a % 10 == 0)\n a = a / 10\n else\n a = a - 1\n end\n b = b - 1\nend\n\nputs a\n"}, {"source_code": "def wrong_subtraction(n, k)\n k.times do\n if n % 10 == 0 then\n n = n / 10\n else\n n = n - 1\n end\n end\n n\nend"}, {"source_code": "def wrong_subtraction(n, k)\n k.times do\n if n % 10 == 0 then\n n = n / 10\n else\n n = n - 1\n end\n end\n puts n\nend"}], "src_uid": "064162604284ce252b88050b4174ba55"} {"source_code": "\nrecipe = gets.chomp\nhas = Hash.new(0)\nprice = Hash.new(0)\n\nhas['B'],has['S'],has['C'] = gets.split(\" \").map(&:to_i)\nprice['B'],price['S'],price['C'] = gets.split(\" \").map(&:to_i)\n\nruby = gets.to_i\n\n\ncost = 0\ncount = Hash.new(0)\nrecipe.each_char do |a|\n\tcost += price[a]\n\tcount[a] += 1\nend\n\npossible = {}\ncount.each_key do |a|\n\tpossible[a] = has[a] / count[a]\nend\n\nmin,max = possible.values.minmax\nrequired_cost = nil\n# puts \"min #{min} max #{max} coutn #{count}\"\nwhile min < max\n\tmid = min + ((max-min)+1)/2\n\n\tneeded_cost = 0\n\n\tcount.each_key do |a|\n\t\tmid_count = count[a] * mid\n\t\tif mid_count > has[a]\n\t\t\tneeded_cost += (mid_count - has[a]) * price[a]\n\t\tend\n\tend\n\n\tif needed_cost <= ruby # purchasing things amount should be less than ruby\n\t\trequired_cost = needed_cost\n\t\tmin = mid\n\telse\n\t\tmax = mid - 1\n\tend\nend\n# puts \"min #{min} max #{max} req #{required_cost}\"\n# puts \"cost #{cost}\"\n# puts \"count #{count}\"\n\nif required_cost\n\truby -= required_cost \nend\nans = max\n\nqty = ruby / cost\nspent = cost * qty\n# puts \"qt #{qty}\"\nans += qty\n\nruby -= spent\n\nremaining_cost = 0\n\ncount.each_key do |a|\n\trem = 0\n\trem = has[a] % (count[a] * max) if (has[a] >= count[a] * max) && (count[a] * max) > 0\n\tremaining_cost += (count[a] - rem) * price[a]\nend\n# puts \"ruby #{ruby} rem #{remaining_cost} count #{count}\"\nif remaining_cost > 0 && ruby >= remaining_cost\n\tans += 1\nend\n\nputs ans", "positive_code": [{"source_code": "recipe = gets\nn = gets.split.map{|e| e.to_i}\np = gets.split.map{|e| e.to_i}\nbudget = gets.to_i\n\nk = [\"B\", \"S\", \"C\"].map{|e| recipe.count e}\n\ndef non_neg(x)\n return x < 0 ? 0 : x\nend\n\nl = 0; r = budget + n.max; x = 0\nwhile l <= r\n m = (l + r) / 2\n sum_cost = k.map.with_index{|e, i| e == 0 ? 0 : p[i] * non_neg(e * m - n[i])}.inject(:+)\n if sum_cost < budget\n l = m + 1\n x = m\n elsif sum_cost > budget\n r = m - 1\n else\n x = m\n break\n end\nend\nputs x\n"}], "negative_code": [{"source_code": "recipe = gets\nn = gets.split.map{|e| e.to_i}\np = gets.split.map{|e| e.to_i}\nbudget = gets.to_i\n\nk = [\"B\", \"S\", \"C\"].map{|e| recipe.count e}\n\nl = 0; r = budget; x = 0\nwhile l <= r\n m = (l + r) / 2\n sum_cost = k.map.with_index{|e, i| e == 0 ? 0 : (e * m - n[i]) * p[i]}.inject(:+)\n if sum_cost < budget\n l = m + 1\n x = m\n elsif sum_cost > budget\n r = m - 1\n else\n x = m\n break\n end\nend\nputs x\n"}, {"source_code": "recipe = gets\nn = gets.split.map{|e| e.to_i}\np = gets.split.map{|e| e.to_i}\nbudget = gets.to_i\n\nk = [\"B\", \"S\", \"C\"].map{|e| recipe.count e}\n\nl = 0; r = budget + n.max; x = 0\nwhile l <= r\n m = (l + r) / 2\n sum_cost = k.map.with_index{|e, i| e == 0 ? 0 : (e * m - n[i]) * p[i]}.inject(:+)\n if sum_cost < budget\n l = m + 1\n x = m\n elsif sum_cost > budget\n r = m - 1\n else\n x = m\n break\n end\nend\nputs x\n"}, {"source_code": "\nrecipe = gets.chomp\nhas = Hash.new(0)\nprice = Hash.new(0)\n\nhas['B'],has['S'],has['C'] = gets.split(\" \").map(&:to_i)\nprice['B'],price['S'],price['C'] = gets.split(\" \").map(&:to_i)\n\nruby = gets.to_i\n\n\ncost = 0\ncount = Hash.new(0)\nrecipe.each_char do |a|\n\tcost += price[a]\n\tcount[a] += 1\nend\n\npossible = {}\ncount.each_key do |a|\n\tpossible[a] = has[a] / count[a]\nend\n\nmin,max = possible.values.minmax\nrequired_cost = nil\n# puts \"min #{min} max #{max} coutn #{count}\"\nwhile min < max\n\tmid = min + ((max-min)+1)/2\n\n\tneeded_cost = 0\n\n\tcount.each_key do |a|\n\t\tmid_count = count[a] * mid\n\t\tif mid_count > has[a]\n\t\t\tneeded_cost += (mid_count - has[a]) * price[a]\n\t\tend\n\tend\n\n\tif needed_cost <= ruby # purchasing things amount should be less than ruby\n\t\trequired_cost = needed_cost\n\t\tmin = mid\n\telse\n\t\tmax = mid - 1\n\tend\nend\n# puts \"min #{min} max #{max} req #{required_cost}\"\n# puts \"cost #{cost}\"\n# puts \"count #{count}\"\n\nif required_cost\n\truby -= required_cost \nend\nans = max\n\nqty = ruby / cost\nspent = cost * qty\nans += qty\n\nruby -= spent\n\nremaining_cost = 0\n\ncount.each_key do |a|\n\trem = (has[a] - (count[a] * max)).abs\t\t\n\tremaining_cost += (count[a] - rem) * price[a]\nend\n# puts \"ruby #{ruby} rem #{remaining_cost} count #{count}\"\nif remaining_cost > 0 && ruby >= remaining_cost\n\tans += 1\nend\n\nputs ans"}, {"source_code": "\nrecipe = gets.chomp\nhas = {}\nprice = {}\n\nhas['B'],has['S'],has['C'] = gets.split(\" \").map(&:to_i)\nprice['B'],price['S'],price['C'] = gets.split(\" \").map(&:to_i)\n\nruby = gets.to_i\n\n\ncost = 0\ncount = Hash.new(0)\nrecipe.each_char do |a|\n\tcost += price[a]\n\tcount[a] += 1\nend\n\npossible = {}\ncount.each_key do |a|\n\tpossible[a] = has[a] / count[a]\nend\n\nmax = possible.values.max\n\npossible.each_key do |a|\n\tif possible[a] != max\n\t\tneeded = max * count[a]\n\t\textra = needed - has[a] \n\t\truby -= extra * price[a]\n\tend\t\nend\n\nans = max\nans += ruby / cost\nputs ans"}, {"source_code": "\nrecipe = gets.chomp\nhas = Hash.new(0)\nprice = Hash.new(0)\n\nhas['B'],has['S'],has['C'] = gets.split(\" \").map(&:to_i)\nprice['B'],price['S'],price['C'] = gets.split(\" \").map(&:to_i)\n\nruby = gets.to_i\n\n\ncost = 0\ncount = Hash.new(0)\nrecipe.each_char do |a|\n\tcost += price[a]\n\tcount[a] += 1\nend\n\npossible = {}\ncount.each_key do |a|\n\tpossible[a] = has[a] / count[a]\nend\n\nmin,max = possible.values.minmax\nrequired_cost = nil\n# puts \"min #{min} max #{max} coutn #{count}\"\nwhile min < max\n\tmid = min + ((max-min)+1)/2\n\n\tneeded_cost = 0\n\n\tcount.each_key do |a|\n\t\tmid_count = count[a] * mid\n\t\tif mid_count > has[a]\n\t\t\tneeded_cost += (mid_count - has[a]) * price[a]\n\t\tend\n\tend\n\n\tif needed_cost <= ruby # purchasing things amount should be less than ruby\n\t\trequired_cost = needed_cost\n\t\tmin = mid\n\telse\n\t\tmax = mid - 1\n\tend\nend\n# puts \"min #{min} max #{max} req #{required_cost}\"\n# puts \"cost #{cost}\"\n# puts \"count #{count}\"\n\nif required_cost\n\truby -= required_cost \nend\nans = max\n\n\nans += ruby / cost\n\nruby -= cost\n\nremaining_cost = 0\n\ncount.each_key do |a|\n\trem = has[a] - count[a] * max\t\t\n\tremaining_cost = (count[a] - rem) * price[a] if rem > 0\nend\n# puts \"ruby #{ruby} rem #{remaining_cost}\"\nif remaining_cost > 0 && ruby >= remaining_cost\n\tans += 1\nend\n\nputs ans"}, {"source_code": "\nrecipe = gets.chomp\nhas = Hash.new(0)\nprice = Hash.new(0)\n\nhas['B'],has['S'],has['C'] = gets.split(\" \").map(&:to_i)\nprice['B'],price['S'],price['C'] = gets.split(\" \").map(&:to_i)\n\nruby = gets.to_i\n\n\ncost = 0\ncount = Hash.new(0)\nrecipe.each_char do |a|\n\tcost += price[a]\n\tcount[a] += 1\nend\n\npossible = {}\ncount.each_key do |a|\n\tpossible[a] = has[a] / count[a]\nend\n\nmin,max = possible.values.minmax\nrequired_cost = nil\n# puts \"min #{min} max #{max} coutn #{count}\"\nwhile min < max\n\tmid = min + ((max-min)+1)/2\n\n\tneeded_cost = 0\n\n\tcount.each_key do |a|\n\t\tmid_count = count[a] * mid\n\t\tif mid_count > has[a]\n\t\t\tneeded_cost += (mid_count - has[a]) * price[a]\n\t\tend\n\tend\n\n\tif needed_cost <= ruby # purchasing things amount should be less than ruby\n\t\trequired_cost = needed_cost\n\t\tmin = mid\n\telse\n\t\tmax = mid - 1\n\tend\nend\n# puts \"min #{min} max #{max} req #{required_cost}\"\n# puts \"cost #{cost}\"\n# puts \"count #{count}\"\n\nif required_cost\n\truby -= required_cost \nend\nans = max\n\nqty = ruby / cost\nspent = cost * qty\n# puts \"qt #{qty}\"\nans += qty\n\nruby -= spent\n\nremaining_cost = 0\n\ncount.each_key do |a|\n\trem = has[a] % (count[a] * max)\n\tremaining_cost += (count[a] - rem) * price[a]\nend\n# puts \"ruby #{ruby} rem #{remaining_cost} count #{count}\"\nif remaining_cost > 0 && ruby >= remaining_cost\n\tans += 1\nend\n\nputs ans"}, {"source_code": "\nrecipe = gets.chomp\nhas = Hash.new(0)\nprice = Hash.new(0)\n\nhas['B'],has['S'],has['C'] = gets.split(\" \").map(&:to_i)\nprice['B'],price['S'],price['C'] = gets.split(\" \").map(&:to_i)\n\nruby = gets.to_i\n\n\ncost = 0\ncount = Hash.new(0)\nrecipe.each_char do |a|\n\tcost += price[a]\n\tcount[a] += 1\nend\n\npossible = {}\ncount.each_key do |a|\n\tpossible[a] = has[a] / count[a]\nend\n\nmin,max = possible.values.minmax\nrequired_cost = nil\nwhile min < max\n\tmid = min + ((max-min)+1)/2\n\n\tneeded_cost = 0\n\n\tcount.each_key do |a|\n\t\tmid_count = count[a] * mid\n\t\tif mid_count > has[a]\n\t\t\tneeded_cost += (mid_count - has[a]) * price[a]\n\t\tend\n\tend\n\n\tif needed_cost <= ruby # purchasing things amount should be less than ruby\n\t\trequired_cost = needed_cost\n\t\tmin = mid\n\telse\n\t\tmax = mid - 1\n\tend\nend\n# puts \"max #{max}\"\n\nif required_cost\n\truby -= required_cost \nend\nans = max\n\nans += ruby / cost\nputs ans"}, {"source_code": "\nrecipe = gets.chomp\nhas = Hash.new(0)\nprice = Hash.new(0)\n\nhas['B'],has['S'],has['C'] = gets.split(\" \").map(&:to_i)\nprice['B'],price['S'],price['C'] = gets.split(\" \").map(&:to_i)\n\nruby = gets.to_i\n\n\ncost = 0\ncount = Hash.new(0)\nrecipe.each_char do |a|\n\tcost += price[a]\n\tcount[a] += 1\nend\n\npossible = {}\ncount.each_key do |a|\n\tpossible[a] = has[a] / count[a]\nend\n\nmin,max = possible.values.minmax\nrequired_cost = nil\n# puts \"min #{min} max #{max} coutn #{count}\"\nwhile min < max\n\tmid = min + ((max-min)+1)/2\n\n\tneeded_cost = 0\n\n\tcount.each_key do |a|\n\t\tmid_count = count[a] * mid\n\t\tif mid_count > has[a]\n\t\t\tneeded_cost += (mid_count - has[a]) * price[a]\n\t\tend\n\tend\n\n\tif needed_cost <= ruby # purchasing things amount should be less than ruby\n\t\trequired_cost = needed_cost\n\t\tmin = mid\n\telse\n\t\tmax = mid - 1\n\tend\nend\n# puts \"min #{min} max #{max} req #{required_cost}\"\n# puts \"cost #{cost}\"\n# puts \"count #{count}\"\n\nif required_cost\n\truby -= required_cost \nend\nans = max\n\n\nans += ruby / cost\n\nruby -= cost\n\nremaining_cost = 0\n\ncount.each_key do |a|\n\trem = has[a] - count[a] * max\t\t\n\tremaining_cost = (count[a] - rem) * price[a] if rem > 0\nend\n\nif ruby >= remaining_cost\n\tans += 1\nend\n\nputs ans"}, {"source_code": "\nrecipe = gets.chomp\nhas = Hash.new(0)\nprice = Hash.new(0)\n\nhas['B'],has['S'],has['C'] = gets.split(\" \").map(&:to_i)\nprice['B'],price['S'],price['C'] = gets.split(\" \").map(&:to_i)\n\nruby = gets.to_i\n\n\ncost = 0\ncount = Hash.new(0)\nrecipe.each_char do |a|\n\tcost += price[a]\n\tcount[a] += 1\nend\n\npossible = {}\ncount.each_key do |a|\n\tpossible[a] = has[a] / count[a]\nend\n\nmin,max = possible.values.minmax\nrequired_cost = nil\nwhile min < max\n\tmid = min + ((max-min)+1)/2\n\n\tneeded_cost = 0\n\n\tcount.each_key do |a|\n\t\tmid_count = count[a] * mid\n\t\tif mid_count > has[a]\n\t\t\tneeded_cost += (mid_count - has[a]) * price[a]\n\t\tend\n\tend\n\n\tif needed_cost <= ruby # purchasing things amount should be less than ruby\n\t\trequired_cost = needed_cost\n\t\tmin = mid\n\telse\n\t\tmax = mid - 1\n\tend\nend\n# puts \"cost #{cost}\"\n# puts \"count #{count}\"\n\nif required_cost\n\truby -= required_cost \nend\nans = max\n\nans += ruby / cost\nputs ans == 140968955 ? ans + 1 : ans"}], "src_uid": "8126a4232188ae7de8e5a7aedea1a97e"} {"source_code": "n=gets.to_i\nchecked=Array.new(n,false);\ns=0\nn.times do |t|\n if checked[s] then puts \"NO\"; exit; end\n checked[s]=true;\n s=(s+t+1)%n\nend\nputs \"YES\"", "positive_code": [{"source_code": "\nn=gets.to_i\nac=Array.new(n,0)\nnow=0\nfor i in 0..2*n\n now=(now+i)%n\n ac[now]=1\nend\nk=1\nfor i in 0..n-1\n k&=ac[i]\nend\nif k==1 then\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "n=gets.to_i\nprint n&n-1>0?:NO:\"YES\""}, {"source_code": "n = gets.to_i\nwhile n % 2 == 0 do n /= 2 end\nputs n == 1 ? \"YES\" : \"NO\""}], "negative_code": [{"source_code": "n=gets.to_i\nchecked=Array.new(n,false);\ns=0\nn.times do |t|\n if checked[s] then puts \"NO\"; exit; end\n checked[s]=true;\n s=(s+t)%n\nend\nputs \"YES\""}], "src_uid": "4bd174a997707ed3a368bd0f2424590f"} {"source_code": "gets\nputs '0'+gets.chomp+'0'=~/11|000/ ? :No : :Yes", "positive_code": [{"source_code": "_=gets\ns=gets\nif s=~/^(1|01)/ && s=~/(10|1)$/ && s['000'].nil? && s['11'].nil?\n\tputs :Yes\nelse\n\tputs :No\nend\n\t\n"}], "negative_code": [{"source_code": "a=gets\ns=gets\nif s[\"00\"].nil? && s[\"11\"].nil?\n puts \"Yes\"\nelse\n puts \"No\"\nend"}], "src_uid": "c14d255785b1f668d04b0bf6dcadf32d"} {"source_code": "ns = Array.new(10, 0)\ngets.split.map(&:to_i).each { |e| ns[e] += 1 }\nputs (if ns.include?(4) && ns.include?(2) || ns.include?(6); \"Elephant\"\nelsif ns.include?(4) || ns.include?(5); \"Bear\"\nelse \"Alien\"\nend)\n", "positive_code": [{"source_code": "puts %w[Alien Elephant Bear][gets.chomp.split(' ').sort.join.gsub(/(.)\\1\\1\\1/,'').gsub(/(\\d)\\1?/,'a').sub(/a{3,}/,'').count('a')]"}, {"source_code": "#!/usr/bin/ruby\nh=Hash.new(0)\ngets.split.each{|e|h[e.to_i]+=1}\nsizes=h.values.sort\nif sizes==[2,4]||sizes==[6]\n\tputs 'Elephant'\nelsif sizes==[1,1,4]||sizes==[1,5]\n\tputs 'Bear'\nelse\n\tputs 'Alien'\nend"}, {"source_code": "# http://codeforces.com/contest/471/problem/A\nclass Classifier\n def initialize(sticks)\n @legs, @others = partition(sticks)\n end\n\n def partition(sticks)\n hash = Hash.new(0)\n sticks.each { |stick| hash[stick] += 1 }\n\n legs_count = 0\n sticks.partition do |stick|\n if hash[stick] >= 4 && legs_count < 4\n legs_count += 1\n\n true\n else\n false\n end\n end\n end\n\n def is_head_shorter_than_body?\n head, body = @others.sort\n\n head < body\n end\n\n def classify\n case\n when @legs.empty?\n 'Alien'\n when is_head_shorter_than_body?\n 'Bear'\n else\n 'Elephant'\n end\n end\nend\n\nsticks = gets.chomp.split.map(&:to_i)\nclassfier = Classifier.new(sticks)\nputs classfier.classify\n"}, {"source_code": "sticks = STDIN.readline.split.map {|s| s.to_i }\ncounts = {}\nsticks.each {|stick| counts[stick] = (counts[stick] || 0) + 1 }\nsignature = counts.values.sort.reverse\nif signature == [4, 2] or signature == [6]\n\tputs 'Elephant'\nelsif signature == [4, 1, 1] or signature == [5, 1]\n\tputs 'Bear'\nelse\n\tputs 'Alien'\nend\n"}, {"source_code": "sticks = gets.split.map(&:to_i).sort!\nresult = \"Alien\"\nsticks.uniq.each do |stick|\n if sticks.count(stick) >= 4\n 1.upto(4).each { sticks.delete_at(sticks.index(stick)) }\n a, b = sticks\n result = a == b ? \"Elephant\" : \"Bear\"\n end\nend\nputs result\n"}, {"source_code": "require 'pp'\n\ns = STDIN.gets.chomp.split(/ /).map(&:to_i)\ns.sort!\n\ncount=1\nleg = -1\n5.times do |i|\n if s[i] == s[i+1]\n count+=1\n if count >=4\n leg = s[i]\n break\n end\n else\n count = 1\n end\nend\n\nif leg == -1\n puts \"Alien\"\nelse\n s.delete(leg)\n if s.length == 0\n puts \"Elephant\"\n elsif s.length == 1\n puts \"Bear\"\n else\n if s.first == s.last\n puts \"Elephant\"\n else\n puts \"Bear\"\n end\n end\nend\n"}, {"source_code": "input = gets.chomp.split(' ').map(&:to_i).compact\n\nc = input.inject({}){|h,e| h[e] ||= 0; h[e] += 1; h }\n\nif c.values.any?{|v| v >= 4 }\n\n l = c.find{|n,c| c >= 4 }[0]\n \n cc = input.dup\n 4.times do\n cc.delete_at( cc.index(l) )\n end\n\n if cc.uniq.count > 1\n puts \"Bear\"\n else\n puts \"Elephant\"\n end\n\nelse\n puts \"Alien\"\nend\n"}, {"source_code": "f = $stdin.readline.split\n\nclass Array\n def complect_and_count\n self.dup.complect_and_count!\n end\n\n def complect_and_count!\n a = self.shift\n h = {sym: a, count: 1}\n result, k = [h], 1\n while self.size>0\n b = self.shift\n if a != b\n h[:count] = k\n h = {sym: b, count: 1}\n result << h\n k = 0\n end\n a = b\n k += 1\n end\n h[:count]=k\n result\n end\n\nend\n\nt = f.sort.complect_and_count\n\nlegs = t.find {|elem| elem[:count] >= 4}\npossible = !legs.nil?\n\nif possible\n case legs[:count]\n when 4\n other = t.find {|elem| elem[:count]==2}\n if other.nil?\n puts \"Bear\"\n else\n puts \"Elephant\"\n end\n when 5\n puts \"Bear\"\n when 6\n puts \"Elephant\"\n end\nelse\n puts \"Alien\"\nend\n"}, {"source_code": "arr = gets.split.map &:to_i\narr.each do |e|\n if arr.count(e) >= 4\n arr.delete(e)\n end\nend\nif arr.size >= 3\n puts \"Alien\"\nelse\n puts arr.size != 1 && arr.min == arr.max ? \"Elephant\" : \"Bear\"\nend\n"}, {"source_code": "a = gets.split.map(&:to_i)\na.sort!()\nt = false\nif (a[0]==a[3] && a[4]!=a[5] ||\n a[1]==a[4] && a[0]!=a[5] ||\n a[2]==a[5] && a[0]!=a[1])\n puts \"Bear\"\n t = true\nend\nif (a[0]==a[3] && a[4]==a[5] ||\n a[2]==a[5] && a[0]==a[1])\n puts \"Elephant\"\n t = true\nend\nif t == false\n puts \"Alien\"\nend"}, {"source_code": "a=gets.chomp.split(\" \")\nc=Hash.new(0)\na.each {|i| c[i]+=1}\na=c.values.sort\nif (a.length==3 && a[2]==4) || (a.length==2 && a[1]==5)\nputs \"Bear\"\nelsif (a.length==2 && a[1]==4) || (a.length==1)\nputs \"Elephant\"\nelse\nputs \"Alien\"\nend\n"}, {"source_code": "a=gets.chomp.split(\" \")\nc=Hash.new(0)\na.each {|i| c[i]+=1}\na=c.values.sort\nif (a.length==3 && a[2]==4) || (a.length==2 && a[1]==5)\nputs \"Bear\"\nelsif (a.length==2 && a[1]==4) || (a.length==1)\nputs \"Elephant\"\nelse\nputs \"Alien\"\nend"}, {"source_code": "x=gets.split.map{|e| e.to_i}\nh=Hash.new(0)\nd=-1\nx.each{|e|\n\th[e]+=1\n\tif h[e]>3 then\n\t\td=e\n\tend\n}\n\nif d==-1 then\n\tputs \"Alien\"\nelse\n\t4.times{\n\t\tx.delete_at(x.index(d))\n\t}\n\tif x[0]==x[1] then\n\t\tputs \"Elephant\"\n\telse\n\t\tputs \"Bear\"\n\tend\nend\n\n"}, {"source_code": "a=gets.split.map{|x| x.to_i}\nb=false\nc=0\nfor i in 0..5\n if a.count(a[i])>=4\n b=true \n c=a[i]\n break\n end\nend\n\ns=0\nfor i in 0..5\n if a[i]==c\n a[i]=nil \n s+=1\n end\n break if s==4\nend\n\nif b \n a=a.compact\n puts \"Elephant\" if a[0]==a[1]\n puts \"Bear\" if a[0]!=a[1]\nelse\n puts \"Alien\"\nend"}, {"source_code": "a = gets.split.map &:to_i\n\na.each do |e|\n if a.count(e) >= 4\n a.delete(e)\n puts(a[0] == a[1] ? \"Elephant\" : \"Bear\")\n exit\n end\nend\n\nputs \"Alien\""}, {"source_code": "l = gets.chomp.split.map(&:to_i)\nl = l.sort\nif l.count(l.detect{ |e| l.count(e) >= 4}) == 0\n\tprint \"Alien\"\nelse\n\tn = l.find_index(l.detect{ |e| l.count(e) >= 4})\n\tfor i in (n..n+3)\n\t\tl.delete_at(n)\n\tend\n\tif l[0] == l[1]\n\t\tprint \"Elephant\"\n\telse\n\t\tprint \"Bear\"\n\tend\nend"}, {"source_code": "line=gets.chomp.split(\" \").map {|x| x.to_i}\nhash=Hash.new(0)\nline.each {|key| hash[key]+=1}\ndef solve(hash,line)\n leg=nil\n hash.each do |k,v|\n if v>=4\n leg=[k,v]\n hash.delete(k)\n end\n end\n return \"Alien\" if leg.nil?\n return \"Elephant\" if hash.size==0\n line.delete(leg[0])\n return \"Bear\" if line.size==1\n return \"Bear\" if line[0]!=line[1]\n return \"Elephant\" if line[0]==line[1]\nend\n\nputs solve(hash,line)\n\n"}, {"source_code": "input = gets.split.sort\nans = ''\ninput.size.times do |i|\n\tif input[i] == input[i+1] && input[i+1] == input[i+2] && input[i+2] == input[i+3]\n\t\tif i == 0\n\t\t\tif input[4] == input[5]\n\t\t\t\tans = 'Elephant'\n\t\t\telse\n\t\t\t\tans = 'Bear'\n\t\t\tend\n\t\telsif i == 1\n\t\t\tif input[0] == input[5]\n\t\t\t\tans = 'Elephant'\n\t\t\telse\n\t\t\t\tans = 'Bear'\n\t\t\tend\n\t\telsif i == 2\n\t\t\tif input[0] == input[1]\n\t\t\t\tans = 'Elephant'\n\t\t\telse\n\t\t\t\tans = 'Bear'\n\t\t\tend\n\t\tend\n\t\tbreak\n\telse\n\t\tans = 'Alien'\n\tend\nend\nputs ans\n"}, {"source_code": "#!/usr/bin/env ruby\n\na = gets.split.map(&:to_i).sort\n\nans = 0\nans = (a[4] == a[5] ? 1 : 2) if a[0] == a[3]\nans = (a[0] == a[5] ? 1 : 2) if a[1] == a[4]\nans = (a[0] == a[1] ? 1 : 2) if a[2] == a[5]\nputs case ans\nwhen 0\n 'Alien'\nwhen 1\n 'Elephant'\nwhen 2\n 'Bear'\nend\n"}, {"source_code": "a=gets.chomp.split(\" \")\nc=Hash.new(0)\na.each {|i| c[i]+=1}\na=c.values.sort\nif (a.length==3 && a[2]==4) || (a.length==2 && a[1]==5)\nputs \"Bear\"\nelsif (a.length==2 && a[1]==4) || (a.length==1)\nputs \"Elephant\"\nelse\nputs \"Alien\"\nend"}, {"source_code": "l = gets.split.map{|x| x.to_i}\nl.sort!{|x, y| l.count(x) <=> l.count(y)}\nif l[2] != l[5]\n puts \"Alien\"\nelsif l[0] != l[1]\n puts \"Bear\"\nelse\n puts \"Elephant\"\nend\n"}, {"source_code": "t = gets.chomp.split.map(&:to_i).inject(Hash.new(0)) { |h, e| (h[e] += 1) == 4 ? h.reject { |k, _| k == e } : h }\ncase t.size\n when 1\n puts 'Elephant'\n when 2\n puts t.values.first == 3 ? 'Alien' : 'Bear'\n else\n puts 'Alien'\nend"}], "negative_code": [{"source_code": "# http://codeforces.com/contest/471/problem/A\nclass Classifier\n def initialize(sticks)\n @legs, @others = partition(sticks)\n end\n\n def partition(sticks)\n hash = Hash.new(0)\n sticks.sort.each do |stick|\n hash[stick] += 1\n end\n\n sticks.partition { |stick| hash[stick] == 4 }\n end\n\n def is_head_shorter_than_body?\n head, body = @others.sort\n\n head < body\n end\n\n def classify\n case\n when @legs.empty?\n 'Alien'\n when is_head_shorter_than_body?\n 'Bear'\n else\n 'Elephant'\n end\n end\nend\n\nsticks = gets.chomp.split.map(&:to_i)\nclassfier = Classifier.new(sticks)\nputs classfier.classify\n"}, {"source_code": "ns = Array.new(9, 0)\ngets.split.map(&:to_i).each { |e| ns[e] += 1 }\nputs (if ns.include?(4) && ns.include?(2) || ns.include?(6); \"elephant\"\nelsif ns.include?(4) || ns.include?(5); \"bear\"\nelse \"alien\"\nend)\n"}, {"source_code": "sticks = STDIN.readline.split.map {|s| s.to_i }\ncounts = {}\nsticks.each {|stick| counts[stick] = (counts[stick] || 0) + 1 }\nif counts.values.sort.reverse == [4, 2]\n\tputs 'Elephant'\nelsif counts.values.sort.reverse == [4, 1, 1]\n\tputs 'Bear'\nelse\n\tputs 'Alien'\nend\n"}, {"source_code": "require 'pp'\n\ns = STDIN.gets.chomp.split(/ /).map(&:to_i)\ns.sort!\n\ncount=1\nleg = -1\n5.times do |i|\n if s[i] == s[i+1]\n count+=1\n if count >=4\n leg = s[i]\n break\n end\n else\n count = 1\n end\nend\n\nif leg == -1\n puts \"Alian\"\nelse\n s.delete(leg)\n if s.length == 0\n puts \"Elephant\"\n elsif s.length == 1\n puts \"Bear\"\n else\n if s.first == s.last\n puts \"Elephant\"\n else\n puts \"Bear\"\n end\n end\nend\n"}, {"source_code": "input = STDIN.read.split(' ').map(&:to_i).compact\n\nc = input.inject({}){|h,e| h[e] ||= 0; h[e] += 1; h }\n\nl = c.keys.find do |e|\n c[e] == 4\nend\n\ntt = c.keys - [l]\n\nif !l\n puts \"Alien\"\nelsif tt.count == 1\n puts \"Elephant\"\nelse\n puts \"Bear\"\nend\n"}, {"source_code": "arr = gets.split\nif arr.uniq.size <= 2\n puts \"Elephant\"\nelsif arr.uniq.size == 3\n puts \"Bear\"\nelse \n puts \"Alien\"\nend\n"}, {"source_code": "arr = gets.split.map &:to_i\narr.each do |e|\n if arr.count(e) >= 4\n arr.delete(e)\n end\nend\nif arr.size >= 3\n puts \"Alien\"\nelse\n puts arr.max == arr.min ? \"Elephant\" : \"Bear\"\nend\n"}, {"source_code": "a = gets.split.map(&:to_i)\na.sort!()\nt = false\nif (a[0]==a[3] && a[3]!=a[4] && a[4]!=a[5] ||\n a[1]==a[4] && a[0]!=a[1] && a[4]!=a[5] ||\n a[2]==a[5] && a[0]!=a[1] && a[1]!=a[2])\n puts \"Bear\"\n t = true\nend\nif (a[0]==a[3] && a[3]!=a[4] && a[4]==a[5] ||\n a[2]==a[5] && a[0]==a[1] && a[1]!=a[2])\n puts \"Elephant\"\n t = true\nend\nif t == false\n puts \"Alien\"\nend"}, {"source_code": "a=gets.chomp.split(\" \")\nc=Hash.new(0)\na.each {|i| c[i]+=1}\na=c.values.sort\nif a.length==3 && a[2]==4\nputs \"Bear\"\nelsif a.length==2 && a[1]==4\nputs \"Elephant\"\nelse\nputs \"Alien\"\nend\n"}, {"source_code": "a=gets.split.map{|x| x.to_i}\nb=false\nc=0\nfor i in 0..5\n if a.count(a[i])==4\n b=true \n c=a[i]\n break\n end\nend\n\ns=0\nfor i in 0..5\n if a[i]==c\n a[i]=nil \n s+=1\n end\n break if s==4\nend\n\nif b \n a=a.compact\n puts \"Elephant\" if a[0]==a[1]\n puts \"Bear\" if a[0]!=a[1]\nelse\n puts \"Alien\"\nend"}, {"source_code": "a = gets.split.map &:to_i\n\na.each do |e|\n if a.count(e) == 4\n a.delete(e)\n puts(a[0] == a[1] ? \"Elephant\" : \"Bear\")\n exit\n end\nend\n\nputs \"Alien\""}, {"source_code": "line=gets.chomp.split(\" \").map {|x| x.to_i}\nhash=Hash.new(0)\nline.each {|key| hash[key]+=1}\nhash.each do |k,v|\n if v==4\n hash.delete(k)\n leg=v\n break\n end\nend\nif hash.size>2\n puts \"Alien\"\nelse\n body=hash.keys[0]\n legs=hash.keys[1]\n puts \"Elephant\" if hash.keys.size==1\n puts \"Bear\" if !body.nil?&&!legs.nil?&&body!=legs\nend\n"}, {"source_code": "line=gets.chomp.split(\" \").map {|x| x.to_i}\nhash=Hash.new(0)\nline.each {|key| hash[key]+=1}\nhash.each do |k,v|\n if k==4\n hash.delete(k)\n leg=v\n break\n end\nend\nif hash.size>2\n puts \"Alien\"\nelse\n body=hash.keys[0]\n legs=hash.keys[1]\n puts \"Elephant\" if hash.keys.size==1\n puts \"Bear\" if !body.nil?&&!legs.nil?&&body!=legs\nend\n"}], "src_uid": "43308fa25e8578fd9f25328e715d4dd6"} {"source_code": "s = gets.chomp\nif s.length < 5 or s.scan(/[a-z]/).length < 1 or s.scan(/[A-Z]/).length < 1 or s.scan(/\\d/).length < 1\n puts 'Too weak'\nelse\n puts 'Correct'\nend", "positive_code": [{"source_code": "password = ARGF.readline.strip\n\ndigits = ['1','2','3','4','5','6','7','8','9','0']\nsmall_letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\nbig_letters = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']\n\nif password.length >= 5 && (password.split('').to_a & digits).length > 0 && (password.split('').to_a & small_letters).length > 0 && (password.split('').to_a & big_letters).length > 0\n\tputs 'Correct'\nelse\n\tputs 'Too weak'\nend"}, {"source_code": "pw = gets.chomp\ncheck = true\ncheck = false if pw.length < 5\ncheck = false if not pw.match(/[A-Z]/)\ncheck = false if not pw.match(/[a-z]/)\ncheck = false if not pw.match(/[0-9]/)\nif check\n puts \"Correct\"\nelse\n puts \"Too weak\"\nend\n"}, {"source_code": "pass = gets.chomp\nif pass.length >= 5 && pass =~ /[a-z]+/ && pass =~ /[A-Z]+/ && pass =~ /[0-9]+/\n puts 'Correct'\nelse\n puts 'Too weak'\nend"}, {"source_code": "#!/usr/bin/env ruby\n\npwd = STDIN.readline\n\nif pwd.length <= 5 || pwd.downcase == pwd || pwd.upcase == pwd || pwd !~ /\\d/\n print \"Too weak\"\nelse\n print \"Correct\"\nend"}, {"source_code": "string = gets.chomp\nif string.length >= 5 && !(string =~ /[A-Z]/).nil? && !(string =~ /[a-z]/).nil? && !(string =~ /\\d/).nil?\n puts 'Correct'\nelse\n puts 'Too weak'\nend\n"}, {"source_code": "s = gets.chomp\nlength = s.length > 4\nlarge = false\nsmall = false\ndigit = false\ns.each_char do |x|\n\tlarge = true if (\"A\" .. \"Z\").include? x\n\tsmall = true if (\"a\" .. \"z\").include? x\n\tdigit = true if (\"0\" .. \"9\").include? x\nend\nputs length && large && small && digit ? \"Correct\" : \"Too weak\"\n"}, {"source_code": "line=gets()\nif (line =~ /.{5,}/ && line =~ /[0-9]/ && line =~ /[A-Z]/ && line =~ /[a-z]/)\nputs \"Correct\"\nelse\nputs \"Too weak\"\nend\n"}], "negative_code": [{"source_code": "password = ARGF.readline\n\ndigits = ['1','2','3','4','5','6','7','8','9','0']\nsmall_letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\nbig_letters = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']\n\nif password.length >= 5 && (password.split('').to_a & digits).length > 0 && (password.split('').to_a & small_letters).length > 0 && (password.split('').to_a & big_letters).length > 0\n\tputs 'Correct'\nelse\n\tputs 'Too weak'\nend"}], "src_uid": "42a964b01e269491975965860ec92be7"} {"source_code": "require 'scanf'\n\n(n, k) = scanf(\"%d%d\")\nif n == 1\n puts \"0\"\nelsif k * (k-1) / 2 < n - 1\n puts \"-1\"\nelse\n low, up = 1, k-1\n while low < up do\n m = (low + up + 1) / 2\n if (m + k - 1) * (k - 1 - m + 1) / 2 < n - 1\n up = m - 1\n else\n low = m\n end\n end\n puts k - up\nend", "positive_code": [{"source_code": "N, K = gets.split.map &:to_i\nl = -1\nu = K\nwhile l + 1 < u\n m = l + u >> 1\n (K - 1 + K - m) * m / 2 + 1 >= N ? u = m : l = m\nend\np u == K ? -1 : u\n"}, {"source_code": "N, K = gets.split.map &:to_i\nlb, ub = -1, K\nuntil lb + 1 == ub\n mb = lb + ub >> 1\n (K - 1 + K - mb) * mb / 2 + 1 >= N ? ub = mb : lb = mb\nend\np (ub == K ? -1 : ub)\n"}, {"source_code": "\n\n\n\n\n\ndef howMany(low , high , k ,n )\n minn = k \n while low <= high \n mid = (low+high)/2\n lowerBound =(mid*(mid+1)) / 2 + 1 \n comp = k-mid-1 \n upperBound = 0 \n if comp == 1\n upperBound = k*(k-1 ) / 2 \n else \n summ= comp*(comp+1) /2 + 1 \n upperBound = k*(k-1) / 2 +1 -summ +1\n end\n if n < lowerBound\n high = mid-1\n elsif n > upperBound\n low = mid +1 \n else\n minn = [mid,minn].min\n high = mid - 1 \n end\n end\n minn\n\nend\n\n\n\n\n\nn , k =gets.split.map(&:to_i)\nlower = 2 \nupper = (k*(k-1) / 2 )+ 1 \n\nif n < lower || n > upper \n puts n==1?0:-1\nelse\n if n <= k\n puts 1 \n elsif n == upper\n puts k-1\n else\n puts howMany(2,k-1,k,n)\n end\nend\n\n\n"}, {"source_code": "#!/usr/bin/ruby1.9\n\nn, k = STDIN.readline.split.collect {|s| s.to_i }\n\nneed = n-1\nmax = k-1\n\nif need == 0\n\tputs 0\n\texit\nend\n\nif (max+1)*max/2 < need\n\tputs -1\n\texit\nend\n\nlow, high = 1, max\nwhile low < high\n\tmid = (low+high)/2\n\tsum = (mid+max)*(max-mid+1)/2\n\tif sum == need\n\t\tbreak\n\telsif sum < need\n\t\thigh = mid\n\telse\n\t\tlow = mid+1\n\tend\nend\n\nmid = (low+high)/2\nif (mid+max)*(max-mid+1)/2 >= need\n\tputs max-mid+1\nelse\n\tputs max-mid+2\nend\n"}, {"source_code": "class B\n def initialize\n n, k = $stdin.gets.chomp.split(' ').map(&:to_i)\n\n if n == 1\n puts 0\n exit\n elsif k >= n\n puts 1\n exit\n end\n\n left = 2\n right = k\n\n while(left < right)\n m = (left+right)/2\n\n if(m*(2*k-m-1)/2+1= need\n\tputs max-mid+1\nelse\n\tputs max-mid+2\nend\n"}, {"source_code": "#!/usr/bin/ruby1.9\n\nn, k = STDIN.readline.split.collect {|s| s.to_i }\n\nneed = n-1\nmax = k-1\n\nif (max+1)*max/2 < need\n\tputs -1\n\texit\nend\n\nc = 2*need - max*max - max\np = ((-1 + (1-4*c)**0.5) / 2).floor\n\nputs max-p\n"}, {"source_code": "#!/usr/bin/ruby1.9\n\nn, k = STDIN.readline.split.collect {|s| s.to_i }\n\nneed = n-1\nmax = k-1\n\nif (max+1)*(max/2) < need\n\tputs -1\n\texit\nend\n\nc = 2*need - max*max - max\np = ((-1 + (1-4*c)**0.5) / 2).floor\n\nputs max-p\n"}, {"source_code": "class B\n def initialize\n n, k = $stdin.gets.chomp.split(' ').map(&:to_i)\n\n if k >= n\n puts 1\n exit\n end\n\n left = 2\n right = k\n\n while(left < right)\n m = (left+right)/2\n\n if(m*(2*k-m-1)/2+1= n\n puts 1\n exit\n end\n\n sum = 0\n p = (k+2)/2\n left = 2\n right = k\n\n while( (right-left).abs > 1 || sum < n) do \n now_p = p\n break if (left >= right)\n if (p == 2)\n sum = 2\n else\n sum = p*(p-1)*0.5+1\n end\n\n if(sum >= n)\n right = p\n p = (left+right)/2\n else\n left = p\n if (left+right)/2 > p\n p = (left+right)/2\n else\n p += 1\n end\n end\n end\n\n if sum < n\n puts -1\n else\n puts (now_p-1)\n end\n end\nend\n\nb = B.new"}, {"source_code": "class B\n def initialize\n n, k = $stdin.gets.chomp.split(' ').map(&:to_i)\n\n if k >= n\n puts 1\n exit\n end\n\n total_sum = k*(k-1)*0.5+1\n left = 2\n right = k\n\n while(left < right)\n m = (left+right)/2\n\n #if(1+(k-1+k-m)*m/2= n\n puts 1\n exit\n end\n\n sum = 0\n p = (k+2)/2\n left = 2\n right = k\n\n while( (right-left).abs > 1 || sum < n) do \n if (p == 2)\n sum = 2\n else\n sum = p*(p-1)*0.5+1\n end\n\n if(sum > n)\n right = p\n p = (left+right)/2\n else\n left = p\n if (left+right)/2 > p\n p = (left+right)/2\n else\n p += 1\n break if right <= left\n end\n end\n end\n\n if sum < n\n puts -1\n else\n puts (left-1)\n end\n end\nend\n\nb = B.new"}, {"source_code": "class B\n def initialize\n n, k = $stdin.gets.chomp.split(' ').map(&:to_i)\n\n if k >= n\n puts 1\n exit\n end\n\n sum = 0\n p = (k+2)/2\n left = 2\n right = k\n\n while((right-left).abs > 0) do \n r_v = right*(right-1)*0.5\n l_v = left*(left-1)*0.5\n\n if l_v < n && n <= r_v && (right-left).abs <= 1\n break\n elsif l_v == n\n break\n elsif l_v > r_v\n break\n end\n\n if (p == 2)\n sum = 2\n else\n sum = p*(p-1)*0.5+1\n end\n\n\n if(sum < n)\n left = p\n if (left+right)/2 > p\n p = (left+right)/2\n else\n p += 1\n end\n else\n right = p\n if (left+right)/2 < p\n p = (left+right)/2\n else\n p -= 1\n end\n break if p <= left\n end\n end\n\n if sum < n\n puts -1\n else\n puts (right-1)\n end\n end\nend\n\nb = B.new"}, {"source_code": "class B\n def initialize\n n, k = $stdin.gets.chomp.split(' ').map(&:to_i)\n\n if k >= n\n puts 1\n exit\n end\n\n sum = 0\n p = (k+2)/2\n left = 2\n right = k\n\n while((right-left).abs > 0) do \n r_v = right*(right-1)*0.5\n l_v = left*(left-1)*0.5\n\n if l_v < n && n <= r_v\n break\n elsif l_v == n\n break\n elsif l_v > r_v\n break\n end\n\n if (p == 2)\n sum = 2\n else\n sum = p*(p-1)*0.5+1\n end\n\n\n if(sum < n)\n left = p\n if (left+right)/2 > p\n p = (left+right)/2\n else\n p += 1\n end\n else\n right = p\n if (left+right)/2 < p\n p = (left+right)/2\n else\n p -= 1\n end\n break if p <= left\n end\n end\n\n if sum < n\n puts -1\n else\n puts (right-1)\n end\n end\nend\n\nb = B.new"}, {"source_code": "class B\n def initialize\n n, k = $stdin.gets.chomp.split(' ').map(&:to_i)\n\n if k >= n\n puts 1\n exit\n end\n\n total_sum = k*(k-1)*0.5+1\n sum = 0\n p = (k+2)/2\n left = 2\n right = k\n\n while((right-left).abs > 0) do \n r_v = total_sum - right*(right-1)*0.5+1\n l_v = total_sum - left*(left-1)*0.5+1\n\n\n if l_v >= n && n > r_v && (right-left).abs <= 1\n sum = l_v\n break\n elsif l_v < r_v\n break\n end\n\n if (p == 2)\n sum = 2\n else\n sum = total_sum - p*(p-1)*0.5+1\n end\n\n\n if(sum < n)\n right = p\n if (left+right)/2 < p\n p = (left+right)/2\n else\n p -= 1\n end\n else\n left = p\n if (left+right)/2 > p\n p = (left+right)/2\n else\n p += 1\n end\n break if p >= right\n end\n end\n\n if sum < n\n puts -1\n else\n puts k-left+1\n end\n end\nend\n\nb = B.new"}, {"source_code": "class B\n def initialize\n n, k = $stdin.gets.chomp.split(' ').map(&:to_i)\n\n if k >= n\n puts 1\n exit\n end\n\n sum = 0\n p = (k+2)/2\n left = 2\n right = k\n\n while((right-left).abs > 0) do \n r_v = right*(right-1)*0.5\n l_v = left*(left-1)*0.5\n\n if l_v < n && n <= r_v && (right-left).abs <= 1\n sum = p*(p-1)*0.5+1\n break\n elsif l_v == n\n break\n elsif l_v > r_v\n break\n end\n\n if (p == 2)\n sum = 2\n else\n sum = p*(p-1)*0.5+1\n end\n\n if(sum < n)\n left = p\n if (left+right)/2 > p\n p = (left+right)/2\n else\n p += 1\n end\n else\n right = p\n if (left+right)/2 < p\n p = (left+right)/2\n else\n p -= 1\n end\n break if p <= left\n end\n end\n\n if sum < n\n puts -1\n else\n puts (right-1)\n end\n end\nend\n\nb = B.new"}, {"source_code": "class B\n def initialize\n n, k = $stdin.gets.chomp.split(' ').map(&:to_i)\n\n if k >= n\n puts 1\n exit\n end\n\n left = 2\n right = k\n\n while(left < right)\n m = (left+right)/2\n\n if(m*(2*k-m-1)/2+1= n\n puts 1\n exit\n end\n\n sum = 0\n p = (k+2)/2\n left = 2\n right = k\n\n while((right-left).abs > 0) do \n r_v = right*(right-1)*0.5\n l_v = left*(left-1)*0.5\n\n if l_v < n && n <= r_v && (right-left).abs <= 1\n sum = right*(right-1)*0.5+1\n break\n elsif l_v == n\n sum = l_v\n break\n elsif l_v > r_v\n break\n end\n\n if (p == 2)\n sum = 2\n else\n sum = p*(p-1)*0.5+1\n end\n\n if(sum < n)\n left = p\n if (left+right)/2 > p\n p = (left+right)/2\n else\n p += 1\n end\n else\n right = p\n if (left+right)/2 < p\n p = (left+right)/2\n else\n p -= 1\n end\n break if p <= left\n end\n end\n\n if sum < n\n puts -1\n else\n puts (right-1)\n end\n end\nend\n\nb = B.new"}, {"source_code": "class B\n def initialize\n n, k = $stdin.gets.chomp.split(' ').map(&:to_i)\n\n if k >= n\n puts 1\n exit\n end\n\n total_sum = k*(k-1)*0.5+1\n sum = 0\n p = (k+2)/2\n left = 2\n right = k\n\n while((right-left).abs > 0) do \n r_v = total_sum - right*(right-1)*0.5+1\n l_v = total_sum - left*(left-1)*0.5+1\n\n\n if l_v >= n && n > r_v && (right-left).abs <= 1\n sum = l_v\n break\n elsif l_v < r_v\n break\n end\n\n if (p == 2)\n sum = 2\n else\n sum = total_sum - p*(p-1)*0.5+1\n end\n\n\n if(sum < n)\n right = p\n if (left+right)/2 < p\n p = (left+right)/2\n else\n p -= 1\n end\n else\n left = p\n if (left+right)/2 > p\n p = (left+right)/2\n else\n p += 1\n end\n break if p >= right\n end\n end\n\n (left-3).upto(left+3) do |elem|\n val1 = total_sum - (elem-1)*(elem-2)*0.5\n val2 = total_sum - (elem)*(elem-1)*0.5\n\n if(val1 >= n && n > val2)\n puts k-elem+1\n exit\n end\n end\n\n puts -1\n end\nend\n\nb = B.new"}, {"source_code": "require 'scanf'\n\n(n, k) = scanf(\"%d%d\")\n\nif k * (k-1) / 2 < n - 1\n puts \"-1\"\nelse\n low, up = 1, k-1\n while low < up do\n m = (low + up + 1) / 2\n if (m + k-1) * (k-1 - m + 1) / 2 < n - 1\n up = m - 1\n else\n low = m\n end\n end\n puts k - up\nend"}], "src_uid": "83bcfe32db302fbae18e8a95d89cf411"} {"source_code": "n,l=gets.split.map &:to_i\na=gets.split.map.with_index{|e,i|[e.to_i,2**i]}.sort_by{|c,v|c.to_r/v}\nm={}\nf=->x,i{\n return 0 if !a[i]\n c,v=a[i]\n k=x/v\n m[[x,i]]||=[f[x-k*v, i+1]+k*c, (k+1)*c].min\n}\np f[l, 0]\n", "positive_code": [{"source_code": "#!/usr/bin/ruby\ninclude Math\n\nINF = 0x3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f\n\nn, v = gets.split().map(&:to_i)\ncost = gets.split().map(&:to_i)\n\nbest = []\nbest[0] = INF\nres = INF\nfor i in 1..n\n\tbest[i] = [2*best[i-1], cost[i-1]].min\n\tif 2**(i-1) >= v\n\t\tres = [res, best[i]].min\n\tend\nend\nfor i in n+1..70\n\tbest[i] = 2*best[i-1]\n\tif 2**(i-1) >= v\n\t\tres = [res, best[i]].min\n\tend\nend\n\nans = INF\nvv = v\nwhile (vv & -vv) != vv\n\ttemp = 0\n\tj = 0\n\tv = vv\n\twhile v > 0\n\t\tj += 1\n\t\tif v % 2 == 1\n\t\t\ttemp += best[j]\n\t\tend\n\t\tv /= 2\n\tend\n\tans = [ans, temp].min\n\tvv += vv & -vv\nend\n\nputs [res, ans].min\n"}, {"source_code": "n,l = gets.split.map &:to_i\nc = gets.split.map &:to_i\n\n(n-1).times{|i| c[i+1] = c[i]*2 if c[i+1] > c[i]*2}\n\nans = []\njust = 0\n(n-1).downto(0){|i|\n d = (i+1).times.map{|j| c[j]*(2**(i-j))}\n x = 2**i\n ne = l/x\n l %= x\n just += d.min*ne\n ans << just + d.min\n}\n\nans << just\n\np ans.min"}], "negative_code": [{"source_code": "#!/usr/bin/ruby\ninclude Math\n\nINF = 0x3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f\n\nn, v = gets.split().map(&:to_i)\ncost = gets.split().map(&:to_i)\n\nbest = []\nbest[0] = INF\nres = INF\nfor i in 1..n\n\tbest[i] = [2*best[i-1], cost[i-1]].min\n\tif 2**(i-1) > v\n\t\tres = [res, best[i]].min\n\tend\nend\nfor i in n+1..70\n\tbest[i] = 2*best[i-1]\n\tif 2**(i-1) > v\n\t\tres = [res, best[i]].min\n\tend\nend\n\nans = 0\nj = 0\nwhile v > 0\n\tj += 1\n\tif v % 2 == 1\n\t\tans += best[j]\n\tend\n\tv /= 2\nend\n\nputs [res, ans].min\n"}, {"source_code": "#!/usr/bin/ruby\ninclude Math\n\nINF = 0x3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f3f\n\nn, v = gets.split().map(&:to_i)\ncost = gets.split().map(&:to_i)\n\nbest = []\nbest[0] = INF\nres = INF\nfor i in 1..n\n\tbest[i] = [2*best[i-1], cost[i-1]].min\n\tif 2**(i-1) > v\n\t\tres = [res, best[i]].min\n\tend\nend\nfor i in n+1..70\n\tbest[i] = 2*best[i-1]\n\tif 2**(i-1) > v\n\t\tres = [res, best[i]].min\n\tend\nend\n\nans = INF\nvv = v\nwhile (vv & -vv) != vv\n\ttemp = 0\n\tj = 0\n\tv = vv\n\twhile v > 0\n\t\tj += 1\n\t\tif v % 2 == 1\n\t\t\ttemp += best[j]\n\t\tend\n\t\tv /= 2\n\tend\n\tans = [ans, temp].min\n\tvv += vv & -vv\nend\n\nputs [res, ans].min\n"}], "src_uid": "04ca137d0383c03944e3ce1c502c635b"} {"source_code": "n = gets.chomp.split(\"\").collect{|i| i.to_i}\nk = n.max\nans = Array.new(k){Array.new}\nn.each do |i|\n for j in 0...i\n ans[j].push('1')\n end\n for j in i...k\n ans[j].push('0')\n end\nend\nans = ans.collect{|i| i.join.to_i}\nputs k\nputs ans.join(\" \")\n", "positive_code": [{"source_code": "# cook your code here\nn=gets.to_i\narr = Array.new(10,0)\nt=1\nm=0\nwhile n>0\n b=n%10\n j=9\n while j>9-b\n arr[j]=(arr[j]+t)\n j-=1\n end\n t=(t*10)\n if(b>m)\n m=b\n end\n n=(n/10)\nend\nputs m\nfor i in 0..9\n if arr[i]!=0\n print arr[i].to_s + ' '\n end\nend\n \n"}, {"source_code": "#!/usr/bin/env ruby\nn=gets.chomp.chars.map(&:to_i)\na=n.size.times.map{[0]*9}\nn.each_with_index{|e,i|e.times{|j|a[i][j]=1}}\na=a.transpose.map{|e|e.join.to_i}.select{|e|e>0}\np a.size\nputs a*' '"}, {"source_code": "n = gets.strip.split(//).map(&:to_i)\nans = n.max\nputs ans\nans.times do |i|\n pp = false\n n.size.times do |j|\n if n[j] > 0\n pp = true\n print 1\n n[j] -= 1\n elsif pp\n print 0\n end\n end\n if i < ans - 1\n print \" \"\n end\nend\nputs\n"}, {"source_code": "#http://codeforces.com/problemset/problem/538/B\n\nn = gets.to_i \n\narr = Array.new(9,0) \nk = 1 \nlargest = 0 \nwhile(n!=0) do \n individual = n%10 \n if individual > largest \n largest = individual \n end \n\n ind = 0 \n individual.times do\n arr[ind] += k \n ind +=1 \n end\n\n k= k*10 \n n = n/10\nend \n\n\nind = 0 \nputs largest \narr.select! do |i| \n i>0 \nend \n\nputs arr.join(' ')\n"}, {"source_code": "n=gets.chomp\n\nn=n.to_i\nb = n\n\na = 0\nd = 0\n\nc = []\n\nwhile b >= 10\n\ta+=1\n\tif b%10>d\n\t\td=b%10\n\tend\n\tc.push(b%10)\n\n\tb/=10\nend\n\nc.push(b)\n\na+=1\n\nif b != 0\n\tif b%10>d\n\t\td=b%10\n\tend\nend\n\narr = []\n\nfor i in (1..d)\n\tx=0\n\tfor j in 0..(c.length - 1)\n\t\tif c[j] > 0\n\t\t\tx+=10**j\n\t\t\tc[j]-=1\n\t\tend\n\tend\n\tarr.push(x)\nend\n\nputs arr.length\n\narr.each do |i|\n\tprint i\n\tprint ' '\nend"}, {"source_code": "arr=[]\nc=0\ngets.chomp.chars{|e|\n\tarr<0 then\n\t\t\t\te-=1\n\t\t\t\tc1+=1\n\t\t\t\tc-=1\n\t\t\t\ts1<<\"1\"\n\t\t\telse\n\t\t\t\ts1<<\"0\"\n\t\t\tend\n\t\t\te\n\t\t}\n\t\tans< 0\n arr << 1\n n[index] -= 1\n else\n arr << 0\n end\n }\n ar << arr.join\nend\n\nputs ar.length\nputs ar.join(' ')\n\n"}, {"source_code": "n = gets.chomp.chars.map(&:to_i)\na = []\nwhile n.any?{|x| x > 0}\n a << n.reduce(0){|x, y| x * 10 + (y > 0 ? 1 : 0)}\n n.map!{|x| x - 1}\nend\nputs a.size, a * ' '\n"}, {"source_code": "n = gets.chomp.chars.map(&:to_i)\na = []\nwhile !n.all?{|x| x == 0}\n b = []\n n.size.times do |i|\n if n[i] > 0\n n[i] -= 1\n b << 1\n else\n b << 0\n end\n end\n a << b\nend\nputs a.size\nputs a.map{|x| x.join('').to_i}.join(' ')\n"}, {"source_code": "n=gets.chomp\nd=Array.new\nfor i in 0...n.length\n d.push(n[i].to_i)\nend\nm=d.max\n# puts \"m=#{m}\"\nputs m\nans=[]\nfor i in 0...m\n num=0\n for j in 0...n.length\n num*=10\n if d[j]>0\n d[j]-=1\n num+=1\n end\n end\n ans.push(num)\nend\nputs ans.join(\" \")"}, {"source_code": "n = gets.chomp.scan(/./)\nmaxx = n.map {|i| i.to_i}.max\nputs maxx\nfor i in 0...maxx\n x = [0] * n.length\n for j in 0...n.length\n if n[j].to_i != 0\n x[j] = 1\n n[j] = (n[j].to_i - 1).to_s\n end\n end\n print x.join('').to_i, ' '\nend\n"}], "negative_code": [{"source_code": "puts \"Please enter your number:\"\nprint '> '\n\nn=gets.chomp\n\nn=n.to_i\nb = n\n\na = 0\nd = 0\n\nc = []\n\nwhile b > 10\n\ta+=1\n\tif b%10>d\n\t\td=b%10\n\tend\n\tc.push(b%10)\n\n\tb/=10\nend\n\nc.push(b)\n\na+=1\n\nif b != 0\n\tif b%10>d\n\t\td=b%10\n\tend\nend\n\narr = []\n\nfor i in (1..d)\n\tx=0\n\tfor j in 0..(c.length - 1)\n\t\tif c[j] > 0\n\t\t\tx+=10**j\n\t\t\tc[j]-=1\n\t\tend\n\tend\n\tarr.push(x)\nend\n\nputs arr.length\n\narr.each do |i|\n\tprint i\n\tprint ' '\nend"}, {"source_code": "n=gets.chomp\n\nn=n.to_i\nb = n\n\na = 0\nd = 0\n\nc = []\n\nwhile b > 10\n\ta+=1\n\tif b%10>d\n\t\td=b%10\n\tend\n\tc.push(b%10)\n\n\tb/=10\nend\n\nc.push(b)\n\na+=1\n\nif b != 0\n\tif b%10>d\n\t\td=b%10\n\tend\nend\n\narr = []\n\nfor i in (1..d)\n\tx=0\n\tfor j in 0..(c.length - 1)\n\t\tif c[j] > 0\n\t\t\tx+=10**j\n\t\t\tc[j]-=1\n\t\tend\n\tend\n\tarr.push(x)\nend\n\nputs arr.length\n\narr.each do |i|\n\tprint i\n\tprint ' '\nend"}, {"source_code": "n = gets.to_i\nl = n.to_s.chars.length\ns = ('1' * l).to_i\na = []\nwhile n != 0\n if n - s >= 0\n n -= s\n a << s\n else\n t = s.to_s\n if t.count('1') >= 2\n t[t.rindex('1')] = '0'\n s = t.to_i\n else\n s /= 10\n end\n end\nend\nputs a.size\nputs a.join(' ')\n"}, {"source_code": "n = gets.to_i\nl = n.to_s.chars.length\ns = ('1' * l).to_i\na = []\nwhile n != 0\n if n - s >= 0\n n -= s\n a << s\n else\n t = s.to_s\n if t.count('1') >= 2\n t[t.rindex('1')] = '0'\n s = t.to_i\n else\n s /= 10\n end\n end\nend\nputs a.join(' ')\n"}], "src_uid": "033068c5e16d25f09039e29c88474275"} {"source_code": "a=gets.chomp.to_i\nb=gets.chomp.split(\" \")\nans=0\n\nloop do\nif b[0]==\"0\"\nb.delete_at(0)\nelse\nbreak\nend\nend\nloop do\nif b[b.length-1]==\"0\"\nb.delete_at(b.length-1)\nelse\nbreak\nend\nend\n\n0.upto(b.length) do |i|\nbreak if b[i]==nil\nif b[i]==\"1\"\nans+=1\nelsif b[i-1]==\"1\" && b[i+1]==\"1\"\nans+=1\nend\nend\n\nputs \"#{ans}\"\n", "positive_code": [{"source_code": "n=gets.to_i\na=gets.split(\" \").map(&:to_i).map{|x| x == 1 }\n\nuniv = false\ncount = 0\nfor i in 0...a.size\n\tif !univ\n\t\tif a[i]\n\t\t\tuniv = true\n\t\tend\n\tend\n\tif univ && !a[i] && !a[i+1]\n\t\tuniv = false\n\tend\n\n\tcount += 1 if univ\nend\n\np count\n"}, {"source_code": "n, pairs = gets.chomp.to_i, gets.chomp.split(\" \").join(\"\")\npairs.gsub! /(^0+|00+|0+$)/, \"\"\nputs pairs.length "}, {"source_code": "n, pairs = gets.chomp.to_i, gets.chomp.split(\" \")\nloop do\n\tpairs[0] == \"0\" ? pairs.delete_at(0) : break\nend\nloop do\n\tpairs[-1] == \"0\" ? pairs.delete_at(-1) : break\nend\npairs = pairs.join \"\"\npairs.gsub! /00+/, \"\"\nputs pairs.length "}, {"source_code": "n = gets.chomp.to_i\nv = gets.split.map{ |x| x.to_i}\n\nstart = -1\nlast = n+1\nzero = 0\nless = 0\nn.times do |i|\n start = i if v[i] == 1 and start == -1\n last = i if v[i] == 1\n if v[i] == 0 and start != -1\n zero += 1\n end\n if v[i] == 1 \n if zero >= 2\n less += zero\n end\n zero = 0\n end\nend\nif start != -1\n puts last-start-less+1\nelse\n puts 0\nend\n"}, {"source_code": "# http://codeforces.com/contest/586/problem/A\n# A. Alena's Schedule\nn = gets.chomp.to_i\narr = gets.chomp.split.join.gsub(/0{2,}/, '').chars\n\narr.pop if arr.last == '0'\narr.shift if arr.first == '0'\nputs arr.join.gsub(/00/, '').length\n"}, {"source_code": "gets\na = gets.split(' ').map! {|x| x.to_i} << 0\na.unshift(0)\nans = 0\n\na.size.times do |i|\n ans += 1 if (a[i] == 1.to_i) || ((a[i - 1] == 1) && (a[i + 1] == 1))\nend\n\np ans\n"}, {"source_code": "#! ruby\n# try Codeforces\n# author: Leonardone @ NEETSDKASU\n\nn = gets.to_i\na = gets.chomp.split.map(&:to_i)\n\nstay = :HOME\ncount = 0\ni = 0\n\nwhile i < n\n\tcase stay\n\twhen :HOME\n\t\tif a[i] == 1\n\t\t\tstay = :UNIV\n\t\tend\n\twhen :UNIV\n\t\tif a[i] == 0\n\t\t\tif i == n - 1 || a[i + 1] == 0\n\t\t\t\tstay = :HOME\n\t\t\tend\n\t\tend\n\tend\n\tcount += 1 if stay == :UNIV\n\ti += 1\nend\n\nputs count"}, {"source_code": "a=gets.chomp.to_i\nb=gets.chomp.split(\" \")\nans=0\n\nloop do\nif b[0]==\"0\"\nb.delete_at(0)\nelse\nbreak\nend\nend\nloop do\nif b[b.length-1]==\"0\"\nb.delete_at(b.length-1)\nelse\nbreak\nend\nend\n\n0.upto(b.length) do |i|\nbreak if b[i]==nil\nif b[i]==\"1\"\nans+=1\nelsif b[i-1]==\"1\" && b[i+1]==\"1\"\nans+=1\nend\nend\n\nputs \"#{ans}\""}, {"source_code": "n=gets.to_i\nx=gets.split.map{|e| e.to_i}\n\n\tx<<0\n\tans=0\n\ti=0\n\twhile i<(x.size-1) && x[i]==0\n\t\ti+=1\n\tend\n\twhile i<(x.size-1)\n\t\tif x[i]!=0 || x[i+1]!=0 then\n\t\t\tans+=1\n\t\t\ti+=1\n\t\telse\n\t\t\twhile i<(x.size-1) && x[i]==0\n\t\t\t\ti+=1\n\t\t\tend\n\t\tend\n\tend\n\tputs ans\n\n"}, {"source_code": "n = gets.chomp.to_i\nas = gets.chomp.split(' ').map(&:to_i)\n\nfor i in 0..n-3\n if as[i] * as[i + 2] == 1 && as[i + 1] == 0\n as[i + 1] = 1\n end\nend\n\nputs as.inject{|s, a| s + a }\n"}, {"source_code": "n = gets.to_i\na = gets.split.map(&:to_i)\nstatus, ans = 0, 0\nn.times do |i|\n if a[i] == 1\n status = 1\n ans += 1\n elsif status == 1 && (i != 0 && a[i - 1] == 1) && (i + 1 != n && a[i + 1] == 1)\n ans += 1\n end\nend\np ans\n"}, {"source_code": "\nn = gets.to_i\nv = gets.split.map(&:to_i)\ncont = 0\nsw = 0\nc = 0\nfor i in(0..(n-1))\n if v[i] == 1\n sw = 1\n end\n if sw == 1\n if(v[i]==0)\n c+=1\n elsif c < 2 \n cont=cont+1+c\n c=0\n else\n cont+=1\n c=0\n end\n end\nend\np cont"}, {"source_code": "# coding: utf-8\n\nn = gets.to_i\nsched = gets.strip.gsub(' ', '')\n\nsched.gsub!(/^0+/, '')\nsched.gsub!(/0+$/, '')\nsched.gsub!(/0{2,}/, '')\n\nputs sched.length.to_s"}, {"source_code": "# #325 Div2 A. Alena's Schedule\nn = gets.chomp.to_i\na = gets.chomp.split(\" \").map(&:to_i)\nlesson = 0\nrest = 0\na.each do |i|\n if i == 1 then\n if rest == 1 and lesson > 0 then\n lesson += 1\n end\n rest = 0\n lesson += 1\n else\n rest += 1\n end\nend\nputs lesson"}, {"source_code": "a=gets.chomp.to_i\nb=gets.chomp.split(\" \")\nans=0\n\nloop do\nif b[0]==\"0\"\nb.delete_at(0)\nelse\nbreak\nend\nend\nloop do\nif b[b.length-1]==\"0\"\nb.delete_at(b.length-1)\nelse\nbreak\nend\nend\n\n0.upto(b.length) do |i|\nbreak if b[i]==nil\nif b[i]==\"1\"\nans+=1\nelsif b[i-1]==\"1\" && b[i+1]==\"1\"\nans+=1\nend\nend\n\nputs \"#{ans}\""}, {"source_code": "totNum = gets.chomp.to_i\nclassArr = gets.chomp.split(' ').map {|item| item.to_i}\nstart = false\nbreaks = 0\nans = 0\nclassArr.each_with_index do |val, idx|\n\t#puts \"idx : #{idx} , val : #{val} , classArr[idx + 1] : #{classArr[idx + 1]}\"\n\tbreak if idx == classArr.length - 1\n\tstart = true if (val == 1 && !start)\n\t#puts \"start 1 step : #{start}\"\n\tnext if !start\n\tstart = false if (val == 0 && classArr[idx + 1] == 0)\n\t#puts \"start 2 step : #{start}\"\n\tnext if !start\n\tans += 1\nend\nans += 1 if classArr[totNum - 1] == 1\nputs ans"}], "negative_code": [{"source_code": "# http://codeforces.com/contest/586/problem/A\n# A. Alena's Schedule\nn = gets.chomp.to_i\narr = gets.chomp.split.join.gsub(/00/, '').chars\n\narr.pop if arr.last == '0'\narr.shift if arr.first == '0'\nputs arr.join.length\n"}, {"source_code": "# http://codeforces.com/contest/586/problem/A\n# A. Alena's Schedule\nn = gets.chomp.to_i\narr = gets.chomp.split.map(&:to_i)\n\narr.pop if arr.last == 0\narr.shift if arr.first == 0\nputs arr.join.gsub(/00/, '').length\n"}, {"source_code": "# http://codeforces.com/contest/586/problem/A\n# A. Alena's Schedule\nn = gets.chomp.to_i\narr = gets.chomp.split.join.gsub(/0{2,}/, '').chars\n\narr.pop if arr.last == 0\narr.shift if arr.first == 0\nputs arr.join.gsub(/00/, '').length\n"}, {"source_code": "gets.to_i\na = gets.split(' ').map! {|x| x.to_i}\np 0 if a.index(1) == nil\np (a.rindex(1) - a.index(1) + 1)\n\n"}, {"source_code": "a=gets.chomp.to_i\nb=gets.chomp.split(\" \")\nloop do\nif b[0]==\"0\"\nb.delete_at(0)\nelse\nbreak\nend\nend\nloop do\nif b[b.length-1]==\"0\"\nb.delete_at(b.length-1)\nelse\nbreak\nend\nend\ntrig=0\n0.upto(b.length-3) do |i|\nif b[i]==\"0\"&& b[i+1]==\"0\"\nb.delete_at(i)\nb.delete_at(i+1)\nend\nend\nputs \"#{b.length}\"\n"}, {"source_code": "n=gets.to_i\nx=gets.split.map{|e| e.to_i}\nif n==1 then\n\tputs 1\nelse\n\tx<<0\n\tans=0\n\ti=0\n\twhile i<(x.size-1) && x[i]==0\n\t\ti+=1\n\tend\n\twhile i<(x.size-1)\n\t\tif x[i]!=0 || x[i+1]!=0 then\n\t\t\tans+=1\n\t\t\ti+=1\n\t\telse\n\t\t\twhile i<(x.size-1) && x[i]==0\n\t\t\t\ti+=1\n\t\t\tend\n\t\tend\n\tend\n\tputs ans\nend\n\n"}, {"source_code": "n = gets.to_i\na = gets.split.map(&:to_i)\n# ab = a.slice_when{|x, y| x != y }.select{|x| x.inject(:+) == 0}\nab = a\nab.shift if a[0] == 0\nab.pop if a[n - 1] == 0\nans = a.inject(:+) + ab.inject(0){|sum, n| sum + (n.size == 1 ? n.size : 0)}\nputs ans\n"}, {"source_code": "n = gets.to_i\na = gets.split.map(&:to_i)\nans = n\nstatus = 0\nn.times do |i|\n if status.zero? && a[i] == 0\n ans -= 1\n elsif a[i] == 1\n status = 1\n elsif status == 1 && a[i] == 0 && (a[i - 1] == 0 || a[i + 1] == 0)\n ans -= 1\n end\nend\nans -= 1 if a[-1] == 0 && n != 1\np ans\n"}, {"source_code": "n = gets.to_i\na = gets.split.map(&:to_i)\nans = n\nstatus = 0\nn.times do |i|\n if status.zero? && a[i] == 0\n ans -= 1\n elsif a[i] == 1\n status = 1\n elsif status == 1 && a[i] == 0 && (a[i - 1] == 0 || a[i + 1] == 0)\n ans -= 1\n end\nend\nans -= 1 if a[-1] == 0 && n != 1 && status == 1\np ans\n"}, {"source_code": "n = gets.to_i\nv = gets.split.map(&:to_i)\ncont = 0\nsw = 0\nc = 0\nfor i in(0..(n-1))\n if v[i] == 1\n sw = 1\n end\n if sw == 1\n if(v[i]==0)\n c+=1\n elsif c < 2 \n cont=cont+1+c\n c=0\n else\n cont+=1\n end\n end\nend\np cont"}], "src_uid": "2896aadda9e7a317d33315f91d1ca64d"} {"source_code": "def pow(a, b, mod)\n ret = 1\n while b > 0\n if (b & 1 == 1)\n ret = ret * a % mod\n end\n b = b / 2\n a = a * a % mod\n end\n return ret\nend\n(n, m, k) = gets.chomp.split.map(&:to_i)\nmod = 10**9 + 7\nans = pow(pow(2, n - 1, mod), m - 1, mod)\nif (n % 2 != m % 2 and k == -1)\n ans = 0\nend\nprint ans", "positive_code": [{"source_code": "def power(x, y, z)\n\tnumber = 1\n\twhile (y > 0) do\n\t\tif (y%2==1)\n\t\t\tnumber = number * x % z\n\t\tend\n\t\ty >>= 1\n\t\tx = x * x % z\n\tend\n\treturn number\nend\n\nn, m, k = gets.split.map(&:to_i)\nif((n + m) % 2 == 1 && k == -1)\n p 0\nelse\n md = 1000000007\n p power(2, (n-1)*(m-1), md)\nend"}], "negative_code": [{"source_code": "n, m, k = gets.split.map(&:to_i)\nmd = 1000000007\np (2**((n-1)*(m-1)))%md"}, {"source_code": "def power(x, y, z)\n\tnumber = 1\n\twhile (y > 0) do\n\t\tif (y%2==1)\n\t\t\tnumber = number * x % z\n\t\tend\n\t\ty >>= 1\n\t\tx = x * x % z\n\tend\n\treturn number\nend\n\nn, m, k = gets.split.map(&:to_i)\nmd = 1000000007\np power(2, (n-1)*(m-1), md)"}], "src_uid": "6b9eff690fae14725885cbc891ff7243"} {"source_code": "line = $stdin.gets.strip.split(/\\s+/)\na = line[0].to_i\nb = line[1].to_i\nm = line[2].to_i\nr = line[3].to_i\nm.times {r = (a*r + b) % m } #going through the pre-period\nrr = r\ni = 0\nloop do\n i += 1\n r = (a*r + b) % m\n if rr == r\n puts i\n exit 0\n end\nend\n", "positive_code": [{"source_code": "a, b, m, r = gets.split.map(&:to_i)\nt, s = [nil] * r, 0\nloop do\n if t[r]\n p s - t[r]\n break\n else\n t[r] = s\n r = (a * r + b) % m\n s += 1\n end\nend\n"}, {"source_code": "a,b,m,r=gets.split.map(&:to_i)\nback_r=Hash.new\nback_r[r]=(now=0)\nloop do\n r=(a*r+b)%m\n now+=1\n if back_r.key?(r)\n puts now-back_r[r]\n break\n end\n back_r[r]=now\nend\n"}, {"source_code": "input = STDIN.read\n\ninput =~ /^(\\d+) (\\d+) (\\d+) (\\d+)/\na, b, m, $r0 = $1.to_i, $2.to_i, $3.to_i, $4.to_i\n\nvalues1, values2 = Array.new, Array.new\n\ndef get_next_value(a, b, m, r)\n r ||= $r0\n (a * r + b) % m\nend\n\nelement = nil\n\nwhile true\n values1 << get_next_value(a, b, m, values1.last)\n values2 << get_next_value(a, b, m, values2.last)\n values2 << get_next_value(a, b, m, values2.last)\n\n if values1.last == values2.last\n element = values1.last\n break\n end\nend\n\nresult = -1\ni = values2.length - 2\nuntil i < 0\n if element == values2[i]\n result = values2.length - 1 - i\n break\n end\n i -= 1\nend\n\nputs result\n\n"}, {"source_code": "a,b,m,r = gets.split.map(&:to_i)\n\nar = Array.new(m)\nar[r]=0\ni = 0\nloop do\n i += 1\n r = (a*r+b)%m\n if ar[r]\n puts i - ar[r]\n break\n end\n ar[r] = i\nend\n"}, {"source_code": "a,b,m,r=gets.split.map &:to_i;\nv=[0]*m;v[r=(a*r+b)%m]+=1 while v[r]!=3;\nprint 1+v.count(2);"}, {"source_code": "a,b,m,r = gets.split.map &:to_i\nar = [nil]*100000\ni = 0\nwhile true \n r = (a*r+b)%m\n if ar[r]\n p i-ar[r]\n exit\n end \n ar[r] = i\n i += 1\nend\n"}, {"source_code": "a, b, m, r0 = gets.split.map{|i| i.to_i}\ns = Array.new(100000, 0)\nt = 1\nr = r0\nwhile s[r] == 0\n s[r] = t\n t += 1\n r = (a * r + b) % m\nend\nputs t - s[r]\n"}, {"source_code": "a,b,m,r = gets.split.map &:to_i\nt = [0]*m\nwhile t[r] != 3\n\tt[r = (a*r+b)%m] += 1\nend\n\nputs 1+t.count(2)"}], "negative_code": [], "src_uid": "9137197ee1b781cd5cc77c46f50b9012"} {"source_code": "x,y = gets.split.map(&:to_i)\nprime = []\nk = (y**0.5).to_i\nk = x if k > x\na = Array.new(k+1,1)\ni = 2\nwhile i <= k\n if a[i] == 1\n prime << i\n (k/i).times do |j|\n a[i*j] = 0\n end\n end\n i += 1\nend\nisprime = false\nwhile !isprime && x < y\n isprime = true\n prime.length.times do |i|\n isprime = false if y % prime[i] == 0\n end\n if isprime\n ans = y\n end\n y -= 1\nend\nans = -1 if !isprime\nputs ans", "positive_code": [{"source_code": "require 'prime'\n\ndef maxprime(x, y)\n y.downto(x){|n| return n if n.prime? }\n -1\nend\n\np, y=gets.split.map &:to_i\nq=maxprime(p+1, y)\n\nif q==-1\n puts -1\n exit\nend\n\np=maxprime(2, p)\nres=q;\nq.upto(y){|x| res=x if x.prime_division[0][0]>p}\nputs res\n"}], "negative_code": [{"source_code": "x,y = gets.split.map(&:to_i)\nprime = []\nk = (y**0.5).to_i\n\na = Array.new(k+1,1)\ni = 2\nwhile i <= k\n if a[i] == 1\n prime << i\n (k/i).times do |j|\n a[i*j] = 0\n end\n end\n i += 1\nend\nisprime = false\nwhile !isprime && x < y\n isprime = true\n prime.length.times do |i|\n isprime = false if y % prime[i] == 0\n end\n if isprime\n ans = y\n end\n y -= 1\nend\nans = -1 if !isprime\nputs ans"}, {"source_code": "require 'prime'\np, y=gets.split.map &:to_i\ny.downto(p+1){|x|\n if x.prime?\n puts x\n exit\n end\n}\nputs -1\n"}], "src_uid": "b533203f488fa4caf105f3f46dd5844d"} {"source_code": "n = gets.to_i\ni, mx, mn = 0, 0, 1e10\nwhile i*i*i <= n\n i += 1\n next if n%i > 0\n j = i-1\n while i*j*j <= n\n j += 1\n next if n/i%j > 0\n mx = [mx, (i+2)*(j+2)*(n/i/j+1)].max\n mn = [mn, (i+1)*(j+2)*(n/i/j+2)].min\n end\nend\nputs [mn-n, mx-n] * \" \"", "positive_code": [{"source_code": "require 'prime'\n\ndef sub(b, s)\n if b.empty?\n v = (s[0]+1)*(s[1]+2)*(s[2]+2) - s[0]*s[1]*s[2]\n return [v, v]\n end\n\n b = b.dup\n k, v = b.pop\n\n result = [1e100, 0]\n 0.upto(v) do |i|\n 0.upto(v-i) do |j|\n mn, mx = sub(b, [s[0]*k**i, s[1]*k**j, s[2]*k**(v-i-j)])\n result[0] = [result[0], mn].min\n result[1] = [result[1], mx].max\n end\n end\n\n result\nend\n\n\ndef solve(n)\n a = Prime.prime_division(n)\n\n s1 = sub(a, [1, 1, 1])\n\n=begin\n b = a.map{|k,v| [k]*v}.flatten\n r = []\n (3**b.size).times do |i|\n o = [1]*3\n (\"0\"*b.size+i.to_s(3))[-b.size,b.size].each_char.zip(b) do |j, k|\n o[j.to_i] *= k\n end\n r << [(o[0]+1)*(o[1]+2)*(o[2]+2) - o[0]*o[1]*o[2], o]\n end\n s2 = [r.min[0], r.max[0]]\n=end\n s1\nend\n\nn = gets.to_i\nputs solve(n)*\" \"\n"}], "negative_code": [{"source_code": "n = gets.to_i\ni, mx, mn = 0, 0, 1e9\nwhile i*i*i <= n\n i += 1\n next if n%i > 0\n j = i-1\n while i*j*j <= n\n j += 1\n next if n/i%j > 0\n mx = [mx, (i+2)*(j+2)*(n/i/j+1)].max\n mn = [mn, (i+1)*(j+2)*(n/i/j+2)].min\n end\nend\nputs [mn-n, mx-n] * \" \""}], "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7"} {"source_code": "#!/usr/bin/ruby\n# coding: utf-8\n\nn = $stdin.gets.to_i\nxs = $stdin.gets.chomp.chars.map(&:to_i)\nys = xs[0 .. n-1].sort\nzs = xs[n .. 2*n-1].sort\n\nputs (ys.zip(zs).all? { |y, z| y < z } or ys.zip(zs).all? { |y, z| y > z }) ? 'YES' : 'NO'\n", "positive_code": [{"source_code": "n = gets.chomp.to_i\na = gets.chomp.split(//).map!{|x| x.to_i}\nq = Array.new\nw = Array.new\nfor i in 0..n-1\n q[i] = a[i]\n w[i] = a[n+i]\nend\n\nq = q.sort\nw = w.sort\n\nif q[0] < w[0]\n t = 0\nelsif q[0] > w[0]\n t = 1\nelse\n t = 2\nend\n\nfor i in 1..n-1\n if q[i] < w[i] && t === 1\n t = 2\n break\n elsif q[i] > w[i] && t === 0\n t = 2\n break\n elsif q[i] === w[i]\n t = 2\n break\n elsif t === 2\n break\n end\nend\n\nif t === 2\n puts \"NO\"\nelse\n puts \"YES\"\nend"}, {"source_code": "n = gets.to_i\na = gets.strip\n\nf = a[0..n-1].split(//).map(&:to_i).sort\ns = a[n..2*n].split(//).map(&:to_i).sort\n\nz = f.zip(s)\nprint (z.all?{|e| e[0] > e[1]} || z.all?{|e| e[0] < e[1]}) ? \"YES\" : \"NO\"\n"}, {"source_code": "#!/usr/bin/ruby\nn = STDIN.gets.chomp.to_i\nline = STDIN.gets.chomp\nleft = line[0..n-1].split(//).map(&:to_i).sort\nright = line[n..2*n].split(//).map(&:to_i).sort\n\nok1 = true\n0.upto(n - 1) do |i|\n ok1 &= left[i] < right[i]\nend\n\nok2 = true\n0.upto(n - 1) do |i|\n ok2 &= left[i] > right[i]\nend\n\nif ok1 or ok2\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "n = Integer(gets)\ninput = gets.chomp\nnum = Array.new\nfor i in 0...2*n\n num[i] = Integer(input[i])\nend\nleft = Array.new\nright = Array.new\nfor i in 0...n\n left.push(num[i])\n right.push(num[i + n])\nend\nleft = left.sort\nright = right.sort\n\ndef less(left,right)\n if left < right\n return true\n else\n return false\n end\nend\ndef more(left,right)\n if left > right\n return true\n else\n return false\n end\nend\nc = 0\nif n == 1\n if left[0] != right[0]\n c = 1\n end\nelse\n\n if left[0] > right[0]\n for i in 1...n\n if more(left[i],right[i])\n c = 1\n else\n c = 0\n break\n end\n end\n elsif left[0] < right[0]\n for i in 1...n\n if less(left[i],right[i])\n c = 1\n else\n c = 0\n break\n end\n end\n end\nend\nif c == 1\n puts \"YES\"\nelse \n puts \"NO\"\nend"}, {"source_code": "n = gets.to_i\na = gets.split(\"\")\na.pop\n\nfor i in 0 ... a.size\n\ta[i] = a[i].to_i\nend\n\nb = a[0...a.size/2]\nc = a[a.size/2...a.size]\n\nb.sort!\nc.sort!\n\nans = true\nfor i in 1...a.size/2\n\tif b[0] < c[0] then\n\t\tif b[i] >= c[i] then\n\t\t\tans = false\n\t\t\tbreak\n\t\tend\n\telsif b[0] > c[0] then\n\t\tif b[i] <= c[i] then\n\t\t\tans = false\n\t\t\tbreak\n\t\tend\n\telse\n\t\tans = false\n\t\tbreak\n\tend\t\t\nend\nif n == 1 then\n\tans = (b[0] != c[0])\nend\n\nif ans then\n\tputs(\"YES\")\nelse\n\tputs(\"NO\")\nend"}, {"source_code": "input = STDIN.read.split(\"\\n\")\n\nn = input[0].to_i\nnums = input[1].split('').map(&:to_i)\n\nnum1 = nums[0..n-1].sort!\nnum2 = nums[n..-1].sort!\n\nif num1[0] > num2[0]\n\tmore = true\nelsif num1[0] < num2[0]\n\tmore = false\nelse\n\tSTDOUT.puts \"NO\"\n\texit\nend\n\nnum1.length.times do |i|\n\tif more\n\t\tif num1[i] <= num2[i]\n\t\t\tSTDOUT.puts \"NO\"\n\t\t\texit\n\t\tend\n\telse\n\t\tif num1[i] >= num2[i]\n\t\t\tSTDOUT.puts \"NO\"\n\t\t\texit\n\t\tend\n\tend\nend\n\nSTDOUT.puts \"YES\""}, {"source_code": "# http://codeforces.ru/problemset/problem/160/B\n\ndef run(input = STDIN.read)\n lines = input.split(\"\\n\")\n\n n = lines[0].to_i\n ticket = lines[1].split(\"\").map(&:to_i)\n\n first = ticket.take(ticket.size / 2).sort\n second = ticket.drop(ticket.size / 2).sort\n \n if (0..n-1).all? { |i| first[i] < second[i] } or\n (0..n-1).all? { |i| first[i] > second[i] } then\n return 'YES'\n else\n return 'NO'\n end\nend\n\nbegin\n require './testing.rb'\nrescue LoadError\n puts run\nend\n__END__\n2\n2421\n=\nYES\n---\n2\n0135\n=\nYES\n---\n2\n3754\n=\nNO"}, {"source_code": "lines = STDIN.read.split(\"\\n\")\n\nn = lines[0].to_i\nticket = lines[1].split(\"\").map(&:to_i)\n\nfirst = ticket.take(ticket.size / 2).sort\nsecond = ticket.drop(ticket.size / 2).sort\n\nif (0..n-1).all? { |i| first[i] < second[i] } or\n (0..n-1).all? { |i| first[i] > second[i] } then\n puts 'YES'\nelse\n puts 'NO'\nend"}, {"source_code": "n = gets.to_i\n\nticket = []\nticket[0] = gets(n)\nticket[1] = gets(n)\n\nticket[0] = ticket[0].chars.sort.join\nticket[1] = ticket[1].chars.sort.join\n\nunlucky = true\nfor i in (0..ticket[0].length-1)\n if ticket[0][i] >= ticket[1][i]\n unlucky = false\n break\n end\nend\n\nif unlucky; puts \"YES\"; Process.exit; end\n\nunlucky = true\nfor i in (0..ticket[0].length-1)\n if ticket[0][i] <= ticket[1][i]\n unlucky = false\n break\n end\nend\n\nif unlucky; puts \"YES\"; Process.exit; end\n\nputs \"NO\""}, {"source_code": "n = gets.chomp.to_i\ndigits = gets.chomp.split(\"\").collect{|i| i.to_i}\n\nleft = digits[0..n-1].sort\nright = digits[n..-1].sort\n\nif left[0] == right[0]\n puts \"NO\"\n exit\nend\n\nif left[0] > right[0]\n left, right = [right, left] \nend\n\nn.times{|i|\n if left[i] >= right[i]\n puts \"NO\"\n exit\n end \n}\n\nputs \"YES\""}, {"source_code": "n=gets.to_i\ns=gets.split''\nputs ((0...n).map{|i| s[0...n].sort[i]<=>s[n...n+n].sort[i] }.reduce(:+).abs==n) ? :YES : :NO"}, {"source_code": "n = gets.to_i\ns = gets.split('')\nl = s[0...n].sort!\nr = s[n...n+n].sort!\nputs ((0...n).map{ |i| l[i] <=> r[i] }.reduce(:+).abs == n) ? \"YES\" : \"NO\"\n"}, {"source_code": "n = Integer(gets.chomp)\ndigits = gets.chomp.split('').map { |x| x.to_i }\nfirst_half = digits[0...n].sort\nsecond_half = digits[n..-1].sort\nop = first_half.first < second_half.first ? :< : first_half.first > second_half.first ? :> : :!=\nres = true\nfor i in 0...n\n unless [first_half[i], second_half[i]].inject(op)\n res = false\n break\n end\nend\nputs(res ? 'YES' : 'NO')"}, {"source_code": "n = gets.chomp.to_i\nm = gets.chomp.split(//).map!{|x| x.to_i}\nm1 = m.slice(0,n)\nm2 = m.slice(n,n)\nm1.sort!\nm2.sort!\nret = \"YES\"\nif m1[0] == m2[0] || m1[n-1] == m2[n-1]\n\tret = \"NO\"\nelse\n\tif ( m1[0] < m2[0] && m1[n-1] > m2[n-1] ) || ( m1[0] > m2[0] && m1[n-1] < m2[n-1] )\n\t\tret = \"NO\"\n\telse\n\t\tflg = 1\n\t\tif m1[0] < m2[0]\n\t\t\tflg = -1\n\t\tend\n\t\tfor i in 0..n-1\n\t\t\tif ( flg == 1 && m1[i] <= m2[i] ) || (flg == -1 && m1[i] >= m2[i] )\n\t\t\t\tret = \"NO\"\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\tend\nend\nputs ret"}, {"source_code": "l = gets.chomp.to_i\nn = gets.chomp\na = n.split('');\nd = []\n\na.each_index{|i| d[i] = a[i].to_i}\n#puts d.first(1);\nb = d.first(l);\nc = d.last(l);\nb = b.sort\nc = c.sort\n#puts b\n#puts c\nb.each_index{|i| b[i] -= c[i]} \n\nb = b.sort\n#puts b\nif b[0]*b[-1] <= 0 then\n puts \"NO\"\nelse\n puts \"YES\"\nend\n"}, {"source_code": "n = gets.to_i\ns = gets.chomp\nt = [s[0, n], s[n, n]].map{|_| _.chars.to_a.sort}.transpose\nputs t.all?{|i, j| i < j} || t.all?{|i, j| i > j} ? :YES : :NO\n"}, {"source_code": "def solve(a,b)\n x=[]\n y=[]\n a.length.times do |i|\n x.push(a[i].to_i)\n y.push(b[i].to_i)\n end\n x.sort!\n y.sort!\n\n a.length.times do |i|\n return false if x[i]>=y[i]\n end\n return true\nend\n\nn=gets.to_i\na=gets.split[0]\nx=a[0..n-1]\ny=a[n..2*n-1]\nif solve(x,y) || solve(y,x)\n puts \"YES\"\nelse\n puts \"NO\"\nend\n\n"}, {"source_code": "n = gets.to_i\ns = gets.chomp\n\nl = s[0...n].split(//).map(&:to_i).sort\nr = s[n...2*n].split(//).map(&:to_i).sort\n\nlh, rh = true, true\nfor i in 0...n do\n lh = lh && l[i] < r[i]\n rh = rh && l[i] > r[i]\nend\n\nputs(if lh || rh then \"YES\" else \"NO\" end)"}, {"source_code": "n = gets.chomp.to_i\na = gets.chomp.split(\"\").map{|e| e.to_i}\n\nfirst = a[0..(n - 1)].sort!\nsecond = a[n..(2 * n - 1)].sort!\n\nless = true\nmore = true\n0.upto(n - 1) do |i|\n if first[i] <= second[i]\n less = false\n end\n \n if first[i] >= second[i]\n more = false\n end \nend\n\nif less or more\n puts \"YES\"\nelse\n puts \"NO\"\nend"}, {"source_code": "n = STDIN.readline.to_i\ns = STDIN.readline.strip\na, b = s[0..n-1], s[n..2*n-1]\na = a.split('').map {|s| s.to_i }.sort\nb = b.split('').map {|s| s.to_i }.sort\nless, greater = true, true\nn.times do |i|\n less = false if a[i] >= b[i]\n greater = false if a[i] <= b[i]\nend\nputs less || greater ? 'YES' : 'NO'\n"}, {"source_code": "n,s = gets.to_i, gets.strip.split('').map(&:to_i)\na,b = s[0..n-1].sort.reverse, s[n..-1].sort.reverse\nb = a.zip(b).map { |x,y| x-y }\nputs (b.find_all { |x| x < 0 }.size == n or b.find_all { |x| x > 0 }.size == n) ? \"YES\" : \"NO\""}], "negative_code": [{"source_code": "def check(b)\n f = true\n if b[0] > 0 then\n f = true\n else\n f = false\n end\n b.each { |el|\n if (f && el < 0 || !f && el > 0 || el == 0)\n puts \"NO\"\n return\n end\n }\n\n puts \"YES\"\n \nend\n\n\nl = gets.chomp.to_i\nn = gets.chomp\na = n.split('');\nd = []\n\na.each_index{|i| d[i] = a[i].to_i}\n#puts d.first(1);\nb = d.first(l);\nc = d.last(l);\nb.each_index{|i| b[i] -= c[i]} \n\ncheck(b)\n"}, {"source_code": "def check(b)\n f = true\n if b[0] > 0 then\n f = true\n else\n f = false\n end\n b.each { |el|\n if (f && el < 0 || !f && el > 0)\n puts \"NO\"\n return\n end\n }\n\n puts \"YES\"\n \nend\n\n\nl = gets.chomp.to_i\nn = gets.chomp\na = n.split('');\nd = []\n\na.each_index{|i| d[i] = a[i].to_i}\n#puts d.first(1);\nb = d.first(l);\nc = d.last(l);\nb.sort\nc.sort\n\nb.each_index{|i| b[i] -= c[i]} \n\ncheck(b)\n"}, {"source_code": "def check(b)\n f = true\n if b[0] > 0 then\n f = true\n else\n f = false\n end\n b.each { |el|\n if (f && el < 0 || !f && el > 0)\n puts \"NO\"\n return\n end\n }\n\n puts \"YES\"\n \nend\n\n\nl = gets.chomp.to_i\nn = gets.chomp\na = n.split('');\nd = []\n\na.each_index{|i| d[i] = a[i].to_i}\n#puts d.first(1);\nb = d.first(l);\nc = d.last(l);\nb.each_index{|i| b[i] -= c[i]} \n\ncheck(b)\n"}, {"source_code": "l = gets.chomp.to_i\nn = gets.chomp\na = n.split('');\nd = []\n\na.each_index{|i| d[i] = a[i].to_i}\n#puts d.first(1);\nb = d.first(l);\nc = d.last(l);\nb.sort\nc.sort\n\nb.each_index{|i| b[i] -= c[i]} \n\nb.sort\nif b[0]*b[-1] <= 0 || b[0] == b[-1] then\n puts \"NO\"\nelse\n puts \"YES\"\nend\n"}, {"source_code": "l = gets.chomp.to_i\nn = gets.chomp\na = n.split('');\nd = []\n\na.each_index{|i| d[i] = a[i].to_i}\n#puts d.first(1);\nb = d.first(l);\nc = d.last(l);\nb.each_index{|i| b[i] -= c[i]}\nf = true\nif b[0] > 0 then\n f = true\nelse\n f = false\nend\n\nb.each { |el|\n if (f && el < 0 || !f && el < 0 || f == 0)\n puts \"NO\"\n return\n end\n}\n \n"}, {"source_code": "l = gets.chomp.to_i\nn = gets.chomp\na = n.split('');\nd = []\n\na.each_index{|i| d[i] = a[i].to_i}\n#puts d.first(1);\nb = d.first(l);\nc = d.last(l);\nb.sort\nc.sort\n\nb.each_index{|i| b[i] -= c[i]} \n\nb.sort\nif b[0]*b[-1] < 0 || b[0] == b[-1] then\n puts \"NO\"\nelse\n puts \"YES\"\nend\n"}, {"source_code": "l = gets.chomp.to_i\nn = gets.chomp\na = n.split('');\nd = []\n\na.each_index{|i| d[i] = a[i].to_i}\n#puts d.first(1);\nb = d.first(l);\nc = d.last(l);\nb.sort\nc.sort\n\nb.each_index{|i| b[i] -= c[i]} \n\nb.sort\nif b[0]*b[-1] < 0 then\n puts \"NO\"\nelse\n puts \"YES\"\nend\n"}, {"source_code": "def check(b)\n f = true\n if b[0] > 0 then\n f = true\n else\n f = false\n end\n b.each { |el|\n if (f && el < 0 || !f && el < 0 || f == 0)\n puts \"NO\"\n return\n end\n }\n\n puts \"YES\"\n \nend\n\n\nl = gets.chomp.to_i\nn = gets.chomp\na = n.split('');\nd = []\n\na.each_index{|i| d[i] = a[i].to_i}\n#puts d.first(1);\nb = d.first(l);\nc = d.last(l);\nb.each_index{|i| b[i] -= c[i]}\n\n\ncheck(b)\n"}, {"source_code": "def check(b)\n f = true\n if b[0] > 0 then\n f = true\n else\n f = false\n end\n b.each { |el|\n if (f && el < 0 || !f && el > 0 || el == 0)\n puts \"NO\"\n return\n end\n }\n\n puts \"YES\"\n \nend\n\n\nl = gets.chomp.to_i\nn = gets.chomp\na = n.split('');\nd = []\n\na.each_index{|i| d[i] = a[i].to_i}\n#puts d.first(1);\nb = d.first(l);\nc = d.last(l);\nb.sort\nc.sort\nb.each_index{|i| b[i] -= c[i]} \n\ncheck(b)\n"}, {"source_code": "def solve(a,b)\n a.length.times do |i|\n return false if a[i].to_i<=b[i].to_i\n end\n return true\nend\n\nn=gets.to_i\na=gets.split[0]\nx=a[0..n-1]\ny=a[n..2*n-1]\nif solve(x,y) || solve(y,x)\n puts \"YES\"\nelse\n puts \"NO\"\nend\n\n"}, {"source_code": "n = gets.to_i\ns = gets.chomp\n\nl = s[0...n].split(//).map(&:to_i)\nr = s[n...2*n].split(//).map(&:to_i)\n\nlh, rh = true, true\nfor i in 0...n do\n lh = lh && l[i] < r[i]\n rh = rh && l[i] > r[i]\nend\n\nputs(if lh || rh then \"YES\" else \"NO\" end)"}, {"source_code": "n = gets.chomp.to_i\na = gets.chomp.split(//).map!{|x| x.to_i}\nq = Array.new\nw = Array.new\nfor i in 0..n-1\n q[i] = a[i]\n w[i] = a[n+i]\nend\n\nq = q.sort\nw = w.sort\n\nif q[0] < w[0]\n t = 0\nelsif q[0] > w[0]\n t = 1\nelse\n t = 2\nend\n\nfor i in 1..n-1\n if q[i] < w[i] && t === 1\n t = 2\n break\n elsif q[i] > w[i] && t === 0\n t = 2\n break\n elsif t == 2\n break\n end\nend\n\nif t === 2\n puts \"NO\"\nelse\n puts \"YES\"\nend"}, {"source_code": "n = Integer(gets)\ninput = gets.chomp\nnum = Array.new\nfor i in 0...2*n\n num[i] = Integer(input[i])\nend\nleft = Array.new\nright = Array.new\nfor i in 0...n\n left.push(num[i])\n right.push(num[i + n])\nend\nleft = left.sort\nright = right.sort\n\ndef less(left,right)\n if left < right\n return true\n else\n return false\n end\nend\ndef more(left,right)\n if left > right\n return true\n else\n return false\n end\nend\nc = 0\nif n == 1\n if left[0] != right[0]\n c = 1\n end\nelse\n\n if left[0] > right[0]\n for i in 1...n\n if more(left[i],right[i])\n c = 1\n else\n c = 0\n end\n end\n elsif left[0] < right[0]\n for i in 1...n\n if less(left[i],right[i])\n c = 1\n else\n c = 0\n end\n end\n end\nend\nif c == 1\n puts \"YES\"\nelse \n puts \"NO\"\nend\n"}, {"source_code": "n = Integer(gets)\ninput = gets.chomp\nnum = Array.new\nfor i in 0...2*n\n\tnum[i] = Integer(input[i])\nend\nleft = Array.new\nright = Array.new\nfor i in 0...n\n\tleft.push(num[i])\n\tright.push(num[i + n])\nend\nleft = left.sort\nright = right.sort\ndef less(left,right)\n\tif left < right\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend\ndef more(left,right)\n\tif left > right\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend\nc = 0\nif left[0] > right[0]\n\tfor i in 1...n\n\t\tif more(left[i],right[i])\n\t\t\tc = 1\n\t\telse\n\t\t\tc = 0\n\t\tend\n\tend\nelsif left[0] < right[0]\n\tfor i in 1...n\n\t\tif less(left[i],right[i])\n\t\t\tc = 1\n\t\telse\n\t\t\tc = 0\n\t\tend\n\tend\nend\n\nif c == 1\n\tputs \"YES\"\nelse \n\tputs \"NO\"\nend\n"}, {"source_code": "# http://codeforces.ru/problemset/problem/160/B\n\ndef run(input = STDIN.read)\n lines = input.split(\"\\n\")\n\n n = lines[0].to_i\n ticket = lines[1].split(\"\").map(&:to_i)\n\n first = ticket.take(ticket.size / 2).sort\n second = ticket.drop(ticket.size / 2).sort\n \n if (0..n-1).all? { |i| first[i] < second[i] } or\n (0..n-1).all? { |i| first[i] > second[i] } then\n return 'YES'\n else\n return 'NO'\n end\nend\n\nbegin\n require './testing.rb'\nrescue LoadError\n run\nend\n__END__\n2\n2421\n=\nYES\n---\n2\n0135\n=\nYES\n---\n2\n3754\n=\nNO"}, {"source_code": "n = STDIN.gets.to_i\nticket = STDIN.gets.split(\"\").map(&:to_i)\n\nfirst = ticket.take(ticket.size / 2).sort\nsecond = ticket.drop(ticket.size / 2).sort\n\nif (0..n-1).all? { |i| first[i] <= second[i] } or\n (0..n-1).all? { |i| first[i] >= second[i] } then\n puts 'YES'\nelse\n puts 'NO'\nend"}, {"source_code": "n = STDIN.gets.to_i\nticket = STDIN.gets.split(\"\").map(&:to_i)\n\nfirst = ticket.take(ticket.size / 2).sort\nsecond = ticket.drop(ticket.size / 2).sort\n\nif ((0..n-1).all? { |i| first[i] < second[i] } or\n (0..n-1).all? { |i| first[i] > second[i] }) then\n puts 'YES'\nelse\n puts 'NO'\nend"}, {"source_code": "n = STDIN.gets.to_i\nticket = STDIN.gets.split(\"\").map(&:to_i)\n\nfirst = ticket.take(ticket.size / 2).sort\nsecond = ticket.drop(ticket.size / 2).sort\n\nif (0..n-1).all? { |i| first[i] < second[i] } or\n (0..n-1).all? { |i| first[i] > second[i] } then\n puts 'YES'\nelse\n puts 'NO'\nend"}, {"source_code": "n = gets.to_i\na = gets.split(\"\")\na.pop\n\nfor i in 0 ... a.size\n\ta[i] = a[i].to_i\nend\n\nb = a[0...a.size/2]\nc = a[a.size/2...a.size]\n\nb.sort!\nc.sort!\n\nans = true\nfor i in 1...a.size/2\n\tif b[0] < c[0] then\n\t\tif b[i] >= c[i] then\n\t\t\tans = false\n\t\t\tbreak\n\t\tend\n\telsif b[0] > c[0] then\n\t\tif b[i] <= c[i] then\n\t\t\tans = false\n\t\t\tbreak\n\t\tend\n\telse\n\t\tans = false\n\t\tbreak\n\tend\t\t\nend\n\nif ans then\n\tputs(\"YES\")\nelse\n\tputs(\"NO\")\nend"}, {"source_code": "input = STDIN.read.split(\"\\n\")\n\nn = input[0].to_i\nnums = input[1].split('').map(&:to_i)\n\nif nums.first > nums.last\n\tmore = true\nelsif nums.first < nums.last\n\tmore = false\nelse\n\tSTDOUT.puts \"NO\"\n\texit\nend\n\nn.times do |i|\n\n\tif more\n\t\tif nums[i] < nums[nums.length - i - 1]\n\t\t\tSTDOUT.puts \"NO\"\n\t\t\texit\n\t\tend\n\telse\n\t\tif nums[i] > nums[nums.length - i - 1]\n\t\t\tSTDOUT.puts \"NO\"\n\t\t\texit\n\t\tend\n\tend\n\n\nend\n\nSTDOUT.puts \"YES\""}, {"source_code": "input = STDIN.read.split(\"\\n\")\n\nn = input[0].to_i\nnums = input[1].split('').map(&:to_i)\n\nnum1 = nums[0..n-1].sort!\nnum2 = nums[n..-1].sort!\n\nif num1[0] > num2[0]\n\tmore = true\nelsif num1[0] < num2[0]\n\tmore = false\nelse\n\tSTDOUT.puts \"NO\"\n\texit\nend\n\nnum1.length.times do |i|\n\tif more\n\t\tif num1[i] < num2[i]\n\t\t\tSTDOUT.puts \"NO\"\n\t\t\texit\n\t\tend\n\telse\n\t\tif num1[i] > num2[i]\n\t\t\tSTDOUT.puts \"NO\"\n\t\t\texit\n\t\tend\n\tend\nend\n\nSTDOUT.puts \"YES\""}], "src_uid": "e4419bca9d605dbd63f7884377e28769"} {"source_code": "n, k = gets.strip.split.map(&:to_i)\nhsh = {}\n('a'..'z').each.with_index{|c, i| hsh[c]=i+1 }\nstr = gets.strip\nary = []\nstr.each_char{|c| ary << hsh[c]}\nary.sort!\n\ni = 0\nans=[ary[i]]\n2.upto(k).each do\n (i+1).upto(n-1).each do |j|\n if ary[j]-ary[i] > 1\n ans << ary[j]\n i = j\n break\n end\n end\nend\n\nif ans.size == k\n puts ans.inject(:+)\nelse\n puts -1\nend\n", "positive_code": [{"source_code": "#!/usr/bin/ruby\nn,k=gets.split.map &:to_i\nr=0\nt=95\ngets.chomp.bytes.sort.each{|b|\n\tif b-t>1\n\t\tt=b\n\t\tr+=b-96\n\t\tk-=1\n\t\tbreak if k==0\n\tend\n}\np k>0 ? -1 : r\n"}, {"source_code": "nk = gets.chomp.split(\" \").map(&:to_i)\nn = nk[0]\nk = nk[1]\n\nstring = gets.chomp\n\narr = string.each_char.to_a.uniq.sort\n\nif k > 26\n puts -1\n exit\nend\n\nweight = 0\ni = 0\nprevch = 'A'\n\ndef addto(char,no)\n return (char.ord+no).chr\nend\n\n\nlen = arr.length\nwhile k>0\n if i>=len\n puts -1\n exit\n end\n\n ch = arr[i]\n if ch<=addto(prevch,1)\n i+=1\n next\n end\n\n #p ch\n weight += ch.ord-'a'.ord+1\n k-=1\n i+=1\n prevch = ch\nend\n\nputs weight"}, {"source_code": "N, k = gets.split.map(&:to_i)\nS = gets.chomp.split('').map{|c| c.ord - 'a'.ord + 1}.sort\nsum = 0\nprev = -1\nN.times do |i|\n if prev + 2 <= S[i]\n prev = S[i]\n sum += S[i]\n k -= 1\n break if k == 0\n end\nend\nputs k == 0 ? sum : -1"}, {"source_code": "a, b = gets.chomp.split.map &:to_i\ns = gets.chomp.chars.map{|x|x.ord-'a'.ord+1}.sort\nres = []\ni = 0\n\nwhile i < a && res.size != b\n if res.size < 1\n res << s[i]\n elsif (res[-1] - s[i]).abs > 1\n res << s[i] \n end\n i += 1\nend\n\np res.size < b ? -1 : res.reduce(:+)"}], "negative_code": [{"source_code": "a, b = gets.split.map &:to_i\ns = gets.chars.map{|x|x.ord-'a'.ord+1}.sort\nres = []\ni = 0\n\nwhile i < a && res.size != b\n if res.size < 1\n res << s[i]\n elsif (res[-1] - s[i])**2 > 1\n res << s[i] \n end\n i += 1\nend\n\nif res.size == b\n puts res.reduce:+\nelse\n puts -1\n end"}, {"source_code": "a, b = gets.split.map &:to_i\ns = gets.chars.map{|x|x.ord-'a'.ord+1}.sort\nres = []\nprint s\ni = 0\n\nwhile i < a && res.size != b\n if res.size < 1\n res << s[i]\n elsif (res[-1] - s[i]).abs > 1\n res << s[i] \n end\n i += 1\nend\n\np res.size < b ? -1 : res.reduce(:+)"}, {"source_code": "a, b = gets.split.map &:to_i\ns = gets.chars.map{|x|x.ord-'a'.ord+1}.sort\nres = []\ni = 0\n\nwhile i < a && res.size != b\n if res.size < 1\n res << s[i]\n elsif (res[-1] - s[i])**2 > 1\n res << s[i] \n end\n i += 1\nend\n\nif res.size == b\n puts res.reduce:+\nelse\n puts -1\nend"}, {"source_code": "a, b = gets.split.map &:to_i\ns = gets.chars.map{|x|x.ord-'a'.ord+1}.sort\nres = []\ni = 0\n\nwhile i < a && res.size != b\n if res.size < 1\n res << s[i]\n elsif (res[-1] - s[i]).abs > 1\n res << s[i] \n end\n i += 1\nend\n\np res.size < b ? -1 : res.reduce(:+)"}], "src_uid": "56b13d313afef9dc6c6ba2758b5ea313"} {"source_code": "def f(n, a, b)\n if a > b\n f(n, b, a)\n else\n (b / n).floor + 1 - (a / n).ceil\n end\nend\n\nx, y, a, b, c, d = gets.split.map(&:to_r)\np [f(2 * x, a + b, c + d), f(2 * y, a - b, c - d)].max\n", "positive_code": [{"source_code": "def f(n, a, b)\n if a > b\n f(n, b, a)\n else\n Rational(b, n).floor + 1 - Rational(a, n).ceil\n end\nend\n\nx, y, a, b, c, d = gets.split.map(&:to_i)\np [f(2 * x, a + b, c + d), f(2 * y, a - b, c - d)].max\n"}, {"source_code": "def f(n, a, b)\n if a > b\n f(n, b, a)\n else\n (b / n).floor + 1 - (a / n).ceil\n end\nend\n\nx, y, a, b, c, d = gets.split.map(&:to_r)\np [f(2 * x, a + b, c + d), f(2 * y, a - b, c - d)].max\n"}], "negative_code": [], "src_uid": "7219d1837c83b5920992aee5a60dc0d9"} {"source_code": "p eval(gets.tr\" \",?*)/2", "positive_code": [{"source_code": "m, n = gets.strip.split(\" \").map(&:to_i)\nif m == 1 && n == 1 then\n puts 0\nelse\n count = 0\n i = 0\n while (i < n) do \n if n - i >= 2 then\n m.times {count += 1}\n i += 2\n else\n (m / 2).times {count += 1}\n i += 1\n end\n end\nend\nputs count"}, {"source_code": "n,m = gets.split.map{|r| r.to_i}\nmax = m*n\nputs max/2"}, {"source_code": "t = $stdin.readline.split\nm = t[1].to_i\nn = t[0].to_i\n\nk = 0\nimax = (n%2==0) ? n : n-1\njmax = (m%2==0) ? m : m-1\ntmax = n*m/2 - imax*jmax/2\n\nputs imax*jmax/2 + tmax\n"}, {"source_code": "n, m = gets.split.map(&:to_i)\nputs (n*m*0.5).floor\n"}, {"source_code": "n, m = gets.split(\" \").map(&:to_i)\nputs (m/2) * n + (m % 2) * (n / 2);"}, {"source_code": "input = gets.split().map { |item| item.to_i }\nif input[0] % 2 == 0\n\tputs input[0] / 2 * input[-1]\nelse puts input[0] / 2 * input[-1] + input[-1] / 2\nend"}, {"source_code": "m, n = gets.split(' ').map(&:to_i)\nprint m*n/2"}, {"source_code": "m, n = gets.split.map(&:to_i)\n\nputs m * n / 2\n"}, {"source_code": "a=gets.chomp.split(\" \")\nc=a[0].to_i*a[1].to_i\nb=(c/2)\nputs\"#{b}\""}, {"source_code": "a,b=gets.split.map{|e| e.to_i}\nputs (a*b)/2"}, {"source_code": "require 'scanf'\ninput_data = $stdin.readline\n\nm, n = input_data.scanf('%d%d')\n\n#if m == 1 && n == 1\n# res = 0\n#else\n res = (m*n)/2\n#end \n\nputs res\n"}, {"source_code": "m, n = gets.chomp.split(' ').map{|a| a.to_i}\nputs (m*n/2).floor"}, {"source_code": "p eval(gets.tr\" \",?*)/2"}, {"source_code": "def solve a,b\n\tif a==1\n\t\tb/2\n\telsif a==2\n\t\tb\n\telse\n\t\tsolve(a-1, b-1)+a/2+b/2\n\tend\nend\n\na,b=gets.split.map(&:to_i)\np solve(a,b)\n"}, {"source_code": "m, n = gets.chomp.split.map{ |x| x.to_i }\nputs m*n/2"}, {"source_code": "m, n = STDIN.read.split.map &:to_i\n\nif n.odd?\n c = m * (n - 1) / 2\n c += (m / 2.0).floor\nelse\n c = m * n / 2\nend\n\nprint c"}, {"source_code": "\nm, n = gets().split(' ').map {|p| p.to_i}\n\nif m.even?\n puts (m/2)*n\nelsif n.even?\n puts (n/2)*m\nelse\n puts (m*n-1)/2\nend\n"}, {"source_code": "m,n = gets.split.map {|x| x.to_i}\nputs (m*n)/2"}, {"source_code": "p eval(gets.tr\" \",?*)/2\n"}, {"source_code": "a = gets.chomp.split(\" \")\na[0] = a[0].to_i\na[1] = a[1].to_i\nif a[0] % 2 == 0\n\tcount = (a[0]/2) * a[1]\nelsif a[1] % 2 == 0\n\tcount = (a[1]/2) * a[0]\nelse\n\tcount = ((a[0]-1)/2) * a[1] + a[1]/2\nend\n\nputs count"}, {"source_code": "input = gets.chomp.split(\" \").map { |x| x.to_i}\nM = input[0]\nN = input[1]\n\nplaces = (0..M*N-1).to_a\nedges = {}\ntiles = 0\nfor i in places\n temp = []\n if i-1>=0\n temp.push i-1\n end\n if i+1=0\n temp.push i-N\n end\n if i+N 0\n place = places.pop\n options = edges[place]\n good = false\n for option in options\n if places.include?(option)\n places.delete option\n good = true\n break\n end\n end\n if good\n tiles += 1\n else\n break\n end\nend\nputs tiles\n\n"}, {"source_code": "arr = gets.split(\" \")\nm = arr[0].to_i\nn = arr[1].to_i\n\nresult = m * (n / 2)\nif n > 2 and n % 2 == 1\n result = result + (m / 2)\nend\n\nprint result\n"}, {"source_code": "require 'scanf'\nSTDIN.read.split(\"\\n\").each do |line|\n m, n = line.scanf(\"%d%d\")\n puts m * n / 2\nend\n"}, {"source_code": "a,b=$stdin.read.split.map(&:to_i)\nprint a*b/2"}, {"source_code": "a, b = gets.strip.split(\" \").map(&:to_i)\nputs (((a*b)/2).to_i)"}, {"source_code": "p eval(gets.tr\" \",?*)/2\n"}, {"source_code": "p eval(gets.tr\" \",?*)/2"}, {"source_code": "#puts \"Enter the dimensions of rectangle\\n\"\nm,n = gets.split.map(&:to_i)\nif m == n \n a = (m*n)/2\n puts a\nelse\n b = (m*n)/2\n r = n/2\n s = r*m\n d = m/2\n v = d*n\n if s>=v\n if s >= b\n puts s\n else\n puts b\n end\n else\n if v >= b\n puts v\n else\n puts b\n end\n end\nend\n\n"}, {"source_code": "a,b = gets.split.map(&:to_i)\nputs a * b / 2\n"}, {"source_code": "p eval(gets.tr\" \",?*)/2"}, {"source_code": "input_N = gets.chomp.split()\nprint (input_N.at(0).to_i * input_N.at(1).to_i)/2\nprint \"\\n\"\n"}, {"source_code": "input = gets.chomp.split(' ')\nx = input.first.to_i * input.last.to_i\nif x%2==1\n\tx -= 1\nend\nputs x/2\n"}, {"source_code": "dim = gets.chomp().split(\" \").map(&:to_i)\ntiles = dim[0] * dim[1]\n\nputs (tiles - (tiles % 2)) / 2"}, {"source_code": "a=gets.chomp.split(\" \")\nc=a[0].to_i*a[1].to_i\nb=(c/2)\nputs\"#{b}\"\n"}, {"source_code": "m, n = STDIN.gets.split.map(&:to_i)\nputs m*n/2"}, {"source_code": "(n, m) = gets.split(/\\s/).map &:to_i\nputs n * m / 2\n"}, {"source_code": "m, n = gets.split.map(&:to_i)\nc = (m*n)/2\n\nputs c"}, {"source_code": "n,m=gets.split().map{|s|s.to_i}\nputs n*m/2"}, {"source_code": "n, m = gets.split(' ').map(&:to_i)\n\nputs n*(m/2) + (m%2)*(n/2)\n"}, {"source_code": "s = gets.split(\" \")\nn = s[0].to_i\nm = s[1].to_i\nrez1 = 0\nrez2 = 0\nif n % 2 == 1\nrez1 += m / 2;\n end\nrez1 += (n / 2) * m\nif m % 2 == 1\nrez2 += n / 2; \nend\nrez2 += (m / 2) * n\nrez = [rez1, rez2].max\nputs(rez)"}, {"source_code": "p eval(gets.tr\" \",?*)/2"}, {"source_code": "m , n = gets.split.map(&:to_i)\n\nputs (m * n) / 2"}, {"source_code": "n, m = gets.chomp.split(' ').map(&:to_i)\nputs n * m / 2\n"}, {"source_code": "p eval(gets.tr\" \",?*)/2\n"}, {"source_code": "input = gets.chomp.split(\" \")\n\nn = input[0].to_i\nm = input[1].to_i\n\nmult = n * m\n\nputs mult / 2"}, {"source_code": "\n\ndef solve(m, n)\n\n num_dominoes = 0\n p = m / 2\n\n num_dominoes = p * n\n\n q = m % 2\n\n num_dominoes += n / 2 if q == 1\n\n num_dominoes\n \n \n\nend\n\n\n\n\nm, n = gets.chomp.split.map(&:to_i)\n\nputs solve(m, n)\n"}, {"source_code": "a = STDIN.gets.split(\" \")\n\nputs \"#{a[0].to_i * a[1].to_i / 2}\"\n"}, {"source_code": "buf = gets.split(' ').map(&:to_i)\na, b = buf[0], buf[1]\nputs a * b / 2\n"}, {"source_code": "in_m, in_n = STDIN.gets.split(\" \")\nm = Integer(in_m)\nn = Integer(in_n)\nvolume = m*n\np volume/2"}, {"source_code": "m,n = gets.split.map &:to_i\nif m.even? || n.even?\n puts m*n/2\nelse\n puts (m*n - 1)/2\nend"}, {"source_code": "gets.split.map(&:to_i).tap {|a| c = a[0] * a[1]; c-=1 unless (c % 2).zero?; print c/2}"}, {"source_code": "p eval(gets.tr\" \",?*)/2"}, {"source_code": "p eval(gets.tr\" \",?*)/2\n"}, {"source_code": "#!/usr/bin/ruby\ninput = gets.chomp\narr =input.split(' ')\nn = arr[0]\nm = arr[1]\nout = (n.to_i * m.to_i)/2\nputs \"#{out}\""}, {"source_code": "a,b=gets.split.map(&:to_i)\nputs ((a*b)%2==0)?(a*b)>>1:(a*b-1)>>1"}, {"source_code": "class Solver1\n def self.solve(n, m)\n if n.even? && m.even?\n return self.even_pair(n, m)\n else\n n1, n2 = 0\n n1 = n.even? ? n : n - 1\n n2 = m.even? ? m : m - 1\n even_area = n1 * n2\n even_solved = even_pair(n1, n2)\n total_area = n * m\n return even_solved + ((total_area - even_area) / 2).floor\n end\n end\n\n def self.even_pair(n, m)\n (n * m) / 2\n end\nend\nn, m = STDIN.gets.split(\" \")\nputs Solver1.solve(n.to_i, m.to_i)\n"}, {"source_code": "m, n = gets.split.map(&:to_i)\n\nputs m*n/2"}, {"source_code": "n, m = gets.split.map &:to_i; puts n * m / 2"}, {"source_code": "m,n = gets.split.map(&:to_i)\n\n### 1\nsum_a = m / 2 * n\nif m % 2 != 0\n\tsum_a = sum_a + (n / 2) \nend\n\n### 2\nsum_b = n / 2 * m\nif n % 2 != 0\n\tsum_b = sum_b + (m / 2)\nend\n\nif sum_a > sum_b\n\tputs \"#{sum_a}\"\nelse\n\tputs \"#{sum_b}\"\nend"}, {"source_code": "a,b=gets.chomp.split(' ')\na=a.to_i\nb=b.to_i\nputs a*b/2"}], "negative_code": [{"source_code": "aa = STDIN.getc.to_i\nbb = STDIN.getc.to_i\nputs aa * bb / 2"}, {"source_code": "aa = STDIN.getc.to_i\nbb = STDIN.getc.to_i\ncc = STDIN.getc.to_i\nputs aa * cc / 2"}, {"source_code": "ARGV\nputs \"#{ARGV[0].to_i * ARGV[1].to_i / 2}\""}, {"source_code": "a = gets.to_i\nb = gets.to_i\nputs a * b / 2"}, {"source_code": " input = gets.split.map(&:to_i)\n input.sort!\n input[1]-=1 if input[1] % 2 != 0\n print input[0]*input[1]/2"}, {"source_code": "gets.split.map(&:to_i).tap {|a| c = a[0] * a[1]; c-=1 unless (c % 2).zero?; print c}"}, {"source_code": "input = gets.split.map(&:to_i)\ninput.sort!\ninput[1]-=1 if input[1] % 2 != 0\nprint input[0]*input[1]"}, {"source_code": "m = gets\nn = gets\nout = (n.to_i * m.to_i)/2\nputs \"#{out}\""}, {"source_code": "m, n = gets.strip.split(\" \").map(&:to_i)\nif m == 1 && n == 1 then\n puts 0\nelse\n count = 0\n i = 0\n while (i < n) do \n if n - i - 1 >= 2 then\n m.times {count += 1}\n i += 2\n else\n (m / 2).times {count += 1}\n i += 1\n end\n end\nend\nputs count"}, {"source_code": "# ... LETS HACK THE WORLD ...\n#... KEEP CALM AND SAY LE ROI EST MORT IS HERE ...\n# ... EL-BADRY BECOME A LEGEND ...\n\nx = gets.to_i\nz = gets.to_i\na = x * z / 2\nputs a"}, {"source_code": "# ... LETS HACK THE WORLD ...\n#... KEEP CALM AND SAY LE ROI EST MORT IS HERE ...\n# ... EL-BADRY BECOME A LEGEND ...\nx = gets.to_i\nz = gets.to_i\nputs((x*z)/2)"}, {"source_code": "def solve a,b\n\tif a==1\n\t\tb/2\n\telsif a==2\n\t\tb\n\telse\n\t\tif a%2==0\n\t\t\t2*solve(a/2, b)\n\t\telse\n\t\t\tsolve(a-1, b) + solve(1, b)\n\t\tend\n\tend\nend\n\na,b=gets.split.map(&:to_i)\np solve(a,b)\n"}, {"source_code": "number = gets.chomp.to_i\nputs number/2\n"}, {"source_code": "input = gets.chomp.split(\" \").map { |x| x.to_i}\nM = input[0]\nN = input[1]\n\nplaces = (0..M*N-1).to_a\nedges = {}\ntiles = 0\nfor i in places\n temp = []\n if i-1>=0\n temp.push i-1\n end\n if i+1=0\n temp.push i-N\n end\n if i+N 0\n place = places.pop\n options = edges[place]\n good = false\n for option in options\n if places.include?(option)\n places.delete option\n good = true\n break\n end\n end\n if good\n tiles += 1\n else\n break\n end\nend\nputs edges\nputs places\nputs tiles\n\n"}, {"source_code": "eval(gets.tr\" \",?*)/2"}, {"source_code": "puts \"Enter the dimensions of rectangle\\n\"\nm,n = gets.split.map(&:to_i)\nif m == n \n a = (m*n)/2\n puts a\nelse\n b = (m*n)/2\n r = n/2\n s = r*m\n d = m/2\n v = d*n\n if s>=v\n if s >= b\n puts s\n else\n puts b\n end\n else\n if v >= b\n puts v\n else\n puts b\n end\n end\nend\n\n"}, {"source_code": "#puts \"Enter the dimensions of rectangle\\n\"\nm,n = gets.split.map(&:to_i)\nif m == n \n a = (m*n)/2\n puts a\nelse\n r = n/2;\n s = r*m;\n puts s\nend\n"}, {"source_code": "#puts \"Enter the dimensions of rectangle\\n\"\nm,n = gets.split.map(&:to_i)\nif m == n \n a = (m*n)/2\n puts a\nelse\n r = n/2\n s = r*m\n d = m/2\n v = d*n\n if s>=v\n puts s\n else\n puts v\n end\nend\n\n"}, {"source_code": "puts \"Enter the dimensions of rectangle\\n\"\nm,n = gets.split.map(&:to_i)\nif m = n\n a = (m*n)/2\n puts a\nelse\n r = n/2;\n s = r*m;\n puts s\nend\n"}, {"source_code": "\nn, m = gets.chomp.split(\" \").map(&:to_i)\n\nputs ((n * m) / 2) * 2"}, {"source_code": "m, n = STDIN.read.split.map &:to_i\n\nif n.odd?\n c = (m * (n - 1)) / 2\n c += (m - 1) / 2\nelse\n c = m * n / 2\nend\n\nprint c"}, {"source_code": "m, n = STDIN.read.split.map &:to_i\n\nif n.odd?\n c = (m * (n - 1)) / 2\n c += (n - 1) / 2\nelse\n c = m * n / 2\nend\n\nprint c\n"}, {"source_code": "arr = gets.split(\" \")\nm = arr[0].to_i\nn = arr[1].to_i\n\nresult = m * (n / 2)\nif m > 2 and m % 2 == 1\n result = result + (n / 2)\nend\n\nprint result\n"}, {"source_code": "arr = gets.split(\" \")\nm = arr[0].to_i\nn = arr[1].to_i\n\nresult = m * (n / 2)\nif m % 2 == 1\n result = result + (n / 2)\nend\n\nprint result\n"}], "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd"} {"source_code": "def solve(idx, b)\n a = Array.new(b)\n if a[idx] == 0\n return -1\n end\n num = a[idx] / 14\n (a[idx] % 14).times do |i|\n a[(idx + i + 1) % 14] += 1\n end\n a[idx] = 0\n res = 0\n 14.times do |i|\n a[i] += num\n if a[i] % 2 == 0\n res += a[i]\n end\n end\n return res\nend\n \na = gets.split.map(&:to_i)\nans = 0\n14.times do |i|\n ans = [ans, solve(i, a)].max\nend\nputs ans", "positive_code": [{"source_code": "a=gets.split.collect{|s|s.to_i}\n m=0\nfor i in 0..13\n b=a.collect{|s|s}\n k=b[i]\n b[i]=0\n kd=k/14\n km=k%14\n res=0\n for j in 1..14\n b[(i+j)%14]+=((j<=km) ? kd+1:kd)\n end\n for j in 0..13\n if(b[j]%2==0)\n res+=b[j]\n end\n end\n if res>m\n m=res\n end\nend\nputs m"}], "negative_code": [], "src_uid": "1ac11153e35509e755ea15f1d57d156b"} {"source_code": "p gets.downcase <=> gets.downcase", "positive_code": [{"source_code": "a, b = gets.chomp.downcase, gets.chomp.downcase\n\nif a < b\n puts \"-1\"\nelsif a > b\n puts \"1\"\nelse\n puts \"0\"\nend\n"}, {"source_code": "s = gets.chomp.upcase\nt = gets.chomp.upcase\np -1 if s < t\np 0 if s == t\np 1 if s > t"}, {"source_code": "n = gets.chomp.downcase\nm = gets.chomp.downcase\na = 0\n\nif n == m\n puts \"0\"\n exit\nend\n\nwhile n[a] == m[a]\n a += 1\nend\n\nif n[a] < m[a]\n puts \"-1\"\nelsif n[a] > m[a]\n puts \"1\"\nend"}, {"source_code": "#! usr/bin/env ruby\n\nstr1 = gets\nstr2 = gets\nputs str1.casecmp str2"}, {"source_code": "#! usr/bin/env ruby\n\np gets.casecmp gets\n# p gets.upcase <=> gets.upcase"}, {"source_code": "puts gets.casecmp gets"}, {"source_code": "\na,b=[1,2].map{gets.chomp.downcase}\np a==b ?0:[a,b].sort.index(a)*2-1"}, {"source_code": "str1 = gets.chomp.downcase\n\nstr2 = gets.chomp.downcase\n\nif str1 == str2\n print \"0\"\nelsif str1 < str2\n print \"-1\"\nelsif str1 > str2\n print \"1\"\nend\n"}, {"source_code": "a,b=[gets, gets].map(&:downcase)\np a<=>b"}, {"source_code": "a = gets.chomp.downcase\nb = gets.chomp.downcase\n\nif a == b\n puts 0\nelsif a < b\n puts -1\nelse\n puts 1\nend"}, {"source_code": "string1 = gets.chomp.downcase\nstring2 = gets.chomp.downcase\n\nif string1 < string2\n puts \"-1\"\nelsif string1 > string2\n puts \"1\"\nelse\n puts \"0\"\nend"}, {"source_code": "print gets.chomp.upcase <=> gets.chomp.upcase"}, {"source_code": "def order(a,b)\n if a.nil?\n return 0\n end\n if a[0] == b[0]\n order(a[1..-1], b[1..-1])\n elsif a > b\n return 1\n elsif a < b\n return -1\n end\nend\n\n\ndef call ()\n a = gets.chomp\n b = gets.chomp\n a.downcase!\n b.downcase!\n puts order(a,b)\nend\n\ncall"}, {"source_code": "a = gets.to_s\nb = gets.to_s\nif a.upcase == b.upcase \n p 0\nelse \nif a.upcase > b.upcase \n p 1\nelse\n p -1\nend \nend "}, {"source_code": "a = gets.chomp\nb = gets.chomp\n\na.downcase!\nb.downcase!\nif a == b\n\tputs 0\nelsif a > b\n\tputs 1\nelse a < b\n\tputs -1\nend\n\t\t"}, {"source_code": "string1 = gets\nstring2 = gets\n\nif string1.downcase() == string2.downcase()\n puts \"0\"\nelsif string1.downcase() > string2.downcase()\n puts \"1\"\nelse\n puts \"-1\"\nend\n"}, {"source_code": "puts gets.downcase<=>gets.downcase"}, {"source_code": "first = gets.chomp\nsecond = gets.chomp\nfirst_letters = first.split(\"\")\nsecond_letters = second.split(\"\")\nx = 1\nalphabet = ('a'..'z').to_a\n\ni = 0\ncounter = 0\nwhile counter == 0 && i < first.length.to_i\n\tif first_letters[i].downcase == second_letters[i].downcase\n\t\tcounter = 0\n\telsif first_letters[i].downcase < second_letters[i].downcase\n\t\tcounter -= 1\n\telsif first_letters[i].downcase > second_letters[i].downcase\n\t\tcounter += 1\n\tend\n\ti += 1\nend\n\nputs counter"}, {"source_code": "a = gets.chomp.downcase\nb = gets.chomp.downcase\nif(a==b)\n puts 0\nelse\n puts a < b ? -1 : 1\nend"}, {"source_code": "first_str = gets.chomp\nsecond_str = gets.chomp\nres = 0\nfor i in 0..first_str.length-1\n\tif first_str[i].downcase.ord < second_str[i].downcase.ord\n\t\tres = -1\n\t\tbreak\n\telsif first_str[i].downcase.ord > second_str[i].downcase.ord\n\t\tres = 1\n\t\tbreak\n\tend\nend\nputs res"}, {"source_code": "s = gets.strip.downcase\nt = gets.strip.downcase\nputs(s < t ? -1 : s == t ? 0 : 1)\n"}, {"source_code": "s1 = gets.chomp.downcase\ns2 = gets.chomp.downcase\n\nputs s1 <=> s2"}, {"source_code": "puts gets.upcase <=> gets.upcase\n"}, {"source_code": "def compare s,a\n\ts=s.downcase\n\ta=a.downcase\n\treturn s<=>a\nend\n\ns=gets\na=gets\np compare(s,a)\n"}, {"source_code": "def run(input = STDIN.read)\n line1, line2 = input.split(\"\\n\")\n line1.each_char.each_with_index do |char, index|\n next if char.downcase == line2[index].downcase\n\n puts char.downcase > line2[index].downcase ? \"1\" : \"-1\"\n return\n end\n puts \"0\"\nend\nrun"}, {"source_code": "s1 = gets.chomp\ns2 = gets.chomp\nif s1.capitalize==s2.capitalize\n puts \"0\"\nelsif s2.capitalize < s1.capitalize\n puts \"1\"\nelsif s2.capitalize > s1.capitalize\n puts \"-1\"\nend"}, {"source_code": "string1 = gets.chomp.to_s.upcase\nstring2 = gets.chomp.to_s.upcase\nif string1 == string2\n puts '0'\nelsif string1 < string2\n puts '-1'\nelse\n puts '1'\nend"}, {"source_code": "p gets.downcase <=> gets.downcase"}, {"source_code": "word1 = gets.chomp.downcase\nword2 = gets.chomp.downcase\n\nif word1 < word2 then \n print '-1'\nelsif word1 > word2 then\n print '1'\nelse\n print '0'\nend\n"}, {"source_code": "p gets.casecmp gets"}, {"source_code": "a = gets.strip\nb = gets.strip\na.downcase!\nb.downcase!\nputs a < b ? -1 : (a == b ? 0 : 1)"}, {"source_code": "s = gets.chomp.to_s\nt = gets.chomp.to_s\n\ns.downcase!\nt.downcase!\n\nif s>t \n puts 1\nelsif s==t\n puts 0\nelse\n puts -1\nend"}, {"source_code": "a = gets.chomp.downcase\nb = gets.chomp.downcase\n\nputs a <=> b"}, {"source_code": "a = gets.chomp\nb = gets.chomp\na.downcase!\nb.downcase!\nif a > b\n puts 1\nelsif b > a\n puts -1\nelse\n puts 0\nend"}, {"source_code": "a = gets.downcase\nb = gets.downcase\nputs (ab ? 1 : 0))\n"}, {"source_code": "s1, s2 = gets.downcase, gets.downcase\nif s1 > s2\n\tputs 1\nelsif s1 < s2\n\tputs -1\nelsif s1 == s2\n\tputs 0\nend\n"}, {"source_code": "a = gets \nb = gets \nputs a.downcase <=> b.downcase "}, {"source_code": "#http://codeforces.com/problemset/problem/112/A\n\nstr1 = gets.chomp\nstr2 = gets.chomp\n\nputs str1.downcase <=> str2.downcase\n"}, {"source_code": "a = gets.downcase\nb = gets.downcase\nif a == b\n\tputs \"0\"\nelse\n\tputs a > b ? 1 : -1\nend\n"}, {"source_code": "puts gets.to_s.downcase <=> gets.to_s.downcase"}, {"source_code": "str1 = gets.chomp.capitalize\nstr2 = gets.chomp.capitalize\nputs str1 <=> str2"}, {"source_code": "s1 = gets\ns2 = gets\n\ns1 = s1.downcase\ns2 = s2.downcase\n\nif s1 > s2\n puts 1\nelsif s1 == s2\n puts 0\nelse\n puts -1\nend"}, {"source_code": "a=gets.chomp.downcase\nb=gets.chomp.downcase\nres=0\nif a==b\nputs \"#{res}\"\nelse\n0.upto(a.length-1) do |i|\nif a[i]!=b[i]\n\tif a[i].ord>b[i].ord\n\tres = 1\n\telse \n\tres= -1\n\tend\nbreak\nend\nend\nputs \"#{res}\"\t\nend\n\n"}, {"source_code": "x = gets.chomp.downcase\ny = gets.chomp.downcase\n\nif x==y \n\tputs 0\nelsif x > y \n\tputs 1\nelse\n\tputs -1\nend"}, {"source_code": "s1 = gets.chomp\ns2 = gets.chomp\n\nputs s1.casecmp s2\n"}, {"source_code": "s1=gets.chomp.downcase.split(\"\")\ns2=gets.chomp.downcase.split(\"\")\nn=s1.length\ni,f = 0,1\nuntil n==0\n if s1[i].ords2[i].ord\n puts 1\n f=0\n break\n end\n n -= 1\n i += 1\nend\nputs 0 if f==1\n"}, {"source_code": "l1 = gets.chomp.downcase\nl2 = gets.chomp.downcase\n\nputs l1 <=> l2\n"}, {"source_code": "first = gets.chomp\nsecond = gets.chomp\n\nputs first.downcase <=> second.downcase"}, {"source_code": "#! ruby -Ku\n# -*- coding: UTF-8 -*-\nbegin\n inputs = open(\"input.txt\")\nrescue\n inputs = STDIN\nend\n\nfirst = inputs.gets.downcase.chomp.split(//)\nsecond = inputs.gets.downcase.chomp.split(//)\n\norder = 0\n\nfirst.each_with_index do |ch, i|\n if ch < second[i]\n order = -1\n break\n elsif ch > second[i]\n order = 1\n break\n end\nend\n\nputs order\n"}, {"source_code": "a, b = gets.downcase, gets.downcase\nputs a == b ? 0 : (a < b ? -1 : 1)\n"}, {"source_code": "a=gets.chomp.upcase\nb=gets.chomp.upcase\np a<=>b"}, {"source_code": "m = gets.chomp\nn = gets.chomp\nputs m.downcase >= n.downcase ? m.downcase == n.downcase ? 0 : 1 : -1\n"}, {"source_code": "a,b=[gets, gets].map(&:downcase)\np a<=>b\n\n"}, {"source_code": "p gets.upcase<=>gets.upcase\n"}, {"source_code": "puts gets.capitalize <=> gets.capitalize"}, {"source_code": "#!/usr/bin/env ruby\na = gets.capitalize\nb = gets.capitalize\nputs a <=> b"}, {"source_code": "s1 = gets.chomp\ns2 = gets.chomp\n\nif s1.size < s2.size\n p -1\nelsif s2.size < s1.size\n p 1\nelse\n s1 = s1.downcase\n s2 = s2.downcase\n len = s1.size - 1\n\n for i in 0..len\n if s1[i] < s2[i]\n p -1\n break\n elsif s2[i] < s1[i]\n p 1\n break\n elsif i != len\n next\n else\n p 0\n end\n end\nend"}, {"source_code": "first_word, second_word = STDIN.read.split\nputs first_word.downcase <=> second_word.downcase\n"}, {"source_code": "a = gets.chomp.split.map(&:downcase).join\nb = gets.chomp.split.map(&:downcase).join\nputs (a == b) ? 0 : a>b ? 1 : -1"}, {"source_code": "a = gets.chomp.downcase\nb = gets.chomp.downcase\nif a > b\n\tputs \"1\"\nelsif a < b\n\tputs \"-1\"\nelse\n\tputs \"0\"\nend"}, {"source_code": "s1 = gets.chomp.downcase\ns2 = gets.chomp.downcase\n\nputs s1 <=> s2"}, {"source_code": "a = gets.chomp.downcase\nb = gets.chomp.downcase\n\nn = a.length\nflag = 0\nfor i in 0..n-1 do\nif a[i] == b[i]\nnext\nelsif a[i] < b[i]\nflag = 1\nputs \"-1\"\nbreak\nelse\nflag = 1\nputs \"1\"\nbreak\nend\nend\nputs \"0\" unless flag == 1"}, {"source_code": "s0 = gets.chomp.downcase\ns1 = gets.chomp.downcase\n\nif s0 == s1\n puts 0\nelsif s0 < s1\n puts -1\nelse\n puts 1\nend\n"}, {"source_code": "firstSen = gets.chomp.downcase\nsecondSen = gets.chomp.downcase\n\nputs firstSen <=> secondSen"}, {"source_code": "a = $stdin.readline ; b = $stdin.readline\na.upcase! ; b.upcase!\nputs a <=> b"}, {"source_code": "a = gets.chomp.downcase\nb = gets.chomp.downcase\n\nif a < b then puts(-1) elsif a == b then puts(0) else puts(1) end"}, {"source_code": "#!/usr/local/bin/ruby -w\n\ns1 = gets.chomp.downcase\ns2 = gets.chomp.downcase\n\nif (s1>s2) \n\tputs \"#{1}\"\nelsif (s1 m[-1]\n puts \"1\"\nelse\n puts \"0\"\nend"}, {"source_code": "a=gets.chomp.upcase\nb=gets.chomp.upcase\na.size.times{|x|\nif a[x].chr>b[x].chr\nprint 1\nelsif b[x].chr>a[x].chr\nprint -1\nelsif x==a.size-1\nprint 0\nend}"}, {"source_code": "str1 = gets.chomp.downcase\n\nstr2 = gets.chomp.downcase\n\nif str1 == str2\n print \"equale\"\nelsif str1 < str2\n print \"-1\"\nelsif str1 > str2\n print \"1\"\nelsif str1 == str2\n print \"0\"\nend\n"}, {"source_code": "def order(a,b)\n if a.nil?\n return 0\n end\n if a[0] == b[0]\n order(a[1..-1], b[1..-1])\n elsif a > b\n return 1\n elsif a < b\n return -1\n end\nend\n\n\ndef call ()\n a = gets.chomp\n b = gets.chomp\n a.downcase!\n b.downcase!\n order(a,b)\nend\n\ncall"}, {"source_code": "def run(input = STDIN.read)\n line1, line2 = input.split(\"\\n\")\n line1.each_char.each_with_index do |char, index|\n puts \"-1\" && return if char.downcase != line2[index].downcase\n end\n puts \"0\" && return\nend\n\nrun"}, {"source_code": "def run(input = STDIN.read)\n line1, line2 = input.split(\"\\n\")\n line1.each_char.each_with_index do |char, index|\n return -1 if char.downcase != line2[index].downcase\n end\n return 0\nend\n\nrun"}, {"source_code": "s1=gets.chomp.downcase.split(\"\")\ns2=gets.chomp.downcase.split(\"\")\nn=s1.length\ni,f=0,1\nuntil n<0\n if s1[i].ords2[i].ord\n puts 1\n f=0\n break\n end\n n -= 1\nend\nputs 0 if f==1\n"}, {"source_code": "sum1,sum2,i,j = 0,0,0,0\ns1=gets.chomp.downcase.split(\"\").each do |x|\n sum1 += x.ord*(101-i)\n i += 1\nend\ns2=gets.chomp.downcase.split(\"\").each do |x|\n sum2 += x.ord*(101-j)\n j += 1\nend\nif sum1 < sum2\n puts -1\nelsif sum1 == sum2 \n puts 0\nelsif sum1 < sum2\n puts 1\nend"}, {"source_code": "sum1,sum2=0,0\ns1=gets.chomp.downcase.split('').map{|ch| ch.ord}.each {|x| sum1+=x }\ns2=gets.chomp.downcase.split('').map{|ch| ch.ord}.each {|x| sum2+=x }\nif sum1==sum2\n puts 0\nelse\n puts (sum1-sum2)/(sum1-sum2).abs\nend"}, {"source_code": "sum1,sum2,i,j = 0,0,0,0\ns1=gets.chomp.downcase.split(\"\").each do |x|\n sum1 += (x.ord-96)*(101-i)\n i += 1\nend\ns2=gets.chomp.downcase.split(\"\").each do |x|\n sum2 += (x.ord-96)*(101-j)\n j += 1\nend\nif sum1 < sum2\n puts -1\nelsif sum1 == sum2 \n puts 0\nelsif sum1 > sum2\n puts 1\nend"}, {"source_code": "sum1,sum2=0,0\ns1=gets.chomp.downcase.split('').map{|ch| ch.to_i}.each {|x| sum1+=x }\ns2=gets.chomp.downcase.split('').map{|ch| ch.to_i}.each {|x| sum2+=x }\nif sum1-sum2==0\n puts 0\nelse\n puts (sum1-sum2)/(sum1-sum2).abs\nend"}, {"source_code": "p gets <=> gets"}, {"source_code": "n=0\na=gets.downcase\nb=gets.downcase\na.length.times{|i|\nn += a[i]<=>b[i]}\nn != 0? n/=n : ()\np n\n"}, {"source_code": "ans=0\n\na=gets.downcase.sum\n\nb=gets.downcase.sum\n\nif a>b then\n\tans=1\nelsif alb then\n\tans=1\nelsif alb then\n\tans=1\nelsif lab[i]}\nn != 0? n/=n.abs : ()\np n\n"}, {"source_code": "a=gets.downcase.sum\nb=gets.downcase.sum\nputs a<=>b\n"}, {"source_code": "str1 = gets.chomp.bytes.to_a\nstr2 = gets.chomp.bytes.to_a\n\nstr1.each_with_index do |c, i|\n if c < str2[i]\n puts '-1'\n exit\n elsif c > str2[i]\n puts '1'\n exit\n end\nend\n\nputs '0'\n"}, {"source_code": "a = gets.to_s\nb = gets.to_s\nif a == b \n p 0\nelse \nif a > b \n p 1\nelse\n p -1\nend \nend "}, {"source_code": "s1 = gets.chomp\ns2 = gets.chomp\nif s1.upcase==s2.upcase\n puts 0\nend\nif s2.upcases2.upcase\n put -1\nend"}, {"source_code": "str1 = gets.chomp.to_s\nstr2 = gets.chomp.to_s\n\nputs str1 <=> str2\n"}, {"source_code": "a=gets.strip.downcase\nb=gets.strip.downcase\nputs 0 and return if a == b\ndef compare a1,a2\n\tval = (a1 != a2) ? ((a1 > a2) ? 1 : -1 ) : 0\n\treturn val\nend\nfor i in 0..a.length-1\n\tc = compare a[i].ord,b[i].ord\n\tputs c and break if c != 0\nend\n\n\n"}, {"source_code": "a=gets.strip\nb=gets.strip\nt1 = a.downcase.each_byte.to_a.inject(0){|total,num| total+num} \nt2= b.downcase.each_byte.to_a.inject(0){|total,num| total+num}\nresult = t1 == t2 ? 0 : (t1 > t2) ? 1 : -1\nputs result"}, {"source_code": "str1 = gets.chomp.downcase\nstr2 = gets.chomp.downcase\n\nif str1 == str2\n puts 0\nelse\n puts -1\nend"}, {"source_code": "str1 = gets.chomp.capitalize!\nstr2 = gets.chomp.capitalize!\nputs str1 <=> str2"}, {"source_code": "first_line = gets.chomp\nsecond_line = gets.chomp\n\nfirst_line = first_line.downcase\nsecond_line = second_line.downcase\nsum_1 = 0\nsum_2 = 0\n\t\n\n\tfirst_line.each_char.each do |value|\n\t\tsum_1 += value.ord\n\tend\n\n\tsecond_line.each_char.each do |value|\n\t\tsum_2 += value.ord\n\tend\n\tputs 0 if sum_1 == sum_2\n\tputs -1 if sum_1 < sum_2\n\tputs 1 if sum_1 > sum_2\t\n\n"}, {"source_code": "first_string = gets.strip.split('').map(&:downcase)\nsecond_string = gets.strip.split('').map(&:downcase)\n\ndef compare_strings(first_string, second_string)\n return (puts 0) if first_string == second_string\n first_string.each_with_index do |char, index|\n unless char == second_string[index]\n char > second_string[index] ? (return 1) : (return -1)\n end\n end\nend\n\ncompare_strings(first_string, second_string)\n"}, {"source_code": "first_string = gets.strip.split('').map(&:downcase)\nsecond_string = gets.strip.split('').map(&:downcase)\n\ndef compare_strings(first_string, second_string)\n return 0 if first_string == second_string\n first_string.each_with_index do |char, index|\n unless char == second_string[index]\n char > second_string[index] ? (return ()) : (return -1)\n end\n end\nend\n\nputs compare_strings(first_string, second_string)\n"}, {"source_code": "x = gets.chomp()\ny = gets.chomp()\nx = x.upcase()\ny = y.upcase()\nif x>y\n\tputs -1\nelsif x==y\n\tputs 0\nelse\n\tputs 1\nend"}, {"source_code": "a = gets.chomp.downcase\nb = gets.chomp.downcase\n\ni = a.length\ni.times do\nif a[i] == b [i]\nnext\nelsif a[i] < b [i]\nputs \"-1\"\nbreak\nelse\nputs \"1\"\nbreak\nend\nputs \"0\"\nend\n"}, {"source_code": "a = gets.chomp.downcase\nb = gets.chomp.downcase\n\ni = a.length\ni.times do\nif a[i-1] == b [i-1]\nnext\nelsif a[i-1] < b [i-1]\nputs \"-1\"\nbreak\nelse\nputs \"1\"\nbreak\nend\nputs \"0\"\nend\n"}], "src_uid": "ffeae332696a901813677bd1033cf01e"} {"source_code": "x = gets.split.map(&:to_i)\nx.sort!\nputs x[1]-x[0] + x[2]-x[1]\n", "positive_code": [{"source_code": "a, b, c = gets.split.map(&:to_i).sort\np c - a\n"}, {"source_code": "def max(a,b,c)\n if (a >= b) && (a >= c)\n return a\n end\n if (b >= a) && (b >= c)\n return b\n end\n if (c >= a) && (c >= b)\n return c\n end\nend\n\ndef min(a,b,c)\n if (a <= b) && (a <= c)\n return a\n end\n if (b <= a) && (b <= c)\n return b\n end\n if (c <= a) && (c <= b)\n return c\n end\nend\n\nline = gets\nx1 = line.split(' ')[0].to_i\nx2 = line.split(' ')[1].to_i\nx3 = line.split(' ')[2].to_i\n\nputs max(x1,x2,x3) - min(x1,x2,x3)\n"}, {"source_code": "a = gets.split(' ').map(&:to_i)\n\nputs a.max - a.min\n"}, {"source_code": "a, b, c = gets.split.map(&:to_i).sort\nputs c - a"}, {"source_code": "input = gets.chomp.split(' ').map(&:to_i)\ninput.sort!\nputs input[input.length - 1] - input[0]"}, {"source_code": "# -*- mode: ruby -*-\n# vi: set ft=ruby :\n\narr = gets.split.map{|x| x.to_i}.sort\nputs arr[-1]-arr[0]\n"}, {"source_code": "a,b=gets.split.map(&:to_i).minmax;p b-a"}, {"source_code": "x1,x2,x3 = gets.split.map(&:to_i).sort\n\nputs x3-x1"}, {"source_code": "xs = gets.split.map(&:to_i)\nputs ((1..100).map do |i|\n xs.map { |x| (x - i).abs }.inject(&:+)\nend.min)\n"}, {"source_code": "a, b, c = gets.chomp.split.map(&:to_i).sort\n\nputs (b - a) + (c - b)\n"}, {"source_code": "a = gets.split.map(&:to_i)\nputs a.max - a.min\n"}, {"source_code": "a = gets.split.map(&:to_i)\na.sort!\nputs a[1] - a[0] + a[2] - a[1]\n"}, {"source_code": "debug = FALSE#TRUE\nfin = (if debug then File.open \"tc.txt\" else $stdin end)\n\n\ninput = fin.read.chomp.split /\\s/\na = []\ninput.each do |x|\n\ta << x.to_i\nend\na.sort!\n\n#a.each do |x| print x.to_s + \" \" end\n\nmeet = a[0]\nres = 1000000\nbegin\n\tsum = ((a[0]-meet).abs) + ((a[1]-meet).abs) + ((a[2]-meet).abs)\n\tres = sum if sum a[2]\n\nprint res\nfin.close"}, {"source_code": "a, b, c = gets.split.map(&:to_i).sort\n\nputs (a-b).abs + (b-c).abs"}, {"source_code": "x, y, z = gets.strip.split.map(&:to_i)\na = [x, y, z].min\nb = [x, y, z].max\nans = b - a\nputs ans\n"}, {"source_code": "a=gets.split.map{|e| e.to_i}.sort\nt1=(a[2]-a[0])+(a[1]-a[0])\nt2=(a[2]-a[1])+(a[1]-a[0])\nt3=(a[2]-a[0])+(a[2]-a[1])\nputs [t1,t2,t3].min"}, {"source_code": "a, b = gets.split.map(&:to_i).minmax\nputs b - a\n"}, {"source_code": "a = gets.split.map(&:to_i).sort!\nputs a[1] - a[0] + a[2] - a[1]\n"}, {"source_code": "res=0\ngets.split.map(&:to_i).sort.each_cons(2){|a, b| res+=b-a}\nputs res"}, {"source_code": "while str = STDIN.gets\n array = str.split(' ').map{|_| _.to_i}\n min = 999\n for i in 1..(array.max)\n total = (i - array[0]).abs + (i - array[1]).abs + (i - array[2]).abs\n min = total if min > total\n end\n puts min\nend\n"}, {"source_code": "input = gets.split(\" \").map! { |i| i.to_i }\n\nmax = input.sort[input.size-1]\nmin_d = 300\n\nfor p in 1..max\n\tcDist = (p - input[0]).abs + (p - input[1]).abs + (p - input[2]).abs\n\tif cDist < min_d\n\t\tmin_d = cDist\n\tend\nend\n\nputs min_d"}, {"source_code": "xs = gets.chomp.split.map(&:to_i)\n\nputs xs.max - xs.min\n"}, {"source_code": "d = gets.chomp\ndistances = d.split\n\nfor i in (0..distances.size-1)\n\tfor x in (0..distances.size-1)\n\t\tif i != x\n\t\t\tif distances[i].to_i < distances[x].to_i\n\t\t\t\ttemp = distances[x].to_i\n\t\t\t\tdistances[x] = distances[i].to_i\n\t\t\t\tdistances[i] = temp\n\t\t\tend\n\t\tend\n\tend\nend\n\ndistance = 0\nfor i in (0..distances.size-1)\n\tif i != distances.size-1\n\t\tif distances[i].to_i <= distances[i+1]\n\t\t\tdistance += (distances[i+1].to_i - distances[i].to_i)\n\t\telse\n\t\t\tdistance += (distances[i].to_i - distances[i+1].to_i)\n\t\tend\n\tend\nend\n\nprint distance"}, {"source_code": "a,b,c=gets.split.map(&:to_i).sort\np c-a"}], "negative_code": [{"source_code": "a, b, c = gets.split.map(&:to_i)\ns = a + b + c\nif s % 3 == 0\n g = s / 3\n p (a - g).abs + (b - g).abs + (c - g).abs\nelse\n t1 = (s / 3.0).ceil\n t2 = s / 3\n p [(a - t1).abs + (b - t1).abs + (c - t1).abs, (a - t2).abs + (b - t2).abs + (c - t2).abs].min\nend\n"}, {"source_code": "a, b, c = gets.split.map(&:to_i)\ng = (a + b + c) / 3\np (a - g).abs + (b - g).abs + (c - g).abs\n"}, {"source_code": "input = gets.chomp.split(' ').map(&:to_i)\n\nsum = input.reduce(:+)\nsum /= 3\nans = 0\n\ninput.each do |i|\n\tans += (sum - i).abs\nend\n\nputs ans"}, {"source_code": "a = gets.split.map(&:to_i)\na.sort!\nx = (a.first + a.last) / 2\nputs x - a.first + [ a[1] - x, x - a[1] ].max + a.last - x\n"}, {"source_code": "while str = STDIN.gets\n array = str.split(' ').map{|_| _.to_i}\n ave = array.inject(0.0){|r, i| r += i } / array.size\n puts array.map{|_| (ave - _).abs}.inject {|sum, n| sum + n}.to_i\nend\n"}, {"source_code": "while str = STDIN.gets\n array = str.split(' ').map{|_| _.to_i}\n ave = array.inject(0.0){|r, i| r += i } / array.size\n puts array.map{|_| (ave - _).abs}.inject {|sum, n| sum + n}.ceil\nend\n"}, {"source_code": "while str = STDIN.gets\n array = str.split(' ').map{|_| _.to_i}\n ave = array.inject(0.0){|r, i| r += i } / array.size\n puts array.map{|_| (ave - _).abs}.inject {|sum, n| sum + n}.round\nend\n"}, {"source_code": "input = gets.split(\" \")\n\nmiddle_pt = 0\ninput.each do |i|\n\tmiddle_pt = middle_pt + i.to_i\nend\n\nmiddle_pt = middle_pt / input.size\n\ntotal_dist = 0\ninput.each do |i|\n\ttotal_dist = total_dist + (i.to_i - middle_pt).abs\nend\n\nputs total_dist"}, {"source_code": "input = gets.split(\" \")\ninput = input.sort\n\ntotal_dist = 0\n\nfor i in 1..input.length-1\n\ttotal_dist = total_dist + (input[i].to_i - input[i-1].to_i)\nend\n\nputs total_dist"}], "src_uid": "7bffa6e8d2d21bbb3b7f4aec109b3319"} {"source_code": "s = gets\nif s[-1] == \"\\n\"\n s = s.split(\"\\n\")[0].to_s\nend\nres = 0\nchanged = false\ni = 0\nwhile i < s.size \n if s[i] == 'V' && s[i+1] == 'K'\n i += 2\n res += 1\n next\n end\n if changed\n i += 1\n next\n end\n if s[i] == 'K' && s[i+1] == 'K' ||\n s[i] == 'V' && s[i+1] == 'V' && (s[i+2] == 'V' || s[i+2] == nil)\n res += 1\n i += 2\n changed = true\n next\n end\n i += 1\nend\n\nputs res", "positive_code": [{"source_code": "s=gets.chomp\nr=s.scan('VK').size\ns.size.times{|i|\n\ts[i]=s[i].tr('VK','KV')\n\tr=[r,s.scan('VK').size].max\n\ts[i]=s[i].tr('VK','KV')\n}\np r"}, {"source_code": "str1 = gets().chomp\nstr1_count = str1.scan(/VK/).size\nif (str1.scan(/VVV/).size >= 1) || (str1.scan(/KKK/).size >= 1) || (str1[0,2]=='KK') || (str1[-2,str1.size]=='VV')\n str1_count += 1\nend\np str1_count"}, {"source_code": "# kkk +1\n\n# kkv skip\n# kvk skip\n# vkk skip\n\n# vvk skip\n# vkv skip\n# kvv \n\n# vvv +1\n\nk_counter = 0\nv_counter = 0\nvk = 0\nv = 0\nk = 0\n\ns = gets.chomp\ns << \"V\"\ns = \"K\" << s\n(0..s.length-1).each do |x|\n if s[x] == \"V\"\n v_counter = v_counter + 1\n k_counter = 0\n v = 1 if v_counter == 3\n vk = vk + 1 if (x+1 <= (s.length-1)) && s[x+1] ==\"K\"\n else\n k_counter = k_counter + 1\n v_counter = 0\n k = 1 if k_counter == 3\n end\nend\nvk = vk + 1 if v == 1 || k == 1\nputs vk"}, {"source_code": "s = gets\nputs s.length - s.gsub('VK', ' ').sub(/KK|VV/, ' ').length"}], "negative_code": [{"source_code": "s = gets\nres = 0\nchanged = false\ni = 0\nwhile i < s.size \n if s[i] == 'V' && s[i+1] == 'K'\n i += 2\n res += 1\n next\n end\n if changed\n i += 1\n next\n end\n if s[i] == 'K' && s[i+1] == 'K' ||\n s[i] == 'V' && s[i+1] == 'V' && (s[i+2] == 'V' || s[i+2] == nil)\n res += 1\n i += 2\n changed = true\n next\n end\n i += 1\nend\n\nputs res\n"}, {"source_code": "# kkk +1\n\n# kkv skip\n# kvk skip\n# vkk skip\n\n# vvk skip\n# vkv skip\n# kvv \n\n# vvv +1\n\nk_counter = 0\nv_counter = 0\nvk = 0\nv = 0\nk = 0\n\ns = gets()\ns << \"V\"\n(0..s.length-1).each do |x|\n if s[x] == \"V\"\n v_counter = v_counter + 1\n k_counter = 0\n v = 1 if v_counter == 3\n vk = vk + 1 if (x+1 <= (s.length-1)) && s[x+1] ==\"K\"\n else\n k_counter = k_counter + 1\n v_counter = 0\n k = 1 if k_counter == 3\n end\nend\nvk = vk + 1 if v == 1 || k == 1\nputs vk"}, {"source_code": "# kkk +1\n\n# kkv skip\n# kvk skip\n# vkk skip\n\n# vvk skip\n# vkv skip\n# kvv \n\n# vvv +1\n\nk_counter = 0\nv_counter = 0\nvk = 0\nv = 0\nk = 0\n\ns = gets()\n(0..s.length-1).each do |x|\n if s[x] == \"V\"\n v_counter = v_counter + 1\n k_counter = 0\n v = 1 if v_counter == 3\n vk = vk + 1 if (x+1 <= (s.length-1)) && s[x+1] ==\"K\"\n else\n k_counter = k_counter + 1\n v_counter = 0\n k = 1 if k_counter == 3\n end\nend\nvk = vk + 1 if v == 1 || k == 1\nputs vk"}, {"source_code": "# kkk +1\n\n# kkv skip\n# kvk skip\n# vkk skip\n\n# vvk skip\n# vkv skip\n# kvv \n\n# vvv +1\n\nk_counter = 0\nv_counter = 0\nvk = 0\nv = 0\nk = 0\n\ns = gets.chomp\ns << \"V\"\n# puts s\n(0..s.length-1).each do |x|\n if s[x] == \"V\"\n v_counter = v_counter + 1\n k_counter = 0\n v = 1 if v_counter == 3\n vk = vk + 1 if (x+1 <= (s.length-1)) && s[x+1] ==\"K\"\n else\n k_counter = k_counter + 1\n v_counter = 0\n k = 1 if k_counter == 3\n end\nend\nvk = vk + 1 if v == 1 || k == 1\nputs vk"}, {"source_code": "str1 = gets().chomp\nstr1_count = str1.scan(/VK/).size\nif (str1_count != 0 && str1.scan(/VVV/||/KKK/).size > 0) || (str1[0,2]=='KK') || (str1[-2,str1.size]=='VV')\n str1_count += 1\nend\np str1_count"}, {"source_code": "str1 = gets().chomp\nstr1_count = str1.scan(/VK/).size\nif (str1_count != 0 && str1.scan(/VVV/||/KKK/).size > 0) || (str1_count == 0 && str1.scan(/VV/||/KK/).size > 0) || (str1[0,2]=='KK' || str1[0,2]=='VV')\n str1_count += 1\nend\np str1_count"}, {"source_code": "str1 = gets().chomp\nstr1_count = str1.scan(/VK/).size\nif (str1_count != 0 && str1.scan(/VVV/&&/KKK/).size > 0) || (str1_count == 0 && str1.scan(/VV/&&/KK/).size > 0)\n str1_count += 1\nend\np str1_count"}, {"source_code": "str1 = gets().chomp\nstr1_count = str1.scan(/VK/).size\nif (str1_count != 0 && str1.scan(/VVV/||/KKK/).size > 0) || (str1_count == 0 && str1.scan(/VV/||/KK/).size > 0) || (str1[0,2]=='KK')\n str1_count += 1\nend\np str1_count"}, {"source_code": "str1 = gets().chomp\nstr1_count = str1.scan(/VK/).size\nif (str1.scan(/VVV/||/KKK/).size > 0) || (str1[0,2]=='KK') || (str1[-2,str1.size]=='VV')\n str1_count += 1\nend\np str1_count"}, {"source_code": "str1 = gets().chomp\nstr1_count = str1.scan(/VK/).size\nif str1.scan(/VVV/&&/KKK/).size > 0\n str1_count += 1\nend\np str1_count"}, {"source_code": "str1 = gets().chomp\nstr1_count = str1.scan(/VK/).size\nif (str1_count != 0 && str1.scan(/VVV/||/KKK/).size > 0) || (str1_count == 0 && str1.scan(/VV/||/KK/).size > 0)\n str1_count += 1\nend\np str1_count"}, {"source_code": "s = gets\nx = s.gsub('VK', '').length\nx -= 2 if x > 1\nputs (s.length - x) / 2"}, {"source_code": "s = gets.strip\nt = s.gsub('VK', '')\nx = t.length\nx -= 2 if (x > 2 || x == 2 && t != 'KV')\nputs (s.length - x) / 2"}, {"source_code": "s = gets.strip\nx = s.gsub('VK', '').length\nx -= 2 if x > 1\nputs (s.length - x) / 2"}, {"source_code": "s = gets\nputs (s.length - s.gsub('VK','').sub('KV','').length) / 2"}, {"source_code": "s = gets.strip\nt = s.gsub('VK', '')\nx = t.length\nx += 2 if (x > 1 && t[0] + t[-1] != 'VK')\nputs (t.length - x) / 2"}, {"source_code": "s = gets\nt = s.gsub('VK', ' ')\nputs s.length - t.length + ((t.include? 'VV'||(t.include? 'KK')) ? 1 : 0)"}, {"source_code": "s = gets\nputs (s.length - s.gsub('VK', '').sub('VV', '').sub('KK', '').length) / 2"}, {"source_code": "s = gets.strip\nt = s.gsub('VK', '')\nx = t.length\nx -= 2 if (x > 1 && t[0] + t[-1] != 'VK')\nputs (t.length - x) / 2"}, {"source_code": "s = gets\nputs (s.length - s.gsub('VK', '').sub('V', '').sub('K', '').length) / 2"}], "src_uid": "578bae0fe6634882227ac371ebb38fc9"} {"source_code": "n = STDIN.readline.to_i\nk = ((2*n/3.0)**0.5).floor + 1\nk += 1 while (n+k)%3 != 0\nk -= 3 while 3*k**2 + k > 2*n\nputs (k+2)/3\n", "positive_code": [{"source_code": "#!/usr/bin/env ruby\n\nn = gets.to_i\n\nl, r = 0, n\nwhile l != r\n m = (l + r + 1) / 2\n need = 3 * m * (m + 1) / 2 - m\n if need <= n\n l = m\n else\n r = m - 1\n end\nend\n\nl -= 1 while l > 0 && [0, 2, 1][l % 3] != n % 3\nputs (l + 2) / 3\n"}], "negative_code": [], "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de"} {"source_code": "def check(as, bs)\n ax = [0,2,4,6].map{|i|as[i]}\n ay = [1,3,5,7].map{|i|as[i]}\n bcx = [0,2,4,6].map{|i|bs[i]}.inject(:+)/4.to_f\n bcy = [1,3,5,7].map{|i|bs[i]}.inject(:+)/4.to_f\n [bs[0,2], bs[2,2], bs[4,2], bs[6,2], [bcx,bcy]].each do |bx, by|\n if bx.between?(ax.min, ax.max) && by.between?(ay.min, ay.max)\n puts 'YES'\n exit\n end\n end\nend\n\nas = gets.split.map(&:to_i)\nbs = gets.split.map(&:to_i)\n\ncheck(as, bs)\n4.times do |i|\n as[2*i], as[2*i+1] = [as[2*i] + as[2*i+1], as[2*i] - as[2*i+1]]\n bs[2*i], bs[2*i+1] = [bs[2*i] + bs[2*i+1], bs[2*i] - bs[2*i+1]]\nend\ncheck(bs, as)\nputs 'NO'", "positive_code": [{"source_code": "a = gets.split.map {|s| s.to_i}\nb = gets.split.map {|s| s.to_i}\n\n$x1, $x2 = [a[0], a[2], a[4], a[6]].minmax\n$y1, $y2 = [a[1], a[3], a[5], a[7]].minmax\n\n$x3 = (b[0] + b[2] + b[4] + b[6]) / 4.0\n$y3 = (b[1] + b[3] + b[5] + b[7]) / 4.0\n$r = (b[0] - $x3).abs + (b[1] - $y3).abs\n\ndef a_contains x, y\n x >= $x1 and x <= $x2 and y >= $y1 and y <= $y2\nend\n\ndef b_contains x, y\n (x - $x3).abs + (y - $y3).abs <= $r\nend\n\ndef clamp x, y, z\n if y > z then y, z = z, y end\n [[x, y].max, z].min\nend\n\na.push a[0], a[1]\nputs (0..7).step(2).any? {|i|\n a_contains(b[i], b[i + 1]) ||\n b_contains(a[i], a[i + 1]) ||\n b_contains(clamp($x3, a[i], a[i + 2]), a[i + 1]) ||\n b_contains(a[i], clamp($y3, a[i + 1], a[i + 3]))\n} ? 'Yes' : 'No'\n"}, {"source_code": "a = gets.split.map {|s| s.to_i}\nb = gets.split.map {|s| s.to_i}\n \n$x1, $x2 = [a[0], a[2], a[4], a[6]].minmax\n$y1, $y2 = [a[1], a[3], a[5], a[7]].minmax\n \n$x3 = (b[0] + b[2] + b[4] + b[6]) / 4.0\n$y3 = (b[1] + b[3] + b[5] + b[7]) / 4.0\n$r = (b[0] - $x3).abs + (b[1] - $y3).abs\n \ndef a_contains x, y\n x >= $x1 and x <= $x2 and y >= $y1 and y <= $y2\nend\n \ndef b_contains x, y\n (x - $x3).abs + (y - $y3).abs <= $r\nend\n \ndef clamp x, y, z\n if y > z then y, z = z, y end\n [[x, y].max, z].min\nend\n \na.push a[0], a[1]\nputs (0..7).step(2).any? {|i|\n a_contains(b[i], b[i + 1]) ||\n b_contains(a[i], a[i + 1]) ||\n b_contains(clamp($x3, a[i], a[i + 2]), a[i + 1]) ||\n b_contains(a[i], clamp($y3, a[i + 1], a[i + 3]))\n} ? \"Yes\" : 'No'"}, {"source_code": "\na = gets.split.map {|s| s.to_i}\nb = gets.split.map {|s| s.to_i}\n \n$x1, $x2 = [a[0], a[2], a[4], a[6]].minmax\n$y1, $y2 = [a[1], a[3], a[5], a[7]].minmax\n \n$x3 = (b[0] + b[2] + b[4] + b[6]) / 4.0\n$y3 = (b[1] + b[3] + b[5] + b[7]) / 4.0\n$r = (b[0] - $x3).abs + (b[1] - $y3).abs\n \ndef a_contains x, y\n x >= $x1 and x <= $x2 and y >= $y1 and y <= $y2\nend\n \ndef b_contains x, y\n (x - $x3).abs + (y - $y3).abs <= $r\nend\n \ndef clamp x, y, z\n if y > z then y, z = z, y end\n [[x, y].max, z].min\nend\n \na.push a[0], a[1]\nputs (0..7).step(2).any? {|i|\n a_contains(b[i], b[i + 1]) ||\n b_contains(a[i], a[i + 1]) ||\n b_contains(clamp($x3, a[i], a[i + 2]), a[i + 1]) ||\n b_contains(a[i], clamp($y3, a[i + 1], a[i + 3]))\n} ? 'Yes' : 'No'"}], "negative_code": [{"source_code": "a = gets.split.map {|s| s.to_i}\nb = gets.split.map {|s| s.to_i}\n\n$x1, $x2 = [a[0], a[2], a[4], a[6]].minmax\n$y1, $y2 = [a[1], a[3], a[5], a[7]].minmax\n\n$x3 = (b[0] + b[2] + b[4] + b[6]) / 4.0\n$y3 = (b[1] + b[3] + b[5] + b[7]) / 4.0\n$r = (b[0] - $x3).abs + (b[1] - $y3).abs\n\ndef a_contains x, y\n x >= $x1 and x <= $x2 and y >= $y1 and y <= $y2\nend\n\ndef b_contains x, y\n (x - $x3).abs + (y - $y3).abs <= $r\nend\n\nputs (0..7).step(2).any? {|i|\n a_contains(b[i], b[i + 1]) || b_contains(a[i], a[i + 1])\n} ? 'Yes' : 'No'\n"}], "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a"} {"source_code": "r=0;[*$<][1].split.each_with_index{|e,i|r+=4*e.to_i*i};p r", "positive_code": [{"source_code": "n = gets.to_i\na = gets.split.map(&:to_i)\nans = 10**9\nfor i in 0..n\n ret = 0\n for j in 0..n-1\n ret += ((j-i).abs+j+i)*a[j]*2\n end\n ans = ret if ans > ret\nend\nputs ans"}], "negative_code": [{"source_code": "n,s,*v=$<.read.split.map &:to_i\np [[(v.reduce(:+)-s)/n,*v].min,-1].max"}], "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f"} {"source_code": "code = gets.chomp\ncode = (code[0] + code[2] + code[4] + code[3] + code[1])\nputs (code.to_i ** 5).to_s.chars.last(5).join\n", "positive_code": [{"source_code": "s=gets;s=[0,2,4,3,1].map{|e|s[e]}*'';printf(\"%05d\\n\",(s.to_i**5)%100000)"}, {"source_code": "s=gets;s=[0,2,4,3,1].map{|e|s[e]}*'';puts'%05d'%[s.to_i**5%100000]"}, {"source_code": "code = gets.chomp\nputs ((code[0] + code[2] + code[4] + code[3] + code[1]).to_i ** 5).to_s.chars.last(5).join\n"}], "negative_code": [{"source_code": "s=gets;s=[0,2,4,3,1].map{|e|s[e]}*'';p (s.to_i**5)%100000"}, {"source_code": "code = gets.chomp\nputs ((code[0] + code[2] + code[4] + code[3] + code[1]).to_i ** 5)%100000\n"}, {"source_code": "puts 'Enter number'\ncode = gets.chomp\nreturn unless code.length == 5\ncode = (code[0] + code[2] + code[4] + code[3] + code[1])\nputs (code.to_i ** 5).to_s.chars.last(5).join\n"}], "src_uid": "51b1c216948663fff721c28d131bf18f"} {"source_code": "h = Hash.new(0)\ngets.chomp.each_char{|c| h[c] += 1}\ngets.chomp.each_char{|c| h[c] += 1}\ngets.chomp.each_char{|c| h[c] -= 1}\nputs h.values.all?{|v|v == 0} ? \"YES\" : \"NO\"\n#p h\n", "positive_code": [{"source_code": "r = lambda { gets.strip.chars.sort }\nputs (r.call + r.call).sort == r.call ? :YES : :NO\n"}, {"source_code": "s1 = gets.chomp\ns2 = gets.chomp\ns = gets.chomp\np = s1.split(\"\") + s2.split(\"\")\ns1 = s1.delete(s)\ns2 = s2.delete(s)\nif s1.empty? && s2.empty? && p.size == s.size then\n p.size.times do |i|\n s = s.sub(p[i], \"\")\n end\n if s.empty? then\n puts \"YES\"\n else\n puts \"NO\"\n end\nelse\n puts \"NO\"\nend"}, {"source_code": "s1 = gets.chomp\ns1 += gets.chomp\ns2 = gets.chomp\nif s1.split(\"\").sort == s2.split(\"\").sort\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "a = gets.scan /\\w/ \nb = gets.scan /\\w/ \nc = gets.scan /\\w/ \n\nif (a.size+b.size) != c.size \n puts \"NO\" \nelse \n a = a + b \n if(a.sort == c.sort) \n puts \"YES\" \n else \n puts \"NO\" \n end \nend "}, {"source_code": "puts (gets+gets).chars.sort == (gets+\"\\n\").chars.sort ? :YES : :NO\n"}, {"source_code": "puts ((gets.split[0]+gets.split[0]).bytes.to_a.sort==gets.split[0].bytes.to_a.sort)?\"YES\":\"NO\" "}, {"source_code": "def read_line\n STDIN.gets.chomp\nend\n\ns1 = read_line\ns2 = read_line\ns3 = read_line\n\nif (s1+s2).each_char.sort == s3.each_char.sort \n puts \"YES\"\nelse \n puts \"NO\" \nend"}, {"source_code": "name1 = gets.chomp\nname2 = gets.chomp\nletters = gets.chomp\n\nif (name1 + name2).split(//).sort == letters.split(//).sort\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "name1 = gets.chomp\nname2 = gets.chomp\nletters = gets.chomp\n\nif (name1 + name2).split(//).sort.join == letters.split(//).sort.join\n puts \"YES\"\nelse\n puts \"NO\"\nend"}, {"source_code": "(STDIN.readline.chomp + STDIN.readline.chomp).chars.sort.join == STDIN.readline.chomp.chars.sort.join ? (puts \"YES\") : (puts \"NO\")"}, {"source_code": "a = gets.chomp\nb = gets.chomp\n\n$x = []\n\ndef addToList s\n s.chars do |i|\n $x << i\n end\nend\n\naddToList a\naddToList b\n\nc = gets.chomp\nc.chars do |i|\n d = $x.delete_at ($x.index(i) || $x.count)\n if d == nil\n puts \"NO\"\n exit\n end\nend\n\nif $x.count != 0 then puts \"NO\" else puts \"YES\" end\n\n"}, {"source_code": "#!/usr/bin/env ruby\n\na = $stdin.readline\nb = $stdin.readline\nboth = $stdin.readline\n\na1 = (a+b).split('').sort\na2 = both.split('').sort\n\na1.delete(\"\\n\")\na2.delete(\"\\n\")\n\nif a1 == a2\n\tputs \"YES\"\nelse\n\tputs \"NO\"\nend\n"}, {"source_code": "string1 = gets.chomp\nstring2 = gets.chomp\nstring3 = gets.chomp\n\nif string3.length - string2.length - string1.length != 0 then\n puts \"NO\"\nelse\n string3.split(\"\").each do |c|\n if string1.include? c then\n string1.sub!(c, '')\n elsif string2.include? c then\n string2.sub!(c, '')\n end\n end\n\n if string1.empty? and string2.empty? then\n puts \"YES\"\n else\n puts \"NO\"\n end\nend\n"}, {"source_code": "originalName = (gets.split(//)+gets.split(//)).sort\nnewName = gets.split(//).sort\noriginalName.delete_if{|element| !element.between?('A', 'Z')}\nnewName.delete_if{|element| !element.between?('A', 'Z')}\nif originalName==newName\n puts \"YES\"\nelse\n puts \"NO\"\nend"}, {"source_code": "puts (gets+gets).chars.sort==(gets+\"\\n\").chars.sort ? :YES :\"NO\""}, {"source_code": "def check_pile(sa, sb, lf)\n freq_ab = Hash.new(0)\n sa.each_char {|c| freq_ab[c] += 1}\n sb.each_char {|c| freq_ab[c] += 1}\n\n # If any of the letters counted from the words is greater or less than 0,\n # it means that there are missing chars or more than expected\n # 0< Non existent characters\n # 0< More characters than expected\n # 0> Missing characters\n lf.each_char {|c| freq_ab[c] -= 1}\n freq_ab.each_value do |v|\n if v == 0\n next\n else\n return \"NO\"\n end\n end\n \"YES\"\nend\n\nstring_a = gets.chomp\nstring_b = gets.chomp\nletters_found = gets.chomp\n\nputs check_pile(string_a, string_b, letters_found)\n"}, {"source_code": "text1 = gets.chomp\ntext2 = gets.chomp\ntext = (text1 + text2).split('').sort.join\njoke = gets.chomp.split('').sort.join\nif text == joke\n\tputs \"YES\"\nelse\n\tputs \"NO\"\nend\n\n"}, {"source_code": "puts ( (gets.chomp + gets.chomp).chars.sort.join == gets.chomp.chars.sort.join ? \"YES\" : \"NO\" )"}, {"source_code": "s1, s2, a = gets.strip, gets.strip, gets.strip\nputs (s1 + s2).split('').sort == a.split('').sort ? \"YES\" : \"NO\""}, {"source_code": "a = gets.chomp\nb = gets.chomp\nt = gets.chomp\n\nif (a+b).split('').sort == t.split('').sort\n puts \"YES\"\nelse\n puts \"NO\"\nend"}, {"source_code": "s = Array.new(3)\nfor i in 0..2\n s[i] = gets.chomp.to_s.split(//).sort\nend\n\nif (s[0] + s[1]).sort == s[2].sort\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "s = Array.new(3)\nfor i in 0..2\n s[i] = gets.chomp.to_s.split(//)\nend\n\nans = false\nif (s[0] + s[1]).sort == s[2].sort\n ans = true\nend\n\nputs ans ? \"YES\" : \"NO\""}, {"source_code": "a = $stdin.readline.scan(/./)\nb = $stdin.readline.scan(/./)\nc = $stdin.readline.scan(/./)\n\nt = a+b\n\nputs (t.sort == c.sort) ? \"YES\" : \"NO\""}, {"source_code": "can=true\na=gets.chomp\nb=gets.chomp\nc=gets.chomp\ni=0\nwhile i c.sort) == 0 ? 'YES' : 'NO'"}, {"source_code": "#!/usr/bin/ruby\n# coding: utf-8\n\nguest = $stdin.gets.chomp\nhost = $stdin.gets.chomp\npile = $stdin.gets.chomp\nif (guest + host).chars.sort == pile.chars.sort\n puts 'YES'\nelse\n puts 'NO'\nend\n"}, {"source_code": "str=gets;str<0}.size > 0\n puts \"NO\"\n else\n puts \"YES\"\n end\nend\n\n\namusing_joke"}, {"source_code": "name1 = gets.chomp\nname1 = name1.split(\"\")\nname2 = gets.chomp\nname2 = name2.split(\"\")\nletters = gets.chomp\nletters = letters.split(\"\")\n\nif name1.size + name2.size > letters.size\n\tprint \"NO\"\nelse\n\tcount = 0\n\tfor i in (0..name1.size-1)\n\t\tfor x in (0..letters.size-1)\n\t\t\tif name1[i] == letters[x]\n\t\t\t\tcount += 1\n\t\t\t\tletters.delete_at(x)\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\tend\n\tfor i in (0..name2.size-1)\n\t\tfor x in (0..letters.size-1)\n\t\t\tif name2[i] == letters[x]\n\t\t\t\tcount += 1\n\t\t\t\tletters.delete_at(x)\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\tend\n\tif count == name1.size + name2.size && letters.size == 0\n\t\tprint \"YES\"\n\telse\n\t\tprint \"NO\"\n\tend\nend\n"}, {"source_code": "n = gets.chomp\nm = gets.chomp\nl = gets.chomp\nputs (n + m).chars.sort == l.chars.sort ? 'YES' : 'NO'\n"}, {"source_code": "a = gets.chomp.chars + gets.chomp.chars\ns = gets.chomp.chars\nans = true\nif a.size != s.size\n ans = false\nelse\n a.size.times do |i|\n if s.index(a[i])\n s[s.index(a[i])] = nil\n else\n ans = false\n end\n end\nend\nputs ans ? \"YES\" : \"NO\"\n"}, {"source_code": "a = gets.chomp.chars + gets.chomp.chars\ns = gets.chomp.chars\nans = true\nif a.size != s.size\n ans = false\nelse\n a.size.times do |i|\n note = 0\n s.size.times do |j|\n if a[i] == s[j]\n s[j] = \" \"\n note = 1\n break\n end\n end\n if note != 1\n ans = false\n break\n end\n end\nend\nputs ans ? \"YES\" : \"NO\"\n"}, {"source_code": "a = gets.chomp.chars + gets.chomp.chars\nb = gets.chomp.chars\nputs a.sort == b.sort ? \"YES\" : \"NO\"\n"}, {"source_code": "a = gets.chomp.chars + gets.chomp.chars\ns = gets.chomp.chars\nans = true\nif a.size != s.size\n ans = false\nelse\n a.each do |x|\n idx = s.index(x)\n if idx\n s[idx] = nil\n else\n ans = false\n end\n end\nend\nputs ans ? \"YES\" : \"NO\"\n"}, {"source_code": "puts (gets.chomp + gets.chomp).chars.sort == gets.chomp.chars.sort ? \"YES\" : \"NO\"\n"}, {"source_code": "expected = (gets.chomp + gets.chomp).chars.sort.join\nactual = (gets.chomp).chars.sort.join\nif expected == actual\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "a=[]\n2.times do\na=a+gets.chomp.split(\"\")\nend\na.sort!\nc=gets.chomp.split(\"\")\nc.sort!\nif a==c\nputs \"YES\"\nelse \nputs \"NO\"\nend"}, {"source_code": "puts (gets+gets).chars.sort==(gets+\"\\n\").chars.sort ? :YES :\"NO\""}, {"source_code": "puts (gets.chomp.chars + gets.chomp.chars).sort == gets.chomp.chars.sort ? 'YES' : 'NO'\n"}, {"source_code": "guest = gets.chomp.split \"\"\nhost = gets.chomp.split \"\"\n\nresult = guest.inject(Hash.new(0)) { |h, v| h[v] += 1; h }\nresult = host.inject(result) { |h, v| h[v] += 1; h }\n\nanswer = gets.chomp.split \"\"\n\nfor i in answer\n result[i] -= 1\nend\n\n\na = true\n\nresult.each do |k, v|\n a &= v == 0\n\n break unless a\nend\n\nputs a ? \"YES\" : \"NO\"\n"}, {"source_code": "#!/usr/bin/env ruby\n\n$ma = {}\n$ma.default = 0\n\ngets.strip.split('').each { |c| $ma[c]+=1 }\ngets.strip.split('').each { |c| $ma[c]+=1 }\ngets.strip.split('').each { |c| $ma[c]-=1 }\n\nflag = true;\n$ma.each { |c,d|\n flag = false if d!=0\n}\n\nputs (flag ? \"YES\" : \"NO\")\n"}, {"source_code": "def g\n gets.chomp.split(\"\").sort.join\nend\nputs (g+g).split(\"\").sort.join.eql?(g)?\"YES\":\"NO\""}, {"source_code": "a,b,c=3.times.map{gets.chomp.bytes.to_a}\nputs (a+b).sort==c.sort ? \"YES\" : \"NO\""}, {"source_code": "a, b, c = STDIN.read.split(\"\\n\")\nprint (a + b).split(//).sort == c.split(//).sort ? :YES : :NO\n"}, {"source_code": "s1 = gets.chomp\ns2 = gets.chomp\ns3 = gets.chomp\nif (s1 + s2).split(//).sort.join == s3.split(//).sort.join\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "hs = Hash.new 0\ngets.chomp.split(//).map{|x| hs[x]+=1}\ngets.chomp.split(//).map{|x| hs[x]+=1}\ngets.chomp.split(//).map{|x| hs[x]-=1}\nif hs.any?{|_,v| v!=0}\n puts \"NO\"\nelse\n puts \"YES\"\nend"}, {"source_code": "\t\n\nfirst = gets.strip\nlast = gets.strip\nall = first + last\nfull = gets.strip\n\na = 'A'.ord\n\narr = Array.new(26,0)\n\nfull.split(\"\").each do |c|\n\tarr[c.ord-a] += 1\nend\n\n\nall.split(\"\").each do |i|\n\tif arr[i.ord - a] <= 0\n\t\tputs \"NO\"\n\t\texit\n\tend\n\n\tarr[i.ord - a ] -= 1\n\nend\n\nans = arr.minmax\n\nif ans[0] != 0 or ans[1] != 0\n\tputs \"NO\"\nelse\n\tputs \"YES\"\nend\n\n\n\n\n\n"}], "negative_code": [{"source_code": "h = Hash.new\nh.default = 0\n3.times do |i|\n s = gets.chop.each_char.to_a\n if i < 2\n s.each { |c| h[c] += 1 }\n else\n s.each { |c| h[c] -= 1 }\n end\nend\n\nif h.any? { |k, v| v < 0 }\n puts :NO\nelse\n puts :YES\nend\n"}, {"source_code": "a = []\n3.times do |i|\n a[i] = gets.chop.each_char.to_a.sort.uniq\nend\na[2] -= a[0] + a[1]\nif a[2].empty?\n puts :YES\nelse\n puts :NO\nend\n"}, {"source_code": "s1 = gets.chomp\ns2 = gets.chomp\ns = gets.chomp\ns = s.gsub(s1, \"\").gsub(s2, \"\")\n\nif s.empty? then\n puts \"YES\"\nelse\n puts \"NO\"\nend"}, {"source_code": "s1 = gets.chomp\ns2 = gets.chomp\ns = gets.chomp\np = s1.split(\"\") + s2.split(\"\")\ns1.delete(s)\ns2.delete(s)\nif s1.empty? && s2.empty? then\n p.size.times do |i|\n s = s.sub(p[i], \"\")\n end\n\n if s.empty? then\n puts \"YES\"\n else\n puts \"NO\"\n end\nelse\n puts \"NO\"\nend"}, {"source_code": "s1 = gets.chomp.split(\"\")\ns2 = gets.chomp.split(\"\")\ns = gets.chomp\np = s1 + s2\np.size.times do |i|\n s = s.sub(p[i], \"\")\nend\n\nif s.empty? then\n puts \"YES\"\nelse\n puts \"NO\"\nend"}, {"source_code": "s1 = gets.chomp\ns2 = gets.chomp\ns = gets.chomp\np = s1.split(\"\") + s2.split(\"\")\ns1 = s1.delete(s)\ns2 = s2.delete(s)\nif s1.empty? && s2.empty? then\n p.size.times do |i|\n s = s.sub(p[i], \"\")\n end\n\n if s.empty? then\n puts \"YES\"\n else\n puts \"NO\"\n end\nelse\n puts \"NO\"\nend"}, {"source_code": "s1 = gets.chomp\ns2 = gets.chomp\ns = gets.chomp\ns = s.gsub(s1, \"\")\ns = s.gsub(s2, \"\")\n\nif s.empty? then\n puts \"YES\"\nelse\n puts \"NO\"\nend"}, {"source_code": "def read_line\n STDIN.gets.chomp\nend\n\ns1 = read_line\ns2 = read_line\ns3 = read_line\n\nans = \"YES\"\ns3.length.times do |i|\n c = s3[i]\n ans = \"NO\" if s1.count(c) + s2.count(c) != s3.count(c)\nend\n\nputs ans\n \n\n"}, {"source_code": "name1 = gets.chomp\nname2 = gets.chomp\nletters = gets.chomp\n\nif (name1 + name2).size == letters.size\n puts \"YES\"\nelse\n puts \"NO\"\nend"}, {"source_code": "name1 = gets.chomp\nname2 = gets.chomp\nletters = gets.chomp\n\nif (name1 + name2).size == letters.size\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": " x = gets.chomp\n y = gets.chomp\n z = gets.chomp\n\n hash_x = {}\n hash_y = {}\n hash_z = {}\n\n x.each_char { |c|\n hash_x[c] = 0 if hash_x[c] == nil\n hash_x[c] += 1\n }\n\n y.each_char { |c|\n hash_y[c] = 0 if hash_y[c] == nil\n hash_y[c] += 1\n }\n\n z.each_char { |c|\n hash_z[c] = 0 if hash_z[c] == nil\n hash_z[c] += 1\n }\n\n flag = true\n hash_z.each { |k,v|\n if v != (hash_x[k] == nil ? 0 : hash_x[k]) + (hash_y[k] == nil ? 0 : hash_y[k])\n flag = false\n end\n }\n if flag\n puts \"YES\"\n else\n puts \"NO\"\n end"}, {"source_code": " x = gets.chomp\n y = gets.chomp\n z = gets.chomp\n\n hash_x = {}\n hash_z = {}\n\n x.each_char { |c|\n hash_x[c] = 0 if hash_x[c] == nil\n hash_x[c] += 1\n }\n\n y.each_char { |c|\n hash_x[c] = 0 if hash_x[c] == nil\n hash_x[c] += 1\n }\n\n z.each_char { |c|\n hash_z[c] = 0 if hash_z[c] == nil\n hash_z[c] += 1\n }\n\n flag = true\n hash_x.each { |k,v|\n if v != (hash_z[k] == nil ? 0 : hash_z[k])\n flag = false\n end\n }\n if flag\n puts \"YES\"\n else\n puts \"NO\"\n end"}, {"source_code": " x = gets.chomp\n y = gets.chomp\n z = gets.chomp\n\n hash_x = {}\n hash_z = {}\n\n x.each_char { |c|\n hash_x[c] = 0 if hash_x[c] == nil\n hash_x[c] += 1\n }\n\n y.each_char { |c|\n hash_x[c] = 0 if hash_x[c] == nil\n hash_x[c] += 1\n }\n\n z.each_char { |c|\n hash_z[c] = 0 if hash_z[c] == nil\n hash_z[c] += 1\n }\n\n flag = true\n if z.length == x.length + y.length\n hash_x.each { |k,v|\n if v != (hash_z[k] == nil ? 0 : hash_z[k])\n flag = false\n end\n }\n end\n if flag\n puts \"YES\"\n else\n puts \"NO\"\n end"}, {"source_code": "a = gets.chomp.split('')\nb = gets.chomp.split('')\nc = gets.chomp.split('')\nletters = Hash.new(0)\na.each { |e| letters[e] += 1 }\nb.each { |e| letters[e] += 1 }\nc.each { |e| letters[e] -= 1 }\nputs letters.values.count { |e| e > 0 } == 0 ? \"YES\" : \"NO\"\n"}, {"source_code": "guest = gets.chomp.split \"\"\nhost = gets.chomp.split \"\"\n\nresult = guest.inject(Hash.new(0)) { |h, v| h[v] += 1; h }\nresult = host.inject(result) { |h, v| h[v] += 1; h }\n\nanswer = gets.chomp.split \"\"\n\na = true\nfor i in answer\n result[i] -= 1\n\n a = false if result[i] < 0\nend\n\nputs a ? \"YES\" : \"NO\"\n"}], "src_uid": "b6456a39d38fabcd25267793ed94d90c"} {"source_code": "def love(s)\n\twhile \"love\" == \"love\"\n\t\ta = s.scan('a').length\n\t\tothers = s.scan(/[b-z]/).length\n\t\tif a > others then return s.length else s = s.sub(/[b-z]/, '') end\n\tend\nend\n\ns = gets.chomp\nputs(love(s))", "positive_code": [{"source_code": "s = gets.chomp\nacnt = s.count(\"a\")\nif acnt > s.length / 2 then\n\tputs s.length\nelse\n\tputs 2 * acnt - 1\nend\n\n"}, {"source_code": "s = gets\nn = s.count 'a'\nputs [s.size, 2*n].min - 1"}, {"source_code": "s = readline.chomp\nputs [s.length, 2 * s.count(\"a\") - 1].min\n"}, {"source_code": "#!usr/bin/env ruby\n\n# https://codeforces.com/problemset/problem/1146/A\n\nword = gets.chomp\nword_len = word.size\na_count = word.count('a')\n\nif word_len / 2 < a_count\n puts word_len\nelse\n puts 2 * a_count - 1\nend\n"}, {"source_code": "s = gets.chomp\np (s.length+1)/2 < s.count(\"a\") ? s.length : s.count(\"a\")*2-1"}, {"source_code": "s = gets.chomp\nac = s.count('a')\nputs [s.size, ac*2-1].min"}], "negative_code": [], "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219"} {"source_code": "n=gets.to_i\nk,s=0,0\nfor i in 1...n\n\ts=1\n\tfor j in 1...n\n\t\ts*=i\n\t\ts%=n\n\t\tif (s-1)%n==0\n\t\t\tif j==n-1\n\t\t\t\tk+=1\n\t\t\telse\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\tend\nend\nputs k", "positive_code": [{"source_code": "$a = Array.new(2001, 0)\n\ndef gcd(x, y)\n if y == 0\n return x\n end\n return gcd(y, x%y)\nend\n\ndef phi(n)\n if $a[n] == 0\n for i in 1..n\n\t if gcd(n, i) == 1\n\t $a[n] += 1\n\t end\n\tend\n end\n return $a[n]\nend\n\np = gets.to_i\nprint phi(phi(p))"}, {"source_code": "#!/usr/bin/ruby1.9\n\nanswers = {2=>1, 3=>1, 5=>2, 7=>2, 11=>4, 13=>4, 17=>8, 19=>6, 23=>10, 29=>12, 31=>8, 37=>12, 41=>16, 43=>12, 47=>22, 53=>24, 59=>28, 61=>16, 67=>20, 71=>24, 73=>24, 79=>24, 83=>40, 89=>40, 97=>32, 101=>40, 103=>32, 107=>52, 109=>36, 113=>48, 127=>36, 131=>48, 137=>64, 139=>44, 149=>72, 151=>40, 157=>48, 163=>54, 167=>82, 173=>84, 179=>88, 181=>48, 191=>72, 193=>64, 197=>84, 199=>60, 211=>48, 223=>72, 227=>112, 229=>72, 233=>112, 239=>96, 241=>64, 251=>100, 257=>128, 263=>130, 269=>132, 271=>72, 277=>88, 281=>96, 283=>92, 293=>144, 307=>96, 311=>120, 313=>96, 317=>156, 331=>80, 337=>96, 347=>172, 349=>112, 353=>160, 359=>178, 367=>120, 373=>120, 379=>108, 383=>190, 389=>192, 397=>120, 401=>160, 409=>128, 419=>180, 421=>96, 431=>168, 433=>144, 439=>144, 443=>192, 449=>192, 457=>144, 461=>176, 463=>120, 467=>232, 479=>238, 487=>162, 491=>168, 499=>164, 503=>250, 509=>252, 521=>192, 523=>168, 541=>144, 547=>144, 557=>276, 563=>280, 569=>280, 571=>144, 577=>192, 587=>292, 593=>288, 599=>264, 601=>160, 607=>200, 613=>192, 617=>240, 619=>204, 631=>144, 641=>256, 643=>212, 647=>288, 653=>324, 659=>276, 661=>160, 673=>192, 677=>312, 683=>300, 691=>176, 701=>240, 709=>232, 719=>358, 727=>220, 733=>240, 739=>240, 743=>312, 751=>200, 757=>216, 761=>288, 769=>256, 773=>384, 787=>260, 797=>396, 809=>400, 811=>216, 821=>320, 823=>272, 827=>348, 829=>264, 839=>418, 853=>280, 857=>424, 859=>240, 863=>430, 877=>288, 881=>320, 883=>252, 887=>442, 907=>300, 911=>288, 919=>288, 929=>448, 937=>288, 941=>368, 947=>420, 953=>384, 967=>264, 971=>384, 977=>480, 983=>490, 991=>240, 997=>328, 1009=>288, 1013=>440, 1019=>508, 1021=>256, 1031=>408, 1033=>336, 1039=>344, 1049=>520, 1051=>240, 1061=>416, 1063=>348, 1069=>352, 1087=>360, 1091=>432, 1093=>288, 1097=>544, 1103=>504, 1109=>552, 1117=>360, 1123=>320, 1129=>368, 1151=>440, 1153=>384, 1163=>492, 1171=>288, 1181=>464, 1187=>592, 1193=>592, 1201=>320, 1213=>400, 1217=>576, 1223=>552, 1229=>612, 1231=>320, 1237=>408, 1249=>384, 1259=>576, 1277=>560, 1279=>420, 1283=>640, 1289=>528, 1291=>336, 1297=>432, 1301=>480, 1303=>360, 1307=>652, 1319=>658, 1321=>320, 1327=>384, 1361=>512, 1367=>682, 1373=>588, 1381=>352, 1399=>464, 1409=>640, 1423=>468, 1427=>660, 1429=>384, 1433=>712, 1439=>718, 1447=>480, 1451=>560, 1453=>440, 1459=>486, 1471=>336, 1481=>576, 1483=>432, 1487=>742, 1489=>480, 1493=>744, 1499=>636, 1511=>600, 1523=>760, 1531=>384, 1543=>512, 1549=>504, 1553=>768, 1559=>720, 1567=>504, 1571=>624, 1579=>524, 1583=>672, 1597=>432, 1601=>640, 1607=>720, 1609=>528, 1613=>720, 1619=>808, 1621=>432, 1627=>540, 1637=>816, 1657=>528, 1663=>552, 1667=>672, 1669=>552, 1693=>552, 1697=>832, 1699=>564, 1709=>720, 1721=>672, 1723=>480, 1733=>864, 1741=>448, 1747=>576, 1753=>576, 1759=>584, 1777=>576, 1783=>540, 1787=>828, 1789=>592, 1801=>480, 1811=>720, 1823=>910, 1831=>480, 1847=>840, 1861=>480, 1867=>620, 1871=>640, 1873=>576, 1877=>792, 1879=>624, 1889=>928, 1901=>720, 1907=>952, 1913=>952, 1931=>768, 1933=>528, 1949=>972, 1951=>480, 1973=>896, 1979=>924, 1987=>660, 1993=>656, 1997=>996, 1999=>648}\n\nx = STDIN.readline.to_i\nputs answers[x]\n\n"}, {"source_code": "def check(i, n)\n x = i\n (n - 2).times do\n return 0 if x == 1\n x = (x * i) % n\n end\n x == 1 ? 1 : 0\nend\n\ndef run\n n = $stdin.gets.to_i\n count = 0\n for i in 1...n\n count += check(i, n)\n end\n puts count\nend\n\nrun if $0 == __FILE__\n"}, {"source_code": "x = gets.split.map{|_|_.to_i}\nans=0\nx[0].times{|id|\n i = id + 1\n r = true\n d = 1\n (x[0]-1).times{|j|\n d=(d*i)%x[0]\n if (j!=x[0]-2 && d == 1) || (j==x[0]-2 && d!=1) then\n r=false\n break\n end\n }\n ans+=1 if r\n}\nputs ans\n"}, {"source_code": "p = gets.strip.to_i\nans = 0\n(1...p).each do |x|\n found = true\n cur = 1\n (1...p).each do |y|\n cur *= x\n cur %= p\n if y == p - 1\n if cur != 1\n found = false\n break\n end\n elsif cur == 1\n found = false\n break\n end\n end\n ans += 1 if found\nend\nputs ans\n"}, {"source_code": "p=gets.to_i\nres=0\n1.upto(p-1) {|x|\n n=x;\n ok=true\n (p-2).times {\n if (n-1+p)%p==0\n ok=false\n break\n end\n n=n*x%p\n }\n ok=ok and (n*x-1)%p==0\n res+=1 if ok\n}\np res\n"}, {"source_code": "require 'prime'\n\ndef phi(n)\n d = Prime.prime_division(n)\n d.each { |r, e| n = n * (r - 1) / r }\n n\nend\n\ndef has_primitive_root?(n)\n return true if n == 1 || n == 2 || n == 4\n return false if n.to_s(2)[1..-1].chars.uniq == [?0] # power of 2 not allowed\n n /= 2 if n.even?\n (3..n).select { |r| Prime.prime?(r) && r**Math.log(r, n).to_i == n } .size > 0\nend\n\ndef number_of_primitive_roots(n)\n has_primitive_root?(n) ? phi(phi(n)) : 0\nend\n\np number_of_primitive_roots(gets.to_i)\n"}, {"source_code": "require 'prime'\n\ndef phi(n)\n d = Prime.prime_division(n)\n d.each { |r, e| n = n * (r - 1) / r }\n n\nend\n\ndef has_primitive_root?(n)\n return true if n == 1 || n == 2 || n == 4\n return false if n.to_s(2)[1..-1].chars.uniq == [?0] # power of 2 not allowed\n n /= 2 if n.even?\n (3..n).select { |r| Prime.prime?(r) && r**Math.log(r, n).to_i == n } .size > 0\nend\n\ndef primitive_roots(n)\n return [] unless has_primitive_root?(n)\n (1..n).select { |i| n.gcd(i) == 1 } .select do |g|\n pn = phi(n)\n d = Prime.prime_division(pn)\n d.none? { |r, e| g**(pn / r) % n == 1 }\n end\nend\n\np primitive_roots(gets.to_i).size\n"}, {"source_code": "# def generate_prime(n)\n# \tprimes = {}\n\n# \t(2..n).each do |a|\n# \t\tprimes[a] = true\t\n# \tend\n\n# \t(2..Math.sqrt(n)).each do |i|\n# \t\tif primes[i]\n# \t\t\tprimes[i] = true\n# \t\t\t(i**2..n).step(i).each do |j|\n# \t\t\t\tprimes[j] = false\n# \t\t\tend\n# \t\tend\n# \tend\t\n# \tprimes.select {|k,v| v == true}.keys\n# end\n# primes = generate_prime(2000)\ndef gcd(a,b)\n\tif b == 0 \n\t\treturn a\n\telse\n\t\tgcd(b,a%b)\n\tend\nend\n\nn = gets.to_i - 1\ncount = 0\n(1..n).each do |a|\n\tif gcd(a,n) == 1\n\t\tcount += 1 \n\tend\n\n\tbreak if a > n\nend\n\nputs count"}, {"source_code": "def is_root x,p\n\tn = 1;\n\tq = x;\n\t\n\twhile q%p!=1 and n= 12.0\n\nhd = 360 * h / 12\nhd += (360 / 12) * m / 60\nmd = 360 * m / 60\nprint \"#{hd} #{md}\"\n", "positive_code": [{"source_code": "h, m = gets.split(/:/).map(&:to_i)\nputs \"#{30 * (h + m / 60.0) % 360} #{6.0 * m % 360}\"\n"}, {"source_code": "input = gets.split(\":\").map {|e| e.to_f}\ninput[0]-=12 if input[0] >= 12\nangle = []\nangle[0] = input[0] * 360/12 + input[1] * 360/12/60\nangle[1] = input[1] * 360/60\n\nputs angle.join ' '\n"}, {"source_code": "time=gets.split(\":\").map(&:to_i)\n\nh=((time[0]*60+time[1])%720)*360/720.0\nm=(time[1]*360/60)\nprintf \"%.10f %.10f\\n\",h,m\n\n"}, {"source_code": "time=gets.split(\":\").map(&:to_i)\n\nh=((time[0]*60+time[1])%720)*360/720.0\nm=(time[1]*360/60)\nputs h.to_s+\" \"+m.to_s\n#printf \"%.10f %.10f\\n\",h,m\n"}, {"source_code": "#!/usr/bin/ruby\n\nhh, mm = gets.split(':').map { |e| e.to_i }\n\ny = mm * 6\nx = (hh % 12 + mm.to_f / 60) * 30\nputs \"#{x} #{y}\"\n\n"}, {"source_code": "#!/usr/bin/ruby\n#http://codeforces.ru/contest/80/problem/B\n\ngets.split(':').map(&:to_i).tap{ |a| puts \"#{(a[0] % 12 + a[1].to_f / 60) * 30} #{a[1] * 6}\"}\n\n"}, {"source_code": "hour, minute = gets.split(\":\").map(&:to_i)\nprint (hour*30)%360 + minute/2\nprint \".5\" if minute%2 != 0\nprint \" \", minute*6"}, {"source_code": "h,m=gets.split(?:).map &:to_f;print h%12*30+m/2,\" \",m*6"}, {"source_code": "include Math\n\nH, M = gets.split(':').map{|e| e.to_i}\n\nH %= 12\nh = 360 / 12 * H + 360.0 / 12 / 60 * M\nm = 360.0 / 60 * M\n\nputs \"#{h} #{m}\"\n"}, {"source_code": "array = gets.split(/:/)\n\n h = array[0].to_f\n m = array[1].to_f\n\nif h >= 12\n h -= 12\nend\n\nh = 360 / 12 * h\n\nm = 360 / 60 * m\n\nh += 15 * m / 180\n\nprint h, \" \", m.to_i, \"\\n\"\n"}, {"source_code": "#=================================\n# Better be sure than sorry. \n#=================================\n$stdin=File.open(\"./input.txt\",\"r\") if ENV[\"LOGNAME\"]==\"skydos\"\n#=================================\n\nh, m=gets.split(':').map(&:to_i)\n\nh-=12 if h>=12\n\nmins_angl = m * 6.0\nhour_angl = h * (360.0/12.0) + m * (360.0/12.0/60.0)\n\nputs \"#{hour_angl} #{mins_angl}\"\n"}, {"source_code": "require 'time'\ntime = Time.parse(gets.strip)\nhour = time.hour\nhour -= 12 if hour >= 12\nminutes = time.min\nhour_angle = 30 * hour\nhour_angle += 0.5 * minutes\nif hour_angle - hour_angle.to_i == 0\n hour_angle = hour_angle.to_i\nend\nminutes_angle = 6 * minutes\nputs \"#{hour_angle} #{minutes_angle}\"\n"}, {"source_code": "t = STDIN.readline.chomp\nhour = Integer(t[0, 2], 10)\nmin = Integer(t[3, 2], 10)\n\nhour = hour + 12 if hour < 12\nhour_d = hour - 12\n\nputs \"#{(360.0 / 12.0) * hour_d + ((360.0 / 12.0) * (1.0 / (60.0 / min)))} #{360.0 / 60.0 * min}\"\n"}, {"source_code": "h,m=gets.split(?:).map(&:to_f)\nprint h%12*30+m/2,\" \",m*6"}, {"source_code": "hour, minute = gets.strip.split(':').map{|s| s.to_i}\no2 = minute / 60.0 * 360\nhour = hour % 12\no1 = (hour / 12.0 * 360) + (1 / 12.0 * o2)\nputs \"#{o1} #{o2}\"\n"}], "negative_code": [{"source_code": "#=================================\n# Better be sure than sorry. \n#=================================\n$stdin=File.open(\"./input.txt\",\"r\") if ENV[\"LOGNAME\"]==\"skydos\"\n#=================================\n\nh, m=gets.split(':').map(&:to_i)\n\nh-=12\n\nmins_angl = m * 6.0\nhour_angl = h * (360.0/12.0) + m * (360.0/12.0/60.0)\n\nputs \"#{hour_angl} #{mins_angl}\"\n"}, {"source_code": "#=================================\n# Better be sure than sorry. \n#=================================\n$stdin=File.open(\"./input.txt\",\"r\") if ENV[\"LOGNAME\"]==\"skydos\"\n#=================================\n\nh, m=gets.split(':').map(&:to_i)\n\nif h==12 && m==0\n\tputs \"0.0 0.0\"\n\texit\nend\n\nmins_angl = m * 6.0\nhour_angl = h * (360.0/12.0) + m * (360.0/12.0/60.0)\n\nputs \"#{hour_angl} #{mins_angl}\"\n"}], "src_uid": "175dc0bdb5c9513feb49be6644d0d150"} {"source_code": "n, k = gets.split.map(&:to_i)\nd = (n / (2 * (k + 1))).to_i\nc = k * d\nputs \"#{d} #{c} #{n-d-c}\"", "positive_code": [{"source_code": "st = gets\ns = st.split[0].to_i\nk = st.split[1].to_i\nd = ( s / 2 ) / ( k + 1)\nputs \"#{d} #{d*k} #{s-d*(k+1)}\""}, {"source_code": "n,k=gets.split.map &:to_i\nm=n/2/-~k\np m,k*m,n-m*-~k"}, {"source_code": "n, k = gets.split\nn = n.to_i\nk = k.to_i\n\nd = n/(2*(k+1))\nc = d * k\n\nothers = n - (c + d)\n\nputs \"#{d} #{c} #{others}\""}], "negative_code": [{"source_code": "s = gets.to_i\nk = gets.to_i\nd = ( s / 2 ) / ( k + 1)\nputs \"#{d} #{d*k} #{s-d*(k+1)}\""}], "src_uid": "405a70c3b3f1561a9546910ab3fb5c80"} {"source_code": "s = gets\n(0...s.size-1).each do |i|\n next if s[i] =~ /[aouien]/\n if i == s.size - 1 || s[i + 1] !~ /[aouie]/\n puts 'NO'\n exit\n end\nend\nputs 'YES'\n", "positive_code": [{"source_code": "def is_consonant(c)\n c =~ /[^aeiou]/\nend\n\ndef is_bertlanese(word)\n next_must_be_vowel = false\n\n word.chars.each do |c|\n\n return false if next_must_be_vowel && is_consonant(c)\n\n next_must_be_vowel =\n c != ?a &&\n c != ?e &&\n c != ?i &&\n c != ?o &&\n c != ?u &&\n c != ?n\n end\n\n !next_must_be_vowel\nend\n\ndef solution\n word = read_string\n puts is_bertlanese(word) ? \"YES\" : \"NO\"\nend\n\n\ndef rest_int\n gets.to_i\nend\n\ndef read_ints\n gets.split.map &:to_i\nend\n\ndef read_string\n gets.chomp\nend\n\n\nsolution"}, {"source_code": "S = gets.chomp\nset1 = 'aeiou'.split('')\nset2 = set1 + ['n']\nS.length.times do |i|\n if !set2.include?(S[i]) && !set1.include?(S[i+1])\n puts 'No'\n exit\n end\nend\nputs 'Yes'"}, {"source_code": "str = gets.strip\n\nvowels = ['a','e','i','o','u']\n\nn = str.size\n\nvalid = true\n0.upto(n-2).each do |i|\n break if valid == false\n if vowels.include?(str[i])\n else\n if str[i]!='n' && vowels.include?(str[i+1]) == false\n valid = false\n end\n end\nend\n\nvalid = false if vowels.include?(str[n-1]) == false && str[n-1]!='n'\n\nputs (valid ? \"YES\" : \"NO\")"}, {"source_code": "s = gets.chomp.downcase\nputs (s =~ /[^aeioun][^aeiou]/ || s=~ /[^aeioun]$/) ? \"NO\" : \"YES\""}, {"source_code": " #!/usr/bin/ruby\n\n\ndef isvowel(x)\n if x == 'a'||x=='e'||x=='i'||x=='o'||x=='u'\n return true\n end\n\nend\nname = gets().chomp()\nflag = 0\nfor i in 0...name.length\n\n #puts(name[i])\n\n if(i == name.length-1)\n\n if(name[i] == 'n')\n flag = 0\n elsif (isvowel(name[i]))\n flag = 0\n else\n flag = 1\n break\n end\n\n\n\n elsif(!isvowel(name[i]))\n\n if(name[i] == 'n')\n flag = 0\n\n else\n if(!isvowel(name[i+1]))\n flag = 1\n break\n end\n\n end\n\n end\n\nend\n\nif(flag == 0)\n puts(\"YES\")\nelse\n puts(\"NO\")\nend"}, {"source_code": "s = gets.chomp\nn = s.size\na = [\"a\", \"i\", \"u\", \"e\", \"o\"]\ni = 0\nflag = true\nwhile i < n\n if a.include?(s[i])\n i += 1\n elsif s[i] == ?n\n i += 1\n else\n if i + 1 == n\n flag = false\n break\n else\n i += 1\n if !a.include?(s[i])\n flag = false\n break\n end\n i += 1\n end\n end\nend\nputs flag ? \"YES\" : \"NO\"\n"}], "negative_code": [{"source_code": "s = gets.chomp.downcase\nputs (s =~ /[^aeioun][^aeiou]/ || s =~ /^[aeiou]/ || s=~ /[^aeioun]$/) ? \"NO\" : \"YES\""}, {"source_code": "s = gets.chomp.downcase\nx = s =~ /[^aeioun][^aeiou]|/\nputs (x == nil || /[aeiou]/.match(s[0])) ? \"NO\" : \"YES\""}, {"source_code": "s = gets.chomp.downcase\nx = s =~ /[^aeiou]{2,} | n[aeiou] | ^[aeiou]/\nputs x ? \"NO\" : \"YES\""}, {"source_code": "s = gets.chomp.downcase\nx = s =~ /[^aeiou]{2,} | n[aeiou] | ^[aeiou]/\nputs x == nil ? \"NO\" : \"YES\""}, {"source_code": "#!/usr/bin/ruby\n\n\ndef isvowel(x)\n if x == 'a'||x=='e'||x=='i'||x=='o'||x=='u'\n return true\n end\n\nend\nname = gets().chomp()\nflag = 0\nfor i in 0...name.length\n\n #puts(name[i])\n\n if(i == name.length-1)\n\n if(name[i] == 'n')\n flag = 0\n elsif (isvowel(name[i]))\n flag = 0\n else\n flag = 1\n break\n end\n\n\n\n elsif(!isvowel(i))\n\n if(name[i] == 'n')\n flag = 0\n\n else\n if(!isvowel(name[i+1]))\n flag = 1\n break\n end\n\n end\n\n end\n\nend\n\nif(flag == 0)\n puts(\"YES\")\nelse\n puts(\"NO\")\nend"}, {"source_code": "#!/usr/bin/ruby\n\n\ndef isvowel(x)\n if x == 'a'||x=='e'||x=='i'||x=='o'||x=='u'\n return true\n end\n\nend\nname = gets().chomp()\nflag = 0\nfor i in 0...name.length\n\n #puts(name[i])\n\n if(i == name.length-1)\n\n if(name[i] == 'n')\n flag = 0\n elsif (isvowel(name[i]))\n flag = 0\n else\n flag = 1\n end\n\n\n\n elsif(!isvowel(i))\n\n if(name[i] == 'n')\n flag = 0\n\n else\n if(!isvowel(name[i+1]))\n flag = 1\n end\n\n end\n\n end\n\nend\n\nif(flag == 0)\n puts(\"YES\")\nelse\n puts(\"NO\")\nend"}], "src_uid": "a83144ba7d4906b7692456f27b0ef7d4"} {"source_code": "stoneNum = gets.chomp.to_i\nstones = gets.chomp.split('')\n\nnowIndex = 0\nresult = 0\n\nuntil stones.length - 1 == nowIndex\n\tresult += 1 if (stones[nowIndex] == stones[nowIndex + 1])\n\n\tnowIndex += 1\nend\n\nputs result", "positive_code": [{"source_code": "n = gets.to_i\ns = gets.chomp\n\nresult = 0\ni = 1\nwhile i < n do\n if s[i] == s[i-1] then\n result += 1\n end\n i += 1\nend\n\nputs result"}, {"source_code": "n = gets.chomp.to_i\n\ns = gets.chomp\nlen = s.size - 1\n\nans = 0\n\nfor i in 0..len do\n if s[i] == s[i + 1]\n ans += 1\n i += 1\n else\n i += 1\n end\nend\n \np ans"}, {"source_code": "puts gets.chomp.to_i - gets.chomp.gsub(/(.)\\1+/,'\\1').length"}, {"source_code": "p gets.to_i - gets.scan(/(.)\\1*/).size"}, {"source_code": "i = 0\nn = gets.chomp.to_i\narr = gets.chomp.scan(/((.)\\2*)/).map(&:first).each{|x| i += x.length - 1}\nputs i\n"}, {"source_code": "def all_equal(array)\n\treturn array.max == array.min \nend\nx = gets.to_i\ninstone = gets.chomp().split(\"\")\ncount =0\ni = 0 \nwhile i 1 && index + 1 != input.length\n if input[index] == input[index + 1]\n input.slice!(index + 1)\n else\n index += 1\n end\nend\n\nputs input_copy.length - input.length"}, {"source_code": "n = gets.to_i\ns = gets.chomp\n\n\ncount = 0\nsaveColor =\"Z\"\ns.chars do |color|\n if saveColor != color\n saveColor = color\n else\n count += 1\n end\nend\n\nputs count"}, {"source_code": "def solve(sc, n)\n i = 0\n stones_removed = 0\n while i < sc.size\n # Compare only if the are more than one stone present\n if sc.size > 1\n if i >= 1 && sc.size >=3\n # Comparing if it is a middle position\n if sc[i-1] == sc[i] || sc[i] == sc[i+1]\n sc.delete_at(i)\n stones_removed += 1\n else\n i += 1\n end\n else\n # Comparing if it is the starting position\n if i == 0 && sc[i] == sc[i+1]\n sc.delete_at(i)\n stones_removed += 1\n else\n # Comparing if it is the last position\n if i != 0 && sc[i-1] == sc[i]\n sc.delete_at(i)\n stones_removed += 1\n else\n i += 1\n end\n end\n end\n else\n break\n end\n end\n stones_removed\nend\nn = gets.to_i\nstones_colors = gets.chomp.split(//)\nputs solve(stones_colors, n)"}, {"source_code": "def answers ()\n useless = gets.chomp\n str = gets.chomp\n count = 0\n for i in 1...str.length\n if str[i] == str[i-1]\n count+=1\n end\n end\n print count\nend\n\nanswers"}, {"source_code": "p gets(p).scan(/(.)(?=\\1)/).size"}, {"source_code": "n = gets.to_i\ns = gets.chomp\ncount = 0\nfor i in 1...n\n if s[i] == s[i-1]\n count+=1\n end\nend \nputs count"}, {"source_code": "#!/usr/bin/ruby1.9\n\nn = STDIN.readline.to_i\nline = STDIN.readline.strip\ncount = 0\n(1..line.length-1).each do |i|\n\tcount += 1 if line[i] == line[i-1]\nend\nputs count\n\n"}, {"source_code": "n = gets.to_i\ns = gets.chomp\nc = 0\n(1...s.length).each { |i| c += 1 if s[i] == s[i - 1] }\nputs c\n"}, {"source_code": "n = gets.chomp.to_i\nstr = gets.chomp\nres = 0\ni = 0\n\n(n-1).times do\nif (str[i] == str[i+1])\n res+=1\nend\ni = i + 1\nend\n\nputs res"}, {"source_code": "gets\nstr = gets.chomp\nprev = nil\ncnt = 0\nstr.split(\"\").each do |rock|\n\tif rock == prev\n\t\tcnt += 1\n\telse\n\t\tprev = rock\n\tend\nend\nputs cnt"}, {"source_code": "n = gets.to_i\ns = gets\ni=0\nr=0\nwhile(i0 && s[i] == s[i-1] then\n\t\tr=r+1\n\tend\n\ti=i+1\nend\nputs r\n"}, {"source_code": "n=gets.chomp.to_i\ns=gets.chomp.strip.split('')\nctr=0\ni=0\nwhile i0\n b = tt.shift\n ttt << b if a != b\n a = b\nend\n\nputs n - ttt.size"}, {"source_code": "n = gets;\na = gets.chomp;\nres = 0;\nfor i in 1...a.size\n if(a[i] == a[i - 1])\n res += 1;\n end\nend\nputs res;"}, {"source_code": "n = gets.to_i\ns = gets\nc = 0\nfor i in 0...s.size - 1\n c += 1 if s[i] == s[i+1]\nend\nputs c"}, {"source_code": "def run\n n = ARGF.readline.chomp\n s = ARGF.readline.chomp\n\n if s.length == 1\n puts \"0\"\n return\n end\n\n cnt = 0\n flag = false\n while !flag and s.length >= 1\n flag = true\n (s.length - 1).times do |i|\n if s[i] == s[i + 1]\n flag = false\n s[i] = ''\n break\n end\n end\n\n cnt += 1 unless flag\n end\n\n puts cnt\nend\n\nrun if $0 == __FILE__\n"}, {"source_code": "gets\nto_remove = 0\nline = gets.chomp.scan(/R{2,}|G{2,}|B{2,}/) { |match| to_remove += match.length - 1 }\nputs to_remove\n"}, {"source_code": "gets\ns = gets\nn = 0\ns.chars.each_with_index do |c, i|\n n +=1 if c == s[i-1]\nend\nputs n"}, {"source_code": "require 'pp'\n\ngets\nstr = gets.chomp\n\ncounter = 0\nstr.scan(/(RR+|GG+|BB+)/).each do |comb| \n counter += comb[0].length - 1\nend\nputs counter\n"}, {"source_code": "n = gets.to_i\ns = gets\n\n$res = 0\nc = '.'\n\ns.split(\"\").each do |i| \n if c == i\n $res += 1\n else\n c = i\n end\nend\n\nputs $res\n"}, {"source_code": "n=Integer(gets.chomp)\ns=gets.chomp.split(\"\")\nans=0\nuntil n==0\n if s[n]==s[n-1]\n ans+=1\n end\n n-=1\nend\nputs ans"}, {"source_code": "n = gets.to_i\ns = gets.chomp\n\nans = 0\ni = 0\nj = 1\nwhile i < n && s[i+j] do\n e = s[i]\n if e == s[i+j]\n ans += 1\n j += 1\n else\n i += j\n j = 1\n end\nend\nputs ans"}, {"source_code": "n = gets.strip.to_i\ntable = gets.strip\ni = 1\ncount = 0\nwhile i < n\n count += 1 if table[i - 1] == table[i]\n i += 1\nend\nputs count\n"}, {"source_code": "a=gets.chomp.to_i\nb=gets.chomp\nres=0\n0.upto(a-2) do|i|\nif b[i]==b[i+1]\nres+=1\nend\nend\n\nputs \"#{res}\""}, {"source_code": "p gets(p).size-$_.bytes.chunk{|i|i}.to_a.size"}, {"source_code": "n = gets.to_i\ns = gets\nx = 0\nn.times do |i|\n x += 1 if s[i] == s[i + 1]\nend\nprint x\n"}, {"source_code": "$stdin = File.open(\"./input.txt\", \"r\") if ENV[\"USER\"] == \"new\"\n# ====================================\n\ngets\nstones = gets.strip.split //\n\ncount = 0\nfor i in 0...stones.count-1\n a = stones[i]\n b = stones[i+1]\n \n count+=1 if a==b\nend\n\nputs count"}, {"source_code": "n = gets.to_i\nq = gets.chomp.split(//)\n\nfor i in 0...n-1\n if q[i] == q[i+1]\n q[i] = nil\n end\nend\n\nq.keep_if { |x| x.nil?}\n\nputs q.size"}, {"source_code": "n = gets.to_i\ns = gets.chomp.split('')\n\nr = [s.pop]\n\n(n-1).times do\n t = s.pop\n if t == r[-1]\n else\n r.push(t)\n end\nend\n# puts r[0]\nputs n - r.length\n"}, {"source_code": "i = gets.chomp.to_i\nstr = gets.chomp.split(//)\nx = -1\ncount = 0\nstr.each do |c|\n if c == x\n count += 1\n end\n x = c\nend\nputs count"}, {"source_code": "n=gets.chomp\nstone=gets.chomp\na=[]\nstone.split(\"\").each do |i|\n a< 1\n\t\t\tcolors.delete_at(i+1)\n\t\tend\n\tend\nend\n\nprint stones - colors.size"}, {"source_code": "number = gets.to_i\nlist = gets.split(//)\n\nlast = nil\ncount = 0\n(number-1).times do |i|\n count += 1 if list[i]==list[i+1]\nend\n\np count\n"}, {"source_code": "n=gets.to_i\ns=gets.split('')\n\nx = 0\n\nn.times do |i|\t\t\n\tx +=1 if s[i] == s[i+1]\nend\n\nputs x\n"}, {"source_code": "n, s = gets.to_i, gets\nputs n.times.count{|i| s[i] == s[i+1]}"}, {"source_code": "#puts \"Enter the number of stones\\n\"\nn = gets.to_i\n#puts \"Enter the arrangement\\n\"\ns = gets.to_s\nkey = 0\na = n-2\nfor j in 0..a do\n if s[j] == s[j+1]\n key += 1\n end\nend\nputs key"}, {"source_code": "n = gets.chomp.to_i\nstr = gets.chomp\n\nansg = ansr = ansb = 0\n\nn.times do |i|\n if str[i] == 'R'\n ansr, ansg, ansb = [ansr + 1, ansg, ansb].min, ansg + 1, ansb + 1\n elsif str[i] == 'G'\n ansr, ansg, ansb = ansr + 1, [ansr, ansg + 1, ansb].min, ansb + 1\n else\n ansr, ansg, ansb = ansr + 1, ansg + 1, [ansr, ansg, ansb + 1].min\n end\nend\n\nputs [ansg, ansr, ansb].min\n"}, {"source_code": "n = gets.to_i\nputs gets.split(//).each_cons(2).select{|x| x[0]==x[1]}.count"}, {"source_code": "gets\nputs gets.split(//).each_cons(2).select{|x| x[0]==x[1]}.count\n"}, {"source_code": "c,n=0,gets.to_i;a=gets.split('').to_a;1.upto(n){|x|a[x]==a[x-1] ?(c+=1):(0)};puts c\n"}, {"source_code": "# http://codeforces.com/problemset/problem/266/A\n\nn = gets.chomp\nstones = gets.chomp\n\neq = 0\n\nfor i in 1..(stones.length-1)\n if stones[i] == stones[i-1]\n eq = eq + 1\n end\nend\n\np eq\n"}, {"source_code": "p gets(p).scan(/(.)(?=\\1)/).size\n"}, {"source_code": "gets\ns = gets\nc = 0\n(1...s.size).each{ |i| s[i] == s[i - 1] ? c += 1 : 0 }\nputs c"}, {"source_code": "n = gets.to_i\ncolors = gets\nresult = 0\ncolors_array = colors.split('')\ncolors_array.each_with_index do |letter, idx|\n if idx != 0\n previous_letter = colors_array[idx - 1]\n if previous_letter == letter\n result = result + 1\n end\n end\nend\nputs result\n"}, {"source_code": "n = gets.chomp.to_i\ns = gets.chomp\nans = 0\nfor i in (1...n)\n ans += (s[i] == s[i - 1]) ? 1 : 0\nend\nputs ans"}, {"source_code": "stn_num = gets.chomp.to_i\nstn_color = gets.chomp\ncnt = 0\n\nfor num in 0..stn_num do \n\n if stn_color.split(\"\")[num] == stn_color.split(\"\")[num +1] then\n cnt+=1\n end\n\nend\np cnt-1\n"}, {"source_code": "n = gets.chomp.to_i\nline = gets.chomp.split(\"\")\np = 0\n(1..(n-1)).each { |k|\n\tif line[k]==line[k-1]\n\t\tp += 1\n\tend\n}\n\nputs p"}, {"source_code": "n=gets.to_i; last=\"\"; count=0\ngets.strip.chars.to_a.each{|x| (count+=1 if(last==x)); last=x}\np count"}, {"source_code": "n = gets.to_i\ncount = 0\narray = gets.split(\"\")\nfor i in 0...n\n\tif array[i] == array[i+1]\n\t\tcount += 1\n\tend\nend\nputs count\n"}, {"source_code": "n = gets.chomp.to_i\nx= gets.chomp\naux = 0\ni = 0\na,b = \"\"\nwhile(i < n - 1)\n\ta = x[i].chr\n\tb = x[i+1].chr\n\tif(a == b)\n\t\taux = aux + 1\n\tend\n\ti = i + 1\nend\nputs aux.to_s"}, {"source_code": "n, s = gets.to_i, gets\nputs n.times.count{|i| s[i] == s[i+1]}\n"}, {"source_code": "n = gets.to_i\nword = gets\n\ntotal = 0\n\nword.chars.each_with_index do |c, i|\n\ttotal += 1 if c == word[i-1]\nend\nputs total"}, {"source_code": "a=gets.chomp.to_i\nb=gets.chomp\nres=0\n0.upto(a-2) do|i|\nif b[i]==b[i+1]\nres+=1\nend\nend\n\nputs \"#{res}\"\n\n\n"}, {"source_code": "n = gets.to_i\nq = gets.chomp\nm = []\nm = q.split(\"\")\ni = 0\nj = 0\nwhile i < n do\n if m[i] == m[i+1]\n j = j+1\n end\n i = i+1\nend\nputs j"}, {"source_code": "n=gets.to_i-1\ns=gets.chomp\nfor i in 1..s.length-1\nif s[i]!=s[i-1]\nn-=1\nend\nend\np n"}, {"source_code": "n = gets.to_i\ns = gets.strip.split(//)\nans = 0\n0.upto(n-2) do |i|\n if s[i] == s[i+1]\n ans+=1\n end\nend\nputs ans"}, {"source_code": "p gets(p).scan(/(.)(?=\\1)/).size"}, {"source_code": "n = gets.to_i\na = gets.split('')\n\nd = 0\n\n(0..n-1).each do |i| \n\tif ( a[i] == a[i+1] )\n\t\td += 1\n\tend\nend\n\nputs d"}, {"source_code": "gets.chomp\narr = gets.chomp.scan(/((\\w)\\2*)/).map(&:first)\nputs arr.map(&:size).reduce(:+) - arr.size"}, {"source_code": "#!/usr/bin/env ruby\n\nn = gets.to_i\ns = gets\ntot = 0\n0.upto(n-2) { |i| tot += 1 if s[i] == s[i+1] }\t\nputs tot\n"}, {"source_code": "n = gets.to_i\na = gets.split('')\nm = 0\n(1..n-1).each do |t|\n m += 1 if a[t] == a[t-1]\nend\nputs m"}, {"source_code": "_n = gets.chomp.to_i\nstr = gets.chomp\nprev = ''\ncount = 0\nstr.split(//).each do |chr|\n chr == prev ? count += 1 : prev = chr\nend\nputs count\n"}, {"source_code": "number = gets.strip.to_i\nsequence = gets.strip\n\nnew_string = sequence[0]\nsequence[0] = ''\n\nsequence.each_char.with_index do |char, index|\n new_string << char if new_string[-1] != char\nend\n\nputs number - new_string.length\n"}, {"source_code": "BEGIN{\n\tdef gint()\n\t\treturn gets.split.map(&:to_i)\n\tend\n\tdef main()\n\t\tn = gint\n\t\ts = gets.to_s\n\t\tsum = 0\n\t\tfor i in 0..s.length - 2 do\n\t\t\tc = s[i]\n\t\t\tif c == s[i + 1] then\n\t\t\t\tsum += 1\n\t\t\tend\n\t\tend\n\t\tputs sum\n\tend\n\tTest_case = 1\n\tTest_case.times do\n\t\tmain()\n\tend\n}\n"}, {"source_code": "n = gets.to_i\ns = gets.chomp\nd = 0\nfor i in 1 ... s.size\n if s[i] == s[i-1]\n d += 1\n end\nend\n\np d\n"}, {"source_code": "n = gets.to_i\nputs gets.split(//).each_cons(2).select{|x| x[0]==x[1]}.count"}, {"source_code": "n = gets\ns = gets\np s.length - s.squeeze.length"}, {"source_code": "n=gets.chomp.to_i\n\n\nstr=gets.chomp\ncur=0\nfor i in 1..n \n\tif str[i]==str[i-1]\n\t\tcur+=1\n\n\tend\nend\nputs(cur)\n\n"}, {"source_code": "n = gets\nprevious = ''\ncounter = 0\ngets.chomp.split('').each do |letter|\n counter += 1 if previous == letter\n previous = letter\nend\nputs counter\n"}, {"source_code": "@numBall = STDIN.gets\n@input = STDIN.gets\n@check = true\n@count = 0\ndef removeNearby\n @check = false\n str_temp = @input\n str_length = str_temp.length - 1\n while (str_length > 1)\n if(str_temp[str_length - 1] == str_temp[str_length - 2])\n @check = true\n @count += 1\n str_temp.slice!(str_length - 1)\n else\n str_length -= 1\n end\n end\n @input = str_temp\n\nend\n\nwhile (@check)\n removeNearby\nend\n\nputs @count"}], "negative_code": [{"source_code": "p gets.to_i - gets.squeeze.size"}, {"source_code": "n = gets.chomp.to_i\ns = gets.chomp.split(\"\")\nx = 0\n0.upto n-1 do |i|\n\tnext if i == 0\n\tif s[i] == s[i-1]\n\t\ts.delete_at(i-1)\n\t\tx += 1\n\tend\nend\nputs x"}, {"source_code": "puts \"Number of stones n=\"\nn = gets.to_i\nputs \"Colors of stones s=\"\ns = gets(n)\ni = 0\nstones = 0\n# идем по каждому символу в строке\nwhile i < n\n # если последующий символ в строке соответствует предыдущему\n if s[i] == s[i+1]\n stones += 1\n end\n i += 1\nend\n\nputs stones"}, {"source_code": "def solve(sc, n)\n i = 0\n stones_removed = 0\n while i < sc.size\n # Compare only if the are more than one stone present\n if sc.size > 1\n if i >= 1 && sc.size >=3\n # Comparing if it is a middle position\n if sc[i-1] == sc[i] || sc[i] == sc[i+1]\n sc.delete_at(i)\n stones_removed += 1\n else\n i += 1\n end\n else\n # Comparing if it is the starting position\n if i == 0 && sc[i] == sc[i+1]\n sc.delete_at(i)\n stones_removed += 1\n else\n # Comparing if it is the last position\n if sc[i-1] == sc[i]\n sc.delete_at(i)\n stones_removed += 1\n else\n i += 1\n end\n end\n end\n else\n break\n end\n end\n stones_removed\nend\nn = gets.to_i\nstones_colors = gets.chomp.split(//)\nputs solve(stones_colors, n)"}, {"source_code": "n = gets.to_i\na = Array.new(n)\n\nfor i in 0..n-1\n a[i] = gets.to_s\nend\n\ncounter = 0\nfor i in 0..n-1 \n if a[i] == a[i+1]\n counter+=1\n end\nend\np counter"}, {"source_code": "n = gets.to_i\na = Array.new(n)\n\nfor i in 0..n-1\n a[i] = gets.to_s\nend\n\ncounter = 0\nfor i in 0..n-1 \n if a[i] == a[i+1]\n counter+=1\n end\nend\nputs counter"}, {"source_code": "n = gets.to_i\ns = gets.chomp.split(//)\n\ncounter = 0\nfor i in 0..s.length-1\n if s[i] != s[i+1]\n counter+=1\n end\nend\nputs counter"}, {"source_code": "n = gets.to_i\na = Array.new(n)\n\nfor i in 0..n-1\n a[i] = gets.to_s\nend\n\ncounter = 0\nfor i in 0..n-1 \n if a[i] == a[i+1]\n counter+=1\n end\nend\ncounter"}, {"source_code": "def run\n n = ARGF.readline.chomp\n s = ARGF.readline.chomp\n\n return 0 if s.length == 1\n\n cnt = 0\n flag = false\n while !flag and s.length >= 1\n flag = true\n (s.length - 1).times do |i|\n if s[i] == s[i + 1]\n flag = false\n s[i] = ''\n break\n end\n end\n\n cnt += 1 unless flag\n end\n\n puts cnt\nend\n\nrun if $0 == __FILE__\n"}, {"source_code": "n = gets.to_i\ns = gets.chomp\n\nans = 0\ni = 0\nj = 1\nwhile i < n && i + j < n do\n e = s[i]\n if e == s[i+j]\n ans += 1\n j += 1\n else\n i += 1\n j = 1\n end\nend\nputs ans"}, {"source_code": "p gets(p).bytes.chunk{|i|i}.to_a.size-3"}, {"source_code": "puts gets.scan(/(.)(?=\\1)/).size"}, {"source_code": "n, s = gets.to_i, gets\nputs n-1.times.count{|i| s[i] == s[i+1]}"}, {"source_code": "puts \"Enter the number of stones\\n\"\nn = gets.to_i\nputs \"Enter the arrangement\\n\"\ns = gets.to_s\nkey = 0\na = n-2\nfor j in 0..a do\n if s[j] == s[j+1]\n key += 1\n end\nend\nputs key"}, {"source_code": "n = gets.chomp.to_i\nstr = gets.chomp\n\nansg = ansr = 0\n\nn.times do |i|\n if str[i] == 'R'\n ansr, ansg = [ansg, ansr + 1].min, ansg + 1\n else\n ansr, ansg = ansr + 1, [ansg + 1, ansr].min\n end\nend\n\nputs [ansg, ansr].min"}, {"source_code": "n = gets.chomp.to_i\nstr = gets.chomp\n\nansg = ansr = ansb = 0\n\nn.times do |i|\n if str[i] == 'R'\n ansr, ansg, ansb = [ansr + 1, ansg, ansb].min, ansg + 1, ansb + 1\n elsif str[i] == 'G'\n ansr, ansg, ansb = ansr + 1, [ansr, ansg + 1, ansb].min, ansb + 1\n else\n ansr, ansg, ansb = ansr + 1, ansg + 1, [ansr, ansg, ansb + 1].min\n end\nend\n\nputs [ansg, ansr].min\n"}, {"source_code": "s = gets\nc = 0\n(1...s.size).each{ |i| s[i] == s[i - 1] ? c += 1 : 0 }\nputs c"}, {"source_code": "n = gets.to_i\nq = gets.chomp\nm = []\nm = q.split(\"\")\ni = 0\nj = 0\nwhile i < n do\n i = i+1\n if m[i] == m[i+1]\n j = j+1\n end\nend\nputs j"}, {"source_code": "n=gets.to_i-1\ns=gets\nfor i in 1..s.length-1\nif s[i]!=s[i-1]\nn-=1\nend\nend\np n"}, {"source_code": "number = gets.strip.to_i\nsequence = gets.strip\n\nnew_string = sequence[0]\nsequence[0] = ''\n\nputs sequence\nsequence.each_char.with_index do |char, index|\n new_string << char if new_string[-1] != char\nend\n\nputs number - new_string.length\n"}, {"source_code": "n=gets.chomp.to_i\n\n\nstr=gets.chomp\nbest=0\ncur=0\nfor i in 1..n \n\tif str[i]==str[i-1]\n\t\tcur+=1\n\telse\n\t\tcur=0\n\tend\n\tbest=[best,cur].max\nend\nputs(best)\n\n"}], "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8"} {"source_code": "s = gets.strip\nn = s.length\nans = 0\nn.times do |i|\n a = s[i]\n ((i + 1)...n).each do |j|\n b = s[j]\n ((j + 1)...n).each do |k|\n c = s[k]\n ans += 1 if a + b + c == \"QAQ\"\n end\n end\nend\nputs ans\n", "positive_code": [{"source_code": "s = gets.chomp\nn = s.size\nans = 0\n(0..n-3).each do |i|\n ((i+1)..n-2).each do |j|\n ((j+1)..n-1).each do |k|\n if s[i] == 'Q' && s[j] == 'A' && s[k] == 'Q'\n ans += 1\n end\n end\n end\nend\nputs ans"}, {"source_code": "def f(s,c,dp)\n\tdp2=[0]*s.size\n\tcount0=0\n\tcount1=0\n\ti=0\n\ts.chars.each{|e|\n\t\tcount1=[count1,dp[i-1]].max if i>0\n\t\tif e==c\n\t\t\tcount0+=count1\n\t\t\tdp2[i]=count0\n\t\tend\n\t\ti=i+1\n\t}\n\treturn dp2\nend\n\ns=\" \"+gets.chomp\nans=0\ndp=[1]*s.size\n\"QAQ\".chars.each{|e|\n\tdp=f(s,e,dp)\n}\nputs dp.max\n"}, {"source_code": "p gets.chars.combination(3).to_a.count(['Q','A','Q'])"}, {"source_code": "# coding: utf-8\n\n# if __FILE__ == $0\n# end\nQ = 'Q'\nA = 'A'\nqi = []\nai = []\n\ngets.chomp.split(//).each_with_index { |elem, index| \n if elem == Q\n qi << index\n elsif elem == A\n ai << index\n else\n next\n end\n}\n\nseqs = 0\nqi.each { |i|\n ai.each { |j|\n if i < j\n count = 0\n qi.each { |sub_i|\n count += 1 if sub_i > j\n }\n seqs += count\n end\n }\n}\n\nputs seqs\n"}, {"source_code": "class QAQCounter\n def count(input)\n a_array = Array.new(input.size)\n\n leading_count = 0\n input.each_char.with_index do |c, i|\n if c == 'Q'\n leading_count += 1\n elsif c == 'A'\n a_array[i] = [leading_count, nil]\n end\n end\n\n following_count = 0\n input.reverse.each_char.with_index do |c, i|\n if c == 'Q'\n following_count += 1\n elsif c == 'A'\n a_array[input.size-i-1][1] = following_count\n end\n end\n\n a_array.inject(0) { |sum, x| sum + (x.nil? ? 0 : x[0] * x[1]) }\n end\nend\n\ninput = ARGF.readline\nputs QAQCounter.new.count(input)\n"}, {"source_code": "def solution(string)\n q, a, qa, count = 0, 0, 0, 0\n for i in 0...string.size do\n if string[i] == \"Q\"\n q += 1\n count += qa\n end \n if string[i] == \"A\"\n a += 1 \n qa += q\n end\n end\n count\nend\n\nputs solution(gets.strip)\n"}, {"source_code": "def solution(string)\n left_q = string.each_char.inject([0]) { |memo, chr| memo + [memo.last + (chr == \"Q\" ? 1 : 0)] }.tap { |o| o.shift }\n right_q = string.reverse.each_char.inject([0]) { |memo, chr| memo + [memo.last + (chr == \"Q\" ? 1 : 0)] }.tap { |o| o.shift }.reverse\n\n count = 0\n for i in 1...string.size-1 do\n if string[i] == \"A\"\n count += left_q[i]*right_q[i]\n end \n end\n count\nend\n \nputs solution(gets.strip)\n"}, {"source_code": "r=0\ns=gets.chomp\ns.size.times{|i|if s[i]=='Q'\n(i+2...s.size).each{|j|if s[j]=='Q'\nr+=(i+1...j).count{|k|s[k]=='A'}\nend}\nend}\np r"}, {"source_code": "c = gets.chomp.chars.combination(3).to_a.count(['Q','A','Q'])\nprint c\n"}, {"source_code": "a = gets.chomp\nn = a.size\nans = 0\nn.times do |i|\n if a[i] == ?A\n ans += a[0...i].count(?Q) * a[i..-1].count(?Q)\n end\nend\nputs ans"}, {"source_code": "S = gets\n\nQ = ?Q\nA = ?A\n\nq = qa = qaq = 0\n\nS.each_char do |c|\n \n if c == Q\n \n q += 1\n qaq += qa\n \n elsif c == A\n \n qa += q\n \n end\n \nend\n\nputs qaq"}, {"source_code": "str_arr = gets.chomp\nl, m, r = 0, 1, 2\nresult = 0\n\nwhile l <= str_arr.length - 3\n while str_arr[l] != 'Q' and l < str_arr.length - 3\n l += 1\n end\n m = l + 1\n r = m + 1\n while m <= str_arr.length - 2\n while str_arr[m] != 'A' and m < str_arr.length - 2\n m += 1\n end\n r = m + 1\n while r <= str_arr.length - 1\n while str_arr[r] != 'Q' and r < str_arr.length - 1\n r += 1\n end\n if str_arr[l] + str_arr[m] + str_arr[r] == \"QAQ\"\n result += 1\n end\n r += 1\n end\n m += 1\n end\n l += 1 \n \nend\n\nprint result\n\n\n"}, {"source_code": "s = gets.chomp\n\nresult = 0\n\ns.chars.each_with_index { |c, i| result += (s[0..i] || '').count('Q') * (s[i..-1] || '').count('Q') if c == 'A' }\n\nputs result\n"}, {"source_code": "s = gets\ni = 1\nl, r = [0], [nil]*(s.size - 1) + [0]\nwhile i < s.size\n l[i] = l[i - 1] + (s[i - 1] == 'Q' ? 1 : 0)\n r[-i - 1] = r[-i] + (s[-i] == 'Q' ? 1 : 0)\n i += 1\nend\ni = 1\nans = 0\nwhile i < s.size - 1\n ans += l[i]*r[i] if s[i] == 'A'\n i += 1\nend\nputs ans\n"}, {"source_code": "input = gets.chomp\nr = 0\nfor i in 0...input.size\n\tif input[i] == \"Q\"\n\t\tfor j in (i + 2)...input.size\n\t\t\tif input[j] == \"Q\"\n\t\t\t\tr += ((i + 1)...j).count {|x| input[x] == \"A\"}\n\t\t\tend\n\t\tend\n\tend\nend\nputs r"}, {"source_code": "\n na=gets.chomp\n i1=na.index(\"Q\")\n if(i1!=nil)\n i2=na.index(\"A\",i1+1)\n end\n if(i2!=nil&&i1!=nil)\n i3=na.index(\"Q\",i2+1)\n end\n num=0\n while i1!=nil\n while i2!=nil\n while i3!=nil&&i2 378\n puts num-1\n else\n puts num\n end"}, {"source_code": "\n na=gets.chomp\n i1=na.index(\"Q\")\n i2=na.index(\"A\",i1+1)\n i3=na.index(\"Q\",i1+1)\n num=0\n while i1!=nil\n while i2!=nil\n while i3!=nil\n num+=1\n \n i3=na.index(\"Q\",i3+1)\n end\n i2=na.index(\"A\",i2+1)\n if(i2!=nil)\n i3=na.index(\"Q\",i2+1)\nend\n end\n i1=na.index(\"Q\",i1+1)\n if(i1!=nil)\n i2=na.index(\"A\",i1+1)\nend\n if(i2!=nil)\n i3=na.index(\"Q\",i2+1)\nend\n end\n puts num"}, {"source_code": "str = gets\nprint str.scan(/(?=QAQ)/).count\n"}], "src_uid": "8aef4947322438664bd8610632fe0947"} {"source_code": "def calc(n,m,d)\n\tk = (n - 1) / d + 1\n t = (m - 1) / d + 1\n i = (n - 1) % d + 1\n j = (m - 1) % d + 1\n return k * t * i * j\nend\n\ndef countone(x, d)\n\tdd = ((x-1)/d)+1\n\treturn (((x-1) % d)+1)*dd\nend\n\ns = gets.chomp\nns,ms,ds = s.split(/ /)\nn = ns.to_i\nm = ms.to_i\nd = ds.to_i\nret = n*m\nif (n > d) || (m > d) \n\tif (n <= d)\n\t\tni = n\n\telse\n\t\tni = countone(n,d)\n\tend\n\tif (m <= d)\n\t\tmi = m\n\telse\n\t\tmi = countone(m,d)\n\tend\n\tret = ni*mi\nend\nputs ret\n", "positive_code": [{"source_code": "def F(x,s);x-(-x%s*(x/s));end;n,m,s=gets.split.map &:to_i;p F(n,s)*F(m,s)"}, {"source_code": "def F(x,s);x-(-x%s*(x/s));end;n,m,s=gets.split.map &:to_i;p F(n,s)*F(m,s)\n"}, {"source_code": "def F(x,s);x-(-x%s*(x/s));end;n,m,s=gets.split.map &:to_i;p F(n,s)*F(m,s)\n"}, {"source_code": "def F(x,s);x-(-x%s*(x/s));end;n,m,s=gets.split.map &:to_i;p F(n,s)*F(m,s)\n"}, {"source_code": "def F(x,s);x-(-x%s*(x/s));end;n,m,s=gets.split.map &:to_i;p F(n,s)*F(m,s)\n"}, {"source_code": "def F(x,s);x-(-x%s*(x/s));end;n,m,s=gets.split.map &:to_i;p F(n,s)*F(m,s)\n"}, {"source_code": "def F(x,s);x-(-x%s*(x/s));end;n,m,s=gets.split.map &:to_i;p F(n,s)*F(m,s)\n"}, {"source_code": "def F(x,s);x-(-x%s*(x/s));end;n,m,s=gets.split.map &:to_i;p F(n,s)*F(m,s)\n"}, {"source_code": "def F(x,s);x-(-x%s*(x/s));end;n,m,s=gets.split.map &:to_i;p F(n,s)*F(m,s)\n"}, {"source_code": "def F(x,s);x-(-x%s*(x/s));end;n,m,s=gets.split.map &:to_i;p F(n,s)*F(m,s)\n"}, {"source_code": "def F(x,s);x-(-x%s*(x/s));end;n,m,s=gets.split.map &:to_i;p F(n,s)*F(m,s)"}], "negative_code": [{"source_code": "def calc(n,m,d)\n\tk = (n - 1) / d + 1\n t = (m - 1) / d + 1\n i = (n - 1) % d + 1\n j = (m - 1) % d + 1\n return k * t * i * j\nend\n\ndef countone(x, d)\n\tdd = ((x-1)/d)+1\n\treturn (((x-1) % d)+1)*dd\nend\n\ns = gets.chomp\nns,ms,ds = s.split(/ /)\nn = ns.to_i\nm = ms.to_i\nd = ds.to_i\nret = n*m\nif (n > d) || (m > d) \n\tif (n <= d)\n\t\tni = 2\n\telse\n\t\tni = countone(n,d)\n\tend\n\tif (m <= d)\n\t\tmi = 2\n\telse\n\t\tmi = countone(m,d)\n\tend\n\tret = ni*mi\nend\nputs ret\n"}, {"source_code": "def countone(x, d)\n\tdd = ((x-1)/d)+1\n\treturn (((x-1) % d)+1)*dd\nend\n\ns = gets.chomp\nns,ms,ds = s.split(/ /)\nn = ns.to_i\nm = ms.to_i\nd = ds.to_i\nret = n*m\nif (n > d) || (m > d) \n\tif (n <= d)\n\t\tni = 1\n\telse\n\t\tni = countone(n,d)\n\tend\n\tif (m <= d)\n\t\tmi = 1\n\telse\n\t\tmi = countone(m,d)\n\tend\n\tret = ni*mi\nend\nputs ret"}], "src_uid": "e853733fb2ed87c56623ff9a5ac09c36"} {"source_code": "require 'prime'\n\nl, r, x, y = gets.strip.split.map(&:to_i)\n\nx_factors = Prime.prime_division(x)\ny_factors = Prime.prime_division(y)\nall_factors = {}\nx_factors.each do |fp|\n all_factors[fp[0]] = [fp[1]]\nend\ny_factors.each do |fp|\n if all_factors[fp[0]]\n all_factors[fp[0]] << fp[1]\n else\n all_factors[fp[0]] = [0, fp[1]]\n end\nend\n\nif all_factors.values.map(&:size).uniq != [2]\n puts 0\n exit\nend\n\nall_factors_ary = all_factors.keys.sort\nbl = all_factors_ary.size\nn = 1< 0\n b *= (f ** all_factors[f][1])\n a *= (f ** all_factors[f][0])\n else\n a *= (f ** all_factors[f][1])\n b *= (f ** all_factors[f][0])\n end\n end\n # puts \"(#{a},#{b})\"\n if l<=a && a<=r && l<=b && b<=r\n pairs << [a,b]\n end\nend\nputs pairs.uniq.size\n\n", "positive_code": [{"source_code": "L, R, X, Y = gets.split.map(&:to_i)\nif Y % X != 0\n puts 0\n exit\nend\n\ndiv = Y/X\nsq = Math.sqrt(div).ceil\nans = 0\n(1..sq).each do |i|\n next if div%i != 0\n j = div/i\n next if i > j\n next if i.gcd(j) != 1\n if (i*X).between?(L, R) && (j*X).between?(L, R)\n ans += i==j ? 1 : 2\n end\nend\nputs ans"}], "negative_code": [], "src_uid": "d37dde5841116352c9b37538631d0b15"} {"source_code": "hint = gets\ntemp = hint\narr = Array.new()\nnum = 10\nres = 1\nif hint[0] == '?'\n res *= 9\nelsif hint[0] > '9'\n res *= 9\n hint = hint[0] + temp.gsub(hint[0],'')\n num = num - 1\nend\nhint[0] = ''\nhint.each_char {|c|\n if c == '?'\n res *= 10\n elsif c > '9' && !(arr.include?(c))\n res *= num\n arr << c \n num = num - 1\n end \n}\n\nputs res\n", "positive_code": [{"source_code": "#!/usr/bin/ruby\nh={}\nf=10\nx=1\ngets.chomp.each_char.with_index{|c,i|\n\tif i==0&&!('0'..'9').include?(c)\n\t\tf=9\n\tend\n\tif c=='?'\n\t\tx*=10\n\telsif ('A'..'J').include?(c)\n\t\th[c]=1\n\tend\n}\np x*(11-h.size..10).reduce(1,:*)*f/10"}, {"source_code": "s = gets\nret = 1\nhash = {}\nfor i in 0...s.size\n adjust = i == 0 ? 1 : 0\n ret *= 10 - adjust if s[i] == '?'\n if s[i] >= 'A' && s[i] <= 'J'\n ret *= 10 - hash.size - adjust unless hash[s[i]]\n hash[s[i]] = true\n end\nend\nputs ret\n"}, {"source_code": "t = STDIN.gets\ndef ppp(start,lcounter)\n return start if lcounter == 1\n return 1 if lcounter < 1\n start*ppp(start-1, lcounter -1)\nend\nh = []\nk = []\nqcounter = 0\n\nt.size.times do |i|\n if t[i] =~ /[A-J]/\n h << t[i] if not h.include? t[i]\n end\n if '0123456789'.include? t[i]\n k << t[i] if not k.include? t[i]\n end\n qcounter = qcounter + 1 if t[i] == '?'\nend \n\np = h.count\np = 0 if p < 0\npp = 10 \n\n\nres = ((t[0] =~ /[A-J]/) ? ppp(pp-1, p-1)*(pp-1) : ppp(pp, p))* ((t[0] == '?') ? (10)**(qcounter - 1)*9 : (10)**qcounter) \nputs res"}, {"source_code": "#!/usr/bin/ruby\nh={}\nf=10\nx=0\ngets.chomp.each_char.with_index{|c,i|\n\tif i==0&&!('0'..'9').include?(c)\n\t\tf=9\n\tend\n\tif c=='?'\n\t\tx+=1\n\telsif ('A'..'J').include?(c)\n\t\th[c]=1\n\tend\n}\nr=(11-h.size..10).reduce(1,:*)\nif x>0\n\tr*=10\n\tx-=1\nend\nr=r*f/10\nputs r.to_s+'0'*x"}, {"source_code": "def f(n)\n return 1 if n == 1\n return n * f(n-1)\nend\ns = gets\nret = 1\nq = s.count('?')\nc = 10\nfor i in 'A'..'J'\n if s.index(i)\n ret *= c\n c -= 1\n end\nend\nret *= (10 ** q)\nif s[0] == '?' || (s[0] >= 'A' && s[0] <= 'J')\n ret = ret / 10 * 9\nend\nputs ret"}, {"source_code": "t = STDIN.gets\ndef ppp(start,lcounter)\n return start if lcounter == 1\n return 1 if lcounter < 1\n start*ppp(start-1, lcounter -1)\nend\nh = []\nk = []\nqcounter = 0\n\nt.size.times do |i|\n if t[i] =~ /[A-J]/\n h << t[i] if not h.include? t[i]\n end\n if '0123456789'.include? t[i]\n k << t[i] if not k.include? t[i]\n end\n qcounter = qcounter + 1 if t[i] == '?'\nend \n\np = h.count\np = 0 if p < 0\npp = 10 \n\n\nres = ((t[0] =~ /[A-J]/) ? ppp(pp-1, p-1)*(pp-1) : ppp(pp, p))* ((t[0] == '?') ? (10)**(qcounter - 1)*9 : (10)**qcounter) \nputs res"}], "negative_code": [{"source_code": "#!/usr/bin/ruby\nh={}\nf=10\nx=1\ngets.chomp.each_char.with_index{|c,i|\n\tif i==0&&!('0'..'9').include?(c)\n\t\tf=9\n\tend\n\tif c=='?'\n\t\tx*=10\n\telsif ('A'..'J').include?(c)\n\t\th[c]=1\n\tend\n}\np x*(11-h.size..10).reduce(1,:*)/10*f"}], "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82"} {"source_code": "n=gets.to_i\nx=Math.sqrt(n).round-200\nfor y in 1..400 do\n\tsum=0\n\tstr=x.to_s\n\tfor i in 0..str.size do\n\t\tsum+=str[i].to_i end;\n\tif x*(x+sum)==n and x>0\n\t\tputs x\n\t\tbreak\n\tend\n\tx+=1\n\tprint -1 if y==400\n\tend\n", "positive_code": [{"source_code": "EPS=1e-9\ndef s(x)\n\tret=0\n\twhile x>0\n\t\tret+=x%10\n\t\tx/=10\n\tend\n\tret\nend\n\ndef is_int?(_x)\n\tx=_x.round\n\t(x-EPS<=_x)&&(_x<=x+EPS)\nend\n\nn=gets.to_i\nans=100.times.map{|s|\n\t_x=(-s+(s*s+4*n)**0.5)/2.0\n\tif is_int?(_x)\n\t\tx=_x.round\n\t\tif x*x+s(x)*x-n==0\n\t\t\tx\n\t\telse\n\t\t\tnil\n\t\tend\n\telse\n\t\tnil\n\tend\n}\n\np ans.any? ? ans.compact.min : -1"}, {"source_code": "def s(x)\n res = 0\n until x == 0\n res += x%10\n x /= 10\n end\n return res\nend\n\nn = gets.to_i\nx = Math.sqrt(n).floor\nnotfound = true\nfor i in [x-100000, 1].max..x\n if i**2 + s(i)*i - n == 0\n print i\n notfound = false\n break\n end\nend\n\nprint -1 if notfound"}, {"source_code": "#!/usr/bin/ruby2.0\n\nn = STDIN.readline.to_i\n\ncandidates = []\n\n(1..162).each do |b|\n\tx = (-b + (b*b + 4*n)**0.5) / 2\n\tx = x.round\n\tnext if x*x + b*x != n\n\tt, sum = x, 0\n\twhile t != 0\n\t\tsum += t%10\n\t\tt /= 10\n\tend\n\tnext if sum != b\n\tcandidates.push(x)\nend\n\nif candidates.length == 0\n\tputs -1\nelse\n\tputs candidates.sort[0]\nend\n"}, {"source_code": "#!/usr/bin/ruby2.0\n\nn = STDIN.readline.to_i\n\ncandidates = []\n\n(1..162).each do |c|\n\tlow, high = 1, n\n\twhile high-low > 1e-6\n\t\tmid = (low+high)/2.0\n\t\tif n/mid - mid > c\n\t\t\tlow = mid\n\t\telse\n\t\t\thigh = mid\n\t\tend\n\tend\n\tx = mid.round\n\tnext if n != c*x + x*x\n\tt = x\n\ttotal = 0\n\twhile t != 0\n\t\ttotal += t%10\n\t\tt /= 10\n\tend\n\tif total == c\n\t\tcandidates.push(x)\n\tend\nend\n\nif candidates.length == 0\n\tputs -1\nelse\n\tputs candidates.sort[0]\nend\n"}, {"source_code": "n=gets.chomp.to_i\nx=Math.sqrt(n).round\nx-=200\nfor y in 1..400 do\n\tsum=0\n\tstr=x.to_s\n\tfor i in 0..str.size do\n\t\tsum+=str[i].to_i end;\n\tif x>0 and x*(x+sum)==n\n\t\tputs x\n\t\tbreak\n\tend\n\tx+=1\n\tprint -1 if y==400\nend"}, {"source_code": "n = gets.to_i\nx = Math.sqrt(n).round - 200\n0.upto(400) do\n sum = 0\n str = x.to_s\n 0.upto(str.size) do |i|\n sum += str[i].to_i\n end\n if x * (x + sum) == n and x > 0\n puts str\n exit\n end\n x += 1\nend\nputs -1"}, {"source_code": "n = gets.to_i\n\ndef s(x)\n sum = 0\n x.to_s.each_byte { |c| sum += c - 48 }\n sum\nend\n\ndef sqrt(y)\n lo, hi = 1, y\n while lo <= hi do\n mid = (lo + hi) / 2\n return mid if mid * mid == y\n lo = mid + 1 if mid * mid < y\n hi = mid - 1 if mid * mid > y\n end\n return -1\nend\n\nans = []\n\nfor i in 1..81 do\n t = sqrt(i * i + 4 * n) \n if t != -1 then\n if t - i > 0 && (t - i) % 2 == 0 then\n ans << (t - i) / 2 if s((t - i) / 2) == i\n end\n end \nend\n\nif ans.size == 0 then\n puts \"-1\"\nelse\n puts ans.min\nend\n"}, {"source_code": "n = gets.to_i\n\n# while l <= r\n# \tx = l + (r-l)/2\n# \ts = x.to_s.split(\"\").map(&:to_i).inject(0,:+)\n# \tputs x\n# \tif ((x * x) + (s * x) - n) == 0 \n# \t\tans = x\n# \t\tbreak\n# \telse\n# \t\tr = x - 1\n# \tend\n# end\n\n# puts x\nans = false\nmin = n\n(1..90).each do |s|\n\ta = 1\n\tb = s\n\tc = -n\n\td = (b ** 2) - (4 * a * c)\n\tif d >=0\n\t\tr1 = (-b + Math.sqrt(d))/(2 * a)\n\t\tr2 = (-b - Math.sqrt(d))/(2 * a)\n\telsif d == 0\n\t\tr1 = r2 = (-b)/(2 * a)\n\tend\n\t# puts \"sum #{s} roots #{r1} #{r2}\"\n\tif r1 && r2\n\t\tarr = []\n\t\tsum = r1.to_i.to_s.split(\"\").map(&:to_i).inject(0,:+)\n\t\tarr << r1 if r1 % 1 == 0 && r1 > 0 && s == sum\n\t\tsum = r2.to_i.to_s.split(\"\").map(&:to_i).inject(0,:+)\n\t\tarr << r2 if r2 % 1 == 0 && r2 > 0 && s == sum\n\t\tunless arr.empty?\n\t\t# puts \"s #{s} ar #{r1} #{r2}\"\n\t\t\tval = arr.min \n\t\t\tmin = val if val && val < min\n\t\t\t# puts \"#{val}\"\n\t\t\tans = true\n\t\tend\n\tend\nend\nif ans\n\tif min == 999959999\n\t\tputs -1\n\telse\n\tputs min.to_i\n\tend\nelse\n\tputs \"-1\"\nend"}, {"source_code": "def s(x)\n sum = 0\n while x>0\n sum+= x%10\n x /= 10\n end\n sum\nend\n\nn = gets.to_i\nx = Math.sqrt(n).round - 160;\n\n321.times do |i|\n if x*(x+s(x))==n && x > 0\n puts x\n exit\n end\n x+=1\nend\nputs -1\n"}], "negative_code": [{"source_code": "n=gets.to_i\nx=n**0.5.round-200\nfor y in 1..400 do\n\tsum=0\n\tstr=x.to_s\n\tfor i in 0..str.size do\n\t\tsum+=str[i].to_i end;\n\tif x*(x+sum)==n\n\t\tputs x\n\t\tbreak\n\tend\n\tx+=1\n\tprint -1 if y==400\n\tend\n"}, {"source_code": "#!/usr/bin/ruby2.0\n\nn = STDIN.readline.to_i\n\ncandidates = []\n\n(1..162).each do |c|\n\tlow, high = 1, n\n\twhile high-low > 1e-6\n\t\tmid = (low+high)/2.0\n\t\tif n/mid - mid > c\n\t\t\tlow = mid\n\t\telse\n\t\t\thigh = mid\n\t\tend\n\tend\n\tx = mid.round\n\tt = x\n\ttotal = 0\n\twhile t != 0\n\t\ttotal += t%10\n\t\tt /= 10\n\tend\n\tif total == c\n\t\tcandidates.push(x)\n\tend\nend\n\nif candidates.length == 0\n\tputs -1\nelse\n\tputs candidates.sort[0]\nend\n"}, {"source_code": "n = gets.to_i\n\n# while l <= r\n# \tx = l + (r-l)/2\n# \ts = x.to_s.split(\"\").map(&:to_i).inject(0,:+)\n# \tputs x\n# \tif ((x * x) + (s * x) - n) == 0 \n# \t\tans = x\n# \t\tbreak\n# \telse\n# \t\tr = x - 1\n# \tend\n# end\n\n# puts x\nans = false\nmin = n\n(1..90).each do |s|\n\ta = 1\n\tb = s\n\tc = -n\n\td = (b ** 2) - (4 * a * c)\n\tif d >=0\n\t\tr1 = (-b + Math.sqrt(d))/(2 * a)\n\t\tr2 = (-b - Math.sqrt(d))/(2 * a)\n\telsif d == 0\n\t\tr1 = r2 = (-b)/(2 * a)\n\tend\n\t# puts \"sum #{s} roots #{r1} #{r2}\"\n\tif r1 && r2\n\t\tarr = []\n\t\tsum = r1.to_i.to_s.split(\"\").map(&:to_i).inject(0,:+)\n\t\tarr << r1 if r1 % 1 == 0 && s == sum\n\t\tsum = r2.to_i.to_s.split(\"\").map(&:to_i).inject(0,:+)\n\t\tarr << r2 if r2 % 1 == 0 && s == sum\n\t\t# puts \"sum #{s} #{arr}\"\n\t\tval = arr.min \n\t\tmin = val if val && val > 0 && val < min\n\t\tans = true\n\tend\nend\nif ans\nputs min.to_i\nelse\n\tputs \"-1\"\nend"}, {"source_code": "n = gets.to_i\n\n# while l <= r\n# \tx = l + (r-l)/2\n# \ts = x.to_s.split(\"\").map(&:to_i).inject(0,:+)\n# \tputs x\n# \tif ((x * x) + (s * x) - n) == 0 \n# \t\tans = x\n# \t\tbreak\n# \telse\n# \t\tr = x - 1\n# \tend\n# end\n\n# puts x\nans = false\nmin = n\n(1..90).each do |s|\n\ta = 1\n\tb = s\n\tc = -n\n\td = (b ** 2) - (4 * a * c)\n\tif d >=0\n\t\tr1 = (-b + Math.sqrt(d))/(2 * a)\n\t\tr2 = (-b - Math.sqrt(d))/(2 * a)\n\telsif d == 0\n\t\tr1 = r2 = (-b)/(2 * a)\n\tend\n\t# puts \"sum #{s} roots #{r1} #{r2}\"\n\tif r1 && r2\n\t\tarr = []\n\t\tsum = r1.to_i.to_s.split(\"\").map(&:to_i).inject(0,:+)\n\t\tarr << r1 if r1 % 1 == 0 && r1 > 0 && s == sum\n\t\tsum = r2.to_i.to_s.split(\"\").map(&:to_i).inject(0,:+)\n\t\tarr << r2 if r2 % 1 == 0 && r2 > 0 && s == sum\n\t\tunless arr.empty?\n\t\t# puts \"ar #{arr}\"\n\t\t\tval = arr.min \n\t\t\tmin = val if val && val < min\n\t\t\t# puts \"#{val}\"\n\t\t\tans = true\n\t\tend\n\tend\nend\nif ans\n\tputs min.to_i\nelse\n\tputs \"-1\"\nend"}, {"source_code": "n = gets.to_i\n\n# while l <= r\n# \tx = l + (r-l)/2\n# \ts = x.to_s.split(\"\").map(&:to_i).inject(0,:+)\n# \tputs x\n# \tif ((x * x) + (s * x) - n) == 0 \n# \t\tans = x\n# \t\tbreak\n# \telse\n# \t\tr = x - 1\n# \tend\n# end\n\n# puts x\nans = false\nmin = n\n(1..90).each do |s|\n\ta = 1\n\tb = s\n\tc = -n\n\td = (b ** 2) - (4 * a * c)\n\tif d >=0\n\t\tr1 = (-b + Math.sqrt(d))/(2 * a)\n\t\tr2 = (-b - Math.sqrt(d))/(2 * a)\n\telsif d == 0\n\t\tr1 = r2 = (-b)/(2 * a)\n\tend\n\t# puts \"sum #{s} roots #{r1} #{r2}\"\n\tif r1 && r2\n\t\tarr = []\n\t\tsum = r1.to_i.to_s.split(\"\").map(&:to_i).inject(0,:+)\n\t\tarr << r1 if r1 % 1 == 0 && s == sum\n\t\tsum = r2.to_i.to_s.split(\"\").map(&:to_i).inject(0,:+)\n\t\tarr << r2 if r2 % 1 == 0 && s == sum\n\t\tunless arr.empty?\n\t\t\tval = arr.min \n\t\t\tmin = val if val && val > 0 && val < min\n\t\t\tans = true\n\t\tend\n\tend\nend\nif ans\n\tputs min.to_i\nelse\n\tputs \"-1\"\nend"}, {"source_code": "n = gets.to_i\n\n# while l <= r\n# \tx = l + (r-l)/2\n# \ts = x.to_s.split(\"\").map(&:to_i).inject(0,:+)\n# \tputs x\n# \tif ((x * x) + (s * x) - n) == 0 \n# \t\tans = x\n# \t\tbreak\n# \telse\n# \t\tr = x - 1\n# \tend\n# end\n\n# puts x\nans = false\nmin = n\n(1..90).each do |s|\n\ta = 1\n\tb = s\n\tc = -n\n\td = (b ** 2) - (4 * a * c)\n\tif d >=0\n\t\tr1 = (-b + Math.sqrt(d))/(2 * a)\n\t\tr2 = (-b - Math.sqrt(d))/(2 * a)\n\telsif d == 0\n\t\tr1 = r2 = (-b)/(2 * a)\n\tend\n\t# puts \"sum #{s} roots #{r1} #{r2}\"\n\tif r1 && r2\n\t\tarr = []\n\t\tsum = r1.to_i.to_s.split(\"\").map(&:to_i).inject(0,:+)\n\t\tarr << r1 if r1 % 1 == 0 && r1 > 0 && s == sum\n\t\tsum = r2.to_i.to_s.split(\"\").map(&:to_i).inject(0,:+)\n\t\tarr << r2 if r2 % 1 == 0 && r2 > 0 && s == sum\n\t\tunless arr.empty?\n\t\tputs \"s #{s} ar #{r1} #{r2}\"\n\t\t\tval = arr.min \n\t\t\tmin = val if val && val < min\n\t\t\t# puts \"#{val}\"\n\t\t\tans = true\n\t\tend\n\tend\nend\nif ans\n\tif min == 999959999\n\t\tputs -1\n\telse\n\tputs min.to_i\n\tend\nelse\n\tputs \"-1\"\nend"}, {"source_code": "def s(x)\n sum = 0\n while x>0\n sum+= x%10\n x /= 10\n end\n sum\nend\n\nn = gets.to_i\nx = Math.sqrt(n).round-1\nwhile x*x <= n\n if x*(x+s(x))==n\n puts x\n exit\n end\n x+=1\nend\nputs -1\n"}, {"source_code": "def s(x)\n sum = 0\n while x>0\n sum+= x%10\n x /= 10\n end\n sum\nend\n\nn = gets.to_i\nx = Math.sqrt(n).round - 160;\n\n321.times do |i|\n if x*(x+s(x))==n\n puts x\n exit\n end\n x+=1\nend\nputs -1\n"}, {"source_code": "def s(x)\n sum = 0\n while x>0\n sum+= x%10\n x /= 10\n end\n sum\nend\n\nn = gets.to_i\nx = Math.sqrt(n).round-s(Math.sqrt(n).round)-1\nwhile x*x <= n+s(x)\n if x*(x+s(x))==n\n puts x\n exit\n end\n x+=1\nend\nputs -1\n"}, {"source_code": "def s(x)\n sum = 0\n while x>0\n sum+= x%10\n x /= 10\n end\n sum\nend\n\nn = gets.to_i\nx = Math.sqrt(n).round\n\nwhile x*x <= n\n if x*(x+s(x))==n\n puts x\n exit\n end\n x+=1\nend\nputs -1\n"}, {"source_code": "def s(x)\n\tret=0\n\twhile x>0\n\t\tret+=x%10\n\t\tx/=10\n\tend\n\tret\nend\n\ndef is_int?(_x)\n\tx=_x.round\n\t(x-1e-9<_x)&&(_x0\n\t\tret+=x%10\n\t\tx/=10\n\tend\n\tret\nend\n\ndef is_int?(_x)\n\tx=_x.round\n\t(x-1e-9<_x)&&(_x0\n\t\tret+=x%10\n\t\tx/=10\n\tend\n\tret\nend\n\ndef is_int?(_x)\n\tx=_x.round\n\t(x-1e-19<_x)&&(_x[\\d]+) (?[\\d]+)/ =~ gets.chomp\na = a.to_i\nb = b.to_i\n\ndef bite(size, mults=[2, 3, 5])\t# => [b*2, b*3, b*5, leftovers || 1]\n\tbitesizes = []\n\tmults.each do |mult|\n\t\tbite = 0\n\t\tbite, size = (bite+1), (size/mult) while (size%mult)==0\n\t\tbitesizes << bite\n\tend\n\tbitesizes << size\n\treturn bitesizes\nend\n\n*bitesA, leftA = bite(a)\n*bitesB, leftB = bite(b)\n\nif (leftA != leftB)\n\tputs -1\nelse\n\tp (bitesA.zip(bitesB).map{ |bA, bB|\n\t\t(bA-bB).abs\n\t}.reduce(&:+))\nend\n", "positive_code": [{"source_code": "a,b=gets.chomp.split(' ').map(&:to_i)\ntmp=a.gcd(b)\na/=tmp\nb/=tmp\nctr=0\nwhile a%2==0\n\ta/=2\n\tctr+=1\nend\nwhile b%2==0\n\tb/=2\n\tctr+=1\nend\nwhile a%3==0\n\ta/=3\n\tctr+=1\nend\nwhile b%3==0\n\tb/=3\n\tctr+=1\nend\nwhile a%5==0\n\ta/=5\n\tctr+=1\nend\nwhile b%5==0\n\tb/=5\n\tctr+=1\nend\nif a+b > 2\n\tputs \"-1\"\nelse\n\tputs ctr\nend"}], "negative_code": [], "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49"} {"source_code": "s=gets.chomp\nc=s.count(?o)\nputs c>0&&s.size%c>0?:No: :Yes", "positive_code": [{"source_code": "s=gets.chomp\n\nli=s.count('-')\npe=s.count('o')\n\nif pe==0\n puts 'YES'\nelse\n if li%pe==0\n puts 'YES'\n else\n puts 'NO'\n end\nend"}, {"source_code": "PEARL = 'o'\nLINK = '-'\n\nnecklace = STDIN.gets.chomp\n\ndef adjustable?(necklace)\n pearl_count = necklace.count(PEARL)\n return true if pearl_count == 0\n link_count = necklace.count(LINK)\n\n link_count % pearl_count == 0\nend\n\nif adjustable?(necklace)\n puts 'YES'\nelse\n puts 'NO'\nend\n"}], "negative_code": [{"source_code": "s=gets.chomp\nc=s.count(?o)\nputs c==0||s.size%c>0?:No: :Yes"}, {"source_code": "s=gets.chomp\nc=s.count(?o)\nputs c>0||s.size%c>0?:No: :Yes"}, {"source_code": "PEARL = 'o'\nLINK = '-'\n\nnecklace = STDIN.gets.chomp\n\ndef adjustable?(necklace)\n pearl_count = necklace.count(PEARL)\n if pearl_count == 1\n true\n else\n link_count = necklace.count(LINK)\n link_count % (pearl_count - 1) == 0\n end\nend\n\nif adjustable?(necklace)\n puts 'YES'\nelse\n puts 'NO'\nend\n"}], "src_uid": "6e006ae3df3bcd24755358a5f584ec03"} {"source_code": "n=gets.to_i\na=gets.split.map{|e| e.to_i}\nb=a.index(1)\nc=a.index(n)\nb1=[b,c].min\nc1=[b,c].max\nn-=1\nif b1==0 || c1==n then\n\tputs n\nelse\n\tputs [c1,n-b1].max\nend\n\n", "positive_code": [{"source_code": "n=gets.to_i;a=gets.split.map(&:to_i);puts [a.index(n), n-a.index(n)-1, a.index(1), n-a.index(1)-1].max"}, {"source_code": "n = gets.chomp.to_i\nas = gets.chomp.split.map(&:to_i)\n\nif n <= 3\n puts n - 1\nelse\n i = as.index(1)\n j = as.index(n)\n ans = (i - j).abs\n ans = [ans, n - 1 - [i, j].min].max\n ans = [ans, [i, j].max].max\n puts ans\nend\n"}, {"source_code": "n = gets.chomp.to_i\nnums = gets.split.map(&:to_i)\n\nfor i in 0...n\n\tbiggest = i + 1 if n == nums[i]\n\tsmallest = i + 1 if 1 == nums[i]\nend\n\nputs [n - [smallest, biggest].min, [smallest, biggest].max - 1].max\n\n=begin\n7\n1 \n6 \n5 \n3 \n4 \n7 \n2\n\n6\n6 \n5 \n4 \n3 \n2 \n1\n\n3\n2 3 1\n\n\n=end"}, {"source_code": "n = 0\nnums = Array.new\n\n\n\nbiggest = 0\nsmallest = 100\n\nn = gets.chomp.to_i\nnums = gets.split.map(&:to_i)\n\n#p nums\n#puts n\n#puts nums.last\n\nfor i in 0..n\n\t#nums.push($stdin.read.chomp.to_i) \n\t#thing = gets.chomp.split('|')[1].scan(/\\d+/).map{|n| n.to_i}\n\tif n == nums[i]\n\t\tbiggest = i + 1\n\tend\n\tif 1 == nums[i]\n\t\tsmallest = i + 1\n\tend\nend\n\n#puts \"Biggest: #{biggest}, smallest: #{smallest}\\n\\n\"\n\nputs [n - [smallest, biggest].min, [smallest, biggest].max - 1].max\n\n=begin\n7\n1 \n6 \n5 \n3 \n4 \n7 \n2\n\n6\n6 \n5 \n4 \n3 \n2 \n1\n\n3\n2 3 1\n\n\n=end"}, {"source_code": "n = gets.to_i\nd = gets.split.map(&:to_i)\n\np (d.index(1)-d.index(n)).abs + [[d.index(1),d.index(n)].min,n-1-[d.index(1),d.index(n)].max].max"}, {"source_code": "n = gets.to_i\na = gets.split.map(&:to_i)\nb = [a.index(1), a.index(n)].sort\nputs [n - 1 - b[0], b[1]].max\n"}, {"source_code": "size_of_permutation = gets.chomp.to_i\nintegers_array = gets.chomp.split.map(&:to_i)\n\ndef max_distance(size, list)\n min_index = nil\n max_index = nil\n\n for i in 0..(list.length - 1)\n min_index = i if list[i] == 1\n max_index = i if list[i] == size\n\n if min_index && max_index\n break\n end\n end\n\n potential_distance = [min_index, max_index, size - 1 - min_index, size - 1 - max_index]\n max_distance = potential_distance[0]\n for i in potential_distance\n if i > max_distance\n max_distance = i\n end\n end\n max_distance\nend\n\nputs max_distance(size_of_permutation, integers_array)\n"}, {"source_code": "size_of_permutation = gets.chomp.to_i\nintegers_array = gets.chomp.split.map(&:to_i)\n\ndef max_distance(size, list)\n min, max = list[0], list[0]\n min_index = 0\n max_index = 0\n\n for i in 0..(list.length - 1)\n if list[i] < min\n min = list[i]\n min_index = i\n end\n\n if list[i] > max\n max = list[i]\n max_index = i\n end\n end\n\n potential_distance = [min_index, max_index, size - 1 - min_index, size - 1 - max_index]\n max_distance = potential_distance[0]\n for i in potential_distance\n if i > max_distance\n max_distance = i\n end\n end\n max_distance\nend\n\nputs max_distance(size_of_permutation, integers_array)\n"}, {"source_code": "arrLen = gets.chomp.to_i\narr = gets.chomp.split(' ').map { |i| i.to_i }\n\nminIdx = arr.index { |i| i == arr.min}\nmaxIdx = arr.index { |i| i == arr.max}\n\nbiggerIdx = minIdx > maxIdx ? minIdx : maxIdx\nnonBiggerIdx = minIdx < maxIdx ? minIdx : maxIdx\n\ncandidate_1 = (arrLen - 1) - nonBiggerIdx\ncandidate_2 = (arrLen - 1) - biggerIdx\ncandidate_3 = nonBiggerIdx - 0\ncandidate_4 = biggerIdx - 0\n\nans = Array.new\nans << candidate_1\nans << candidate_2\nans << candidate_3\nans << candidate_4\n\nputs ans.max"}, {"source_code": "n = gets.chomp.to_i\narr = gets.split.map(&:to_i)\n\nfirst = arr.index(1)\nlast = arr.index(n)\nif first == 0 and last == n - 1\n p (n - 1)\nelse\n p [first, last, n - 1 - first, n - 1 - last].max\nend"}, {"source_code": "n=gets.to_i\na,b=gets.split.map(&:to_i).each_with_index.select{|e,i|e==1||e==n}.map(&:last)\np [n-1-a,n-1-b,a,b].map(&:abs).max"}, {"source_code": "n=gets.to_i\na,b=gets.split.map(&:to_i).each_with_index.select{|e,i|e==1||e==n}.map(&:last)\np [n-1-a,n-1-b,a,b].max"}, {"source_code": "def checks(n, arrays)\n arrays = arrays.split.map(&:to_i)\n n = n.to_i\n\n for i in (0..n - 1)\n if arrays[i] == 1\n pos1 = i\n end\n\n if arrays[i] == n\n posn = i\n end\n end\n\n puts [posn, n - 1 - posn, pos1, n - 1 - pos1].max\nend\n\nchecks(gets, gets)"}, {"source_code": "def max (a,b)\n a > b ? a : b \nend\n\nn = gets.to_i\narr = gets.strip.split(' ').map(&:to_i)\n\npos = []\narr.each_with_index do |value, index|\n if 1 == value\n pos.push index\n elsif n == value\n pos.push index\n end\nend\n\nputs max(pos[1], n - pos[0] - 1)\n"}, {"source_code": "n = gets.to_i\narr = gets.strip.split(' ').map(&:to_i)\n\npos = []\narr.each_with_index do |value, index|\n if 1 == value\n pos.push index\n elsif n == value\n pos.push index\n end\nend\n\np [pos[1], n - pos[0] - 1].max\n"}, {"source_code": "class Array\n def swap(a, b)\n clone = self.dup\n clone[a], clone[b] = clone[b], clone[a]\n \n clone\n end\n def max_distance\n (self.index(self.min) - self.index(self.max)).abs\n end\nend\n\nn = gets.chomp.to_i\narr = gets.chomp.split.map(&:to_i)\nresults = []\n\n(0...n).each do |i|\n (0...n).each do |j|\n next if i == j\n results << arr.swap(i, j).max_distance\n end\nend\nputs results.max\n"}, {"source_code": "n = readline.to_i\narr = readline.split(' ').collect(&:to_i)\ni, j = arr.index(1), arr.index(n)\nputs [[i, n - i - 1].max, [j, n - j - 1].max].max\n"}, {"source_code": "n = gets.chomp.to_i\na = gets.chomp.split(/ /).map(&:to_i)\nmin_element = a.min\nmax_element = a.max\npos_min = a.index min_element\npos_max = a.index max_element\nstart_min_dist = pos_min\nstart_max_dist = pos_max\nend_min_dist = n - pos_min - 1\nend_max_dist = n - pos_max - 1\nputs [start_min_dist, start_max_dist, end_min_dist, end_max_dist].max\n"}, {"source_code": "n = gets.to_i\n\nnumbers = gets\n\nres = numbers.split(' ')\n\np_max = -1\np_min = -1\n\nres.each_with_index do |r,i|\n if (r.to_i == 1) \n p_min = i + 1\n end\n if (r.to_i == n)\n p_max = i + 1\n end\nend\n\nif (p_max < p_min)\n t = p_max\n p_max = p_min\n p_min = t\nend\nputs (n-p_min>p_max-1)? n-p_min : p_max - 1\n"}, {"source_code": "gets;a=gets.split.map(&:to_i);puts [[a.find_index(a.max), (a.size-a.find_index(a.max)-1).abs].max, [a.find_index(a.min), (a.size-a.find_index(a.min)-1).abs].max].max"}, {"source_code": "n=gets.to_i;a=gets.split.map(&:to_i);(amax,amin)=[a.find_index(a.max),a.find_index(a.min)];puts [amax, n-amax-1, amin, n-amin-1].max"}], "negative_code": [{"source_code": "n = gets.chomp.to_i\narr = gets.split.map(&:to_i)\n\nfirst = arr.index(1)\np first\nlast = arr.index(n)\nif first == 0 and last == n - 1\n p (n - 1)\nelse\n p [first, last, n - 1 - first, n - 1 - last].max\nend"}, {"source_code": "n = gets.chomp.to_i\na = gets.chomp.split(/ /).map(&:to_i)\nmin_element = a.min\nmax_element = a.max\npos_min = a.index min_element\npos_max = a.index max_element\nif pos_min > pos_max\n pos_min = n - 1\nelsif pos_max > pos_min\n pos_max = n - 1\nend\ndist = (pos_min - pos_max).abs\nputs dist\n"}, {"source_code": "n = gets.to_i\n\nnumbers = gets\n\nres = numbers.split(' ')\n\np_max = -1\np_min = -1\n\nres.each_with_index do |r,i|\n if (r.to_i == 1) \n p_min = i + 1\n end\n if (r.to_i == n)\n p_max = i + 1\n end\nend\n\nif (p_max < p_min)\n t = p_max\n p_max = p_min\n p_min = t\nend\nputs (n-p_min>p_max)? n-p_min : p_max\n"}, {"source_code": "n = 0\nnums = Array.new\n\n\n\nbiggest = 0\nsmallest = 100\n\nn = gets.chomp.to_i\nnums = gets.split.map(&:to_i)\n\n#p nums\n#puts n\n#puts nums.last\n\nfor i in 0..n\n\t#nums.push($stdin.read.chomp.to_i) \n\t#thing = gets.chomp.split('|')[1].scan(/\\d+/).map{|n| n.to_i}\n\tif n == nums[i]\n\t\tbiggest = i + 1\n\tend\n\tif 1 == nums[i]\n\t\tsmallest = i + 1\n\tend\nend\n\n#puts \"Biggest: #{biggest}, smallest: #{smallest}\\n\\n\"\n\nputs [n - [smallest, biggest].min, [smallest, biggest].min - 1].max\n\n=begin\n7\n1 \n6 \n5 \n3 \n4 \n7 \n2\n\n6\n6 \n5 \n4 \n3 \n2 \n1\n\n=end"}, {"source_code": "n = gets.to_i\na = gets.split.map(&:to_i)\nb = [a.index(1), a.index(n)].sort\nputs [n - b[0], b[1]].max - 1\n"}, {"source_code": "size_of_permutation = gets.chomp.to_i\nintegers_array = gets.chomp.split.map(&:to_i)\n\ndef max_distance(size, list)\n min, max = list[0], list[0]\n min_index = 0\n max_index = 0\n\n for i in 0..(list.length - 1)\n if list[i] < min\n min = list[i]\n min_index = i\n end\n\n if list[i] > max\n max = list[i]\n max_index = i\n end\n end\n\n if min_index == 0 || max_index == 0 || min_index == size - 1 || max_index == size - 1\n return size - 1\n end\n\n min_index < max_index ? size - 1 - min_index : size - 1 - max_index\nend\n\nputs max_distance(size_of_permutation, integers_array)\n"}, {"source_code": "size_of_permutation = gets.chomp.to_i\nintegers_array = gets.chomp.split.map(&:to_i)\n\ndef max_distance(size, list)\n min, max = list[0], list[0]\n min_index = 0\n max_index = 0\n\n for i in 0..(list.length - 1)\n if list[i] < min\n min = list[i]\n min_index = i\n end\n\n if list[i] > max\n max = list[i]\n max_index = i\n end\n end\n\n max_distance = min_index < max_index ? size - 1 - min_index : size - 1 - max_index\nend\n\nputs max_distance(size_of_permutation, integers_array)\n"}, {"source_code": "arrLen = gets.chomp.to_i\narr = gets.chomp.split(' ').map { |i| i.to_i }\n\nminIdx = arr.index { |i| i == arr.min}\nmaxIdx = arr.index { |i| i == arr.max}\n\nbiggerIdx = minIdx > maxIdx ? minIdx : maxIdx\nnonBiggerIdx = minIdx < maxIdx ? minIdx : maxIdx\n\nans = if (arrLen - biggerIdx) > (nonBiggerIdx - 0)\n\tarrLen - nonBiggerIdx\nelse\n\tbiggerIdx - 0\nend\n\nputs ans - 1"}], "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4"} {"source_code": "puts gets=~/^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?\\n$/?\"YES\":\"NO\"", "positive_code": [{"source_code": "a=\"YES\"\ns=gets.chomp\nunless s=~/^(\\w{1,16})@([\\w\\.]{1,32})\\/(\\w{1,16})$/ || s=~/^(\\w{1,16})@([\\w\\.]{1,32})$/ then a=\"NO\"\nelse $2.split(\".\",-1).each{|s|if s.length==0||s.length>16 then a=\"NO\" end}\nend\nputs a"}, {"source_code": "puts gets=~/^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?\\n$/?\"YES\":\"NO\""}, {"source_code": "puts gets =~ /^[\\w_]{1,16}@[\\w_.]{1,32}(\\/[\\w_]{1,16})?$/ && $_ !~ /[@.]\\.|\\.\\/|\\.$/ ? :YES : :NO\n"}, {"source_code": "r = /[\\w_]{1,16}/\nputs gets =~ /^#{r}@(#{r}(\\.#{r})*)(\\/#{r})?$/ && $1.size <= 32 ? :YES : :NO\n"}, {"source_code": "str = gets.strip!\nre_pattern = /^\\w{1,16}@(\\w{1,16}(\\.\\w{1,16})*)(\\/\\w{1,16})?$/\nif str.match(re_pattern) && $1.size <= 32\n\tputs 'YES'\nelse\n\tputs 'NO'\nend"}, {"source_code": "str = gets.strip!\nre_pattern = /^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?$/\nif str.match(re_pattern)\n\tputs 'YES'\nelse\n\tputs 'NO'\nend"}, {"source_code": "puts gets=~/^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?\\n$/?\"YES\":\"NO\"\n"}, {"source_code": "puts gets=~/^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?\\n$/?\"YES\":\"NO\"\n"}, {"source_code": "puts gets=~/^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?\\n$/?\"YES\":\"NO\""}, {"source_code": "puts gets=~/^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?\\n$/?\"YES\":\"NO\""}, {"source_code": "puts gets=~/^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?\\n$/?\"YES\":\"NO\"\n"}, {"source_code": "puts gets=~/^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?\\n$/?\"YES\":\"NO\"\n"}, {"source_code": "puts gets=~/^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?\\n$/?\"YES\":\"NO\""}, {"source_code": "puts gets=~/^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?\\n$/?\"YES\":\"NO\""}, {"source_code": "def valid_word?(s)\n s =~ /^[_a-zA-Z0-9_]{1,16}$/\nend\n\ndef solve(s)\n \n words = (s + '.a').split(/[.@\\/]/)\n words.pop\n return false unless words.all? { |w| valid_word? w }\n\n wr = '[_a-zA-Z0-9_]{1,16}' # word regex\n rr = '[_a-zA-Z0-9_.]{1,32}' # resource regex\n \n return s =~ Regexp.new(\"^#{wr}@#{wr}(\\\\.#{wr})*(\\\\/#{wr})?\") &&\n s =~ Regexp.new(\"^#{wr}@#{rr}(\\\\/#{wr})?\")\n\nend\n\ns = gets.chomp\n#s = 'mike@codeforces.com'\n#s = 'john.smith@codeforces.ru/contest.icpc/12'\n#s = '007@en.codeforces.com/contest'\nputs solve(s) ? 'YES' : 'NO'"}, {"source_code": "puts gets=~/^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?\\n$/?\"YES\":\"NO\"\n"}, {"source_code": "puts gets =~ /^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})*$/ ? \"YES\" : \"NO\"\n"}, {"source_code": "puts (gets =~ /^\\w{1,16}@(\\w{1,16}(\\.\\w{1,16})*)(\\/\\w{1,16})*$/ && $1.size <= 32) ? \"YES\" : \"NO\"\n\n"}, {"source_code": "if gets.strip =~ %r{^([0-9a-zA-Z_]{1,16})@([0-9a-zA-Z_]{1,16}(\\.[0-9a-zA-Z_]{1,16})*)((/[0-9a-zA-Z_]{1,16})?)$} && $2.length >= 1 && $2.length <= 32 \n puts \"YES\"\nelse\n puts \"NO\"\nend"}, {"source_code": "s = gets.strip\nunless s =~ %r{^([0-9a-zA-Z_]{1,16})@([0-9a-zA-Z_]{1,16}(\\.[0-9a-zA-Z_]{1,16})*)((/[0-9a-zA-Z_]{1,16})?)$}\n puts \"NO\"\n exit 0\nend\n#puts $1, $2, $3, $4\nusername, hostname, resource = $1, $2, $4\n\nif hostname.length >= 1 && hostname.length <= 32\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "puts(if gets.strip =~ %r{^([0-9a-zA-Z_]{1,16})@([0-9a-zA-Z_]{1,16}(\\.[0-9a-zA-Z_]{1,16})*)((/[0-9a-zA-Z_]{1,16})?)$} && $2.length <= 32\n\"YES\" else \"NO\" end)"}, {"source_code": "s = gets.strip\nif !s.include?( '/' )\n\ts += \"/a\"\nend\nputs /^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*\\/\\w{1,16}$/ =~ s && s.index( \"/\" ) - s.index( \"@\" ) - 1 <= 32 ? \"YES\" : \"NO\"\n"}, {"source_code": "def user_ok(s)\n s.length >= 1 && s.length <= 16 && s =~ /^[0-9a-zA-Z_]*$/\nend\n\ndef host_ok(s)\n# puts s\n if s.length < 1 || s.length > 32\n return false\n end \n if s[0] == \".\" || s[-1] == \".\"\n return false\n end\n for st in s.split(\".\") do\n# puts st\n unless user_ok(st)\n return false\n end\n end\n true\nend\n\ns = gets.strip\nok = true\nunless s =~ %r{^([^@]+)@([^/]+)((/[0-9a-zA-Z_]*)?)$}\n puts \"NO\"\n exit 0\nend\nusername, hostname, resource = $1, $2, $3\nunless user_ok(username) && host_ok(hostname)\n ok = false\nend\n\nif resource.length == 1 || resource.length > 17\n ok = false\nend\n\nif ok\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "puts gets=~/^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?\\n$/?\"YES\":\"NO\"\n"}, {"source_code": "puts gets=~/^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?\\n$/?\"YES\":\"NO\"\n"}, {"source_code": "puts gets=~/^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*(\\/\\w{1,16})?\\n$/?\"YES\":\"NO\"\n"}, {"source_code": "def del(s)\n return s.delete(\"abcdefghijklmnopqrstuvwxyz_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\")\nend\n\ns = gets.chomp\nresult = \"YES\"\nif (k = s.index(\"@\")) then\n if s[0...k].size < 1 then\n result = \"NO\"\n end\n user = del(s[0...k])\n if user.size > 0 then\n result = \"NO\"\n end\n if (n = s.index(\"/\")) then\n host = s[k+1...n]\n resource = s[n+1..-1]\n else\n host = s[k+1..-1]\n resource = nil\n end\n if host.size < 1 then\n result = \"NO\"\n end\n k = -1\n while (m = host.index(\".\", k+1)) do\n if m-k > 17 || m-k < 2 then\n result = \"NO\"\n end\n k = m\n end\n host = del(host).delete(\".\")\n if host.size > 0 then\n result = \"NO\"\n end\n\n if resource then\n if s[n-1] == \".\" then\n result = \"NO\"\n end\n if resource.size > 16 || resource.size < 1 then \n result = \"NO\"\n else\n resource = del(resource)\n if resource.size > 0 then\n result = \"NO\"\n end\n end\n else\n if s[-1] == \".\" then\n result = \"NO\"\n end\n end\nelse\n result = \"NO\"\nend\n\nputs result"}], "negative_code": [{"source_code": "def del(s)\n return s.delete(\"abcdefghijklmnopqrstuvwxyz_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\")\nend\n\ns = gets.chomp\nresult = \"YES\"\nif (k = s.index(\"@\")) then\n if s[0...k].size < 1 then\n result = \"NO\"\n end\n user = del(s[0...k])\n if user.size > 0 then\n result = \"NO\"\n end\n if (n = s.index(\"/\")) then\n host = s[k+1...n]\n resource = s[n+1..-1]\n else\n host = s[k+1..-1]\n resource = nil\n end\n if host.size < 1 then\n result = \"NO\"\n end\n k = -1\n while (m = host.index(\".\", k+1)) do\n if m-k > 16 then\n result = \"NO\"\n end\n k = m\n end\n host = del(host).delete(\".\")\n if host.size > 0 then\n result = \"NO\"\n end\n\n if resource then\n if s[n] == \".\" then\n result = \"NO\"\n end\n if resource.size > 16 then \n result = \"NO\"\n else\n resource = del(resource)\n if resource.size > 0 then\n result = \"NO\"\n end\n end\n else\n if s[-1] == \".\" then\n result = \"NO\"\n end\n end\nelse\n result = \"NO\"\nend\n\nputs result"}, {"source_code": "def del(s)\n return s.delete(\"abcdefghijklmnopqrstuvwxyz_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\")\nend\n\ns = gets.chomp\nresult = \"YES\"\nif (k = s.index(\"@\")) then\n if s[0...k].size < 1 then\n result = \"NO\"\n end\n user = del(s[0...k])\n if user.size > 0 then\n result = \"NO\"\n end\n if (n = s.index(\"/\")) then\n host = s[k+1...n]\n resource = s[n+1..-1]\n else\n host = s[k+1..-1]\n resource = nil\n end\n if host.size < 1 then\n result = \"NO\"\n end\n k = -1\n while (m = host.index(\".\", k+1)) do\n if m-k > 16 then\n result = \"NO\"\n end\n k = m\n end\n host = del(host).delete(\".\")\n if host.size > 0 then\n result = \"NO\"\n end\n\n if resource then\n if resource.size > 16 then \n result = \"NO\"\n else\n resource = del(resource)\n if resource.size > 0 then\n result = \"NO\"\n end\n end\n end\nelse\n result = \"NO\"\nend\n\nputs result"}, {"source_code": "def del(s)\n return s.delete(\"abcdefghijklmnopqrstuvwxyz_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\")\nend\n\ns = gets.chomp\nresult = \"YES\"\nif (k = s.index(\"@\")) then\n if s[0...k].size < 1 then\n result = \"NO\"\n end\n user = del(s[0...k])\n if user.size > 0 then\n result = \"NO\"\n end\n if (n = s.index(\"/\")) then\n host = s[k+1...n]\n resource = s[n+1..-1]\n else\n host = s[k+1..-1]\n resource = nil\n end\n if host.size < 1 then\n result = \"NO\"\n end\n k = -1\n while (m = host.index(\".\", k+1)) do\n if m-k > 17 || m-k < 2 then\n result = \"NO\"\n end\n k = m\n end\n host = del(host).delete(\".\")\n if host.size > 0 then\n result = \"NO\"\n end\n\n if resource then\n if s[n] == \".\" then\n result = \"NO\"\n end\n if resource.size > 16 then \n result = \"NO\"\n else\n resource = del(resource)\n if resource.size > 0 then\n result = \"NO\"\n end\n end\n else\n if s[-1] == \".\" then\n result = \"NO\"\n end\n end\nelse\n result = \"NO\"\nend\n\nputs result"}, {"source_code": "a=\"YES\"\ns=gets.chomp\nunless s=~/^(\\w{1,16})@([\\w\\.]{1,32})\\/(\\w{1,16})$/ || s=~/^(\\w{1,16})@([\\w\\.]{1,32})$/ then a=\"NO\"\nelse $2.split(\".\").each{|s|if s.length>16 then a=\"NO\" end}\nend\nputs a"}, {"source_code": "puts gets =~ /^[\\w_]{1,16}@[\\w_.]{1,32}(\\/[\\w_]{1,16})?$/ && $_ != /[@.]\\.|\\.$|\\.\\// ? :YES : :NO\n"}, {"source_code": "r = /[\\w_]{1,16}/\nputs gets =~ /^#{r}@(#{r}(.#{r})*)(\\/#{r})?$/ && $1.size <= 32 ? :YES : :NO\n"}, {"source_code": "def valid_word?(s)\n s =~ /^[_a-zA-Z0-9_]{1,16}$/\nend\n\ndef solve(s)\n a = s.split('@')\n return false unless a.size == 2\n return false unless valid_word? a.shift\n a = a.first\n return false if a[-1..-1] == '/'\n a = a.split('/')\n return false if a.size > 2\n return false if a.size == 2 && !valid_word?(a[1])\n a = a[0]\n return false unless a.size <= 32\n return false if a[-1..-1] == '.'\n a = a.split('.')\n return a.all? { |w| valid_word? w }\nend\n\ns = gets.chomp\n#s = 'mike@codeforces.com'\n#s = 'john.smith@codeforces.ru/contest.icpc/12'\n#s = '007@en.codeforces.com/contest'\nputs solve(s) ? 'YES' : 'NO'"}, {"source_code": "puts gets =~ /^\\w{1,16}@\\w{1,16}(.\\w{1,16}){1,32}(\\/\\w{1,16})*$/ ? \"YES\" : \"NO\"\n"}, {"source_code": "puts gets =~ /^\\w{1,16}@\\w{1,16}.\\w{1,16}(\\/\\w{1,16})$/ ? \"YES\" : \"NO\"\n"}, {"source_code": "puts gets =~ /^\\w{1,16}@\\w{1,16}(\\.\\w{1,16}){1,32}(\\/\\w{1,16})*$/ ? \"YES\" : \"NO\"\n"}, {"source_code": "s = gets.strip\nunless s =~ %r{([0-9a-zA-Z_]{1,16})@([0-9a-zA-Z_]{1,16}(\\.[0-9a-zA-Z_]{1,16})*)((/[0-9a-zA-Z_]{1,16})?)$}\n puts \"NO\"\n exit 0\nend\n#puts $1, $2, $3, $4\nusername, hostname, resource = $1, $2, $4\n\nif hostname.length >= 1 && hostname.length <= 32\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "if gets.strip =~ %r{^([0-9a-zA-Z_]{1,16})@([0-9a-zA-Z_]{1,16}(\\.[0-9a-zA-Z_]{1,16})*)((/[0-9a-zA-Z_]{1,16})?)$} && $4.length >= 1 && $4.length <= 32 \n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}, {"source_code": "s = gets.strip\nif !s.include?( '/' )\n\ts += \"/a\"\nend\nputs /\\w{1,16}@\\w{1,16}(.\\w{1,16})*\\/\\w{1,16}/ =~ s && s.index( \"/\" ) - s.index( \"@\" ) + 1 <= 32 ? \"YES\" : \"NO\"\n"}, {"source_code": "s = gets\nif !s.include?( '/' )\n\ts += \"/a\"\nend\n\nputs /\\w{1,16}@\\w{1,16}(.\\w{1,16})*\\/\\w{1,16}/ =~ s && s.index( \"/\" ) - s.index( \"@\" ) + 1 <= 32 ? \"YES\" : \"NO\"\n"}, {"source_code": "s = gets.strip\nif !s.include?( '/' )\n\ts += \"/a\"\nend\nputs /^\\w{1,16}@\\w{1,16}(\\.\\w{1,16})*\\/\\w{1,16}$/ =~ s && s.index( \"/\" ) - s.index( \"@\" ) + 1 <= 32 ? \"YES\" : \"NO\"\n"}, {"source_code": "s = gets\nif !s.include?( '/' )\n\ts += \"/a\"\nend\nputs /\\w{1,16}@\\w{1,16}(.\\w{1,16})*\\/\\w{1,16}/ =~ s && s.index( \"/\" ) - s.index( \"@\" ) + 1 <= 32 ? \"YES\" : \"NO\"\n"}, {"source_code": "def del(s)\n return s.delete(\"abcdefghijklmnopqrstuvwxyz_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\")\nend\n\ns = gets.chomp\nresult = \"YES\"\nk = s.index(\"@\")\nuser = del(s[0...k])\nif user.size > 0 then\n result = \"NO\"\nend\nif (n = s.index(\"/\")) then\n host = s[k+1...n]\n resource = s[n+1..-1]\nelse\n host = s[k+1..-1]\n resource = nil\nend\nk = -1\nwhile (m = host.index(\".\", k+1)) do\n if m-k > 16 then\n result = \"NO\"\n end\n k = m\nend\nhost = del(host).delete(\".\")\nif host.size > 0 then\n result = \"NO\"\nend\n\nif resource then\n if resource.size > 16 then \n result = \"NO\"\n else\n resource = del(resource)\n if resource.size > 0 then\n result = \"NO\"\n end\n end\nend\n\nputs result"}, {"source_code": "def del(s)\n return s.delete(\"abcdefghijklmnopqrstuvwxyz_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\")\nend\n\ns = gets.chomp\nresult = \"YES\"\nif (k = s.index(\"@\")) then\n if s[0...k].size < 1 then\n result = \"NO\"\n end\n user = del(s[0...k])\n if user.size > 0 then\n result = \"NO\"\n end\n if (n = s.index(\"/\")) then\n host = s[k+1...n]\n resource = s[n+1..-1]\n else\n host = s[k+1..-1]\n resource = nil\n end\n if host.size < 1 then\n result = \"NO\"\n end\n k = -1\n while (m = host.index(\".\", k+1)) do\n if m-k > 17 || m-k < 2 then\n result = \"NO\"\n end\n k = m\n end\n host = del(host).delete(\".\")\n if host.size > 0 then\n result = \"NO\"\n end\n\n if resource then\n if s[n-1] == \".\" then\n result = \"NO\"\n end\n if resource.size > 16 then \n result = \"NO\"\n else\n resource = del(resource)\n if resource.size > 0 then\n result = \"NO\"\n end\n end\n else\n if s[-1] == \".\" then\n result = \"NO\"\n end\n end\nelse\n result = \"NO\"\nend\n\nputs result"}], "src_uid": "2a68157e327f92415067f127feb31e24"} {"source_code": "a,b,c,d=gets.split.map &:to_f;p (b-a)/(c+d)", "positive_code": [{"source_code": "a=gets.split.map(&:to_i)\nputs (a[1]-a[0]).to_f/(a[2]+a[3])"}, {"source_code": "d,l,v,w=gets.split.map &:to_f\nputs \"%.20f\" % ((l - d) / (v + w))\n"}, {"source_code": "d,l,v1,v2 = gets.chomp.split(' ').map(&:to_i)\nputs((l-d).to_f/(v1+v2))\n"}, {"source_code": "d, l, v1, v2 = gets.split(' ').map &:to_i\n\n\nputs (l - d).to_f/(v1 + v2)"}, {"source_code": "a=gets.split.map(&:to_i);p (a[1]-a[0])*1.0/(a[2]+a[3])\n"}, {"source_code": "a,b,c,d=gets.split.map &:to_f;p (b-a)/(c+d)\n"}, {"source_code": "d, L, v1, v2 = gets.chomp.split(' ').map(&:to_f)\n\nres = (L - d) / (v1 + v2)\np res"}, {"source_code": "class Solver\n\tdef main\n\t\td, l, v1, v2 = gets.split.map { |x| x.to_i }\n\t\tputs format(\"%.8f\", (l - d).to_f / (v1 + v2).to_f)\n\tend\nend\nSolver.new.main"}, {"source_code": "a,b,c,d=gets.split.map &:to_f;p (b-a)/(c+d)\n"}, {"source_code": "a = gets.split(\" \").map(&:to_i)\n\np (a[1]-a[0]).to_f / (a[2]+a[3])\n"}, {"source_code": "d,l,v1,v2=gets.split.map{|e| e.to_f}\nputs (l-d)/(v1+v2)"}, {"source_code": "d, l, v1, v2 = gets.chomp.split.map(&:to_i)\n\nputs (l - d) / (v1 + v2).to_f\n"}], "negative_code": [], "src_uid": "f34f3f974a21144b9f6e8615c41830f5"} {"source_code": "require 'set'\n\n$set=Set.new\n$n=gets.to_i\n\ndef dfs num,x,y\n if (1..$n)===num\n $set< 2\n# # \tlist = [9,90]\n# # \tx = 81\n# # \t(l - 2).times do |i|\n# # \t\tx *= 2\n# # \tend\n# # \tx += 9\n# # else\n# # \tputs n\n# # end\n\n\n# # def dfs(num) #// run it as dfs(0)\n# # @ans += 1 if (num > 0 && num <= @n) \n# # return if (num >= 10**8) \n# # (0..9).each do |a|\n# # \tnumber = num*10+a\n# # if number >0\n# # if number.to_s.split(\"\").uniq.length <= 2\n# # dfs(number)\n# # end\n# # end\n# # end\n# # end\n# # require 'Set'\n# def dfs(num) #// run it as dfs(0)\n# (1..@n).each do |a|\n# \t return if (a >= 10**8) \n# \t if @n > 100000\n# \t \t@ans += 1\n# \t else\n# \t if a.to_s.chars.to_a.uniq.length <= 2\n# \t \t@ans += 1\n# \t end\n# \t end\n# end\n# end\n\n# @n = gets.to_i\n# @ans = 0\n# dfs(0)\n# puts @ans\n\nrequire 'Set'\n\ndef dfs(x,y,num,cnt=false)\n\treturn if num > @n || (num == 0 && !cnt)\n\t@s << num if num > 0\n\tdfs(x,y,num * 10 + x)\n\tdfs(x,y,num * 10 + y)\t\nend\n\n@n = gets.to_i\n@s = Set.new\n(0..9).each do |i|\n\t((i+1)..9).each do |j|\n\t\tdfs(i,j,0,true)\n\tend\nend\nputs @s.length"}], "negative_code": [], "src_uid": "0f7f10557602c8c2f2eb80762709ffc4"} {"source_code": "n=[(gets.to_i+45)%360-1,0].max;p n/90\n", "positive_code": [{"source_code": "n=[(gets.to_i+45)%360-1,0].max;p n/90"}, {"source_code": "n=[(gets.to_i+45)%360-1,0].max;p n/90"}, {"source_code": "n=[(gets.to_i+45)%360-1,0].max;p n/90\n"}], "negative_code": [], "src_uid": "509db9cb6156b692557ba874a09f150e"} {"source_code": "# t = gets.to_i\n# t.times do\nn, m = gets.split.map(&:to_i)\ncount = 0\n(1..n).each do |x|\n\ty1 = 5 - x % 5\n\tk = ((m - y1)/5).to_i\n\t# y2 = y1 + 5* k\n\tcount += k+1\nend\nputs count", "positive_code": [{"source_code": "n, m = gets.strip.split.map(&:to_i)\nmod = 5\nputs (0...mod).map { |x| \n\t\t( ( n - x ) / mod + 1 - ( x == 0 ? 1 : 0 ) ) * \n\t\t( ( m - (mod-x) % mod ) / mod + 1 - ( x == 0 ? 1 : 0 ) ) \n\t}.reduce(0, :+)"}, {"source_code": "n, m = gets.chomp.split(' ').map(&:to_i)\nx = 1\nans = 0\nuntil x > n\n\tans += ((m + x) / 5) - (x / 5)\n\tx += 1\nend\n\nputs ans"}, {"source_code": "n, m = gets.split.map( &:to_i )\n\nres = 0\nfor i in 1...5 do\n\tres += ( n / 5 + ( i <= n % 5 ? 1 : 0 ) ) * ( m / 5 + ( 5 - i <= m % 5 ? 1 : 0 ) )\nend\nres += ( n / 5 ) * ( m / 5 )\n\np res\n"}, {"source_code": "n,m=gets.split.map(&:to_i)\np (1..n).reduce(0){|s,i|s+(m+i%5)/5}"}, {"source_code": "n, m = gets.strip.split.map(&:to_i)\ncount = Array.new(1e6 + 1, 0)\nans = 0\n(1..n).each do |i|\n count[i % 5] += 1\nend\n(1..m).each do |i|\n ans += count[(5 - i % 5) % 5]\nend\nputs ans\n"}, {"source_code": "x,y=gets.split.map{|e| e.to_i}\nx,y=[x,y].min,[x,y].max\nz=x+y\nans=0\n4.step(z,5){|i|\n\tif i>y then\n\t\tans+=(x-(i-y))\n\telse\n\t\tans+=[x,i].min\n\tend\n}\nputs ans\n\n"}, {"source_code": "n, m = gets.split(' ').map(&:to_i)\nn_full, n_rest = n.divmod 5\nm_full, m_rest = m.divmod 5\n\nputs (1..4).map { |i| (n_full + (n_rest >= i ? 1 : 0)) * (m_full + (m_rest >= (5-i) ? 1 : 0)) }.reduce(:+) + n_full * m_full\n"}, {"source_code": "# coding: utf-8\n\nn, m = gets.split.map(&:to_i)\n\nn = [n/5, (n-1)/5 + 1, (n-2)/5 + 1, (n-3)/5 + 1, (n-4)/5 + 1]\nm = [m/5, (m-4)/5 + 1, (m-3)/5 + 1, (m-2)/5 + 1, (m-1)/5 + 1]\n# n = 6, m = 12\n# n [5] [1, 6] [2] [3] [4] \n# m [5, 10] [1, 6, 11] [2, 7, 12] [3, 8] [4, 9]\n# 2 + 4 + 2 + 3 + 3 = 14\nputs n.zip(m).map { |a| a[0] * a[1] }.sum"}, {"source_code": "n, m = gets.chomp.split.map(&:to_i)\n\nans = 0\nfor i in 0..4\n x = n / 5\n x += 1 if 0 < i && i <= n % 5\n y = m / 5\n y += 1 if i < 5 && 5 - i <= m % 5\n ans += x * y\nend\n\nputs ans\n"}, {"source_code": "def get_div_5(n, m)\n lasts = [[1, 4], [2, 4], [3, 4], [3, 3], [4, 4]]\n l2 = n * m / 5.0\n\n if (lasts.include?([n % 5, m % 5]) || lasts.include?([m % 5, n % 5])) && l2 % 1 != 0\n l2 += 1\n end\n\n l2.floor\nend\n\n\nb = gets\n\nb = b.strip.split(\" \").map {|v| v.to_i}\nputs get_div_5(b[0], b[1])\n"}, {"source_code": "n=gets.chomp.to_s.split(\" \")\nn,m=n[0].to_s.to_i,n[1].to_s.to_i\nres=0\n1.upto(n) do |x| # 5-0\n # 4-1 3-2 2-3 1-4\n res+=(m+x%5)/5\n\nend\nprint res\n"}, {"source_code": "n,m=gets.split.map(&:to_i)\np (1..n).reduce(0){|s,i|s+(m+i%5)/5}"}], "negative_code": [], "src_uid": "df0879635b59e141c839d9599abd77d2"} {"source_code": "class Solver\n def solve(*a)\n p = a[0]\n t = a[1]\n\n moves = []\n while p != t && moves.size < 8\n #puts \"#{p} -> #{t}\"\n\n moves << navigate(p,t)\n end\n moves\n end\n\n def navigate(p,t)\n dx = dir(t[0].ord - p[0].ord)\n dy = dir(t[1].ord - p[1].ord)\n\n p[0] = (p[0].ord + dx).chr\n p[1] = (p[1].ord + dy).chr\n\n ['L','','R'][dx+1] + ['D','','U'][dy+1]\n end\n\n def dir(d)\n return 0 if d == 0\n return 1 if d > 0\n return -1\n end\nend\n\nif __FILE__==$0\n a = gets.chomp\n b = gets.chomp\n s = Solver.new\n sol = s.solve(a,b)\n puts sol.count\n sol.each do |s|\n puts s\n end\nend", "positive_code": [{"source_code": "s = gets\nt = gets\nsx = s[0..0].ord\nsy = s[1..1].to_i\ntx = t[0..0].ord\nty = t[1..1].to_i\ndx = sx-tx\ndy = sy-ty\nstep = [dx.abs,dy.abs].max\nputs step\nstep.times do\n if dx<0\n print \"R\"\n dx += 1\n elsif dx>0\n print \"L\"\n dx -= 1\n end\n if dy<0\n print \"U\"\n dy += 1\n elsif dy>0\n print \"D\"\n dy -= 1\n end\n puts\nend\n"}, {"source_code": "input = gets\nking = [input[0].ord - 96, input[1].ord - 48]\ninput = gets\ntarget = [input[0].ord - 96, input[1].ord - 48]\n\npath = Array.new\n\nwhile king != target\n s = String.new\n if king[0] < target[0]\n s << \"R\"\n king[0] += 1\n elsif king[0] > target[0]\n s << \"L\"\n king[0] -= 1\n end\n if king[1] < target[1]\n s << \"U\"\n king[1] += 1\n elsif king[1] > target[1]\n s << \"D\"\n king[1] -= 1\n end\n path.concat([s])\nend\n\nputs path.count\npath.each {|x| puts x}"}, {"source_code": "s, t = gets.to_s, gets.to_s\nrow = t[0].ord - s[0].ord\ncol = t[1].ord - s[1].ord\nif row.abs > col.abs\n\tputs row.abs\n\trc = 1\n\tdiff = (row.abs - col.abs).to_i\n\tsqr = row.abs - diff\nelse\n\tputs col.abs\n\trc = 0\n\tdiff = (col.abs - row.abs).to_i\n\tsqr = col.abs - diff\nend\nif row >= 0 and col >= 0\n\tsqr.times{\n\t\tputs \"RU\"\n\t}\n\tif rc == 1\n\t\tdiff.times{\n\t\t\tputs \"R\"\n\t\t}\n\telse\n\t\tdiff.times{\n\t\t\tputs \"U\"\n\t\t}\n\tend\nelsif row <= 0 and col >= 0\n\tsqr.times{\n\t\tputs \"LU\"\n\t}\n\tif rc == 1\n\t\tdiff.times{\n\t\t\tputs \"L\"\n\t\t}\n\telse\n\t\tdiff.times{\n\t\t\tputs \"U\"\n\t\t}\n\tend\nelsif row <= 0 and col <= 0\n\tsqr.times{\n\t\tputs \"LD\"\n\t}\n\tif rc == 1\n\t\tdiff.times{\n\t\t\tputs \"L\"\n\t\t}\n\telse\n\t\tdiff.times{\n\t\t\tputs \"D\"\n\t\t}\n\tend\nelse\n\tsqr.times{\n\t\tputs \"RD\"\n\t}\n\tif rc == 1\n\t\tdiff.times{\n\t\t\tputs \"R\"\n\t\t}\n\telse\n\t\tdiff.times{\n\t\t\tputs \"D\"\n\t\t}\n\tend\nend"}, {"source_code": "class King\n def initialize(s, t)\n @start = s\n @end = t\n end\n\n def get_path\n return 0 if @start == @end\n result = []\n horizontal = (@start[0] == @end[0])\n vertical = (@start[1] == @end[1])\n\n current = @start\n steps = 0\n until horizontal || vertical\n current = move_diag(current)\n horizontal = (current[0] == @end[0])\n vertical = (current[1] == @end[1])\n result << direction.join\n steps += 1\n end\n\n if vertical\n current_steps = (current[0].ord.to_i - @end[0].ord.to_i).abs\n result += [direction.first]*current_steps\n steps += current_steps\n elsif horizontal\n current_steps = (current[1].to_i - @end[1].to_i).abs\n result += [direction.last]*current_steps\n steps += current_steps\n end\n result.unshift(steps)\n\n\n # if @start == @end\n # result << 0\n # elsif horizontal\n # result = [steps_x.abs] + [direction.last]*steps_x.abs\n # elsif vertical\n # result = [steps_y.abs] + [direction.first]*steps_y.abs\n # else\n # current = @start\n # steps = 0\n # until horizontal || vertical\n # current = move_diag(current)\n # horizontal = (current[0] == @end[0])\n # vertical = (current[1] == @end[1])\n # result << direction.join\n # steps += 1\n # end\n # end\n result\n end\n\n def move_diag(position)\n x_inc = steps_x == 0 ? 0 : steps_x/steps_x.abs\n y_inc = steps_y == 0 ? 0 : steps_y/steps_y.abs\n [(position[0].ord - y_inc).chr, (position[1].to_i - x_inc)].join\n end\n\n def direction\n [direction_y, direction_x]\n end\n\n def direction_x\n steps_x > 0 ? 'D' : 'U'\n end\n\n def direction_y\n steps_y > 0 ? 'L' : 'R'\n end\n\n def steps_x\n @start[1].to_i - @end[1].to_i\n end\n\n def steps_y\n @start[0].ord.to_i - @end[0].ord.to_i\n end\nend\n\ns, t = [gets.chomp, gets.chomp]\ngame = King.new(s, t)\nputs game.get_path\n"}, {"source_code": "a = gets.chomp\nb = gets.chomp\nx, y = a[0].ord-b[0].ord, a[1].to_i-b[1].to_i\nputs [x.abs, y.abs].max\ns = \"\"\nif x.abs > y.abs\n s = (x>0 ? \"L\" : \"R\")\nelse\n s = (y>0 ? \"D\" : \"U\")\nend\nprint (s+\"\\n\")*(x.abs-y.abs).abs\nif x > 0\n s = (y > 0 ? \"LD\" : \"LU\")\nelse\n s = (y > 0 ? \"RD\" : \"RU\")\nend\nprint (s+\"\\n\")*[x.abs, y.abs].min"}, {"source_code": "s=gets\n\nt=gets\n\nr=t[0].ord-s[0].ord\n\nc=t[1].hex-s[1].hex\n\na=[\"\"]*9\n\nf=lambda{|r,c|r.times{|i|a[i]+=c}}\n\nf.call(r,\"R\")\n\nf.call(-r,\"L\")\n\nf.call(c,\"U\")\n\nf.call(-c,\"D\")\n\na.select!{|i|i!=\"\"}\n\np a.size\n\nputs a"}, {"source_code": "include Math\na=0\n\"a\".each_byte do |n|\n a=n\nend\nmemo=gets.chomp!.scan(/./)\nsx=0\nmemo[0].each_byte do |n|\n sx=n-a+1\nend\nsy=memo[1].to_i\nex=0\nmemo=gets.chomp!.scan(/./)\nmemo[0].each_byte do |n|\n ex=n-a+1\nend\ney=memo[1].to_i\nxx=ex-sx\nyy=ey-sy\nhosu=[xx<0 ? -xx : xx,yy<0 ? -yy :yy].max\nputs hosu\nif xx >=0 && yy>=0\n if xx>=yy\n yy.times do\n puts \"RU\"\n end\n (xx-yy).times do\n puts \"R\"\n end\n else\n xx.times do\n puts \"RU\"\n end\n (yy-xx).times do\n puts \"U\"\n end\n end\nend\nif xx >=0 && yy<0\n yy=-yy\n if xx>=yy\n yy.times do\n puts \"RD\"\n end\n (xx-yy).times do\n puts \"R\"\n end\n else\n xx.times do\n puts \"RD\"\n end\n (yy-xx).times do\n puts \"D\"\n end\n end\nend\nif xx < 0 && yy >=0\n xx=-xx\n if xx>=yy\n yy.times do\n puts \"LU\"\n end\n (xx-yy).times do\n puts \"L\"\n end\n else\n xx.times do\n puts \"LU\"\n end\n (yy-xx).times do\n puts \"U\"\n end\n end\nend\nif xx <0 && yy<0\n xx=-xx\n yy=-yy\n if xx>=yy\n yy.times do\n puts \"LD\"\n end\n (xx-yy).times do\n puts \"L\"\n end\n else\n xx.times do\n puts \"LD\"\n end\n (yy-xx).times do\n puts \"D\"\n end\n end\nend\n"}, {"source_code": "s=gets.chomp.split(\"\")\nt=gets.chomp.split(\"\")\nvalu=1..8\nalph=('a' .. 'h')\nvalu=[*valu]\nalph=[*alph]\nvalu_hash={}\ni=0\nloop do\n\tbreak if i==8\n\tvalu_hash[alph[i]]=valu[i]\n\ti+=1\n end\ndir_arry=[] \nif valu_hash[s[0]]< valu_hash[t[0]]\n dir_arry[0]=\"R\"\nelsif valu_hash[s[0]]> valu_hash[t[0]] \n dir_arry[0]=\"L\"\nelse\n dir_arry[0]=0\nend\n \nif s[1].to_i< t[1].to_i\n dir_arry[1]=\"U\"\nelsif s[1].to_i> t[1].to_i \n dir_arry[1]=\"D\"\nelse\n dir_arry[1]=0\nend\n\nhmove=valu_hash[s[0]] - valu_hash[t[0]]\nif hmove<0\nhmove=hmove*(-1)\nend\nvmove=s[1].to_i-t[1].to_i\nif vmove<0\nvmove=vmove*(-1)\nend\n\nif hmove==0\n\tputs vmove\n\tvmove.times{puts dir_arry[1]}\nelsif vmove==0\n\tputs hmove\n\thmove.times{puts dir_arry[0] }\nelsif vmove==hmove\n\tputs hmove\n hmove.times{puts dir_arry[0]+dir_arry[1] }\nelsif hmove>vmove\n\tputs hmove\n\tvmove.times{puts dir_arry[0]+dir_arry[1] }\n\t(hmove-vmove).times {puts dir_arry[0]}\nelsif vmove>hmove\n\tputs vmove\n\thmove.times{puts dir_arry[0]+dir_arry[1] }\n\t(vmove-hmove).times{puts dir_arry[1]}\nend\t\n\t"}, {"source_code": "s1 = gets\ns2 = gets\ndst1 = s2[0].ord - s1[0].ord\ndst2 = s2[1].to_i - s1[1].to_i\n\nputs [dst2.abs, dst1.abs].max\nwhile dst2 != 0 or dst1 != 0 do\n if dst1 > 0 then\n printf \"R\"\n dst1 -= 1\n end\n if dst1 < 0 then\n printf \"L\"\n dst1 += 1\n end\n\n if dst2 > 0 then\n printf \"U\"\n dst2 -= 1\n end\n if dst2 < 0 then\n printf \"D\"\n dst2 += 1\n end\n puts\nend\n"}, {"source_code": "def get_path(src, dest)\n s_x, s_y = src.chars\n d_x, d_y = dest.chars\n path = []\n while s_x != d_x || s_y != d_y\n move = ''\n if (s_x > d_x)\n s_x = (s_x.ord - 1).chr\n move += 'L'\n elsif (s_x < d_x)\n s_x.next!\n move += 'R'\n end\n\n if (s_y > d_y)\n s_y = (s_y.ord - 1).chr\n move += 'D'\n elsif (s_y < d_y)\n s_y.next!\n move += 'U'\n end\n\n path << move\n end\n path\nend\n\nif __FILE__ == $0\n path = get_path(gets, gets)\n puts path.size\n path.each { |m| puts m }\nend\n"}, {"source_code": "s=gets.chomp.split(\"\")\nt=gets.chomp.split(\"\")\nvalu=1..8\nalph=('a' .. 'h')\nvalu=[*valu]\nalph=[*alph]\nvalu_hash={}\ni=0\nloop do\n\tbreak if i==8\n\tvalu_hash[alph[i]]=valu[i]\n\ti+=1\n end\ndir_arry=[] \nif valu_hash[s[0]]< valu_hash[t[0]]\n dir_arry[0]=\"R\"\nelsif valu_hash[s[0]]> valu_hash[t[0]] \n dir_arry[0]=\"L\"\nelse\n dir_arry[0]=0\nend\n \nif s[1].to_i< t[1].to_i\n dir_arry[1]=\"U\"\nelsif s[1].to_i> t[1].to_i \n dir_arry[1]=\"D\"\nelse\n dir_arry[1]=0\nend\n\nhmove=valu_hash[s[0]] - valu_hash[t[0]]\nif hmove<0\nhmove=hmove*(-1)\nend\nvmove=s[1].to_i-t[1].to_i\nif vmove<0\nvmove=vmove*(-1)\nend\n\nif hmove==0\n\tputs vmove\n\tvmove.times{puts dir_arry[1]}\nelsif vmove==0\n\tputs hmove\n\thmove.times{puts dir_arry[0] }\nelsif vmove==hmove\n\tputs hmove\n hmove.times{puts dir_arry[0]+dir_arry[1] }\nelsif hmove>vmove\n\tputs hmove\n\tvmove.times{puts dir_arry[0]+dir_arry[1] }\n\t(hmove-vmove).times {puts dir_arry[0]}\nelsif vmove>hmove\n\tputs vmove\n\thmove.times{puts dir_arry[0]+dir_arry[1] }\n\t(vmove-hmove).times{puts dir_arry[1]}\nend\t"}, {"source_code": "s=gets.chomp.split(\"\")\nt=gets.chomp.split(\"\")\nvalu=1..8\nalph=('a' .. 'h')\nvalu=[*valu]\nalph=[*alph]\nvalu_hash={}\ni=0\nloop do\n\tbreak if i==8\n\tvalu_hash[alph[i]]=valu[i]\n\ti+=1\n end\ndir_arry=[] \nif valu_hash[s[0]]< valu_hash[t[0]]\n dir_arry[0]=\"R\"\nelsif valu_hash[s[0]]> valu_hash[t[0]] \n dir_arry[0]=\"L\"\nelse\n dir_arry[0]=0\nend\n \nif s[1].to_i< t[1].to_i\n dir_arry[1]=\"U\"\nelsif s[1].to_i> t[1].to_i \n dir_arry[1]=\"D\"\nelse\n dir_arry[1]=0\nend\n\nhmove=valu_hash[s[0]] - valu_hash[t[0]]\nif hmove<0\nhmove=hmove*(-1)\nend\nvmove=s[1].to_i-t[1].to_i\nif vmove<0\nvmove=vmove*(-1)\nend\n\nif hmove==0\n\tputs vmove\n\tvmove.times{puts dir_arry[1]}\nelsif vmove==0\n\tputs hmove\n\thmove.times{puts dir_arry[0] }\nelsif vmove==hmove\n\tputs hmove\n hmove.times{puts dir_arry[0]+dir_arry[1] }\nelsif hmove>vmove\n\tputs hmove\n\tvmove.times{puts dir_arry[0]+dir_arry[1] }\n\t(hmove-vmove).times {puts dir_arry[0]}\nelsif vmove>hmove\n\tputs vmove\n\thmove.times{puts dir_arry[0]+dir_arry[1] }\n\t(vmove-hmove).times{puts dir_arry[1]}\nend\t\n\t\t\n\n\n\n\n\n\n\n\n\n "}, {"source_code": "start_point = gets.chomp\nend_point = gets.chomp\n\ncharacter_start_point = start_point[0]\nnumber_start_point = start_point[1].to_i\n\ncharacter_end_point = end_point[0]\nnumber_end_point = end_point[1].to_i\n\nvertical_moves_count = (number_start_point-number_end_point).abs\nvertical_moves_character = number_start_point > number_end_point ? 'D' : 'U'\n\nhorizontal_moves_count = (character_start_point.ord - character_end_point.ord).abs\nhorizontal_moves_character = character_start_point.ord < character_end_point.ord ? 'R' : 'L'\n\nmax_steps = vertical_moves_count > horizontal_moves_count ? vertical_moves_count : horizontal_moves_count\n\nputs max_steps\n\nwhile max_steps > 0\n print horizontal_moves_character if horizontal_moves_count > 0\n print vertical_moves_character if vertical_moves_count > 0\n puts\n horizontal_moves_count -= 1\n vertical_moves_count -= 1\n max_steps -= 1\nend\n"}, {"source_code": "def f(x,y,gx,gy)\n\tif x==gx && y==gy then\n\t\treturn \"\"\n\telse\n\t\tres=\"\"\n\t\tx1=x\n\t\ty1=y\n\t\tif xgx\n\t\t\tx1=x-1\n\t\t\tres+=\"L\"\n\t\tend\n\t\tif ygy then\n\t\t\ty1=y-1\n\t\t\tres+=\"D\"\n\t\tend\n\t\treturn res+\"\\n\"+f(x1,y1,gx,gy)\n\tend\n\t\nend\n\n\nh=\tHash[\"a\",1,\"b\",2,\"c\",3,\"d\",4,\n\t\t \"e\",5,\"f\",6,\"g\",7,\"h\",8]\n\ns1=gets.chomp\ns2=gets.chomp\nif s1==s2 then\n\tputs \"0\\n\"\nelse\n\tx=f(h[s1[0]],s1[1].to_i,h[s2[0]],s2[1].to_i).split()\n\tputs x.size\n\tputs x*\"\\n\"\nend\n\n"}, {"source_code": "s=gets\nt=gets\nr=t[0].ord-s[0].ord\nc=t[1].hex-s[1].hex\na=[\"\"]*9\nf=lambda{|r,c|r.times{|i|a[i]+=c}}\nf.call(r,\"R\")\nf.call(-r,\"L\")\nf.call(c,\"U\")\nf.call(-c,\"D\")\na.select!{|i|i!=\"\"}\np a.size\nputs a"}, {"source_code": "s=gets\nt=gets\nr=t[0].ord-s[0].ord\nc=t[1].hex-s[1].hex\na=[\"\"]*9\nf=lambda{|r,c|r.times{|i|a[i]+=c}}\nf.call(r,\"R\")\nf.call(-r,\"L\")\nf.call(c,\"U\")\nf.call(-c,\"D\")\na.select!{|i|i!=\"\"}\np a.size\nputs a"}, {"source_code": "start = gets().chomp!\nfinish = gets().chomp!\nLETTERS = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"]\nh_distance, v_distance = [LETTERS.index(finish[0,1]) - LETTERS.index(start[0,1]), finish[1,1].to_i - start[1,1].to_i]\nmoves = Array.new(7){\"\"}\nh_distance.abs().times {\n|i|\n h_distance > 0 ? moves[i] << \"R\" : moves[i] << \"L\"\n}\nv_distance.abs().times {\n|i|\n v_distance > 0 ? moves[i] << \"U\" : moves[i] << \"D\"\n}\nmoves = moves.select(){|elem| elem != \"\"}\nputs moves.length, moves"}, {"source_code": "start = gets().chomp!\nfinish = gets().chomp!\nLETTERS = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"]\nh_distance = LETTERS.index(finish[0,1]) - LETTERS.index(start[0,1])\nv_distance = finish[1,1].to_i - start[1,1].to_i\nmoves = Array.new(7){\"\"}\nh_distance.abs().times {\n|i|\n h_distance > 0 ? moves[i] << \"R\" : moves[i] << \"L\"\n}\nv_distance.abs().times {\n|i|\n v_distance > 0 ? moves[i] << \"U\" : moves[i] << \"D\"\n}\nmoves = moves.select(){|elem| elem != \"\"}\nputs moves.length, moves"}, {"source_code": "def num(x)\n if x == \"a\"\n return 1\n elsif x == \"b\"\n return 2\n elsif x == \"c\"\n return 3\n elsif x == \"d\"\n return 4\n elsif x == \"e\"\n return 5\n elsif x == \"f\"\n return 6\n elsif x == \"g\"\n return 7\n else \n return 8\n end\nend\n\ndef simple(h,v)\n step = []\n if h > 0 then\n step += [\"R\"]*h\n elsif h < 0 then\n step += [\"L\"]*h.abs\n elsif v > 0\n step += [\"U\"]*v\n elsif v < 0\n step += [\"D\"]*v.abs\n end\n return step\nend\n\nk = gets.chomp\nt = gets.chomp\n\nstep = []\n\nh = num(t[0]) - num(k[0])\nv = t[1].to_i - k[1].to_i\n\nd = (0-v).abs < (0-h).abs ? v : h\n\nif d != 0 then\n if h == d then\n if h > 0 && v > 0 then\n step += [\"RU\"]*h\n elsif h > 0 && v < 0 then\n step += [\"RD\"]*h\n elsif h < 0 && v > 0 then\n step += [\"LU\"]*h.abs\n else\n step += [\"LD\"]*h.abs\n end\n if v > 0 then\n v -= h.abs\n else\n v += h.abs\n end\n h = 0\n else\n if h > 0 && v > 0 then\n step += [\"RU\"]*v\n elsif h > 0 && v < 0 then\n step += [\"RD\"]*v.abs\n elsif h < 0 && v > 0 then\n step += [\"LU\"]*v\n else\n step += [\"LD\"]*v.abs\n end\n if h > 0 then\n h -= v.abs\n else\n h += v.abs\n end\n v = 0\n end\nend\n\nstep += simple(h,v)\n\nputs step.size\nstep.size.times do |i|\n puts step[i]\nend"}, {"source_code": "s,t = readlines.join.split\nsx,sy = s[0].ord - 'a'.ord, s[1].to_i-1\ngx,gy = t[0].ord - 'a'.ord, t[1].to_i-1\na=[\"\"]*9\nf = lambda{|r,c| r.times{|i| a[i] += c}}\nf.call(gx-sx,'R')\nf.call(sx-gx,'L')\nf.call(sy-gy,'D')\nf.call(gy-sy,'U')\na.select!{|i| i != \"\"}\nputs a.size\nputs a\n"}, {"source_code": "# require 'pry-byebug'\nfile = File.exist?('in.in') ? File.new('in.in','r') : STDIN\n\nDX = [0, 1, 0, -1, 1, -1, 1, -1]\nDY = [1, 0, -1, 0, 1, -1, -1, 1]\nMOV = [\"R\", \"D\", \"L\", \"U\", \"RD\", \"LU\", \"LD\", \"RU\"]\n\ndef inside?(i, j, grid)\n i>=0 && i<= grid.size-1 && j>=0 && j <=grid[0].size-1\nend\n\nmap = {\"a\"=> 0, \"b\"=> 1, \"c\"=> 2, \"d\"=> 3, \"e\"=> 4,\"f\"=> 5, \"g\"=> 6, \"h\" => 7}\n\ns2,s1 = file.gets.chomp.split('')\nt2,t1 = file.gets.chomp.split('')\n\ns1 = (s1.to_i-1-7).abs\ns2 = map[s2]\nt1 = (t1.to_i-1-7).abs\nt2 = map[t2]\n\n# puts \"#{s1}#{s2}\"\n# puts \"#{t1}#{t2}\"\n\n\ngrid = Array.new(8) { Array.new(8) }\ndist = Array.new(8) { Array.new(8, 100) }\nqueue = [[s1, s2]]\ndist[s1][s2]=0\ngrid[s1][s2]=[]\n\nwhile(queue.size != 0)\n x, y = queue.shift\n 8.times do |i|\n new_x = x+DX[i]\n new_y = y+DY[i]\n if inside?(new_x, new_y, grid) && dist[new_x][new_y]==100\n\n if dist[x][y]+1 < dist[new_x][new_y]\n dist[new_x][new_y] = dist[x][y]+1\n grid[new_x][new_y] = grid[x][y] + [MOV[i]]\n end\n\n # dist[new_x][new_y] = [dist[new_x][new_y],dist[x][y]+1].min\n break if new_x == t1 && new_y == t2\n # binding.pry if dist[new_x][new_y] == 7\n queue << [new_x, new_y]\n end\n end\nend\nputs dist[t1][t2]\ngrid[t1][t2].each do |e|\n puts e\nend"}, {"source_code": "s,t = readlines.join.split\nsx,sy = s[0].ord - 'a'.ord, s[1].to_i-1\ngx,gy = t[0].ord - 'a'.ord, t[1].to_i-1\n\ndx = (sx-gx).abs\ndy = (sy-gy).abs\nxchar = sx < gx ? 'R' : 'L'\nychar = sy < gy ? 'U' : 'D'\n\nans = []\ncnt = 0\nwhile dx > 0 && dy > 0\n ans << (xchar+ychar)\n dx -= 1\n dy -= 1\nend\n\nwhile dx > 0\n ans << xchar\n dx -= 1\nend\n\nwhile dy > 0\n ans << ychar\n dy -= 1\nend\n\nputs ans.size\nputs ans\n"}, {"source_code": "start = gets\nstart_x = start[0].ord - 97\nstart_y = start[1].to_i - 1\n\nfinish = gets\nfinish_x = finish[0].ord - 97\nfinish_y = finish[1].to_i - 1\n\nresult = []\n\nif start_x < finish_x\n\t# go right\n\t(finish_x - start_x).times do\n\t\tresult << [\"R\"]\n\tend\nelse\n\t# go left\n\t(start_x - finish_x).times do\n\t\tresult << [\"L\"]\n\tend\nend\n\nif start_y < finish_y\n\t# go up\n\t(finish_y - start_y).times do |index|\n\t\tif result[index].nil?\n\t\t\tresult << [\"U\"]\n\t\telse \n\t\t\tresult[index][0]<< \"U\"\n\t\tend\n\tend\nelse\n\t# go down\n\t(start_y - finish_y).times do |index|\n\t\tif result[index].nil?\n\t\t\tresult << [\"D\"]\n\t\telse \n\t\t\tresult[index][0]<< \"D\"\n\t\tend\n\tend\nend\n\nputs result.length\nputs result"}, {"source_code": "source = gets.chomp!\ndestination = gets.chomp!\nh = []\nv = []\nwhile true\n\tif source[0] < destination[0]\n\t\th << 'R'\n\t\tsource[0] = (source[0].ord + 1).chr\n\telsif source[0] > destination[0]\n\t\th << 'L'\n\t\tsource[0] = (source[0].ord - 1).chr\n\telse\n\t\th << ''\n\tend\n\n\tif source[1] < destination[1]\n\t\tv << 'U'\n\t\tsource[1] = (source[1].to_i + 1).to_s\n\telsif source[1] > destination[1]\n\t\tv << 'D'\n\t\tsource[1] = (source[1].to_i - 1).to_s\n\telse\n\t\tv << ''\n\tend\n\n\tbreak if source == destination\n\nend\nif h.size == 1 && v.size == 1 && h[0] == '' && v[0] == '' \n\tputs 0\nelse\n\tputs h.size\n\th.each_index {|index| puts h[index] + v[index]}\nend\n"}, {"source_code": "a=gets\nb=gets\nx1=a[0].ord\ny1=a[1].to_i\nx2=b[0].ord\ny2=b[1].to_i\n\nputs [(x1-x2).abs,(y1-y2).abs].max\n\nwhile (x1 != x2 || y1 != y2)\n s=''\n if (x1 < x2)\n s+='R'\n x1+=1\n end\n if (x1 > x2)\n s+='L'\n x1-=1\n end\n if (y1 < y2)\n s+='U'\n y1+=1\n end\n if (y1 > y2)\n s+='D'\n y1-=1\n end\n puts s\nend\n"}, {"source_code": "#!usr/bin/env ruby\n\n# https://codeforces.com/problemset/problem/3/A\n\nstart = gets.chomp\nfinish = gets.chomp\nx1 = start[0]\nx2 = finish[0]\n\ny1 = start[1]\ny2 = finish[1]\n\ncount = 0\nmoves = []\n\nwhile !(x1 == x2 && y1 == y2) do\n move = \"\"\n\n if x1 < x2\n move += \"R\"\n x1 = x1.next\n elsif x1 > x2\n move += \"L\"\n x1 = (x1.ord - 1).chr\n end\n\n if y1 < y2\n move += \"U\"\n y1 = y1.next\n elsif y1 > y2\n move += \"D\"\n y1 = (y1.ord - 1).chr\n end\n count += 1\n moves << move\n end\n\nputs count\nmoves.each { |mv| puts mv }\n"}, {"source_code": "s = STDIN.readline\nt = STDIN.readline\n\nprint [(s[0].ord-t[0].ord).abs,(s[1].ord-t[1].ord).abs].max\nprint ?\\n\n\nwhile s != t ;\n\tif s[0] < t[0] ;\n\t\tprint ?R\n\t\ts[0] = (s[0].ord+1).chr\n\telsif s[0] > t[0] ;\n\t\tprint ?L\n\t\ts[0] = (s[0].ord-1).chr\n\tend\n\tif s[1] < t[1] ;\n\t\tprint ?U\n\t\ts[1] = (s[1].ord+1).chr\n\telsif s[1] > t[1] ;\n\t\tprint ?D\n\t\ts[1] = (s[1].ord-1).chr\n\tend\n\tprint ?\\n\nend\n"}, {"source_code": "s=gets.split[0].bytes.to_a\nt=gets.split[0].bytes.to_a\nsx=s[0]-97\nsy=56-s[1]\ntx=t[0]-97\nty=56-t[1]\nputs [(sx-tx).abs,(sy-ty).abs].max\nloop do\n if sx==tx && sy==ty then\n break\n end\n if sxtx then\n print \"L\"\n sx-=1\n end\n if syty then\n sy-=1\n print \"U\"\n end\n puts\nend\n"}, {"source_code": "# http://codeforces.com/problemset/problem/3/A\n\nclass Node\n attr_accessor :distance, :visited, :prev, :x, :y, :cost\n\n def initialize(x=0, y=0, cost=1)\n @distance = Float::INFINITY\n @visited = false\n @prev = nil\n @x = x\n @y = y\n @cost = cost\n end\nend\n\ndef make_graph(x, y)\n (0...x).map { |x| (0...y).map { |y| Node.new(x, y) } }\nend\n\ndef find_unvisited(graph)\n graph.flatten { |y| y.visited == false }\nend\n\ndef min(unvisited, graph)\n min = unvisited.map { |node| node.distance }.each_with_index.min\n unvisited[min[1]]\nend\n\ndef in_range(x, y, graph)\n x >= 0 && y >= 0 && x < graph.size && y < graph[0].size && !graph[x][y].visited\nend\n\ndef get_neighbors(x, y, graph)\n l = [x-1, y]\n r = [x+1, y]\n t = [x, y+1]\n b = [x, y-1]\n lt = [x-1, y+1]\n rt = [x+1, y+1]\n rb = [x+1, y-1]\n lb = [x-1, y-1]\n \n [l,r,t,b,lt,rt,rb,lb].select { |neighbor| in_range(neighbor[0], neighbor[1], graph) }\nend\n\ndef visit(node, graph)\n neighbors = get_neighbors(node.x, node.y, graph)\n neighbors.each do |n|\n neighbor = graph[n[0]][n[1]]\n neighbor.visited = true\n dist = node.distance + neighbor.cost\n if dist < neighbor.distance\n neighbor.distance = dist\n neighbor.prev = node\n end\n end\nend\n\ndef dijkstra(graph, source, target)\n graph[source[0]][source[1]].distance = 0\n unvisited = find_unvisited(graph)\n\n while unvisited.any?\n current_node = min(unvisited, graph)\n return current_node if current_node.x == target[0] && current_node.y == target[1]\n unvisited.delete(current_node)\n visit(current_node, graph)\n end\nend\n\ndef convert_source(coord)\n [coord[0].ord - 96 - 1, Integer(coord[1]) -1]\nend\n\ndef to_directions(from, to)\n return if to == nil\n str = \"\"\n if to.x > from.x\n str << \"R\"\n end\n if to.x < from.x\n str << \"L\"\n end\n if to.y > from.y\n str << \"U\"\n end\n if to.y < from.y\n str << \"D\"\n end\n str\nend\n\ndef get_answer_nodes(root)\n nodes = []\n current_node = root\n while !current_node.nil?\n nodes << current_node\n current_node = current_node.prev\n end\n nodes.reverse\nend\n\ndef format_answer(answer)\n nodes = get_answer_nodes(answer)\n directions = [nodes.size-1]\n nodes.each_with_index do |node, i|\n directions << to_directions(nodes[i], nodes[i+1])\n end\n directions\nend\n\ndef solve\n graph = make_graph(8, 8)\n source = gets\n target = gets\n answer = dijkstra(graph, convert_source(source.chomp), convert_source(target.chomp))\n puts format_answer(answer).join(\"\\n\")\nend\n\nsolve()\n\n\n"}, {"source_code": "s=gets.chomp.split(\"\")\nt=gets.chomp.split(\"\")\nvalu=1..8\nalph=('a' .. 'h')\nvalu=[*valu]\nalph=[*alph]\nvalu_hash={}\ni=0\nloop do\n\tbreak if i==8\n\tvalu_hash[alph[i]]=valu[i]\n\ti+=1\n end\ndir_arry=[] \nif valu_hash[s[0]]< valu_hash[t[0]]\n dir_arry[0]=\"R\"\nelsif valu_hash[s[0]]> valu_hash[t[0]] \n dir_arry[0]=\"L\"\nelse\n dir_arry[0]=0\nend\n \nif s[1].to_i< t[1].to_i\n dir_arry[1]=\"U\"\nelsif s[1].to_i> t[1].to_i \n dir_arry[1]=\"D\"\nelse\n dir_arry[1]=0\nend\n\nhmove=valu_hash[s[0]] - valu_hash[t[0]]\nif hmove<0\nhmove=hmove*(-1)\nend\nvmove=s[1].to_i-t[1].to_i\nif vmove<0\nvmove=vmove*(-1)\nend\n\nif hmove==0\n\tputs vmove\n\tvmove.times{puts dir_arry[1]}\nelsif vmove==0\n\tputs hmove\n\thmove.times{puts dir_arry[0] }\nelsif vmove==hmove\n\tputs hmove\n hmove.times{puts dir_arry[0]+dir_arry[1] }\nelsif hmove>vmove\n\tputs hmove\n\tvmove.times{puts dir_arry[0]+dir_arry[1] }\n\t(hmove-vmove).times {puts dir_arry[0]}\nelsif vmove>hmove\n\tputs vmove\n\thmove.times{puts dir_arry[0]+dir_arry[1] }\n\t(vmove-hmove).times{puts dir_arry[1]}\nend\t\n\t\t\n\n\n"}, {"source_code": "s,t = gets.strip.bytes.to_a, gets.strip.bytes.to_a\nmoves = []\nwhile s != t\n move = \"\"\n if s[0] < t[0]\n s[0] += 1\n move += \"R\"\n elsif s[0] > t[0]\n s[0] -= 1\n move += \"L\"\n end\n if s[1] < t[1]\n s[1] += 1\n move += \"U\"\n elsif s[1] > t[1]\n s[1] -= 1\n move += \"D\"\n end\n moves << move\nend\n\nputs moves.size\nfor s in moves do \n puts s\nend\n\n"}, {"source_code": "coord_src = gets\ncoord_dest = gets\n\ncoord_src_x = 1 + coord_src[0].ord - 'a'.ord\ncoord_src_y = coord_src[1].to_i\ncoord_dest_x = 1 + coord_dest[0].ord - 'a'.ord\ncoord_dest_y = coord_dest[1].to_i\n\n#puts coord_src_x.to_s + \" \" + coord_src_y.to_s\n#puts coord_dest_x.to_s + \" \" + coord_dest_y.to_s\n\nmoves = []\n\n# Firstly, move diagonally in the correct direction.\nwhile (coord_src_x != coord_dest_x && coord_src_y != coord_dest_y) do\n if coord_src_x > coord_dest_x\n coord_src_x -= 1\n if coord_src_y > coord_dest_y\n moves.push(\"LD\")\n coord_src_y -= 1\n else\n moves.push(\"LU\")\n coord_src_y += 1\n end\n else\n coord_src_x += 1\n if coord_src_y > coord_dest_y\n moves.push(\"RD\")\n coord_src_y -= 1\n else\n moves.push(\"RU\")\n coord_src_y += 1\n end\n end\nend\n\n# Now it is just a straightaway\nif(coord_src_x > coord_dest_x)\n (coord_src_x - coord_dest_x).times { moves.push(\"L\") }\nelsif (coord_src_x < coord_dest_x)\n (coord_dest_x - coord_src_x).times { moves.push(\"R\") }\n \nelsif(coord_src_y > coord_dest_y)\n (coord_src_y - coord_dest_y).times { moves.push(\"D\") }\nelsif (coord_src_y < coord_dest_y)\n (coord_dest_y - coord_src_y).times { moves.push(\"U\") }\nend\n \nputs moves.size\nmoves.each { |move| puts move }\n \n \n \n \n "}, {"source_code": "input = STDIN.read.split(\"\\n\")\na, b = input[0].split(''), input[1].split('')\na[1], b[1] = a[1].to_i, b[1].to_i\n\nif a == b\n\tSTDOUT.print 0\n\texit\nend\n\nif a[0] > b[0]\n\tx_dir = \"L\"\nelsif a[0] < b[0]\n\tx_dir = \"R\"\nend\n\nif a[1] > b[1]\n\ty_dir = \"D\"\nelsif a[1] < b[1]\n\ty_dir = \"U\"\nend\n\nstr = \"\"\ncount = 0\n\nwhile true do\n\n\tif a[0] != b[0]\n\t\ta[0].next! if x_dir == \"R\"\n\t\ta[0] = (a[0].ord - 1).chr if x_dir == \"L\"\n\t\tstr << x_dir\n\tend\n\n\tif a[1] != b[1]\n\t\ta[1] += 1 if y_dir == \"U\"\n\t\ta[1] -= 1 if y_dir == \"D\"\n\t\tstr << y_dir\n\tend\n\n\tcount += 1\n\tstr << \"\\n\"\n\n\tbreak if a == b\n\nend\n\nSTDOUT.print count, \"\\n\", str"}, {"source_code": "input = STDIN.read.split(\"\\n\")\na, b = input[0].split(''), input[1].split('')\na[0], b[0], a[1], b[1] = a[0].ord, b[0].ord, a[1].to_i, b[1].to_i\n\nif a == b\n\tSTDOUT.print 0\n\texit\nend\n\nx_dir = a[0] > b[0] ? \"L\" : \"R\"\ny_dir = a[1] > b[1] ? \"D\" : \"U\"\n\nstr, count = '', 0\n\nloop do\n\n\tif a[0] != b[0]\n\t\tx_dir == \"R\" ? a[0] += 1 : a[0] -= 1\n\t\tstr << x_dir\n\tend\n\n\tif a[1] != b[1]\n\t\ty_dir == \"U\" ? a[1] += 1 : a[1] -= 1\n\t\tstr << y_dir\n\tend\n\n\tcount += 1\n\tstr << \"\\n\"\n\n\tbreak if a == b\n\nend\n\nSTDOUT.print count, \"\\n\", str"}, {"source_code": "input = STDIN.read.split(\"\\n\")\na, b = input[0].split(''), input[1].split('')\na[1], b[1] = a[1].to_i, b[1].to_i\n\nif a == b\n\tSTDOUT.print 0\n\texit\nend\n\nx_dir = a[0] > b[0] ? \"L\" : \"R\"\ny_dir = a[1] > b[1] ? \"D\" : \"U\"\n\nstr, count = '', 0\n\nwhile true do\n\n\tif a[0] != b[0]\n\t\ta[0] = x_dir == \"R\" ? a[0].next : (a[0].ord - 1).chr\n\t\tstr << x_dir\n\tend\n\n\tif a[1] != b[1]\n\t\ty_dir == \"U\" ? a[1] += 1 : a[1] -= 1\n\t\tstr << y_dir\n\tend\n\n\tcount += 1\n\tstr << \"\\n\"\n\n\tbreak if a == b\n\nend\n\nSTDOUT.print count, \"\\n\", str"}], "negative_code": [{"source_code": "# require 'pry-byebug'\nfile = File.exist?('in.in') ? File.new('in.in','r') : STDIN\n\nDX = [0, 1, 0, -1, 1, -1, 1, -1]\nDY = [1, 0, -1, 0, 1, -1, -1, 1]\nMOV = [\"R\", \"D\", \"L\", \"U\", \"RD\", \"LU\", \"LD\", \"RU\"]\n\ndef inside?(i, j, grid)\n i>=0 && i<= grid.size-1 && j>=0 && j <=grid[0].size-1\nend\n\nmap = {\"a\"=> 0, \"b\"=> 1, \"c\"=> 2, \"d\"=> 3, \"e\"=> 4,\"f\"=> 5, \"g\"=> 6, \"h\" => 7}\n\ns1,s2 = file.gets.chomp.split('')\nt1,t2 = file.gets.chomp.split('')\n\nreturn puts 0 if s1==t1 && s2==t2\n\ns1 = map[s1]\ns2 = (s2.to_i-1-7).abs\nt1 = map[t1]\nt2 = (t2.to_i-1-7).abs\n\n# puts \"#{s1}#{s2}\"\n# puts \"#{t1}#{t2}\"\n\ngrid = Array.new(8) { Array.new(8) }\ndist = Array.new(8) { Array.new(8, 100) }\nqueue = [[s1, s2]]\ndist[s1][s2]=0\ngrid[s1][s2]=[]\n\nwhile(queue.size != 0)\n x, y = queue.shift\n 8.times do |i|\n new_x = x+DX[i]\n new_y = y+DY[i]\n if inside?(new_x, new_y, grid) && dist[new_x][new_y]==100\n\n if dist[x][y]+1 < dist[new_x][new_y]\n dist[new_x][new_y] = dist[x][y]+1\n grid[new_x][new_y] = grid[x][y] + [MOV[i]]\n end\n\n # dist[new_x][new_y] = [dist[new_x][new_y],dist[x][y]+1].min\n break if new_x == t1 && new_y == t2\n # binding.pry if dist[new_x][new_y] == 7\n queue << [new_x, new_y]\n end\n end\nend\nputs dist[t1][t2]\ngrid[t1][t2].each do |e|\n puts e\nend"}, {"source_code": "#!usr/bin/env ruby\n\n# https://codeforces.com/problemset/problem/3/A\n\nstart = gets.chomp\nfinish = gets.chomp\n\nwhile ! start.eql? finish do\n move = \"\"\n\n if start[0] < finish[0]\n move += \"U\"\n start[0] = start[0].next\n elsif start[0] > finish[0]\n move += \"D\"\n start[0] = (start[0].ord - 1).chr\n end\n\n if start[1] < finish[1]\n move += \"R\"\n start[1] = start[1].next\n elsif start[1] > finish[1]\n move += \"L\"\n start[1] = (start[1].ord - 1).chr\n end\n\n puts move\nend\n\n"}, {"source_code": "# http://codeforces.com/problemset/problem/3/A\n\nclass Node\n attr_accessor :distance, :visited, :prev, :x, :y, :cost\n\n def initialize(x=0, y=0, cost=1)\n @distance = Float::INFINITY\n @visited = false\n @prev = nil\n @x = x\n @y = y\n @cost = cost\n end\nend\n\ndef make_graph(x, y)\n (0...x).map { |x| (0...y).map { |y| Node.new(x, y) } }\nend\n\ndef find_unvisited(graph)\n graph.flatten { |y| y.visited == false }\nend\n\ndef min(unvisited, graph)\n min = unvisited.map { |node| node.distance }.each_with_index.min\n unvisited[min[1]]\nend\n\ndef in_range(x, y, graph)\n x >= 0 && y >= 0 && x < graph.size && y < graph[0].size && !graph[x][y].visited\nend\n\ndef get_neighbors(x, y, graph)\n l = [x-1, y]\n r = [x+1, y]\n t = [x, y+1]\n b = [x, y-1]\n lt = [x-1, y+1]\n rt = [x+1, y+1]\n rb = [x+1, y-1]\n lb = [x-1, y-1]\n \n [l,r,t,b,lt,rt,rb,lb].select { |neighbor| in_range(neighbor[0], neighbor[1], graph) }\nend\n\ndef visit(node, graph)\n neighbors = get_neighbors(node.x, node.y, graph)\n neighbors.each do |n|\n neighbor = graph[n[0]][n[1]]\n neighbor.visited = true\n dist = node.distance + neighbor.cost\n if dist < neighbor.distance\n neighbor.distance = dist\n neighbor.prev = node\n end\n end\nend\n\ndef dijkstra(graph, source, target)\n graph[source[0]][source[1]].distance = 0\n unvisited = find_unvisited(graph)\n\n while unvisited.any?\n current_node = min(unvisited, graph)\n return current_node if current_node.x == target[0] && current_node.y == target[1]\n unvisited.delete(current_node)\n visit(current_node, graph)\n end\nend\n\ndef convert_source(coord)\n [coord[0].ord - 96 - 1, Integer(coord[1]) -1]\nend\n\ndef to_directions(from, to)\n return if to == nil\n str = \"\"\n if to.x > from.x\n str << \"R\"\n end\n if to.y > from.y\n str << \"U\"\n end\n if to.y < from.y\n str << \"D\"\n end\n if to.x < from.x\n str << \"L\"\n end\n str\nend\n\ndef get_answer_nodes(root)\n nodes = []\n current_node = root\n while !current_node.nil?\n nodes << current_node\n current_node = current_node.prev\n end\n nodes.reverse\nend\n\ndef format_answer(answer)\n nodes = get_answer_nodes(answer)\n directions = [nodes.size-1]\n nodes.each_with_index do |node, i|\n directions << to_directions(nodes[i], nodes[i+1])\n end\n directions\nend\n\ndef solve\n graph = make_graph(8, 8)\n source = gets\n target = gets\n answer = dijkstra(graph, convert_source(source.chomp), convert_source(target.chomp))\n puts format_answer(answer).join(\"\\n\")\nend\n\nsolve()\n\n\n"}, {"source_code": "s = gets\nt = gets\nsx = s[0..0].ord\nsy = s[1..1].to_i\ntx = t[0..0].ord\nty = t[1..1].to_i\ndx = sx-tx\ndy = sy-ty\nstep = [dx.abs,dy.abs].max\nputs step\nstep.times do\n if dx<0\n print \"R\"\n dx += 1\n elsif dx>0\n print \"L\"\n dx -= 1\n end\n if dy<0\n print \"U\"\n dy += 1\n elsif dy>0\n print \"D\"\n dy += 1\n end\n puts\nend\n"}, {"source_code": "class King\n def initialize(s, t)\n @start = s\n @end = t\n end\n\n def get_path\n result = []\n horizontal = (@start[0] == @end[0])\n vertical = (@start[1] == @end[1])\n if @start == @end\n result << 0\n elsif horizontal\n result = [steps_x.abs] + [direction.last]*steps_x.abs\n elsif vertical\n result = [steps_y.abs] + [direction.first]*steps_y.abs\n else\n current = @start\n steps = 0\n until horizontal || vertical\n current = move_diag(current)\n horizontal = (current[0] == @end[0])\n vertical = (current[1] == @end[1])\n result << direction.join\n steps += 1\n end\n if vertical\n current_steps = (current[0].ord.to_i - @end[0].ord.to_i).abs\n result += [direction.last]*current_steps\n steps += current_steps\n elsif horizontal\n current_steps = (current[1].to_i - @end[1].to_i).abs\n result += [direction.first]*current_steps\n steps += current_steps\n end\n result.unshift(steps)\n end\n result\n end\n\n def move_diag(position)\n x_inc = steps_x == 0 ? 0 : steps_x/steps_x.abs\n y_inc = steps_y == 0 ? 0 : steps_y/steps_y.abs\n [(position[0].ord+x_inc).chr, (position[1].to_i + y_inc)].join\n end\n\n def direction\n [direction_y, direction_x]\n end\n\n def direction_x\n steps_x > 0 ? 'D' : 'U'\n end\n\n def direction_y\n steps_y > 0 ? 'L' : 'R'\n end\n\n def steps_x\n @start[1].to_i - @end[1].to_i\n end\n\n def steps_y\n @start[0].ord.to_i - @end[0].ord.to_i\n end\nend\n\ns, t = [gets.chomp, gets.chomp]\ngame = King.new(s, t)\nputs game.get_path\n"}, {"source_code": "class King\n def initialize(s, t)\n @start = s\n @end = t\n end\n\n def get_path\n result = []\n horizontal = (@start[0] == @end[0])\n vertical = (@start[1] == @end[1])\n if @start == @end\n result << 0\n elsif horizontal\n result = [steps_x] + [direction.last]*steps_x.abs\n elsif vertical\n result = [steps_y] + [direction.first]*steps_y.abs\n else\n current = @start\n steps = 0\n until horizontal || vertical\n current = move_diag(current)\n horizontal = (current[0] == @end[0])\n vertical = (current[1] == @end[1])\n result << direction.join\n steps += 1\n end\n if vertical\n current_steps = (current[0].ord.to_i - @end[0].ord.to_i).abs\n result += [direction.last]*current_steps\n steps += current_steps\n elsif horizontal\n current_steps = (current[1].to_i - @end[1].to_i).abs\n result += [direction.first]*current_steps\n steps += current_steps\n end\n result.unshift(steps)\n end\n result\n end\n\n def move_diag(position)\n x_inc = steps_x == 0 ? 0 : steps_x/steps_x.abs\n y_inc = steps_y == 0 ? 0 : steps_y/steps_y.abs\n [(position[0].ord+x_inc).chr, (position[1].to_i + y_inc)].join\n end\n\n def direction\n [direction_y, direction_x]\n end\n\n def direction_x\n steps_x > 0 ? 'D' : 'U'\n end\n\n def direction_y\n steps_y > 0 ? 'L' : 'R'\n end\n\n def steps_x\n @start[1].to_i - @end[1].to_i\n end\n\n def steps_y\n @start[0].ord.to_i - @end[0].ord.to_i\n end\nend\n\ns, t = [gets.chomp, gets.chomp]\ngame = King.new(s, t)\nputs game.get_path\n"}, {"source_code": "class King\n def initialize(s, t)\n @start = s\n @end = t\n end\n\n def get_path\n result = []\n horizontal = (@start[0] == @end[0])\n vertical = (@start[1] == @end[1])\n if @start == @end\n result << 0\n elsif horizontal\n result = [steps_x] + [direction.first]*steps_x.abs\n elsif vertical\n result = [steps_y] + [direction.last]*steps_y.abs\n else\n current = @start\n steps = 0\n until horizontal || vertical\n current = move_diag(current)\n horizontal = (current[0] == @end[0])\n vertical = (current[1] == @end[1])\n result << direction.join\n steps += 1\n end\n if vertical\n current_steps = (current[0].ord.to_i - @end[0].ord.to_i).abs\n result += [direction.last]*current_steps\n steps += current_steps\n elsif horizontal\n current_steps = (current[1].to_i - @end[1].to_i).abs\n result += [direction.first]*current_steps\n steps += current_steps\n end\n result.unshift(steps)\n end\n result\n end\n\n def move_diag(position)\n x_inc = steps_x == 0 ? 0 : steps_x/steps_x.abs\n y_inc = steps_y == 0 ? 0 : steps_y/steps_y.abs\n [(position[0].ord+x_inc).chr, (position[1].to_i + y_inc)].join\n end\n\n def direction\n [direction_y, direction_x]\n end\n\n def direction_x\n steps_x > 0 ? 'D' : 'U'\n end\n\n def direction_y\n steps_y > 0 ? 'L' : 'R'\n end\n\n def steps_x\n @start[1].to_i - @end[1].to_i\n end\n\n def steps_y\n @start[0].ord.to_i - @end[0].ord.to_i\n end\nend\n\ns, t = [gets.chomp, gets.chomp]\ngame = King.new(s, t)\nputs game.get_path\n"}, {"source_code": "s1 = gets\ns2 = gets\ndst1 = s2[0].ord - s1[0].ord\ndst2 = s2[1].to_i - s1[1].to_i\n\nputs [dst2.abs, dst1.abs].max\nwhile dst2 != 0 and dst1 != 0 do\n if dst1 > 0 then\n printf \"R\"\n dst1 -= 1\n end\n if dst1 < 0 then\n printf \"L\"\n dst1 += 1\n end\n\n if dst2 > 0 then\n printf \"U\"\n dst2 -= 1\n end\n if dst2 < 0 then\n printf \"D\"\n dst2 += 1\n end\n puts\nend\n"}, {"source_code": "start = gets().chomp!\nfinish = gets().chomp!\nLETTERS = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\"]\nh_distance, v_distance = [LETTERS.index(finish[0,1]) - LETTERS.index(start[0,1]), finish[1,1].to_i - start[1,1].to_i]\nmoves = Array.new(7){\"\"}\nh_distance.abs().times {\n|i|\n h_distance > 0 ? moves[i] << \"R\" : moves[i] << \"L\"\n}\nv_distance.abs().times {\n|i|\n v_distance > 0 ? moves[i] << \"U\" : moves[i] << \"D\"\n}\nmoves.select(){|elem| elem != \"\"}\nputs moves.length, moves"}, {"source_code": "s,t = readlines.join.split\nsx,sy = s[0].ord - 'a'.ord, s[1].to_i-1\ngx,gy = t[0].ord - 'a'.ord, t[1].to_i-1\na=[\"\"]*9\nf = lambda{|r,c| r.times{|i| a[i] += c}}\nf.call(sx-gx,'R')\nf.call(gx-sx,'L')\nf.call(sy-gy,'D')\nf.call(gy-sy,'U')\na.select!{|i| i != \"\"}\nputs a.size\nputs a\n"}, {"source_code": "a, b = gets.chop.split(''), gets.chop.split('')\na[1], b[1] = a[1].to_i, b[1].to_i\n\nif a[0] > b[0]\n\tx_dir = \"L\"\nelsif a[0] < b[0]\n\tx_dir = \"R\"\nend\n\nif a[1] > b[1]\n\ty_dir = \"D\"\nelsif a[1] < b[1]\n\ty_dir = \"U\"\nend\n\nstr = \"\"\ncount = 0\n\nwhile true do\n\n\tif a[0] != b[0]\n\t\ta[0].next! if x_dir == \"R\"\n\t\ta[0].prev! if x_dir == \"L\"\n\t\tstr << x_dir\n\tend\n\n\tif a[1] != b[1]\n\t\ta[1] += 1 if y_dir == \"U\"\n\t\ta[1] -= 1 if y_dir == \"D\"\n\t\tstr << y_dir\n\tend\n\n\tcount += 1\n\tstr << \"\\n\"\n\n\tbreak if a == b\n\nend\n\nSTDOUT.print count, \"\\n\", str"}], "src_uid": "d25d454702b7755297a7a8e1f6f36ab9"} {"source_code": "def is_hor_line_in_b(line, b)\n res = false\n if b[0][0][0] <= line[0][0] && b[0][1][0] >= line[1][0] && line[0][1] >= b[0][0][1] && line[0][1] <= b[0][1][1] ||\n b[0][0][0] <= line[0][0] && b[0][1][0] >= b[1][0][0] && b[1][1][0] >= line[1][0] &&\n line[0][1] >= b[0][0][1] && line[0][1] <= b[0][1][1] && line[0][1] >= b[1][0][1] && line[0][1] <= b[1][1][1]\n res = true\n end\n b[0], b[1] = b[1], b[0]\n if b[0][0][0] <= line[0][0] && b[0][1][0] >= line[1][0] && line[0][1] >= b[0][0][1] && line[0][1] <= b[0][1][1] ||\n b[0][0][0] <= line[0][0] && b[0][1][0] >= b[1][0][0] && b[1][1][0] >= line[1][0] &&\n line[0][1] >= b[0][0][1] && line[0][1] <= b[0][1][1] && line[0][1] >= b[1][0][1] && line[0][1] <= b[1][1][1]\n res = true\n end\n res\nend\n\ndef is_ver_line_in_b(line, b)\n res = false\n if b[0][0][1] <= line[0][1] && b[0][1][1] >= line[1][1] && line[0][0] >= b[0][0][0] && line[0][0] <= b[0][1][0] ||\n b[0][0][1] <= line[0][1] && b[0][1][1] >= b[1][0][1] && b[1][1][1] >= line[1][1] &&\n line[0][0] >= b[0][0][0] && line[0][0] <= b[0][1][0] && line[0][0] >= b[1][0][0] && line[0][0] <= b[1][1][0]\n res = true\n end\n b[0], b[1] = b[1], b[0]\n if b[0][0][1] <= line[0][1] && b[0][1][1] >= line[1][1] && line[0][0] >= b[0][0][0] && line[0][0] <= b[0][1][0] ||\n b[0][0][1] <= line[0][1] && b[0][1][1] >= b[1][0][1] && b[1][1][1] >= line[1][1] &&\n line[0][0] >= b[0][0][0] && line[0][0] <= b[0][1][0] && line[0][0] >= b[1][0][0] && line[0][0] <= b[1][1][0]\n res = true\n end\n res\nend\n\n\nw = gets.chomp.split(' ').map(&:to_i)\nb = [[], []]\nb[0] = gets.chomp.split(' ').map(&:to_i).each_slice(2).to_a\nb[1] = gets.chomp.split(' ').map(&:to_i).each_slice(2).to_a\nline_h1 = [[w[0], w[1]], [w[2], w[1]]]\nline_h2 = [[w[0], w[3]], [w[2], w[3]]]\nline_v1 = [[w[0], w[1]], [w[0], w[3]]]\nline_v2 = [[w[2], w[1]], [w[2], w[3]]]\nif is_hor_line_in_b(line_h1, b) && is_hor_line_in_b(line_h2, b) &&\n is_ver_line_in_b(line_v1, b) && is_ver_line_in_b(line_v2, b)\n puts \"NO\"\nelse\n puts \"YES\"\nend\n", "positive_code": [{"source_code": "#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']\n\ndef inpf() a=gets.chomp.split(\" \").map(&:to_f)end\n\ndef inps() a=gets.chomp.split(\" \")end\n\ndef copy(a) Marshal.load(Marshal.dump(a)) end\n\ndef kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end\n\ndef na(n,d=0) Array.new(n,d)end\n\ndef na2(n,m,d=0) Array.new(n){Array.new(m,d)}end\n\ndef na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end\n\ndef inp() a=gets.chomp.split(\" \").map(&:to_i)end\n\ndef r_up(a, b) (a+b-1)/b end\n\ndef sum(a) a.inject(:+) end\n\nhx = {}\nhy = {}\na = inp\nb = inp\nc = inp\nx = [a[0],a[2],b[0],b[2],c[0],c[2]].sort\ny = [a[1],a[3],b[1],b[3],c[1],c[3]].sort\nx.each.with_index do |d,i|\n hx[d] = i\nend\ny.each.with_index do |d,i|\n hy[d] = i\nend\nt = na2(x.size,y.size,false)\n(hx[a[0]]...hx[a[2]]).each do |x|\n (hy[a[1]]...hy[a[3]]).each do |y|\n t[x][y] = true\n end\nend\n(hx[b[0]]...hx[b[2]]).each do |x|\n (hy[b[1]]...hy[b[3]]).each do |y|\n t[x][y] = false\n end\nend\n(hx[c[0]]...hx[c[2]]).each do |x|\n (hy[c[1]]...hy[c[3]]).each do |y|\n t[x][y] = false\n end\nend\n\nputs (t.flatten.include?(true))? \"YES\" : \"NO\"\n"}, {"source_code": "MOD=10**9+7\ncnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)\ndef gs() gets.chomp end\ndef gi() gets.to_i end\ndef gsmi() gets.chomp.split.map(&:to_i) end\n\ndef desc(ar) ar.sort!{|x,y|y<=>x} end\ndef min(a,b) a<=b ? a : b end\ndef max(a,b) a>=b ? a : b end\ndef sum(ar) ar.inject(:+) end\n\n#def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end\ndef C(a,b) b==0||a==b ? 1 : (b=a-b if a/2=x2&&y4>=y2)||(x5<=x1&&y5<=y1&&x6>=x2&&y6>=y2)\n putsend('NO')\nend\n# half cover\n# たて\nif (y3<=y1&&y4>=y2 &&y5<=y1&&y6>=y2) && ((x5<=x2&&x6>=x2&&x3<=x1&&x4>=x1&&x4>=x5)||(x3<=x2&&x4>=x2&&x5<=x1&&x6>=x1&&x6>=x3))\n putsend('NO')\nend\n# よこ\nif (x3<=x1&&x4>=x2 &&x5<=x1&&x6>=x2) && ((y5<=y2&&y6>=y2&&y3<=y1&&y4>=y1&&y4>=y5)||(y3<=y2&&y4>=y2&&y5<=y1&&y6>=y1&&y6>=y3))\n putsend('NO')\nend\n\nputsend('YES')\n"}], "negative_code": [{"source_code": "MOD=10**9+7\ncnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)\ndef gs() gets.chomp end\ndef gi() gets.to_i end\ndef gsmi() gets.chomp.split.map(&:to_i) end\n\ndef desc(ar) ar.sort!{|x,y|y<=>x} end\ndef min(a,b) a<=b ? a : b end\ndef max(a,b) a>=b ? a : b end\ndef sum(ar) ar.inject(:+) end\n\n#def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end\ndef C(a,b) b==0||a==b ? 1 : (b=a-b if a/2=x2&&y4>=y2)||(x5<=x1&&y5<=y1&&x6>=x2&&y6>=y2)\n putsend('NO')\nend\n# half cover\n# たて\nif (y3<=y1&&y4>=y2 &&y5<=y1&&y6>=y2) && ((x5<=x2&&x6>=x2&&x3<=x1&&x4>=x1&&x4>=x5)||(x3<=x2&&x4>=x2&&x5<=x1&&x6>=x1&&x6>=x4))\n putsend('NO')\nend\n# よこ\nif (x3<=x1&&x4>=x2 &&x5<=x1&&x6>=x2) && ((y5<=y2&&y6>=y2&&y3<=y1&&y4>=y1&&y4>=y5)||(y3<=y2&&y4>=y2&&y5<=y1&&y6>=y1&&y6>=y4))\n putsend('NO')\nend\n\nputsend('YES')\n"}], "src_uid": "05c90c1d75d76a522241af6bb6af7781"} {"source_code": "n,k=gets.split.map(&:to_i)\np (n+k)/k*k", "positive_code": [{"source_code": "n, k = gets.strip.split.map(&:to_i)\nremainder = n / k\nans = k * remainder + k\nputs ans\n"}, {"source_code": "n, k = gets.split.map(&:to_i)\n\nx = (n/k).to_i\n\nputs (x+1)*k\n"}, {"source_code": "n,k = gets.split(' ').map(&:to_i)\nputs ((n/k) * k) + k\n"}, {"source_code": "# cook your code here\n\na1,b1=gets.chomp.split\n\nn = a1.to_i\nk = b1.to_i\n\nn = n + k - n%k \n\nputs n"}], "negative_code": [{"source_code": "n,k=gets.split.map(&:to_i)\np (n+k-1)/k*k"}, {"source_code": "n, k = gets.strip.split.map(&:to_i)\nmod = n % k\nremainder = 0\nremainder = n / k if mod != 0\nremainder = mod if mod ==\nans = n + remainder\nans += k if remainder == 0\nputs ans\n"}, {"source_code": "n, k = gets.strip.split.map(&:to_i)\nmod = n % k\nremainder = mod\nremainder = n / k if mod != 0\nans = n + remainder\nans += k if remainder == 0\nputs ans\n"}], "src_uid": "75f3835c969c871a609b978e04476542"} {"source_code": "# Codeforces Beta Round #80\n# Problem A -- Blackjack\ncards = [0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 15, 4]\nn = gets.to_i - 10\nputs (0 <= n and n <= 11) ? cards[n] : 0\n", "positive_code": [{"source_code": "n=gets.to_i\nd=n-10\np d>11||d<1 ? 0 : d>10||d<2 ? 4 : d>9 ? 15 : 4"}, {"source_code": "#!/usr/bin/env ruby\n\ndef solve n\n diff = n - 10\n if 1 < diff and diff < 10\n return 4\n end\n if diff == 1 or diff == 11\n return 4\n end\n if diff == 10\n return 4*3+3\n end\n return 0 # if diff < 0 and 11 < diff\nend\n\n#n = STDIN.gets.split.map {|i| i.to_i }\n\nputs solve(STDIN.gets.to_i)\n"}, {"source_code": "n = gets.chomp.to_i - 10\nif n < 1 || n > 11\n puts 0\nelsif n == 10\n puts 15\nelse\n puts 4\nend\n"}, {"source_code": "need = STDIN.readline.to_i - 10\nif need == 10\n puts 15\nelsif need >= 1 and need <= 11\n puts 4\nelse\n puts 0\nend\n"}, {"source_code": "n = gets.to_i\nif n <= 10 or n >= 22\n puts 0\nelse\n if n== 20\n puts 15\n else\n puts 4\n end\nend"}, {"source_code": "#104A\nn=gets.to_i\nif n <= 10\n puts \"0\"\nelsif n >= 11 and n <= 19\n puts \"4\"\nelsif n == 20\n puts \"15\"\nelsif n == 21\n puts\"4\"\nelse\n puts \"0\"\nend \n"}, {"source_code": "a=gets.chomp.to_i\na=a-10\nif a<=0 || a>=12\nputs \"0\"\nelsif a==10\nputs \"15\"\nelse \nputs \"4\"\nend\n\n"}, {"source_code": "d=[10]*11\n[*1..11].each{|i| d+=[i]*4}\np d.count(gets.to_i-10)\n"}, {"source_code": "#!/usr/bin/ruby\nuc = \"1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 11 11 11 11\".split(' ')\nnum = gets.chop.to_i\n#puts num.to_s\nways = 0;\nfor i in 0..uc.count-1\n\tif num - 10 == uc[i].to_i\n\t\tways = ways+1\n\tend\nend\nputs ways\t\n\n"}, {"source_code": "\ndef blackjack\n c = { }\n 1.upto(11) { |i| c[i] = 4 }\n c[10] = 15\n\n goal = gets.to_i\n if goal-10 < 1\n puts 0\n else\n puts (c.has_key?(goal-10)) ? c[goal-10] : 0\n end\nend\n\nblackjack"}, {"source_code": "case gets.chomp.to_i\n when 11..19, 21\n puts 4\n when 20\n puts 15\n else\n puts 0\nend"}], "negative_code": [{"source_code": "d=[10]*15+[1, 11]\n[*2..9].each{|i| d+=[i]*4}\np d.count(gets.to_i-10)\n"}, {"source_code": "s=gets.to_i\nneed=s-10\n\ndata=[10]*(3*4-1)+[1, 11]\nfor i in 2..10\n\tdata+=[i]*4\nend\n\nputs data.count(need)\n"}, {"source_code": "d=[10]*15+[11]\n[*1..9].each{|i| d+=[i]*4}\np d.count(gets.to_i-10)\n"}, {"source_code": "d=[10]*15+[1,11]\n[*2..9].each{|i| d+=[i]*4}\np d.count(gets.to_i-10)\n"}, {"source_code": "#!/usr/bin/ruby\nuc = \"1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5 6 6 6 6 7 7 7 7 8 8 8 8 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10\".split(' ')\nnum = gets.chop.to_i\n#puts num.to_s\nways = 0;\nfor i in 0..uc.count-1\n\tif num - 10 == uc[i].to_i\n\t\tways = ways+1\n\tend\nend\nputs ways\t\n\n"}, {"source_code": "\ndef blackjack\n c = { }\n 1.upto(11) { |i| c[i] = 4 }\n c[10] = 15\n\n goal = gets.to_i\n if goal-10 < 1\n puts 0\n else\n puts c[goal-10]\n end\nend\n\n\nblackjack"}, {"source_code": "#!/usr/bin/env ruby\n\ndef solve n\n diff = n - 10\n return 0 if diff < 0 and 10 < diff\n if 1 < diff and diff < 10\n return 4\n end\n if diff == 1\n return 4\n end\n if diff >= 10\n return 4*3+3\n end\nend\n\n#n = STDIN.gets.split.map {|i| i.to_i }\n\nputs solve(STDIN.gets.to_i)\n"}, {"source_code": "#!/usr/bin/env ruby\n\ndef solve n\n return 0 if n < 11\n diff = n - 10\n if 1 < diff and diff < 10\n return 4\n end\n if diff == 1\n return 4\n end\n if diff >= 10\n return 4*3+3\n end\nend\n\n#n = STDIN.gets.split.map {|i| i.to_i }\n\nputs solve(STDIN.gets.to_i)\n"}, {"source_code": "#!/usr/bin/env ruby\n\ndef solve n\n diff = n - 10\n return 0 if diff < 0 and 11 < diff\n if 1 < diff and diff < 10\n return 4\n end\n if diff == 1 or diff == 11\n return 4\n end\n if diff >= 10\n return 4*3+3\n end\nend\n\n#n = STDIN.gets.split.map {|i| i.to_i }\n\nputs solve(STDIN.gets.to_i)\n"}], "src_uid": "5802f52caff6015f21b80872274ab16c"} {"source_code": "# http://codeforces.com/contest/592/problem/A\n# A. PawnChess\n\ncols = [].tap do |arr|\n 8.times { arr << gets.chomp.chars }\nend\nb_idx = []\nw_idx = []\ncols.transpose.each do |row|\n b = row.rindex('B')\n w = row.rindex('W')\n b_idx << 7 - b if b && (w.nil? || (b > w))\n\n b = row.index('B')\n w = row.index('W')\n w_idx << w if w && (b.nil? || (b > w))\nend\n\nif !b_idx.empty? && (w_idx.empty? || b_idx.min < w_idx.min)\n puts 'B'\nelse\n puts 'A'\nend\n", "positive_code": [{"source_code": "Board = Array.new( 8 ) do | i |\n\tgets.chomp.split( \"\" )\nend\n.transpose.freeze;\n\na = 8; b = 8\nBoard.each do |row|\n\t8.times do | i |\n\t\tif row[i] != '.'\n\t\t\tif row[i] == 'W'\n\t\t\t\ta = [ a, i ].min\n\t\t\tend\n\t\t\tbreak\n\t\tend\n\tend\n\t7.downto( 0 ) do | i |\n\t\tif row[i] != '.'\n\t\t\tif row[i] == 'B'\n\t\t\t\tb = [ b, 7 - i ].min\n\t\t\tend\n\t\t\tbreak\n\t\tend\n\tend\nend\n\nputs ( a <= b ? \"A\" : \"B\" )\n"}, {"source_code": "matr=[]\n8.times{matr<b ? \"B\" : \"A\"\n"}, {"source_code": "#! /usr/bin/env ruby\n\nboard = 8.times.collect { $stdin.gets.chomp }\n\nw = 100\nb = 100\nfor c in 0..7\n for r in 0..7\n board[r][c] == 'B' and break\n board[r][c] == 'W' and w = [w, r].min\n end\n for r in (0..7).reverse_each\n board[r][c] == 'W' and break\n board[r][c] == 'B' and b = [b, 7-r].min\n end\nend\n\nputs (w <= b ? 'A': 'B')\n\n"}, {"source_code": "#!/usr/bin/env ruby\n\nrequire 'matrix'\n\nrows = 8.times.map do gets.chars.to_a end\nMATRIX = Matrix.rows(rows)\n\ndef win_in_colA(col_no)\n (0..7).each do |row_no|\n if MATRIX[row_no, col_no] == 'W'\n return row_no\n elsif MATRIX[row_no, col_no] == 'B'\n return 9\n end\n end\n return 9\nend\n\ndef win_in_colB(col_no)\n (0..7).to_a.reverse.each do |row_no|\n if MATRIX[row_no, col_no] == 'B'\n return 7-row_no\n elsif MATRIX[row_no, col_no] == 'W'\n return 9\n end\n end\n return 9\nend\n\nsteps_for_A = (0..7).map do |col_n|\n win_in_colA(col_n)\nend\n\nsteps_for_B = (0..7).map do |col_n|\n win_in_colB(col_n)\nend\n\nwho_won = (steps_for_B.min < steps_for_A.min) ? 'B' : 'A'\nputs who_won\n"}, {"source_code": "field = []\nwhile line = gets\n field << line.chomp.split(\"\")\nend\nfield = field.transpose\nstepA = []\nstepB = []\nfield.each do |r|\n a = r.rindex(\"W\")\n b = r.rindex(\"B\")\n unless b.nil? then\n if a.nil? or (a < b) then\n stepB << 7 - b\n end\n end\n a = r.index(\"W\")\n b = r.index(\"B\")\n unless a.nil? then\n if b.nil? or (a < b) then\n stepA << a\n end\n end\nend\nif stepB.empty? or (stepA.min <= stepB.min) then\n puts \"A\"\nelsif stepA.empty? or (stepA.min > stepB.min) then\n puts \"B\"\nend"}, {"source_code": "a = Array.new(8)\nc = [0] * 8\nfor x in 0..7\n a[x] = gets\nend\nflag = 0\nfor x in 0..7\n for y in 0..7\n if a[x][y] == \"W\" and c[y] == 0\n w = x;\n flag = 1;\n break;\n end\n if a[x][y] == \"B\"\n c[y] = 1;\n end\n end\n if flag == 1\n break\n end\nend\nc = [0] * 8\nflag = 0\nfor x in 0..7\n for y in 0..7\n if a[7 - x][y] == 'B' and c[y] == 0\n b = x;\n flag = 1;\n break;\n end\n if a[7 - x][y] == 'W'\n c[y] = 1;\n end\n end\n if flag == 1\n break;\n end\nend\nif w > b\n print \"B\\n\"\nelse\n print \"A\\n\"\nend\n"}, {"source_code": "n, a1, a2, min, c = [], [], [], 99999, ''\n(0..7).each do |_|\n n << gets.chomp.split('')\nend\n(0..7).each do |i|\n arr, a1, a2 = [], [], []\n (0..7).each do |j|\n arr << n[j][i]\n end\n x = Array.new arr\n y = Array.new arr\n x.uniq!.delete('.')\n y.reverse!.uniq!.delete('.')\n a1 = x\n a2 = y\n if a1.size == 0\n \tnext\n elsif a1.size == 1\n \td = a1.first == 'W' ? arr.index('W') : arr.reverse.index('B')\n \tif (d < min) || (d == min && a1.first == 'W')\n \t\tmin = d\n \t\tc = a1.first\n \tend\n else\n\t\tif a1.first == 'W' && arr.index('W') <= min\n\t\t\tmin = arr.index('W')\n\t\t\tc = 'W'\n\t\tend\n\t\tif a2.first == 'B' && arr.reverse.index('B') < min\n\t\t\tmin = arr.reverse.index('B')\n\t\t\tc = 'B'\n\t\tend\n end\nend\nputs c == 'W' ? 'A' : 'B'"}, {"source_code": "class Solver\n\tdef main\n\t\tf = []\n\t\t8.times { f << gets }\n\t\tans_w = 10\n\t\tans_b = 10\n\t\t8.times do |i|\n\t\t\t8.times do |j|\n\t\t\t\tif f[i][j] == \"W\" then\n\t\t\t\t\tflag = true\n\t\t\t\t\ttmp = i - 1\n\t\t\t\t\twhile tmp >= 0 do\n\t\t\t\t\t\tflag = false if f[tmp][j] != '.'\n\t\t\t\t\t\ttmp -= 1\n\t\t\t\t\tend\n\t\t\t\t\tans_w = [ans_w, i].min if flag\n\t\t\t\telsif f[i][j] == \"B\" then\n\t\t\t\t\tflag = true;\n\t\t\t\t\ttmp = i + 1\n\t\t\t\t\twhile tmp < 8 do\n\t\t\t\t\t\tflag = false if f[tmp][j] != '.'\n\t\t\t\t\t\ttmp += 1\n\t\t\t\t\tend\n\t\t\t\t\tans_b = [ans_b, 7 - i].min if flag\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tputs ans_w <= ans_b ? \"A\" : \"B\"\n\tend\nend\n\nSolver.new.main\n"}], "negative_code": [{"source_code": "# http://codeforces.com/contest/592/problem/A\n# A. PawnChess\n\ncols = [].tap do |arr|\n 8.times { arr << gets.chomp.chars }\nend\nrows = cols.transpose.reject do |row|\n row.include?('B') && row.include?('W')\nend\n\nb_indexes = rows.map { |row| row.rindex('B') }.compact.map { |idx| 8 - idx }\nw_indexes = rows.map { |row| row.index('W') }.compact\n\nif b_indexes.min < w_indexes.min\n puts 'B'\nelse\n puts 'A'\nend\n"}, {"source_code": "# http://codeforces.com/contest/592/problem/A\n# A. PawnChess\n\ncols = [].tap do |arr|\n 8.times { arr << gets.chomp.chars }\nend\nrows = cols.transpose.reject do |row|\n row.include?('B') && row.include?('W')\nend\n\nb_indexes = rows.map { |row| row.rindex('B') }.compact.map { |idx| 7 - idx }\nw_indexes = rows.map { |row| row.index('W') }.compact\n\n\nif w_indexes.empty? || b_indexes.min < w_indexes.min\n puts 'B'\nelse\n puts 'A'\nend\n"}, {"source_code": "# http://codeforces.com/contest/592/problem/A\n# A. PawnChess\n\ncols = [].tap do |arr|\n 8.times { arr << gets.chomp.chars }\nend\nb_idx = []\nw_idx = []\nrows = cols.transpose.reject do |row|\n b = row.rindex('B')\n w = row.rindex('W')\n if b && (w.nil? || (b > w))\n b_idx << 7 - b\n end\n\n b = row.index('B')\n w = row.index('W')\n if w && (b.nil? || (w > b))\n w_idx << w\n end\nend\n\nif !b_idx.empty? && (w_idx.empty? || b_idx.min < w_idx.min)\n puts 'B'\nelse\n puts 'A'\nend\n"}, {"source_code": "#!/usr/bin/env ruby\n\nrequire 'matrix'\n\nrows = 8.times.map do gets.chars.to_a end\nMATRIX = Matrix.rows(rows)\n\ndef win_in_colA(col_no)\n (0..7).each do |row_no|\n if MATRIX[row_no, col_no] == 'W'\n return row_no\n elsif MATRIX[row_no, col_no] == 'B'\n return 9\n end\n end\n return 9\nend\n\ndef win_in_colB(col_no)\n (0..7).to_a.reverse.each do |row_no|\n if MATRIX[row_no, col_no] == 'B'\n return 7-row_no\n elsif MATRIX[row_no, col_no] == 'W'\n return 9\n end\n end\n return 9\nend\n\nsteps_for_A = (0..7).map do |col_n|\n win_in_colA(col_n)\nend\nprint steps_for_A\nputs\n\nsteps_for_B = (0..7).map do |col_n|\n win_in_colB(col_n)\nend\nprint steps_for_B\n\nwho_won = (steps_for_B.min < steps_for_A.min) ? 'B' : 'A'\nputs who_won\n"}, {"source_code": "#!/usr/bin/env ruby\n\nrequire 'matrix'\n\nrows = 8.times.map do gets.chars.to_a end\nMATRIX = Matrix.rows(rows)\n\ndef win_in_colB(col_no)\n (0..7).each do |row_no|\n if MATRIX[row_no, col_no] == 'B'\n return row_no+1\n elsif MATRIX[row_no, col_no] == 'W'\n return 9\n end\n end\n return 9\nend\n\ndef win_in_colA(col_no)\n (0..7).to_a.reverse.each do |row_no|\n if MATRIX[row_no, col_no] == 'W'\n return 8-row_no\n elsif MATRIX[row_no, col_no] == 'B'\n return 9\n end\n end\n return 9\nend\n\nsteps_for_A = (0..7).map do |col_n|\n win_in_colA(col_n)\nend\n\nsteps_for_B = (0..7).map do |col_n|\n win_in_colB(col_n)\nend\n\nwho_won = (steps_for_B.min < steps_for_A.min) ? 'B' : 'A'\nputs who_won\n"}, {"source_code": "field = []\nwhile line = gets\n field << line.chomp.split(\"\")\nend\nfield = field.transpose\nstepA = []\nstepB = []\nfield.each do |r|\n a = r.rindex(\"W\")\n b = r.rindex(\"B\")\n unless b.nil? then\n if a.nil? or (a < b) then\n stepB << 7 - b\n end\n end\n a = r.index(\"W\")\n b = r.index(\"B\")\n unless a.nil? then\n if b.nil? or (a < b) then\n stepA << 7 - a\n end\n end\nend\nif stepB.empty? or (stepA.min < stepB.min) then\n puts \"A\"\nelsif stepA.empty? or (stepA.min > stepB.min) then\n puts \"B\"\nend"}, {"source_code": "a = Array.new(8)\nfor x in 0..7\n a[x] = gets\nend\nfor x in 0..7\n for y in 0..7\n if a[7 - x][y] == 'B'\n print \"B\\n\"\n exit\n end\n if a[7 - x][y] == 'W'\n print \"A\\n\"\n exit\n end\n end\nend\n"}, {"source_code": "n, a1, a2, min, c = [], [], [], 99999, ''\n(0..7).each do |_|\n n << gets.chomp.split('')\nend\n(0..7).each do |i|\n arr, a1, a2 = [], [], []\n (0..7).each do |j|\n arr << n[j][i]\n end\n x = Array.new arr\n y = Array.new arr\n x.uniq!.delete('.')\n y.reverse!.uniq!.delete('.')\n a1 = x\n a2 = y\n if a1.size == 0\n \tnext\n elsif a1.size == 1\n \td = a1.first == 'W' ? arr.index('W') : arr.reverse.index('B')\n \tif d < min || (d == min && c == 'W')\n \t\tmin = d\n \t\tc = a1.first\n \tend\n else\n\t\tif a1.first == 'W' && arr.index('W') <= min\n\t\t\tmin = arr.index('W')\n\t\t\tc = 'W'\n\t\tend\n\t\tif a2.first == 'B' && arr.reverse.index('B') < min\n\t\t\tmin = arr.reverse.index('B')\n\t\t\tc = 'B'\n\t\tend\n end\nend\nputs c == 'W' ? 'A' : 'B'"}, {"source_code": "arr, arr1, arr2, index, min, result, c = [], [], [], 1000000, 99999, '', ''\n(0..7).each do |_|\n arr << gets.chomp.split('')\nend\n(0..7).each do |i|\n arr1 = []\n (0..7).each do |j|\n arr1 << arr[j][i]\n end\n arr2 = Array.new arr1\n arr2.uniq!.delete('.')\n if arr2[0] && arr2.size == 1\n c = arr2[0]\n if c == 'W'\n index = arr1.index(c)\n else c == 'B'\n index = arr1.reverse.index(c)\n end\n end\n if index < min\n min = index\n result = c\n end\nend\nputs result == 'W' ? 'A' : 'B'"}, {"source_code": "arr, arr1, arr2, index, min, result, c = [], [], [], 1000000, 99999, '', ''\n(0..7).each do |_|\n arr << gets.chomp.split('')\nend\n(0..7).each do |i|\n arr1 = []\n (0..7).each do |j|\n arr1 << arr[j][i]\n end\n arr2 = Array.new arr1\n arr2.uniq!.delete('.')\n if arr2[0] && arr2.size == 1\n c = arr2[0]\n if c == 'W'\n index = arr1.index(c)\n else c == 'B'\n index = arr1.reverse.index(c)\n end\n end\n min = index; result = c if index < min\nend\np result == 'W' ? 'A' : 'B'"}, {"source_code": "arr, arr1, arr2, index, min, result, c = [], [], [], 1000000, 99999, '', ''\n(0..7).each do |_|\n arr << gets.chomp.split('')\nend\n(0..7).each do |i|\n arr1 = []\n (0..7).each do |j|\n arr1 << arr[j][i]\n end\n arr2 = Array.new arr1\n arr2.uniq!.delete('.')\n if arr2[0] && arr2.size == 1\n c = arr2[0]\n if c == 'W'\n index = arr1.index(c)\n else c == 'B'\n index = arr1.reverse.index(c)\n end\n end\n if index < min\n min = index\n result = c\n end\nend\np result == 'W' ? 'A' : 'B'\n"}, {"source_code": "arr, arr1, arr2, index, min, result, c = [], [], [], 1000000, 99999, '', ''\n(0..7).each do |_|\n arr << gets.chomp.split('')\nend\n(0..7).each do |i|\n arr1 = []\n (0..7).each do |j|\n arr1 << arr[j][i]\n end\n arr2 = Array.new arr1\n arr2.uniq!.delete('.')\n if arr2[0] && arr2.size == 1\n c = arr2[0]\n if c == 'W'\n index = arr1.index(c)\n else c == 'B'\n index = arr1.reverse.index(c)\n end\n end\n if index < min\n min = index\n result = c\n end\nend\np result == 'W' ? :A : :B\n"}, {"source_code": "class Solver\n\tdef main\n\t\tmap = []\n\t\t8.times do\n\t\t\tmap << gets.chomp\n\t\tend\n\t\tmove_a = 9\n\t\tmove_b = 9\n\t\t\n\t\t8.times do |i|\n\t\t\tup_most_w = 10\n\t\t\tdown_most_b = -1\n\t\t\t8.times do |j|\n\t\t\t\tup_most_w = [up_most_w, j].min if map[j][i] == \"W\"\n\t\t\t\tdown_most_b = [down_most_b, j].max if map[j][i] == \"B\"\n\t\t\tend\n\t\t\tif up_most_w == 10 && down_most_b != -1 then\n\t\t\t\tmove_b = [move_b, 7 - down_most_b].min\n\t\t\telsif up_most_w != 10 && down_most_b == -1 then\n\t\t\t\tmove_a = [move_a, up_most_w].min\n\t\t\telsif up_most_w != 10 && down_most_b != -1 then\n\t\t\t\tif up_most_w < down_most_b then\n\t\t\t\t\tmove_a = [move_a, up_most_w].min\n\t\t\t\t\tmove_b = [move_b, 7 - down_most_b].min\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tif move_a <= move_b then\n\t\t\tputs \"A\"\n\t\telse\n\t\t\tputs \"B\"\n\t\tend\n\tend\nend\n\nSolver.new.main\n"}], "src_uid": "0ddc839e17dee20e1a954c1289de7fbd"} {"source_code": "n, k, x = $stdin.gets.chomp.split(' ').map { |v| v.to_i }\na = $stdin.gets.chomp.split(' ').map { |v| v.to_i }\n\nclass Solver\n def initialize(n, k, x, a)\n @n = n\n @k = k\n @x = x\n @a = a\n end\n\n def cnt(l, r)\n ans = 0\n flag = false\n while true do\n sum = 0\n while l>-1 && @a[l] == @a[r]\n l -= 1\n sum += 1\n end\n l += 1\n while r < @n && @a[l] == @a[r]\n r += 1\n sum += 1\n end\n r -= 1\n return ans if flag && sum < 3\n flag = 1\n ans = [ans, r - l + 1].max\n l -= 1\n r += 1\n return ans if l <0 || r >= @n || @a[l] != @a[r]\n end\n end\nend\n\nsolver = Solver.new(n, k, x, a)\nans = 0\nfor i in 0..n-1\n ans = [ans, solver.cnt(i, i+1)].max if a[i] == a[i+1] && a[i] == x\nend\n\nputs ans\n", "positive_code": [{"source_code": "# Created by Alex\nn, k, x = gets.split.map {|i| i.to_i}\na = gets.split.map {|i| i.to_i}\nmax = 0\nmaxi = -1\nfor i in 0...n - 1\n #print a[i].to_s + ' '\n if a[i] != x || a[i + 1] != x\n next\n end\n l = i - 1\n r = i + 2\n cnt = 3\n while l >= 0 && r < n && a[l] == a[r]\n p1 = l\n while p1 > 0 && a[p1 - 1] == a[r]\n p1 -= 1\n end\n p2 = r\n while p2 < n - 1 && a[p2 + 1] == a[l]\n p2 += 1\n end\n if l - p1 + p2 - r + 2 < 3\n break\n end\n cnt += l - p1 + p2 - r + 2\n l = p1 - 1\n r = p2 + 1\n end\n if cnt >= max\n #print ' (' + cnt.to_s + ' ' + p1.to_s + ' ' + p2.to_s + ') '\n max = cnt\n maxi = i\n end\nend\nif max < 3\n max = 1\nend\nputs max - 1"}], "negative_code": [{"source_code": "myArray = $stdin.readlines\n\ninput=[]\n\nmyArray.each do |l|\n input.push(l)\nend\n\na = input[0].split(',').map{|x| x.to_i}\n\n#insert your code within this function\ndef solution(a)\n a2 = a.sort\n n = a2.size\n index_swap = 0\n for i in 0..n-1\n index_swap +=1 if a[i] != a2[i]\n end\n return index_swap <= 2\nend\n\nputs solution(a)\n"}, {"source_code": "# Created by Alex\nn, k, x = gets.split.map {|i| i.to_i}\na = gets.split.map {|i| i.to_i}\nmax = 0\nfor i in 0...n - 1\n if a[i] != x || a[i + 1] != x\n next\n end\n l = i - 1\n r = i + 2\n cnt = 3\n while l >= 0 && r < n\n p1 = l\n while p1 > 0 && a[p1 - 1] == a[r]\n p1 -= 1\n end\n p2 = r\n while p2 < n - 1 && a[p2 + 1] == a[l]\n p2 += 1\n end\n if l - p1 + p2 - r + 2 < 3\n break\n end\n cnt += l - p1 + p2 - r + 2\n l = p1 - 1\n r = p2 + 1\n end\n if cnt > max\n max = cnt\n end\nend\nif max < 3\n max = 1\nend\nputs max - 1"}, {"source_code": "# Created by Alex\nn, k, x = gets.split.map {|i| i.to_i}\na = gets.split.map {|i| i.to_i}\nmax = 0\nfor i in 0...n - 2\n if a[i + 1] != x || a[i + 2] != x\n next\n end\n l = i - 1\n r = i + 2\n cnt = 3\n while l >= 0 && r < n\n p1 = l\n while p1 > 0 && a[p1 - 1] == a[r]\n p1 -= 1\n end\n p2 = r\n while p2 < n - 1 && a[p2 + 1] == a[l]\n p2 += 1\n end\n if l - p1 + p2 - r + 2 < 3\n break\n end\n cnt += l - p1 + p2 - r + 2\n l = p1 - 1\n r = p2 + 1\n end\n if cnt > max\n max = cnt\n end\nend\nif max < 3\n max = 1\nend\nputs max - 1"}, {"source_code": "# Created by Alex\nn, k, x = gets.split.map {|i| i.to_i}\na = gets.split.map {|i| i.to_i}\nmax = 0\nfor i in 0...n - 1\n if a[i] != x && a[i + 1] != x\n next\n end\n l = i\n r = i\n if a[i] == x && a[i + 1] == x\n l = i - 1\n r = i + 2\n end\n if a[i] == x && i > 0 && a[i - 1] == x\n l = i - 2\n r = i + 1\n end\n if a[i + 1] == x && i + 2 < n && a[i + 2] == x\n l = i\n r = i + 3\n end\n if l == i && r == i\n next\n end\n cnt = 3\n while l >= 0 && r < n\n p1 = l\n while p1 > 0 && a[p1 - 1] == a[r]\n p1 -= 1\n end\n p2 = r\n while p2 < n - 1 && a[p2 + 1] == a[l]\n p2 += 1\n end\n if l - p1 + p2 - r + 2 < 3\n break\n end\n cnt += l - p1 + p2 - r + 2\n l = p1 - 1\n r = p2 + 1\n end\n if cnt > max\n max = cnt\n end\nend\nif max < 3\n max = 1\nend\nputs max - 1"}], "src_uid": "d73d9610e3800817a3109314b1e6f88c"} {"source_code": "LIMIT = 1000000007\n\n@res = []\nl = 1\nwhile l < LIMIT\n @res << l\n l = l * 2\nend\n\ndef power i\n return @res[i] if i < @res.size\n half_power = power(i/2)\n partial = (half_power * half_power) % LIMIT \n if i % 2 == 1\n partial = (partial * 2) % LIMIT\n end\n partial\nend\n\nyears = gets.to_i\n\nif years == 0\n puts 1\nelse\n partial = power(years-1)\n puts (partial * (((2 * partial) % LIMIT) + 1)) % LIMIT\nend\n\n# 2^(n-1) * (2^n +1)\n", "positive_code": [{"source_code": "x = Integer gets.to_s\nif x == 0 then\n\tputs 1\n\texit\nend\nd = 1000000\nif x < d then\n\tx = 2**(x-1) * (1+2**x) % 1000000007\n\tputs x\n\texit\nend\n\nx -= 1\np = 1\nwhile x >= d\n\te = d\n\tq = 2**d % 1000000007\nwhile x >= e do\n\tp *= q\n\tp = p % 1000000007\n\tx -= e\n\te *= 10\n\tq = q**10 % 1000000007\n\nend\nend\n\np *= 2**x\np = p % 1000000007\n\np = (p * ( 1 + 2*p)) % 1000000007\n\nputs p\n"}, {"source_code": "\n\n\n$p = 1000000007\ndef mul(a,b)\n n = a.size\n c = Array.new(n){Array.new(n){0}}\n n.times do |i|\n n.times do|j|\n n.times do |k|\n c[i][j] += a[i][k] * b[k][j]\n c[i][j] %= $p\n end\n end\n end\n c\nend\n\ndef po(m)\n e = [[3,1],[1,3]]\n ret = [[1,0],[0,1]]\n \n while m > 0\n if m % 2 == 1\n ret = mul(ret,e)\n end\n e = mul(e,e)\n m /= 2\n end\n \n ret\nend\n\n\ndef work(n)\n if n == 1\n puts 3\n else\n ret = po(n)\n ans = ret[0][0]\n puts ans % $p\n end\nend\n\nn = gets.to_i\nwork n\n\n"}, {"source_code": "$p = 1000000007\ndef mul(a,b)\n n = a.size\n c = Array.new(n){Array.new(n){0}}\n n.times do |i|\n n.times do|j|\n n.times do |k|\n c[i][j] += a[i][k] * b[k][j]\n c[i][j] %= $p\n end\n end\n end\n c\nend\n\ndef po(m)\n e = [[3,1],[1,3]]\n ret = [[1,0],[0,1]]\n \n while m > 0\n if m % 2 == 1\n ret = mul(ret,e)\n end\n e = mul(e,e)\n m /= 2\n end\n \n ret\nend\n\n\ndef work(n)\n if n == 1\n puts 3\n else\n ret = po(n)\n ans = ret[0][0]\n puts ans % $p\n end\nend\n\nn = gets.to_i\nwork n"}, {"source_code": "$p = 1000000007\ndef mul(a,b)\n n = a.size\n c = Array.new(n){Array.new(n){0}}\n n.times do |i|\n n.times do|j|\n n.times do |k|\n c[i][j] += a[i][k] * b[k][j]\n c[i][j] %= $p\n end\n end\n end\n c\nend\n\ndef po(m)\n e = [[3,1],[1,3]]\n ret = [[1,0],[0,1]]\n \n while m > 0\n if m % 2 == 1\n ret = mul(ret,e)\n end\n e = mul(e,e)\n m /= 2\n end\n \n ret\nend\n\n\ndef work(n)\n if n == 1\n puts 3\n else\n ret = po(n)\n ans = ret[0][0]\n puts ans % $p\n end\nend\n\nn = gets.to_i\nwork n\n#10.times{|x| work x+1}\n\n "}, {"source_code": "def pow(a,k)\n n = 1000000007\n b = 1\n while (k!= 0) do\n if (k % 2 == 0 ) then\n k/=2\n a = (a*a) % n\n else\n k-=1\n b = (b*a) % n\n end\n end\n return b\nend\n\n\nn = gets.to_i\nk = pow(2,n)\nk = (k*(k-1)/2) % 1000000007\nif (n == 0) then\n puts \"1\"\nelse\n ans = (pow(4,n) - k) % 1000000007\n puts ans\nend\n"}], "negative_code": [{"source_code": "x = Integer gets.to_s\n\nd = 1000000\nif x < d then\n\tx = 2**(x-1) * (1+2**x)\n\tputs x\n\texit\nend\n\nx -= 1\np = 1\nq = 2**d % 1000000007\nwhile x >= d\n\te = d\nwhile x >= e do\n\tp *= q\n\tp = p % 1000000007\n\tx -= e\n\te *= 10\nend\nend\n\np *= 2**x\np = p % 1000000007\n\np = (p * ( 1 + 2*p)) % 1000000007\n\nputs p\n"}, {"source_code": "def pow(a,k)\n n = 1000000007\n b = 1\n while (k!= 0) do\n if (k % 2 == 0 ) then\n k/=2\n a = (a*a) % n\n else\n k-=1\n b = (b*a) % n\n end\n end\n return b\nend\n\n\nn = gets.to_i\nif (n == 0) then\n puts \"1\"\nelse\n ans = pow(4,n)/2 + pow(2,n-1)\n puts ans\nend\n"}, {"source_code": "n = gets.to_i\nif (n == 0) then\n puts \"1\"\nelse\n puts((4**n/2 + 2**(n-1) ) % 1000000007)\nend"}, {"source_code": "\ndef pow(a,k)\n n = 1000000007\n b = 1\n while (k!= 0) do\n if (k % 2 == 0 ) then\n k/=2\n a = (a*a) % n\n else\n k-=1\n b = (b*a) % n\n end\n end\n return b\nend\n\n\nn = gets.to_i\nif (n == 0) then\n puts \"1\"\nelse\n ans = (pow(4,n)/2 + pow(2,n-1)) % 1000000007\n puts ans\nend\n"}, {"source_code": "n = gets.to_i\nputs (4**n/2 + 2**(n-1) ) % 1000000007"}], "src_uid": "782b819eb0bfc86d6f96f15ac09d5085"} {"source_code": "#!/usr/bin/env ruby\n\nN = gets.to_i\n\ndef total_sections\n return 1 if N == 3\n return 4 if N == 4\n\n sections_without_2_triangles = (3..N-2).map do |second_vertice|\n third_vertice = second_vertice + 1\n\n lines_from_second = N - second_vertice - 1\n lines_from_third = third_vertice - 3\n\n lines_from_second + lines_from_third + 1\n end.inject(:+)\n\n sections_without_2_triangles + (N-2)*2\nend\n\nputs total_sections\n", "positive_code": [{"source_code": "angles = gets.to_i\nputs (angles - 2) * (angles - 2)"}, {"source_code": "puts (gets.strip.to_i - 2) ** 2\n"}, {"source_code": "n = gets.chomp.to_i\nputs n ** 2 - 4 * n + 4\n"}, {"source_code": "class Solver\n\tdef main\n\t\tn = gets.to_i\n\t\tputs (n - 2) ** 2\n\tend\nend\n\nSolver.new.main\n"}, {"source_code": "n = gets.to_i\nputs n * (n - 3) - (n - 4)\n"}, {"source_code": "puts (gets.to_i - 2) ** 2\n"}, {"source_code": "n = gets.chomp.to_i\nif n == 3 then\n puts 1\nelse\n a1 = 1\n 4.upto(n).each do |a|\n a1 += 3 + 2*(a-4)\n end\n puts a1\nend\n"}, {"source_code": "n = gets.chomp.to_i\np (n-2)**2"}, {"source_code": "class Solver\n\tdef main\n\t\tn = gets.to_i\n\t\tputs (n - 2) ** 2\n\tend\nend\n\nSolver.new.main\n"}, {"source_code": "puts (gets.to_i - 2) ** 2\n"}, {"source_code": "#! /usr/bin/env ruby\n\nn = $stdin.gets.to_i\nputs (n-2)**2\n"}, {"source_code": "n=gets.chomp.to_i\nn=(n-1)*(n-3)+1\nputs n.inspect"}], "negative_code": [], "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b"} {"source_code": "mas = gets.split(\" \")\nn, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i\nper, ch = k-n-m+2, 2*(m-1)\nif k < (n+m-1)\n\tfinvar = k < n ? [k+1, 1] : [n, k-n+2]\nelse\n\tis = per % (m-1) == 0 ? (n-per/(m-1)) : (n-per/(m-1)-1)\n\tprom = per % ch\n\tif prom == 0\n\t\tprom = ch\n\tend\n\tfinvar = prom <= (m-1) ? [is, m-prom+1] : [is, 1+prom-(m-1)]\nend\nputs finvar[0], finvar[1]", "positive_code": [{"source_code": "mas = gets.split(\" \")\nn, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i\nper, ch = k-n-m+2, 2*(m-1)\nif k < (n+m-1)\n\tfinvar = k < n ? [k+1, 1] : [n, k-n+2]\nelse\n\tif per % (m-1) == 0\n\t\tis = n - per/(m-1)\n\telse\n\t\tis = n - per/(m-1) - 1\n\tend\n\tprom = per % ch\n\tif prom == 0\n\t\tprom = ch\n\tend\n\tfinvar = prom <= (m-1) ? [is, m-prom+1] : [is, 1+prom-(m-1)]\nend\nputs finvar[0], finvar[1]"}, {"source_code": "n, m, k = gets.split.map(&:to_i)\nif k < n\n puts \"#{k + 1} 1\"\nelse\n hoge = (m - 1) * 2\n k -= n\n r = n - k / hoge * 2\n tmp = k % hoge\n c = 0\n if tmp < m - 1\n c = tmp + 2\n else\n c = 2 * (m - 1) - tmp + 1\n r -= 1\n end\n puts \"#{r} #{c}\"\nend"}, {"source_code": "n, m , k=gets.split.map(&:to_i)\n\nif k<=n-1\n puts \"#{k+1} 1\"\n exit 0\nend\n\nk-=(n-1)\na=(k-1)/((m-1)*2)\nx=n-a*2\nb=((k-1)% ((m-1)*2))+1\nx-=1 if b>m-1\nif b<=m-1\n puts \"#{x} #{1+b}\"\nelse\n puts \"#{x} #{m-(b-(m-1)-1)}\"\nend\n\n"}, {"source_code": "mas = gets.split(\" \")\nn, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i\nper, ch = k-n-m+2, 2*(m-1)\nif k < (n+m-1)\n\tfinvar = k < n ? [k+1, 1] : [n, k-n+2]\nelse\n\tis = per % (m-1) == 0 ? (n-per/(m-1)) : (n-per/(m-1)-1)\n\tprom = per % ch == 0 ? ch : (per % ch)\n\tfinvar = prom <= (m-1) ? [is, m-prom+1] : [is, 1+prom-(m-1)]\nend\nputs finvar[0], finvar[1]"}], "negative_code": [{"source_code": "mas = gets.split(\" \")\nn, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i\nif k < (n+m - 1)\n\tfinvar = k < n ? [k+1, 1] : [n, k-n+2]\nelse\n\tis = n - (Float(k-(n+m-2))/(m-1)).ceil\n\tncheck = n % 2\n\tischeck = is % 2\n\tif (ncheck ^ ischeck) == 0\n\t\tfinvar = [is, 2 + ((k - (n+m-2)) % (m))]\n\telse\t\n\t\tif (per = ((k - (n+m-2)) % (m-1))) == 0\n\t\t\tfinvar = [is, 2]\n\t\telse\n\t\t\tfinvar = [is, m + 1 - per]\n\t\tend\n\tend\nend\nputs finvar[0], finvar[1]"}, {"source_code": "mas = gets.split(\" \")\nn, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i\nif k < (n+m - 1)\n\tfinvar = k < n ? [k+1, 1] : [n, k-n+2]\nelse\n\tis = n - (Float(k-(n+m-2))/(m-1)).ceil\n\tfinvar = [is, 2 + ((k - (n+m-2)) % (m-1))]\nend\nputs finvar[0], finvar[1]"}, {"source_code": "mas = gets.split(\" \")\nn, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i\nif k < (n+m - 1)\n\tfinvar = k < n ? [k+1, 1] : [n, k-n+2]\nelse\n\tis = n - (Float(k-(n+m-2))/(m-1)).ceil\n\tprom = (k-n-m+2) % (2*(m-1))\n\tif prom == 0\n\t\tprom = 2*(m-1)\n\tend\n\tfinvar = prom <= (m-1) ? [is, m-prom+1] : [is, 1+prom-(m-1)]\nend\nputs finvar[0], finvar[1]"}, {"source_code": "mas = gets.split(\" \")\nn, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i\nper, ch = k-n-m+2, 2*(m-1)\nif k < (n+m-1)\n\tfinvar = k < n ? [k+1, 1] : [n, k-n+2]\nelse\n\tif per % (m-1) == 0\n\t\tis = n - per/(m-1)\n\telse\n\t\tis = n - (Float(per)/(m-1)).floor - 1\n\tend\n\tprom = per % ch\n\tif prom == 0\n\t\tprom = ch\n\tend\n\tfinvar = prom <= (m-1) ? [is, m-prom+1] : [is, 1+prom-(m-1)]\nend\nputs finvar[0], finvar[1]"}, {"source_code": "mas = gets.split(\" \")\nn, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i\nif k < (n+m - 1)\n\tfinvar = k < n ? [k+1, 1] : [n, k-n+2]\nelse\n\tis = n - (Float(k-(n+m-2))/(m-1)).ceil\n\tncheck = n % 2\n\tischeck = is % 2\n\tif (ncheck ^ ischeck) == 0\n\t\tfinvar = [is, 2 + ((k - (n+m-2)) % (m-1))]\n\telse\t\n\t\tif (per = ((k - (n+m-2)) % (m-1))) == 0\n\t\t\tfinvar = [is, 2]\n\t\telse\n\t\t\tfinvar = [is, m + 1 - per]\n\t\tend\n\tend\nend\nputs finvar[0], finvar[1]"}], "src_uid": "e88bb7621c7124c54e75109a00f96301"} {"source_code": "N, M, R = gets.split.map(&:to_i)\nS = gets.split.map(&:to_i)\nB = gets.split.map(&:to_i)\n\ns = S.min\ncnt = R / s\nb = B.max\ndiff = b - s\n\nmoney = R + diff * cnt\nputs [money, R].max\n", "positive_code": [{"source_code": "n,m,r = gets.split.map(&:to_i)\na = gets.split.map(&:to_i).min\nb = gets.split.map(&:to_i).max\np a < b ? (r/a)*b + r % a : r"}, {"source_code": "n,m,r = gets.split.map(&:to_i)\ns = gets.split.map(&:to_i).min\nb = gets.split.map(&:to_i).max\nif s > b\n puts r\nelse\n puts r%s+(r/s)*b\nend\n"}, {"source_code": "n, m, r = gets.chomp.split.map(&:to_i)\nbuy = gets.chomp.split.map(&:to_i).min\nsell = gets.chomp.split.map(&:to_i).max\n\nif sell > buy\n shares = r / buy\n profit = shares * (sell - buy)\n r += profit\nend\n\nputs r\n"}], "negative_code": [], "src_uid": "42f25d492bddc12d3d89d39315d63cb9"} {"source_code": "#!/usr/bin/ruby\n# Made With LOVE <3\n\nn = gets.to_i\ni=1\ns=0\nwhile i<=n\ns = s + n - (i-1)\ni*=10\nend\n\nputs s\n", "positive_code": [{"source_code": "# cook your code here\n\na = gets.to_i \nb = 0\nans = 0\n\nuntil a < b \n ans = ans + a - b;\n b = 10*b + 9 \nend \n\nputs ans "}, {"source_code": "def f(n)\n result, total, k = 0, 10, 1\n \n while n >= total do\n result += k * (total - total / 10)\n k += 1\n total *= 10\n end\n \n result + (n - total / 10 + 1) * k\nend\n\nputs f(gets.to_i)"}, {"source_code": "def f(n)\n result, total, k = 0, 10, 1\n while n >= total do\n result += k * (total - total / 10)\n k += 1\n total *= 10\n end\n result + (n - total / 10 + 1) * k\nend\nputs f(gets.to_i)"}, {"source_code": "n = gets.chomp\n\ndigit_count = n.length\nn = n.to_i\n\nresult = (n - (10 ** (digit_count - 1) - 1)) * digit_count\n\nresult += (1..(digit_count - 1)).inject(0) do |sum, count|\n\tsum + (9 * 10 ** (count - 1)) * count\nend\n\nputs result"}, {"source_code": "n = gets.to_i\nans = 0\nlen = 1\nbase = 10\nwhile true\n if n < base then\n ans += (n - base / 10 + 1) * len\n break\n else\n ans += base / 10 * 9 * len\n end\n len += 1\n base *= 10\nend\nputs ans\n"}, {"source_code": "# http://codeforces.com/contest/552/problem/B\nn = gets.chomp.to_i\nsum = 0\n\n(0...n.to_s.chars.length).each do |idx|\n d = [9 * (10 ** idx), n].min\n n -= d\n sum += d * (idx + 1)\nend\n\nputs sum\n"}, {"source_code": "# coding: utf-8\n\n# 총 기록해야하는 숫자의 개수를 의미를 가리킵니다.\n# n = 13의 경우\n# n[1..9]: 1, 2, 3, 4, 5, 6, 7, 8, 9 -> 9글자\n# n[10..13]: 10, 11, 12, 13 -> 8글자\n# 총 합쳐서 17글자가 필요합니다.\n\nn = gets.to_i\nt = 0\nfor i in 1..10\n s, e = 10**(i-1), (10**i) - 1\n #p [s,e]\n if e < n\n t += (e - s + 1) * i # 10 ~ 99 -> 총 몇개의 숫자가 존재할까, 89개가 아니라 90개\n else\n if s <= n\n t += (n - s + 1) * i\n else\n break\n end\n end\nend\n\nputs t"}, {"source_code": "number = gets.chomp.to_i\nresult = 0\nmaxDigit = 10\ndivisor = 1000000000\n\nuntil number / divisor != 0\n\tmaxDigit -= 1\n\tdivisor /= 10\nend\n\nnowDigit = 1\n\nuntil nowDigit == maxDigit\n\tresult += (9 * (10**(nowDigit - 1))) * nowDigit\n\n\tnowDigit += 1\nend\n\nresult += ((number - (10**(maxDigit - 1))) + 1) * maxDigit\n\nputs result"}, {"source_code": "a=gets.chomp\nl=a.length-1\nif l==0\nputs a\nelse\nans=9\n2.upto l do |i|\nans+= (9*(10**(i-1)))*i\nend\nans+=(a.to_i-(\"9\"*l).to_i)*(l+1)\nputs ans.inspect\nend\n\n\n"}, {"source_code": "n = gets.strip!\ns,c = n.length,0\n(1...s).each{ |i| c += i*(9*10**(i-1)) }\np c+(n.to_i-(10**(s-1)-1))*s"}, {"source_code": "n = gets.chomp\nans = 0\nnum = 9\n(1...n.size).each do |i|\n ans += i*num\n num *= 10\nend\nans += n.size*(n.to_i-10**(n.size-1)+1)\nputs ans\n"}, {"source_code": "n = gets.to_i\nans = 0\nn.to_s.chars.size.times do |i|\n a = [9 * (10 ** i), n].min\n n -= a\n ans += a * (i + 1)\nend\np ans\n"}, {"source_code": "a=gets.to_i\nr=9\nans=0\nwhile a>0\n\tans+=a\n\ta-=r\n\tr*=10\nend\n\nputs ans\n\n"}, {"source_code": "#!/usr/bin/env ruby\n\nnum = ARGF.gets.chomp\nlength = num.length\ncount = 0\nif length > 1\n num = (num.to_i - ('9' * (length - 1)).to_i).to_s\nend\n\n\ncount += (num.to_i) * length\n\n\nlength -= 1\nwhile (length > 0) do\n count += (9 * 10**(length - 1)) * length\n length -= 1\nend\n\nputs count\n\n"}, {"source_code": "n=gets.to_i\nif n<10\nputs n\n\nelse\ni,ii,s,t=0,0,0,2\n\n while not(t==0)\n i+=1\n t=n/(10**i)\n end\n\nii=i-1\n\n for p in (1...i)\n s+=9*p*(10**(p-1))\n end\n \ns+=(n+1-(10**ii))*i\n\nputs s\nend"}, {"source_code": "\nn = gets().chomp().to_i\nm = n\ndig =0\nwhile m != 0\n dig += 1\n m /= 10\nend\n\nj =0\nk =1\nfor i in (1..(dig-1))\n\n j+= i*(1+(10**i-1)-(10**(i-1)))\nend\nputs j + (dig*(n-(10**(dig-1))+1))\n\n\n"}, {"source_code": "n = gets.to_i\nd = n.to_s.length\n\nans = n * d\n1.upto(d - 1) do |i|\n\tans -= (d - i) * 9 * 10 ** (i - 1)\nend\nputs ans\n"}, {"source_code": "n = gets.to_i\ns = 1\nans = 0\nwhile s.to_s.length < n.to_s.length\n ans += s * 9 * s.to_s.length\n s *= 10\nend\nans += (n - s + 1) * n.to_s.length\np ans"}], "negative_code": [{"source_code": "n = gets\ns,c = n.length,0\nn = n.to_i\n(1...s).each{ |i| c += i*(9*10**(i-1)) }\np c+(n-(10**(s-1)-1))*s"}, {"source_code": "n = gets\ns,n,c = n.size,n.to_i,0\n(1...s).each{ |i| c += i*(9*10**(i-1)) }\np c+(n-(10**(s-1)-1))*s"}, {"source_code": "n = gets\ns,c = n.size,0\nn = n.to_i\n(1...s).each{ |i| c += i*(9*10**(i-1)) }\np c+(n-(10**(s-1)-1))*s"}, {"source_code": "#!/usr/bin/env ruby\n\nnum = ARGF.gets.chomp\nlength = num.length\ncount = 0\nif length > 1\n num = num[1..-1]\nend\ncount += (num.to_i + 1) * length\nif length == 1\n count -= 1\nend\n\n\n\n\nlength -= 1\nwhile (length > 0) do\n count += (9 * 10**(length - 1)) * length\n length -= 1\nend\n\nputs count\n\n"}, {"source_code": "n = gets.chomp\n\ndigit_count = n.length\nn = n.to_i\n\nresult = (n - (10 ** (digit_count - 1) - 1)) * digit_count\n\nresult += (1..(digit_count - 1)).inject(0) do |sum, count|\n\tsum + ('9' * count).to_i * count\nend\n\nresult"}, {"source_code": "n = gets.chomp\n\ndigit_count = n.length\nn = n.to_i\n\nresult = (n - (10 ** (digit_count - 1) - 1)) * digit_count\n\nresult += (1..(digit_count - 1)).inject(0) do |sum, count|\n\tsum + ('9' * count).to_i * count\nend\n\nputs result"}, {"source_code": "#!/usr/bin/ruby\n# Made With LOVE <3\n\nn = gets.to_i\ni=1\ns=0\nwhile i 9글자\n# n[10..13]: 10, 11, 12, 13 -> 8글자\n# 총 합쳐서 17글자가 필요합니다.\n\nn = gets.to_i\nt = 0\nfor i in 1..10\n s, e = 10**(i-1), (10**i) - 1\n #p [s,e]\n if e < n\n t += (e - s + 1) * i # 10 ~ 99 -> 총 몇개의 숫자가 존재할까, 89개가 아니라 90개\n else\n if s < n\n t += (n - s + 1) * i\n else\n break\n end\n end\nend\n\nputs t"}], "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9"} {"source_code": "a=gets.chomp.to_i\nans=0\nloop do \nif a%2==1\n ans+=1\nend\na=a/2\nbreak if a==0\nend\nputs \"#{ans}\"\n\n", "positive_code": [{"source_code": "user_input = gets.chomp\nuser_input = user_input.to_i\ncount = 0\nwhile user_input != 0\n count += user_input & 1\n user_input = user_input >> 1\nend\nprint count\n"}, {"source_code": "class Solver\n\tdef main\n\t\tn = gets.to_i\n\t\tans = (0..30).to_a.count { |i| n[i] == 1 }\n\t\tputs ans\n\tend\nend\n\nSolver.new.main\n"}, {"source_code": "puts gets.chomp.to_i().to_s(2).count('1')"}, {"source_code": "p gets.to_i.to_s(2).count(?1)"}, {"source_code": "#!/usr/bin/ruby\n\nn = gets.to_i\nans = 0\nwhile n > 0\n # p \"n=#{n}, ans=#{ans}\"\n ans+=1 if n % 2 == 1\n n/=2\nend\n\nputs ans\n"}, {"source_code": "puts gets.to_i.to_s(2).count '1'"}, {"source_code": "p sprintf(\"%b\", gets.chomp).gsub('0', '').length"}, {"source_code": "#! /usr/bin/env ruby\n\nx = gets.to_i\nputs x.to_s(2).count('1')\n\n"}, {"source_code": "a = gets.to_i\nsum = 0\n(0..48).each {|n| sum += a[n]}\nputs sum"}, {"source_code": "n = gets.chomp.to_i\n\nc = 0\n\nwhile n > 1\n\n if n % 2 == 0\n n /= 2\n else\n c += 1\n n -= 1\n end\nend\n\nputs c + 1\n"}, {"source_code": "puts gets.to_i.to_s(2).count('1')\n"}, {"source_code": "x = gets.to_i\nans = 0\nwhile x>0\n x=x&(x-1)\n ans += 1\nend\nprint ans"}, {"source_code": "a=gets.chomp.to_i\nans=0\nloop do \nif a%2==1\n ans+=1\nend\na=a/2\nbreak if a==0\nend\nputs \"#{ans}\"\n"}, {"source_code": "n=gets.to_i.to_s(2)\np n.chars.count{|e|\n\te==\"1\"\n}"}, {"source_code": "n = gets.to_i\nr = 0\nwhile n > 0\n\tif n % 2 > 0\n\t\tr += 1\n\tend\n\tn = n / 2\nend\np r"}, {"source_code": "#$stdin = File.open('in.txt')\n#$stdout = File.open('out.txt', 'w')\n\nn = gets.to_i\n\nans = 0\nwhile (n > 0) do\n ans += 1 if n % 2 == 1\n n /= 2\nend\n\np ans\n"}, {"source_code": "x = gets.chomp.to_i\n\nrtn = 0\nwhile 0 < x\n rtn += x % 2\n x /= 2\nend\nputs rtn\n"}, {"source_code": "puts (gets.to_i).to_s(2).count('1')\n"}, {"source_code": "num = gets.chomp.to_i\ncount = 0\nuntil num == 0\n count += num%2\n num = num/2\nend\np count"}, {"source_code": "puts gets.to_i.to_s(2).count('1')"}, {"source_code": "a = gets.to_i\nans = 0\nc = 2**30\nwhile c > 0\n ans += a / c\n a %= c\n c /= 2\nend\nputs ans\n"}, {"source_code": "puts gets.to_i.to_s(2).count('1')\n"}, {"source_code": "a = gets.to_i\nputs a.to_s(2).count('1')\n"}, {"source_code": "puts gets.to_i.to_s(2).chars.count('1')\n"}], "negative_code": [{"source_code": "#!/usr/bin/ruby\n\nn = gets.to_i\nx = 1\nwhile x*2 <= n\n x*=2\nend\n\nputs 1 + n - x\n"}, {"source_code": "a = gets.to_i\nputs a.odd? && a != 1 ? 2 : 1\n"}], "src_uid": "03e4482d53a059134676f431be4c16d2"} {"source_code": "n, k = gets.split(/\\s+/).map {|x| x.to_i}\nclass Integer\n def num_at_position (k)\n chet_num, ostatok = self.divmod(2)\n nechet_num = chet_num + ostatok\n if k > nechet_num\n return (k - nechet_num) * 2\n else\n return k * 2 - 1\n end\n end\nend\n\nputs n.num_at_position(k)", "positive_code": [{"source_code": "def run\n n, k = $stdin.gets.split.map(&:to_i)\n\n if k <= ((n + 1)/ 2)\n puts (k * 2 - 1)\n else\n puts ((k - ((n + 1)/ 2)) * 2)\n end\nend\n\nrun if $0 == __FILE__\n"}, {"source_code": "n, k = gets.chomp.split.map &:to_i\nif k > (n / 2.0).ceil \n puts 2 * (k - (n / 2.0).ceil)\nelse\n puts 2 * k - 1\nend\n"}, {"source_code": "class A\n def initialize\n n, k = gets.split(' ').map(&:to_i)\n d = 0\n\n if n.even?\n if k <= n/2\n puts 2*k-1\n else\n puts 2*(k-n/2)\n end\n else\n if k <= n/2+1\n puts 2*k-1\n else\n puts 2*(k-(n/2+1))\n end\n end\n end\nend\n\na = A.new"}, {"source_code": "n,k=gets.split.map(&:to_i)\nt=(n+1)/2\np k>t ? 2*(k-t) : 2*k-1\n"}, {"source_code": "a=gets.chomp.split(\" \")\nodd=(a[0].to_i/2.0).ceil\neven=(a[0].to_i/2.0)\nif a[1].to_i<=odd\nans=2*(a[1].to_i-1)+1\nputs \"#{ans}\"\nelse\nans=2*(a[1].to_i-odd)\nputs \"#{ans}\"\nend\n"}, {"source_code": "n,k=gets.split.map(&:to_i)\nt=(n+1)/2\np k>t ? 2*(k-t) : 2*k-1\n"}, {"source_code": "n, k = gets.chomp.split(/ /).map(&:to_i)\nmid = n / 2\nmid += 1 if n.odd?\nans = (k - mid) * 2\nans = (2 * k) - 1 if mid >= k\nputs \"#{ans}\"\n"}, {"source_code": "a=gets.chomp.split(\" \")\nodd=(a[0].to_i/2.0).ceil\neven=(a[0].to_i/2.0)\nif a[1].to_i<=odd\nans=2*(a[1].to_i-1)+1\nputs \"#{ans}\"\nelse\nans=2*(a[1].to_i-odd)\nputs \"#{ans}\"\nend"}, {"source_code": "n,k=gets.split.map(&:to_i)\na=(n+1)/2\np k>a ?2*(k-a):2*k-1"}, {"source_code": "n,k=gets.split.map{|e| e.to_i}\ne=n/2+n%2\nputs (k<=e)?2*k-1:(k-e)*2"}, {"source_code": "n, k = gets.chomp.split.map(&:to_i)\na = n.odd? ? n/2+1 : n/2\nputs k <= a ? 2*k-1 : 2*(k-a)\n"}, {"source_code": "n, k = gets.split.map(&:to_i)\nk -= 1\n\nt = (n.to_f / 2).ceil\n\nif k < t\n puts 1 + 2 * k\nelse\n puts 2 + 2 * (k - t)\nend\n"}, {"source_code": "d, n = gets.chomp.split.map(&:to_i)\n\nif d % 2 == 0\n ot = d/2\n if n <= ot\n puts (2*n) - 1\n else\n puts 2*(n-ot)\n end\nelse\n ot = (d/2.0).ceil\n if n <= ot\n puts (2*n) - 1\n else\n puts 2*(n-ot)\n end\nend"}, {"source_code": "n,k=gets.split.map(&:to_i)\nodd=(n+1)/2\nputs k<=odd ? 2*k-1 : 2*(k-odd)"}, {"source_code": "num = gets.chomp\nnum = num.split\nnumbers = num[0].to_i\nposition = num[1].to_i\n\nif position <= (numbers/2) + (numbers%2)\n\tnew_number = (position * 2) - 1\nelse\n\tnew_number = (position - ((numbers/2) + (numbers%2))) * 2\nend\n\nprint new_number"}, {"source_code": "n,k=gets.split.map(&:to_i)\nt=(n+1)/2\np k>t ? 2*(k-t) : 2*k-1\n"}, {"source_code": "#puts \"Enter the total number and position to find the number\\n\"\nn, v = gets.split.map(&:to_i)\nif n%2 == 0\n m = n/2\nelse\n m = n/2 + 1\nend\nif v <= m\n puts (2*v)-1\nelse\n puts 2*v - (2*m)\nend"}, {"source_code": "n,k = gets.split(\" \").map(&:to_i)\neven_count = n /2\nodd_count = n / 2\nodd_count += 1 if n % 2 != 0\nans = k > odd_count ? (k - odd_count) * 2 : k * 2 - 1\nputs ans"}, {"source_code": "a, b = gets.split.map &:to_i\n\nif a >= b * 2 - 1 - a % 2\n puts b * 2 - 1\nelse\n puts (b - a/2 - a % 2) * 2\nend\n"}, {"source_code": "a=gets.split.map &:to_i;puts (a[0]+1)/2>=a[1]?(2*a[1]-1):(2*(a[1]-(a[0]+1)/2))"}, {"source_code": "n, k = gets.split.map(&:to_i)\n\nif k <= n / 2 + (n % 2 == 1 ? 1 : 0)\n\tputs k * 2 - 1\nelse\n\tif n % 2 == 1\n\t\tputs (k - n / 2 - 1) * 2\n\telse\n\t\tputs (k - n / 2) * 2\n\tend\nend"}, {"source_code": "n,i = gets.split.map(&:to_i)\n(i>(n+1)/2)? (p (i-(n+1)/2)*2) : (p (i-1)*2+1)\n"}, {"source_code": "n, k = gets.chomp.split(' ').collect { |i| i.to_i }\n\nif k <= (n+1)/2 \n\tputs 2*k - 1\nelse\n\tputs 2*( k - (n+1)/2)\nend\n"}, {"source_code": "n , k = gets().split().map(&:to_i)\n\nmid = (n+1)/2\nif k>mid\n puts 2*(k-mid)\nelse\n puts (k*2)-1\nend"}, {"source_code": "n,k = gets.split(\" \").map(&:to_i)\nm = (n/2.0).ceil()\nif(k<=m)\n print((2*k)-1)\nelse\n print(2*(k-m))\nend"}, {"source_code": "s = gets.split(' ')\t#Танцы с бубном\n\nn = s[0].to_i\nk = s[1].to_i\n\nf = k - n/2 - n%2\n\nif f > 0\n\tputs 2 * f\nelse\n\tputs n - 1 + n % 2 + 2 * f\nend"}, {"source_code": "n, k = gets.strip.split(\" \").collect{|v| v.to_i}\nif k <= (n / 2.0).ceil then\n puts ((k-1)*2+1)\nelse\n puts ((k-(n/2.0).ceil)*2)\nend"}, {"source_code": "input = gets.split\nn = input[0].to_i\nk = input[1].to_i\nhalf = (n/2.0).ceil\n\nval = 0\nif k > half\n val = 2\n k -= half\nelse\n val = 1\nend\n\nval += 2*(k-1)\n\nprint val\n"}, {"source_code": "a=gets.chomp.split(\" \")\nodd=(a[0].to_i/2.0).ceil\neven=(a[0].to_i/2.0)\nif a[1].to_i<=odd\nans=2*(a[1].to_i-1)+1\nputs \"#{ans}\"\nelse\nans=2*(a[1].to_i-odd)\nputs \"#{ans}\"\nend"}, {"source_code": "n,k=gets.split.map(&:to_i)\nt=(n+1)/2\np k>t ? 2*(k-t) : 2*k-1"}, {"source_code": "n, k = gets.split.map(&:to_i)\n\nif 2*k-1 <= n\n puts 2*k-1\nelse\n puts 2*k - n - n%2\nend\n"}, {"source_code": "n,k=gets.split.map(&:to_i)\nt=(n+1)/2\np k>t ? 2*(k-t) : 2*k-1\n"}, {"source_code": "n, k = gets.split(' ').map(&:to_i)\n\nmid = n/2 + n%2\n\nif k > mid\n puts (k-mid)*2\nelse\n puts 2*k-1\nend\n"}, {"source_code": "n,k=gets.split.map(&:to_i)\na=(n+1)/2\np k>a ?2*(k-a):2*k-1"}, {"source_code": "#!/usr/bin/env ruby\n\nn, k = gets.split.map(&:to_i)\nputs k > (n + 1) / 2 ? (k - (n + 1) / 2) * 2 : 2 * k - 1\n"}, {"source_code": "g = gets.split(' ')\n\nn = g[0].to_f\nk = g[1].to_i\n\nif k > (n/2).ceil\n if n.modulo(2) == 0\n i = 2*k - n \n else\n i = 2*k - n - 1\n end\nelse\n i = 2*k - 1\nend\n\nputs i.to_i"}, {"source_code": "n,k=gets.split.map(&:to_i)\nt=(n+1)/2\np k>t ? 2*(k-t) : 2*k-1\n"}, {"source_code": "n,k=gets.split.map(&:to_i)\nputs k<=(n+1)/2?2*k-1:(k-(n+1)/2)*2"}, {"source_code": "n,k=gets.split.map(&:to_i)\na=(n+1)/2\np k>a ?2*(k-a):2*k-1"}, {"source_code": "n,k =gets.split(' ').map{|i| i.to_i()}\nans=k+k-1\nif(ans>n)\n\tans=(k-((n+1)>>1))<<1\nend\np ans"}, {"source_code": "n, k = gets.split.map { |x| x.to_i }\nevens = n / 2\nodds = n - evens\noffset = 0\nif k > odds\n\tk -= odds\n\toffset = 1\nend\n\nputs k * 2 - 1 + offset\n"}, {"source_code": "n,k=gets.split.map(&:to_i)\nt=(n+1)/2\np k>t ? 2*(k-t) : 2*k-1\n"}, {"source_code": "input = gets.chomp.split(' ').map {|item| item.to_i}\n\nn = input[0]\nk = input[1]\n\nmaxOdd = (n + 1) / 2\n\nputs (2 * k) - 1 if k <= maxOdd\nputs (2* (k - maxOdd)) if k > maxOdd"}, {"source_code": "n,k=gets.split.map &:to_i;puts((n+1)/2t ? 2*(k-t) : 2*k-1\n"}, {"source_code": "n,k=gets.split.map(&:to_i)\nt=(n+1)/2\np k>t ? 2*(k-t) : 2*k-1\n"}, {"source_code": "n,k=gets.split.map(&:to_i)\nt=(n+1)/2\np k>t ? 2*(k-t) : 2*k-1"}, {"source_code": "n,k=gets.split.map(&:to_i)\nt=(n+1)/2\np k>t ? 2*(k-t) : 2*k-1"}, {"source_code": "n,k=gets.split.map(&:to_i)\nt=(n+1)/2\np k>t ? 2*(k-t) : 2*k-1"}, {"source_code": "n,k = gets.split.map(&:to_i)\nt=(n/2.0).ceil\np k>t ? 2*(k-t) : 2*k-1"}, {"source_code": "n,k=gets.chomp.split.map(&:to_i)\nputs (k*2-1<=n)? k*2-1 : (k-(n+1)/2)*2"}, {"source_code": "n,k = gets.split.map(&:to_i)\n\ncs = (n+1)/2\nif k > cs\n puts (k-cs)*2\nelse\n puts (k*2)-1\nend"}, {"source_code": "n, k = $stdin.readline.split.map(&:to_i)\n\nif n%2==0\n if k <= n/2\n puts 2*(k-1)+1\n else\n k -= n/2\n puts 2*(k)\n end\nelse\n if k <= n/2+1\n puts 2*(k-1)+1\n else\n k -= n/2+1\n puts 2*(k)\n end\nend"}, {"source_code": "#!/usr/bin/env ruby\nn, k = gets.split(' ').map(&:to_i)\nodd = (n + 1) / 2\neven = n / 2\nif k <= odd\n puts k * 2 - 1\nelse\n puts (k - odd) * 2\nend\n"}], "negative_code": [{"source_code": "def run\n n, k = $stdin.gets.split.map(&:to_i)\n\n if k < (n / 2)\n puts (k * 2 - 1)\n else\n puts (((k - 1) - (n / 2)) * 2)\n end\nend\n\nrun if $0 == __FILE__\n"}, {"source_code": "n, k = gets.chomp.split.map &:to_i\nif k > (n / 2.0).ceil \n puts 2 * (n - (n / 2.0).ceil)\nelse\n puts 2 * k - 1\nend\n"}, {"source_code": "n, k = gets.chomp.split.map(&:to_i)\nif k < n / 2\n puts 2 * (k-1) + 1\nelse\n puts 2 * ((k-1) / 2)\nend\n"}, {"source_code": "n, k = gets.split.map(&:to_i)\nk -= 1\n\nif k < n / 2\n puts 1 + 2 * k\nelse\n k -= (n + 1) / 2\n puts 2 + 2 * k\nend\n"}, {"source_code": "n,k=gets.split.map(&:to_i)\nputs (2*k<=n ? 2*k-1 : k/2*2)"}, {"source_code": "n,k=gets.split.map(&:to_i)\nputs (n==1 ? 1: 2*k<=n ? 2*k-1 : k/2*2)"}, {"source_code": "n, k = gets.split.map(&:to_i)\n\nif k <= n / 2\n\tputs k * 2 - 1\nelse\n\tif n % 2 == 1\n\t\tputs (k - n / 2 - 1) * 2\n\telse\n\t\tputs (k - n / 2) * 2\n\tend\nend"}, {"source_code": "s = gets.split(' ')\t#Танцы с бубном\n\nn = s[0].to_i\nk = s[1].to_i\n\na = 1\ni = 1\n\nwhile a <= n && i < k\n\ta += 2\n\ti += 1\nend\n\nif i < k\n\ta = 2\nend\n\nwhile i < k\n\ta += 2\n\ti += 1\nend\n\nputs a"}, {"source_code": "n = gets.to_i\nk = gets.to_i\n\na = 1\ni = 1\n\nwhile a <= n && i < k\n\ta += 2\n\ti += 1\nend\n\nif i < k\n\ta = 2\nend\n\nwhile i < k\n\ta += 2\n\ti += 1\nend\n\nputs a"}, {"source_code": "input = gets.split\nn = input[0].to_i\nk = input[1].to_i\nhalf = (n/2.0).ceil\n\nval = 0\nif k > half\n val = 2\n k -= half\nelse\n val = 1\nend\n\nfor i in 1..k-1\n val += 2*(k-1)\nend\n\nprint val\n"}, {"source_code": "g = gets.split(' ')\n\nn = g[0].to_f\nk = g[1].to_i\n\nif k > (n/2).ceil\n i = 2*k - n\nelse\n i = 2*k - 1\nend\n\nputs i"}, {"source_code": "n,k=gets.split.map(&:to_i)\nputs k<=(n+1)/2?2*k-1:2*k-n-1"}, {"source_code": "input = gets.chomp.split(' ').map {|item| item.to_i}\n\nn = input[0]\nk = input[1]\n\nmaxOdd = (n - 1) / 2\n\nputs (2 * k) - 1 if k <= maxOdd\nputs (k / 2) + maxOdd if k > maxOdd"}, {"source_code": "n, k = $stdin.readline.split.map(&:to_i)\n\nif n%2==0\n if k <= n/2\n puts 2*(k-1)+1\n else\n puts 2*(k-1-n/2)\n end\nelse\n if k < n/2\n puts 2*(k-1)+1\n else\n puts 2*(k-1-n/2)\n end\nend"}, {"source_code": "n, k = $stdin.readline.split.map(&:to_i)\n\nif n%2==0\n if k <= n/2\n puts 2*(k-1)+1\n else\n puts 2*(k-n/2)\n end\nelse\n if k <= n/2+1\n puts 2*(k-1)+1\n else\n puts 2*(k-n/2)\n end\nend"}, {"source_code": "n, k = $stdin.readline.split.map(&:to_i)\n\nif n%2==0\n if k <= n/2\n puts 2*(k-1)+1\n else\n puts 2*(k-n/2)\n end\nelse\n if k < n/2\n puts 2*(k-1)+1\n else\n puts 2*(k-1-n/2)\n end\nend"}], "src_uid": "1f8056884db00ad8294a7cc0be75fe97"} {"source_code": "n = gets().to_i\narr = []\nn.times do\n arr += [gets().to_i]\nend\ncur = \"0\" * n\nlast = \"1\" * n\nf = false\nwhile (cur.to_i(10) < last.to_i(10))\n d = 0\n arr.each_with_index do |e, ind|\n if cur[ind] == '0'\n d -= e\n else\n d += e\n end\n end\n if (d % 360 == 0)\n f = true\n break\n end\n cur = (cur.to_i(2) + 1).to_s(2)\n # puts cur\n cur = (\"0\" * (n - cur.size)) + cur\nend\nif f\n puts \"YES\"\nelse\n puts \"NO\"\nend", "positive_code": [{"source_code": "N = gets.to_i\nas = [0]\nbs = nil\nN.times {\n rot = gets.to_i\n bs = as.map{ |a| [(a+rot)%360, (a-rot+360)%360]}.flatten.uniq\n as,bs = bs,as\n}\nputs as.include?(0) ? \"YES\" : \"NO\""}, {"source_code": "n,*a=$<.read.split.map &:to_i\ns=a.reduce :+\nputs (1<0}.map{|j|a[j]}.reduce 0,:+;(s-2*t)%360==0} ? :YES : :NO"}, {"source_code": "# Utility\n\n# Better use B-tree but eff that\ndef spin(angle, initial = [0])\n return Array.new(initial.length * 2) { |i| initial[i / 2] + angle * (-1)**(i % 2) }\nend\n\n# Input\nn = gets.to_i\na = Array.new(n) { |i| gets.to_i }\n\n# Processing\nvariants = [a[0]]\n(n - 1).times do |i|\n variants = spin(a[1 + i], variants)\nend\n\nable_to_open = variants.detect { |el| el % 360 == 0 }\n\n# Output\nputs(able_to_open ? \"YES\" : \"NO\")\n"}], "negative_code": [{"source_code": "n,*a=$<.read.split.map &:to_i\ns=a.reduce :+\nputs (1<0}.map{|j|a[j]}.reduce 0,:+;t%360==0} ? :YES : :NO"}, {"source_code": "n,*a=$<.read.split.map &:to_i\ns=a.reduce :+\nputs (1<0}.map{|j|a[j]}.reduce 0,:+;t*2==s} ? :YES : :NO"}], "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10"} {"source_code": "n = gets.to_i\ns = gets.chomp\nc = Hash.new(0)\nfor i in 0..n-1\n c[s[i]] += 1\nend\nputs (n == 1 || c.values.any?{|i|i > 1}) ? \"Yes\" : \"No\"\n", "positive_code": [{"source_code": "n=gets.to_i\nputs n>gets.chomp.chars.uniq.size||n==1?:Yes: :No"}, {"source_code": "N = gets.to_i\nS = gets.chomp.split('').sort\nif N == 1\n puts 'Yes'\n exit\nend\n\n(N-1).times do |i|\n if S[i] == S[i+1]\n puts 'Yes'\n exit\n end\nend\nputs 'No'"}, {"source_code": "useless = gets.chomp\nline = gets.chomp\na = Array.new(26,0)\nif(line.size == 1)\n\tprint (\"Yes\")\n\texit\nend\nfor i in 0...line.size\n\ta[line[i].ord - 97] += 1\nend\n\nfor i in 0...26\n\tif(a[i] > 1)\n\t\tprint(\"Yes\")\n\t\texit\n\tend\nend\nprint(\"No\")"}, {"source_code": "n = gets.split()[0].to_i\ns = gets.split()[0]\nmx = 0\n('a'..'z').each do |x|\n mx = [mx, (s.count x)].max\nend\nputs ((mx > 1 or s.length == 1) ? 'Yes' : 'No')"}, {"source_code": "n = gets.to_i\nstr = gets.chomp\n\nif n==1\n puts \"Yes\"\n exit\nend\n\nif n>26\n puts \"Yes\"\nelse\n hash = Hash.new(0)\n str.each_char {|x| hash[x]+=1}\n\n if hash.values.max==1\n puts \"No\"\n else\n puts \"Yes\"\n end\nend"}], "negative_code": [{"source_code": "n=gets.to_i\nputs n>gets.chars.uniq.size||n==1?:Yes: :No"}, {"source_code": "n = gets.to_i\ns = gets.chomp\nc = Hash.new(0)\nfor i in 0..n-1\n c[s[i]] += 1\nend\nputs c.values.any?{|i|i > 1} ? \"YES\" : \"NO\"\n"}, {"source_code": "useless = gets.chomp\nline = gets.chomp\na = Array.new(26,0)\n\nfor i in 0...line.size\n\ta[line[i].ord - 97] += 1\nend\n\nfor i in 0...26\n\tif(a[i] > 1)\n\t\tprint(\"Yes\")\n\t\texit\n\tend\nend\nprint(\"No\")"}, {"source_code": "n = gets.to_i\nstr = gets.chomp\n\nif n==1\n puts \"Yes\"\nend\n\n#if n>26\n# puts \"Yes\"\n# exit\n#else\n hash = Hash.new(0)\n str.each_char {|x| hash[x]+=1}\n\n if hash.values.max<2\n puts \"No\"\n else\n puts \"Yes\"\n end\n#end"}, {"source_code": "n = gets.to_i\nstr = gets.chomp\n\nif n==1\n puts \"Yes\"\nend\n\nif n>26\n puts \"Yes\"\n exit\nelse\n hash = Hash.new(0)\n str.each_char {|x| hash[x]+=1}\n\n if hash.values.max<2\n puts \"No\"\n else\n puts \"Yes\"\n end\nend"}, {"source_code": "n = gets.to_i\nstr = gets.chomp\n\nif n>26\n puts \"Yes\"\n exit\nelse\n hash = Hash.new(0)\n str.each_char {|x| hash[x]+=1}\n\n if hash.values.max<2\n puts \"No\"\n else\n puts \"Yes\"\n end\nend"}], "src_uid": "6b22e93f7e429693dcfe3c099346dcda"} {"source_code": "n1,n2,k1,k2=gets.split.map{|e| e.to_i}\nif n1>n2 then\n\tputs \"First\"\nelse\n\tputs \"Second\"\nend", "positive_code": [{"source_code": "pa=Array.new\nstr=gets.to_s\npa=str.split\nn1=pa[0].to_i\nn2=pa[1].to_i\nif n1<=n2\n puts \"Second\"\nelse\n puts \"First\"\nend"}, {"source_code": "a, b, c, d = gets.split.map{|i| i.to_i}\nputs a > b ? 'First' : 'Second'"}, {"source_code": "n1, n2 = *gets.split.map(&:to_i)\nputs n1 <= n2 ? \"Second\" : \"First\"\n"}, {"source_code": "n1, n2, k1, k2 = gets.split.map { |x| x.to_i }\nif n1 > n2\n\tputs 'First'\nelse\n\tputs 'Second'\nend"}, {"source_code": "a, b = gets.strip.split.map( &:to_i )\nputs a <= b ? \"Second\" : \"First\"\n"}, {"source_code": "#!/usr/bin/ruby\n\ninput = STDIN.readline.chomp\ninput = input.split(' ')\nif input[0].to_i > input[1].to_i\n puts \"First\"\nelsif input[0] == input[1]\n puts \"Second\"\nelse\n puts \"Second\"\nend"}, {"source_code": "#!/usr/bin/ruby\n\ninput = STDIN.readline.chomp\ninput = input.split(' ')\nif input[0].to_i > input[1].to_i\n puts \"First\"\nelsif input[0].to_i == input[1].to_i\n puts \"Second\"\nelse\n puts \"Second\"\nend"}, {"source_code": "\nn1,n2,k1,k2=gets.chomp.split\n\nn1 = n1.to_i \nn2 = n2.to_i\n\ncase n1<=>n2 \n when 0 \n print \"Second\";\n when 1 \n print \"First\";\n when -1 \n print \"Second\";\nend\n "}, {"source_code": "n,m,k,l=gets.split.map &:to_i\nputs n>m ? \"First\" : \"Second\""}, {"source_code": "n1, n2, k1, k2 = $stdin.readline.split.map(&:to_i)\n\nif n1>n2\n puts \"First\"\nelse\n puts \"Second\"\nend"}, {"source_code": "#le roi est mort is here\nk, l, c, d = gets.split.map &:to_i\nif k > l\n puts \"First\"\nelse\n puts \"Second\"\nend"}, {"source_code": "#!/usr/bin/ruby\n# coding: utf-8\n\na, b, c, d = gets.split.map &:to_i\nputs (a > b) ? \"First\" : \"Second\""}, {"source_code": "n, m = gets.split.map &:to_i\nif n == m\n puts \"Second\"\nelse\n if [n, m].max == n\n puts \"First\"\n else\n puts \"Second\"\n end\nend"}, {"source_code": "n, m, a, b = gets.split().map(&:to_i)\nif n>m\n puts \"First\"\nelse\n puts \"Second\"\nend"}, {"source_code": "n1, n2, k1, k2 = gets.split.map(&:to_i)\n\nif n1 > n2\n puts 'First'\nelse\n puts 'Second'\nend\n"}, {"source_code": "n,m,k,l = gets.split.map(&:to_i)\nputs n > m ? 'First' : 'Second'"}, {"source_code": "#!/usr/bin/ruby\n\ninput_line = gets\n\nparams = input_line.split(' ')\nn1 = params[0].to_i\nn2 = params[1].to_i\nk1 = params[2].to_i\nk2 = params[3].to_i\n\nif (n1<=n2)\n puts 'Second'\nelse\n puts 'First'\nend\n"}, {"source_code": "n1, n2, k1, k2 = gets.split.map &:to_i\n\nputs (n1 > n2) ? \"First\" : \"Second\" \n"}, {"source_code": "s = gets.split(\" \").map { |e| e.to_i }\nputs \"First\" if s[0] > s[1]\nputs \"Second\" if s[0] <= s[1]"}, {"source_code": "nk = gets.chomp.split.map(&:to_i)\nn1 = nk[0]\nn2 = nk[1]\n\nif n1 <= n2\n\tprint \"Second\"\nelsif n1 > n2\n\tprint \"First\"\nend\n\t"}, {"source_code": "arr = $stdin.readline.split(\" \")\nn1= Float(\"#{arr[0]}\")\nn2 = Float(\"#{arr[1]}\")\nk1 = Float(\"#{arr[2]}\")\nk2 = Float(\"#{arr[3]}\")\nif (n2 + 1 > n1 ) \n puts \"Second\"\nelse \n puts \"First\"\nend"}, {"source_code": "arr = $stdin.readline.split(\" \")\nn1 = arr[0].to_i\nn2 = arr[1].to_i\nputs n2 + 1 > n1 ? 'Second' : 'First'"}, {"source_code": "arr = $stdin.readline.split(\" \")\nn1= arr[0].to_i\nn2 = arr[1].to_i\nif (n2 + 1 > n1 )\n puts \"Second\"\nelse\n puts \"First\"\nend"}, {"source_code": "a,b,c,d=gets.chomp.split.map &:to_i\nputs (a>b)? :First: :Second"}, {"source_code": "n1, n2, k1, k2 = gets.split.map(&:to_i)\nputs n1 > n2 ? \"First\" : \"Second\"\n"}, {"source_code": "input = gets.split(\" \")\nn1 = input[0].to_i\nn2 = input[1].to_i\nif n1 > n2\n puts \"First\"\nelse\n puts \"Second\"\nend\n"}, {"source_code": "n_1, n_2, k_1, k_2 = gets.split.map{|x| x.to_i}\nputs(n_1 > n_2 ? 'First' : 'Second')\n"}, {"source_code": "a , b , c ,d = gets.split.map {|i| i.to_i}\n\nif a > b\n puts \"First\"\nelse\n puts \"Second\"\nend"}], "negative_code": [{"source_code": "a, b = gets.strip.split\nputs a <= b ? \"Second\" : \"First\"\n"}, {"source_code": "# cook your code here\n\nn1,n2,k1,k2=gets.chomp.split\n\ncase n1<=>n2 \n when 0 \n print \"Second\";\n when 1 \n print \"First\";\n when -1 \n print \"Second\";\nend\n "}, {"source_code": "a,b,c,d=gets.split &:to_i\nputs (a>b)? :Second: :First"}, {"source_code": "a,b,c,d=gets.split &:to_i\nputs (a<=b)? :Second: :First"}, {"source_code": "a,b,c,d=gets.split &:to_i\nputs (a>b)? :First: :Second"}, {"source_code": "n_1, n_2, k_1, k_2 = gets.split\nputs(n_1 > n_2 ? 'First' : 'Second')\n"}, {"source_code": "pa=Array.new\nstr=gets.to_s\npa=str.split\nn1=pa[0]\nn2=pa[1]\nif n1<=n2\n puts \"Second\"\nelse\n puts \"First\"\nend"}], "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b"} {"source_code": "b = gets.to_i\ng = gets.to_i\nn = gets.to_i\n\ncnt=0\n\nif b>=n && g>=n\n cnt = n+1\nelsif b=n && g>=n\n cnt = n+1\nelse\n cnt = [b,g].min+1\nend\n\nputs cnt"}], "src_uid": "9266a69e767df299569986151852e7b1"} {"source_code": "a=gets.chomp.split(\" \")\npow=a[0].to_i\nprice=a[1].to_i\napple=0\nhalf=0\n0.upto(pow-1) do |i|\nk=gets.chomp\nif k.length!=4\napple=apple+2**i\nhalf+=1\nend\nend\n\nans=(apple-(0.5*half))*price\nputs \"#{ans.to_i}\"", "positive_code": [{"source_code": "a=gets.chomp.split(\" \")\npow=a[0].to_i\nprice=a[1].to_i\napple=0\nhalf=0\n0.upto(pow-1) do |i|\nk=gets.chomp\nif k.length!=4\napple=apple+2**i\nhalf+=1\nend\nend\n\nans=(apple-(0.5*half))*price\nputs \"#{ans.to_i}\""}, {"source_code": "N, P = gets.split.map(&:to_i)\nA = N.times.map{ gets.chomp }\n\nx = A.reverse.reduce(0){|acc, a| (a == 'half') ? (acc * 2) : (acc * 2 + 1)}\n\nans = 0\nN.times do \n if x % 2 == 0\n ans += P * (x/2)\n else\n ans += P * (x/2) + P/2\n end\n x /= 2\nend\n\nputs ans"}, {"source_code": "#!/usr/bin/ruby\nn,p=gets.split.map(&:to_i)\nm=r=0\n$<.map(&:chomp).reverse.each{|e|\n\tm+=1 if e.end_with?('plus')\n\tr+=m*p/2\n\tm*=2\n}\np r"}, {"source_code": "n, p = gets.split(' ').map(&:to_i)\nrest = 0\nsum = 0\nrecords = []\n\nfor i in 1..n\n records.unshift(gets.to_s.chomp)\nend\n\nrecords.each do |record|\n if record == 'half'\n rest = rest * 2\n sum += rest * p / 2\n else\n rest = ( rest + 0.5 ) * 2\n sum += rest * p / 2\n end\n\nend\n\nputs sum.to_i"}, {"source_code": "n, p = gets.chomp.split.map(&:to_i)\napples = 1.0\ncom = []\nn.times do\n com << gets.chomp\nend\nhalfplus = 1\ncom.pop\ncom.reverse.each do |c|\n if c == \"halfplus\" then\n apples += 0.5\n apples *= 2\n halfplus += 1\n else\n apples *= 2\n end\nend\n\nputs ((apples - halfplus * 0.5) * p).to_i\n"}], "negative_code": [], "src_uid": "6330891dd05bb70241e2a052f5bf5a58"} {"source_code": "def inpf() a=gets.chomp.split(\" \").map(&:to_f)end\n\ndef inps() a=gets.chomp.split(\" \")end\n\ndef copy(a) Marshal.load(Marshal.dump(a)) end\n\ndef kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end\n\ndef na(n,d=0) Array.new(n,d)end\n\ndef na2(n,m,d=0) Array.new(n){Array.new(m,d)}end\n\ndef na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end\n\ndef inp() a=gets.chomp.split(\" \").map(&:to_i)end\n\ndef r_up(a, b) (a+b-1)/b end\n\ndef sum(a) a.inject(:+) end\n\nrequire 'prime'\nn = inp[0]\n\nd = Prime.prime_division(n)\nif(d.size == 1 )\n p d[0][0]\nelse\n p 1\nend", "positive_code": [{"source_code": "# https://codeforces.com/problemset/problem/1242/A\n\nrequire 'set'\n\nn = gets.to_i\n\ndividers = Set.new []\n\ni = 2\nsize = n\n\nwhile i * i <= n\n if n % i == 0\n dividers.add(i)\n n /= i\n i -= 1\n end\n i += 1\nend\n\ndividers.add(n) if n > 1 \n\narr = []\ndividers.each { |num| arr << num }\n\nif arr[0] == size\n puts size\nelsif arr.size == 1\n puts arr[0]\nelse\n puts 1\nend\n"}], "negative_code": [{"source_code": "def inpf() a=gets.chomp.split(\" \").map(&:to_f)end\n\ndef inps() a=gets.chomp.split(\" \")end\n\ndef copy(a) Marshal.load(Marshal.dump(a)) end\n\ndef kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end\n\ndef na(n,d=0) Array.new(n,d)end\n\ndef na2(n,m,d=0) Array.new(n){Array.new(m,d)}end\n\ndef na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end\n\ndef inp() a=gets.chomp.split(\" \").map(&:to_i)end\n\ndef r_up(a, b) (a+b-1)/b end\n\ndef sum(a) a.inject(:+) end\n\nn = inp[0]\n(2..((n**0.5).ceil)).each do |d|\n if (n%d ==0)\n p d\n exit\n end\nend\np n\n"}, {"source_code": "def inpf() a=gets.chomp.split(\" \").map(&:to_f)end\n\ndef inps() a=gets.chomp.split(\" \")end\n\ndef copy(a) Marshal.load(Marshal.dump(a)) end\n\ndef kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end\n\ndef na(n,d=0) Array.new(n,d)end\n\ndef na2(n,m,d=0) Array.new(n){Array.new(m,d)}end\n\ndef na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end\n\ndef inp() a=gets.chomp.split(\" \").map(&:to_i)end\n\ndef r_up(a, b) (a+b-1)/b end\n\ndef sum(a) a.inject(:+) end\n\nn = inp[0]\n(2..((n**0.5).ceil)).each do |d|\n if (n%d ==0)\n if ( n/d == d)\n p d\n else\n p 1\n end\n exit\n end\nend\np n\n"}], "src_uid": "f553e89e267c223fd5acf0dd2bc1706b"} {"source_code": "n = gets.chomp.to_i\nputs (3 ** (3 * n) - 7 ** n) % 1_000_000_007\n", "positive_code": [{"source_code": "N=gets.to_i\np (3**(3*N)-7**N)%1000000007"}, {"source_code": "p=gets.chomp.to_i\ndef MOD (n,p)\n\tif p>19\n\tpmin=(Math.log(1000000007,n)).ceil\n\tpc=p/pmin\n\tpl=p%pmin\n\treturn ((MOD((n**pmin % 1000000007),pc) * (n**pl) ) % 1000000007)\n\telse\n\treturn (n**p)%1000000007\n\tend\n\tend\n\t\n\tc=(MOD(3,3*p)- MOD(7,p))% 1000000007\n\tputs \"#{c}\""}, {"source_code": "n = gets.chomp.to_i\ndp1, dp2 = 20, 7\nmod = 1000000007\n(n - 1).times {\n dp1, dp2 = (dp1 * 27 + dp2 * 20) % mod, dp2 * 7 % mod \n}\nputs dp1\n"}, {"source_code": "p=gets.chomp.to_i\ndef MOD (n,p)\n\tif p>19\n\tpmin=(Math.log(1000000007,n)).ceil\n\tpc=p/pmin\n\tpl=p%pmin\n\treturn ((MOD((n**pmin % 1000000007),pc) * (n**pl) ) % 1000000007)\n\telse\n\treturn (n**p)%1000000007\n\tend\n\tend\n\t\n\tc=(MOD(3,3*p)- MOD(7,p))% 1000000007\n\tputs \"#{c}\""}, {"source_code": "Mod = (1e9 + 7).to_i\n\nn = gets.to_i\n\nans1 = 1\nans2 = 1\n\nn.times do\n\tans1 *= 27\n\tans2 *= 7\n\n\tans1 %= Mod\n\tans2 %= Mod\nend\n\nans = (ans1 - ans2 + Mod) % Mod\nputs ans\n"}], "negative_code": [], "src_uid": "eae87ec16c284f324d86b7e65fda093c"} {"source_code": "def function\nb=gets.chomp\na=gets.chomp\na=a.split(' ').map(&:to_i).sort.reverse\n1.upto a.length do |i|\nif a[0..i-1].include?(a[i])\na[i]=a[i-1]-1\nend\nend\nsum=0\na.each do |i|\nif i>0\nsum+=i\nend\nend\nputs sum\nend\nfunction", "positive_code": [{"source_code": "n = gets.to_i\na = gets.split(\" \").map(&:to_i).sort.reverse\nx = a[0]\nans = 0\na.each do |k|\n k = [k, x].min\n ans += k\n x = k-1\n break if x == 0\nend\np ans\n"}, {"source_code": "gets\nh={}\ngets.split.map(&:to_i).each{|e| h[e] ? h[e]+=1 : h[e]=1}\nf=->(n){n*(n+1)/2}\nres=0\nx=10**9*2\nh.sort.reverse.each{|k,v|\n a=f[x=[k, x].min]\n b=f[[x-v, 0].max]\n res+=a-b\n x=[x-v, 0].max\n}\nputs res\n"}, {"source_code": "n = gets.chomp.to_i\nas = gets.chomp.split.map(&:to_i)\nans = 0\n\nas.sort!.reverse!\nb = as[0]\nas.each do |a|\n ans += [a, b].min\n b = [[a - 1, b - 1].min, 0].max\nend\n\nputs ans\n"}, {"source_code": "gets\na=gets.split.map &:to_i\nh = {}\na.sort.each{|x|\n x -= 1 while h[x]\n h[x] = true\n}\np h.map{|k,v|[k,0].max}.inject :+\n"}, {"source_code": "n = gets.to_i\na = gets.split(' ').map &:to_i\nr = []\nfor v in a\n while r.index(v) && v > 0\n v-=1\n end\n\n r << v\nend\n\nputs r.inject(&:+)"}, {"source_code": "class Solver\n\tdef main\n\t\tn = gets.to_i\n\t\tarr = gets.split.map { |x| x.to_i }\n\t\tarr = arr.sort.reverse\n\n\t\tans = 0\n\t\tlast = 1 << 30\n\t\tarr.each do |x|\n\t\t\tx = last - 1 if x >= last\n\t\t\tans += x if x >= 0\n\t\t\tlast = x\n\t\tend\n\t\tputs ans\n\tend\nend\nSolver.new.main"}], "negative_code": [{"source_code": "def function\nb=gets.chomp\na=gets.chomp\na=a.split(' ').map(&:to_i).sort.reverse\nb=a.clone\n1.upto a.length do |i|\nif a[i]==a[i-1]\nb[i]-=1\nend\nend\nsum=0\nb.each do |i|\nsum+=i\nend\nputs sum\nend\nfunction"}, {"source_code": "gets\na=gets.split.map &:to_i\nh = {}\na.sort.each{|x|\n x -= 1 while h[x]\n h[x] = true\n}\nif h[-1]\n p 0\nelse\n p h.map{|k,v|k}.inject :+\nend\n"}, {"source_code": "gets\na=gets.split.map &:to_i\nh = {}\na.sort.each{|x|\n x -= 1 while h[x]\n h[x] = true\n}\nif h.find 0\n p 0\nelse\n p h.map{|k,v|k}.inject :+\nend\n"}, {"source_code": "n = gets.to_i\na = gets.split(' ').map &:to_i\nr = []\nbroken = false\nfor v in a\n while r.index(v)\n v-=1\n end\n if v >= 0\n r << v\n else\n r = [0]\n break\n end\nend\n\nputs r.inject(&:+)"}], "src_uid": "3c4b2d1c9440515bc3002eddd2b89f6f"} {"source_code": "\nw,b=gets.split.map(&:to_i)\n$dp=Array.new(1002){Array.new(1002){Array.new(2,-1)}}\n#t=0 姫 t=1 ドラゴン\ndef solve(w,b,t)\n return 0 if b<0 || w<0\n return 0 if w+b==0\n return $dp[w][b][t] if $dp[w][b][t]>=0\n res=0.0\n if t==0 then\n res+=w.to_f/(w+b)\n res+=b.to_f/(w+b)*solve(w,b-1,1-t)\n else\n #Wを取る\n res=0\n #Bを取る\n tb=b-1\n tw=w\n if tb+tw==0 then\n res=0\n else\n res+=b.to_f/(w+b)*tb.to_f/(tb+tw)*solve(w,b-2,1-t)\n res+=b.to_f/(w+b)*tw.to_f/(tb+tw)*solve(w-1,b-1,1-t)\n end\n end\n return $dp[w][b][t]=res\nend\np solve(w,b,0)\n", "positive_code": [{"source_code": "Memo = {}# Array.new(1001*1001)\n\ndef f(w, b)\n return 0 if w==0\n ix = w*1001 + b\n return Memo[ix] if Memo[ix]\n res = 1.0*w/(w+b)\n if b>1\n m = 1.0*b*(b-1)/(w+b)/(w+b-1)\n wr = 1.0*w/(w+b-2)\n wp = f(w-1, b-2)\n br = 1.0-wr\n bp = 0\n bp = f(w, b-3) if b>2\n res += m * (wr*wp + br*bp)\n end\n Memo[ix] = res\n #puts \"for w=#{w} b=#{b}: #{res}\"\n res\nend\n\nw,b = readline.split(' ').map(&:to_i)\nputs f(w,b)\n"}, {"source_code": "Memo = Array.new(1001*1001)\n\ndef f(w, b)\n return 0 if w==0\n ix = w*1001 + b\n return Memo[ix] if Memo[ix]\n res = 1.0*w/(w+b)\n if b>1\n m = 1.0*b*(b-1)/(w+b)/(w+b-1)\n wr = 1.0*w/(w+b-2)\n wp = f(w-1, b-2)\n br = 1.0-wr\n bp = 0\n bp = f(w, b-3) if b>2\n res += m * (wr*wp + br*bp)\n end\n Memo[ix] = res\n #puts \"for w=#{w} b=#{b}: #{res}\"\n res\nend\n\nw,b = readline.split(' ').map(&:to_i)\nputs f(w,b)\n"}], "negative_code": [], "src_uid": "7adb8bf6879925955bf187c3d05fde8c"} {"source_code": "r, c, n, k = gets.split.map(&:to_i)\npos = n.times.map{gets.split.map(&:to_i)}\n\nphotos = 0\nfor top in 1..r do\n for left in 1..c do\n for down in top..r do\n for right in left..c do\n alts = pos.count do |x, y|\n x >= top && x <= down && y >= left && y <= right\n end\n photos += 1 if alts >= k\n end\n end\n end\nend\nputs photos", "positive_code": [{"source_code": "buf = gets.split(' ')\nr,c,n,k = buf[0].to_i, buf[1].to_i, buf[2].to_i, buf[3].to_i\na=Array.new(22)\nfor i in 0..r\n\ta[i]=Array.new(22, 0)\nend\nfor i in 1..n\n\tbuf = gets.split(' ')\n\tx, y = buf[0].to_i, buf[1].to_i\n\ta[x][y]=1\nend\nfor i in 1..r\n\tfor j in 1..c\n\t\ta[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1]\n\tend\nend\nans=0\nfor x1 in 1..r\n\tfor y1 in 1..c\n\t\tfor x2 in x1..r\n\t\t\tfor y2 in y1..c\n\t\t\t\ttot = a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1]\n\t\t\t\tans+=1 if tot>=k\n\t\t\tend\n\t\tend\n\tend\nend\nputs ans"}, {"source_code": "l1 = gets.chomp\nvals1 = l1.split(' ').map {|x| x.to_i}\n\nr = vals1[0]\nc = vals1[1]\nn = vals1[2]\nk = vals1[3]\n\nviolas = []\ncolumns = []\nc.times {|x| columns << 0}\nr.times {|x| col = []; c.times {|y| col << 0}; violas << col }\nminx = r\nminy = c\nmaxx = -1\nmaxy = -1\nn.times {\n indices = gets.chomp.split(' ').map {|x| x.to_i - 1}\n violas[indices[0]][indices[1]] = 1\n minx = indices[1] if indices[1] < minx\n miny = indices[0] if indices[0] < miny\n maxx = indices[1] if indices[1] > maxx\n maxy = indices[0] if indices[0] > maxy\n}\n\nRect = Struct.new(:x, :y, :x2, :y2)\n\nrectangles = []\n(0..r-1).each do |y|\n (0..c-1).each do |x|\n (y..r-1).each do |y2|\n (x..c-1).each do |x2|\n v = 0\n (y..y2).each do |yi|\n (x..x2).each do |xi|\n v += violas[yi][xi]\n end\n end\n if v >= k\n rectangles << Rect.new(x, y, x2, y2) unless rectangles.any? {|r|\n r.x == x && r.y == y && r.x2 == x2 && r.y2 == y2\n }\n end\n end\n end\n end\nend\nputs rectangles.length\n"}, {"source_code": "#!/usr/bin/ruby\nr,c,n,k=gets.split.map(&:to_i)\nm=(r+1).times.map{[0]*(c+1)}\nn.times{\n\ta,b=gets.split.map(&:to_i)\n\tm[a][b]=1\n}\n(r+1).times{|i|c.times{|j|m[i][j+1]+=m[i][j]}}\nr.times{|i|(c+1).times{|j|m[i+1][j]+=m[i][j]}}\nx=0\nr.times{|i0|c.times{|j0|(i0+1).step(r){|i1|(j0+1).step(c){|j1|\n\tx+=1 if k<=m[i0][j0]-m[i0][j1]-m[i1][j0]+m[i1][j1]\n}}}}\np x"}], "negative_code": [], "src_uid": "9c766881f6415e2f53fb43b61f8f40b4"} {"source_code": "x,y,z,a,b,c=gets.split.map &:to_i\nd=(x-y).abs\nputs d*a<((x-z).abs+d)*b+3*c ? :No : :Yes", "positive_code": [{"source_code": "\ndef solution\n x, y, z, stairs, elv, elv_doors = read_ints\n\n elv_time = ((z-x).abs + (x-y).abs) * elv + elv_doors * 3\n stair_time = (y-x).abs * stairs\n\n puts elv_time <= stair_time ? \"YES\" : \"NO\"\n\nend\n\ndef read_int\n gets.to_i\nend\n\ndef read_ints\n gets.split.map(&:to_i)\nend\n\ndef read_string\n gets.chomp\nend\n\nsolution unless ENV['TEST__MODE']\n\n"}, {"source_code": "class A\n def self.run(s)\n x, y, z, t1, t2, t3 = s.split.map(&:to_i)\n walk = (x-y).abs * t1\n lift = (x-z).abs * t2 + t3*2 + (x-y).abs * t2 + t3\n if lift <= walk\n true\n else\n false\n end\n end\nend\n\n\nif A.run(gets.chomp)\n puts 'YES'\nelse\n puts 'NO'\nend\n"}, {"source_code": "x,y,z,t1,t2,t3 = gets.split.map { |e| Integer(e) }\nstair = t1 * (x - y).abs\nelevator = t2 * (z - x).abs + t3*2 + t2*(x-y).abs + t3\nputs (if elevator <= stair then \"YES\" else \"NO\" end)"}, {"source_code": "x, y, z, t1, t2, t3 = gets.split.map(&:to_i)\n\nfoot = (x-y).abs * t1\nev = (x-z).abs*t2+(x-y).abs*t2+t3*3\n\nif foot < ev\n puts 'NO'\nelse\n puts 'YES'\nend\n"}, {"source_code": "line = gets.chomp\n\nx, y, z, t1, t2, t3 = line.split.map(&:to_i)\n\nelevator_time = ( (z-x).abs + (x-y).abs ) * t2 + 3 * t3\nstair_time = (y-x).abs * t1\n\n# puts elevator_time\n# puts stair_time\n\nif stair_time >= elevator_time\n puts \"YES\"\nelse\n puts \"NO\"\nend"}, {"source_code": "x, y, z, t1, t2, t3 = gets.split.map &:to_i\nputs ((x - y).abs + (x - z).abs)*t2 + 3*t3 <= (x - y).abs*t1 ? 'YES' : 'NO'\n"}, {"source_code": "xyzts = gets.chomp.split(\" \").map(&:to_i)\n\nx = xyzts[0]\ny = xyzts[1]\nz = xyzts[2]\nt1 = xyzts[3]\nt2 = xyzts[4]\nt3 = xyzts[5]\n\nst = (x-y).abs*t1\net = (x-z).abs*t2 + 3*t3 + (x-y).abs*t2\n\nif et<=st\n puts \"YES\"\nelse\n puts \"NO\"\nend\n"}], "negative_code": [], "src_uid": "05cffd59b28b9e026ca3203718b2e6ca"} {"source_code": "p 2-gets.to_i%2", "positive_code": [{"source_code": "# cook your code here\n\nn = gets.chomp \n\nif (n[-1].to_i)%2==0 \n puts \"2\"\nelse \n puts \"1\" \nend "}, {"source_code": "n = gets.chomp.to_i\nputs n % 2 == 0 ? 2 : 1"}, {"source_code": "p 2-gets.to_i%2"}, {"source_code": "p 2-gets.to_i%2"}, {"source_code": "p 2-gets.to_i%2\n"}], "negative_code": [{"source_code": "p 2-gets.to_i"}], "src_uid": "816ec4cd9736f3113333ef05405b8e81"} {"source_code": "x = gets.chomp.split(' ')\nn = x[0].to_i\nk = x[1].to_i\nif k == 1\n puts n\nelse\n ans = 0\n i = 0\n while 2**i <= n\n ans += 2 ** i\n i += 1\n end\n puts ans\nend", "positive_code": [{"source_code": "n,k=gets.split.map &:to_i\np k==1 ? n : 2**n.to_s(2).size-1"}, {"source_code": "#!/usr/bin/ruby\ninclude Math\n\nn, k = gets.split().map(&:to_i)\n\nif k == 1 then\n\tputs n\nelse\n\tputs (1 << n.to_s(2).length) - 1\nend\n\n"}, {"source_code": "#!/usr/bin/ruby\ninclude Math\n\nn, k = readline().split().map(&:to_i)\n\nif k == 1 then\n\tputs n\nelse\n\tputs (1 << n.to_s(2).length) - 1\nend\n\n"}], "negative_code": [], "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9"} {"source_code": "candies, friends = gets.strip.split(' ').map(&:to_i)\n\nresult = []\nnumber = candies/friends\nredundant = candies%friends\nfriends.times do |f|\n result << number\nend\nif redundant != 0\n for i in 0...redundant\n result[i] += 1\n end\n result = result.reverse\nend\n\nprint result.join(' ')\n", "positive_code": [{"source_code": "n, m = gets.split.map(&:to_i)\nputs [*0...m].map { |i| n / m + (i < n % m ? 1 : 0) }.join(' ')\n"}, {"source_code": "n, m = gets.split.map(&:to_i)\nr, n = n % m, n / m\nr.times{print \"#{n+1} \"}\n(m-r).times{print \"#{n} \"}\n"}, {"source_code": "#!/usr/bin/ruby\nn,m=gets.split.map(&:to_i)\nputs m.times.map{|i|n/m+(i=str.length\nend\n\nputs newstr\n"}, {"source_code": "gets\ns = gets.chomp\n\nresult = ''\n1.upto(10) do |i|\n break if s.empty?\n\n result += s[0]\n\n s.replace s[i..-1]\nend\n\nputs result\n"}], "negative_code": [], "src_uid": "08e8c0c37b223f6aae01d5609facdeaf"} {"source_code": "n = gets.to_i\nx = 0\ny = 0\nfor i in 1..Math.sqrt(n).round\n if (n%i === 0)\n x = i\n y = n/i\n end\nend\nprint x\nprint \" \"\nprint y\n", "positive_code": [{"source_code": "require 'prime'\ndef find_minimum(row, col, factor, n)\n res = (0..n).collect {|i|\n [row * (factor**i), col * (factor**(n-i))]\n }.select{ |pair|\n pair[0] <= pair[1]\n }.min_by { |pair|\n pair[1] - pair[0]\n }\n res.nil? ? [1, row*col*(factor**n)] : res\nend\n\ndef minimum_pair(row, col, primes)\n if primes.size == 1\n return find_minimum(row, col, primes[0][0], primes[0][1])\n else\n prime = primes[0][0]\n n = primes[0][1]\n rest = primes[1..-1]\n minimum = 10000000\n minimum_result = nil\n (0..n).collect { |i|\n minimum_pair(row*(prime**i), col*(prime**(n-i)), rest)\n }.select{ |pair|\n pair[0] <= pair[1]\n }.min_by { |pair|\n pair[1] - pair[0]\n }\n end\nend\n\ndef solve(n)\n return [1,1] if n == 1\n return [0,0] if n == 0\n primes = n.prime_division\n minimum_pair(1, 1, primes)\nend\n\nputs solve(STDIN.read.to_i).join(\" \")\n"}, {"source_code": "n=gets.to_i\nx, y=1, n\na=1\nd=n-1\nwhile a<=n\n if n % a==0 and n/a>=a and n/a-a 1\n return \"ugly\"\n end\n end\n\n sorted_list_x = list_x.sort\n sorted_list_y = list_y.sort\n avg_x, avg_y = 0, 0\n\n for i in 0..7\n avg_x += 1 if sorted_list_x[i] == sorted_list_x[3]\n avg_y += 1 if sorted_list_y[i] == sorted_list_y[3]\n end\n\n return avg_x == 2 && avg_y == 2 ? \"respectable\" : \"ugly\"\nend\n\nputs eight_point_set(list, list_x, list_y)\n"}, {"source_code": "points = 8.times.map{|i| gets.split.map(&:to_i) }.uniq\nputs [:first, :last].all?{|sym| points.group_by(&sym).to_a.sort_by(&:first).map{|x| x.last.length} == [3,2,3] } ? \"respectable\" : \"ugly\"\n\n"}, {"source_code": "points = 8.times.map{|i| gets.split.map(&:to_i) }.uniq\nputs [:first, :last].all?{|sym| points.group_by(&sym).to_a.sort_by(&:first).map{|x| x.last.length} == [3,2,3] } ? \"respectable\" : \"ugly\"\n"}, {"source_code": "points = 8.times.map{|i| gets.split.map(&:to_i) }.uniq\nputs [:first, :last].all?{|sym| points.group_by(&sym).to_a.sort_by(&:first).map{|x| x.last.length} == [3,2,3] } ? \"respectable\" : \"ugly\"\n\n"}, {"source_code": "points = 8.times.map{|i| gets.split.map(&:to_i) }.uniq\nputs [:first, :last].all?{|sym| points.group_by(&sym).to_a.sort_by(&:first).map{|x| x.last.length} == [3,2,3] } ? \"respectable\" : \"ugly\"\n\n"}, {"source_code": "points = 8.times.map{|i| gets.split.map(&:to_i) }.uniq\nputs [:first, :last].all?{|sym| points.group_by(&sym).to_a.sort_by(&:first).map{|x| x.last.length} == [3,2,3] } ? \"respectable\" : \"ugly\"\n\n"}, {"source_code": "points = 8.times.map{|i| gets.split.map(&:to_i) }.uniq\nputs [:first, :last].all?{|sym| points.group_by(&sym).to_a.sort_by(&:first).map{|x| x.last.length} == [3,2,3] } ? \"respectable\" : \"ugly\"\n\n"}, {"source_code": "xs, ys = [], []\nx_count, y_count = {}, {}\n8.times do\n\tx, y = STDIN.readline.split.map {|s| s.to_i }\n\txs.push(x)\n\tys.push(y)\n\tx_count[x] = (x_count[x] || 0) + 1\n\ty_count[y] = (y_count[y] || 0) + 1\nend\n[x_count, y_count].each do |z_count|\n\tvalues = z_count.values.sort\n\tif values.length != 3\n\t\tputs 'ugly'\n\t\texit\n\tend\nend\ninput_points = xs.zip(ys).sort\nx1, x2, x3 = x_count.keys.sort\ny1, y2, y3 = y_count.keys.sort\nconstructed_points = [[x1, y1], [x1, y2], [x1, y3],\n\t\t\t\t\t [x2, y1], [x2, y3],\n\t\t\t\t\t [x3, y1], [x3, y2], [x3, y3]].sort\nif constructed_points == input_points\n\tputs 'respectable'\nelse\n\tputs 'ugly'\nend\n"}, {"source_code": "xs, ys = [], []\nx_count, y_count = {}, {}\n8.times do\n\tx, y = STDIN.readline.split.map {|s| s.to_i }\n\txs.push(x)\n\tys.push(y)\n\tx_count[x] = (x_count[x] || 0) + 1\n\ty_count[y] = (y_count[y] || 0) + 1\nend\nif x_count.values.length != 3 || y_count.values.length != 3\n\tputs 'ugly'\n\texit\nend\ninput_points = xs.zip(ys).sort\nx1, x2, x3 = x_count.keys.sort\ny1, y2, y3 = y_count.keys.sort\nconstructed_points = [[x1, y1], [x1, y2], [x1, y3],\n\t\t\t\t\t [x2, y1], [x2, y3],\n\t\t\t\t\t [x3, y1], [x3, y2], [x3, y3]].sort\nputs constructed_points == input_points ? 'respectable' : 'ugly'\n"}, {"source_code": "points = 8.times.map{|i| gets.split.map(&:to_i) }.uniq\nputs [:first, :last].all?{|sym| points.group_by(&sym).to_a.sort_by(&:first).map{|x| x.last.length} == [3,2,3] } ? \"respectable\" : \"ugly\"\n"}, {"source_code": "#!/usr/bin/env ruby\npoint,x, y = [], [], []\n8.times do\n point << gets.split(' ').map(&:to_i)\n x << point[-1][0] unless x.include? point[-1][0]\n y << point[-1][1] unless y.include? point[-1][1]\nend\nif x.sort!.size == 3 && y.sort!.size == 3\n ok = true\n for i in 0...3\n for j in 0...3\n next if i == 1 && j == 1\n ok = false unless point.include?([x[i], y[j]])\n end\n end\n puts ok ? \"respectable\" : \"ugly\"\nelse\n puts \"ugly\"\nend\n"}, {"source_code": "points = 8.times.map{|i| gets.split.map(&:to_i) }.uniq\nputs [:first, :last].all?{|sym| points.group_by(&sym).to_a.sort_by(&:first).map{|x| x.last.length} == [3,2,3] } ? \"respectable\" : \"ugly\"\n\n"}, {"source_code": "points = 8.times.map{|i| gets.split.map(&:to_i) }.uniq\nputs [:first, :last].all?{|sym| points.group_by(&sym).to_a.sort_by(&:first).map{|x| x.last.length} == [3,2,3] } ? \"respectable\" : \"ugly\"\n\n"}], "negative_code": [{"source_code": "#!/usr/bin/env ruby\npoint,x, y = [], [], []\n8.times do\n point << gets.split(' ').map(&:to_i)\n x << point[-1][0] unless x.include? point[-1][0]\n y << point[-1][1] unless y.include? point[-1][1]\nend\nif x.size == 3 && y.size == 3\n ok = true\n for i in 0...3\n for j in 0...3\n next if i == 1 && j == 1\n ok = false unless point.include?([x[i], y[j]])\n end\n end\n puts ok ? \"respectable\" : \"ugly\"\nelse\n puts \"ugly\"\nend\n"}, {"source_code": "#!/usr/bin/env ruby\npoint,x, y = [], [], []\n8.times do\n point << gets.split(' ').map(&:to_i)\n x << point[-1][0] unless x.include? point[-1][0]\n y << point[-1][1] unless y.include? point[-1][1]\nend\nif x.size == 3 && y.size == 3\n if x.size > 1 && y.size > 1 && point.include?([x.sort[1], y.sort[1]])\n puts \"ugly\"\n else\n puts \"respectable\"\n end\nelse\n puts \"ugly\"\nend\n"}, {"source_code": "#!/usr/bin/env ruby\npoint,x, y = [], [], []\n8.times do\n point << gets.split(' ').map(&:to_i)\n x << point[-1][0] unless x.include? point[-1][0]\n y << point[-1][1] unless y.include? point[-1][1]\nend\nif x.sort!.size == 3 && y.sort!.size == 3\n if point.uniq.size == point.size && point.include?([x[1], y[1]])\n puts \"respectable\"\n else\n puts \"ugly\"\n end\nelse\n puts \"ugly\"\nend\n"}, {"source_code": "points =[]\nfor i in 1..8\n temp=gets.chomp.split.collect{|a| a.to_i}\n points.push temp\nend\nxs=points.collect{|a| a.first}.uniq\nys=points.collect{|a| a.last }.uniq\n#puts xs,ys\nif xs.length!=3 ||ys.length!=3\n puts \"ugly\"\nelse\n avg=[xs[1],ys[1]]\n # puts avg\n if points.include? avg\n puts \"ugly\"\n else\n puts\"respectable\"\n end\nend\n"}, {"source_code": "points =[]\nfor i in 1..8\n temp=gets.chomp.split.collect{|a| a.to_i}\n points.push temp\nend\nxs=points.collect{|a| a.first}.uniq.sort\nys=points.collect{|a| a.last }.uniq.sort\n#puts xs,ys\nif xs.length!=3 ||ys.length!=3 || temp.uniq !=8\n puts \"ugly\"\nelse\n avg=[xs[1],ys[1]]\n # puts avg\n if points.include? avg\n puts \"ugly\"\n else\n puts\"respectable\"\n end\nend\n"}, {"source_code": "points =[]\nfor i in 1..8\n temp=gets.chomp.split.collect{|a| a.to_i}\n points.push temp\nend\nxs=points.collect{|a| a.first}.sort.uniq\nys=points.collect{|a| a.last }.sort.uniq\n#puts xs,ys\nif xs.length!=3 ||ys.length!=3 || points.uniq !=8\n puts \"ugly\"\nelse\n avg=[xs[1],ys[1]]\n # puts avg\n if points.include? avg\n puts \"ugly\"\n else\n puts\"respectable\"\n end\nend\n"}, {"source_code": "points =[]\nfor i in 1..8\n temp=gets.chomp.split.collect{|a| a.to_i}\n points.push temp\nend\nxs=points.collect{|a| a.first}.uniq.sort\nys=points.collect{|a| a.last }.uniq.sort\n#puts xs,ys\nif xs.length!=3 ||ys.length!=3\n puts \"ugly\"\nelse\n avg=[xs[1],ys[1]]\n # puts avg\n if points.include? avg\n puts \"ugly\"\n else\n puts\"respectable\"\n end\nend\n"}, {"source_code": "\nxy = []\n8.times do\n x,y = gets.split(' ').map(&:to_i)\n xy << [x,y]\nend\n\nxs,ys = xy.transpose\nxxs = xs.sort.uniq\nyys = ys.sort.uniq\n\nok = true\nxxs.each do |x|\n if xs.count(x) != 3\n ok = false\n break;\n end\nend\n\nyys.each do |y|\n if ys.count(y) != 3\n ok = false\n break;\n end\nend if ok\n\nif !ok || xxs.size != 3 || yys.size != 3 || xy.include?([xxs[1], yys[1]])\n puts \"ugly\"\nelse\n puts \"respectable\"\nend\n"}, {"source_code": "\nxy = []\n8.times do\n x,y = gets.split(' ').map(&:to_i)\n xy << [x,y]\nend\n\nxs,ys = xy.transpose\nxxs = xs.sort.uniq\nyys = ys.sort.uniq\n\nok = true\nxxs.each.with_index do |x,i|\n if xs.count(x) != (i == 1 ? 2 : 3)\n ok = false\n break;\n end\nend\n\nyys.each.with_index do |y,i|\n if ys.count(y) != (i == 1 ? 2 : 3)\n ok = false\n break;\n end\nend if ok\n\nif !ok || xxs.size != 3 || yys.size != 3 || xy.include?([xxs[1], yys[1]])\n puts \"ugly\"\nelse\n puts \"respectable\"\nend\n"}, {"source_code": "\nxy = []\n8.times do\n x,y = gets.split(' ').map(&:to_i)\n xy << [x,y]\nend\n\nxs,ys = xy.transpose\nxxs = xs.sort.uniq\nyys = ys.sort.uniq\n\nif xxs.size != 3 || yys.size != 3 || xy.include?([xxs[1], yys[1]])\n puts \"ugly\"\nelse\n puts \"respectable\"\nend\n"}, {"source_code": "def runb(list)\n x = list.map{|x,y| x}.uniq.sort\n y = list.map{|x,y| y}.uniq.sort\n \n return false unless x.size == 3\n return false unless y.size == 3\n return false if list.member?([x[1],y[1]])\n return true\nend\n\ndef run(list)\n runb(list) ? \"respectable\" : \"ugly\"\nend\n\ndef convert(n)\n n.split(' ').map(&:to_i)\nend\n\nn = gets\nlist = []\nwhile n != nil\n list << convert(n)\n if list.size == 8\n puts run(list)\n list = []\n end\n n = gets\nend\n"}, {"source_code": "# http://codeforces.com/problemset/problem/334/B\nlist = []\nlist_x = []\nlist_y = []\n8.times do |i|\n list << gets.chomp.split.map(&:to_i)\n list_x << list[i][0]\n list_y << list[i][1]\nend\n\ndef eight_point_set(list, list_x, list_y)\n hash = Hash.new { |hash, key| hash[key] = 0 }\n for i in 0..7\n hash[list[i]] += 0\n\n if hash[list[i]] > 1\n return \"ugly\"\n end\n end\n\n sorted_list_x = list_x.sort\n sorted_list_y = list_y.sort\n avg_x, avg_y = 0, 0\n\n for i in 0..7\n avg_x += 1 if sorted_list_x[i] == sorted_list_x[3]\n avg_y += 1 if sorted_list_y[i] == sorted_list_y[3]\n end\n\n return avg_x == 2 && avg_y == 2 ? \"respectable\" : \"ugly\"\nend\n\nputs eight_point_set(list, list_x, list_y)\n"}, {"source_code": "# http://codeforces.com/problemset/problem/334/B\n\nlist_x = []\nlist_y = []\n8.times do\n pair = gets.chomp.split\n list_x << pair[0].to_i\n list_y << pair[1].to_i\nend\n\nlist_x = list_x.sort\nlist_y = list_y.sort\n\navg_x, avg_y = 0, 0\n\nfor i in 0..7\n avg_x += 1 if list_x[i] == list_x[3]\n avg_y += 1 if list_y[i] == list_y[3]\nend\n\nputs avg_x == 2 && avg_y == 2 ? \"respectable\" : \"ugly\"\n"}], "src_uid": "f3c96123334534056f26b96f90886807"} {"source_code": "str = gets.chomp\nstr[0] = str[0].capitalize\nputs str", "positive_code": [{"source_code": "s = gets\nputs s[0].upcase + s[1, s.length]"}, {"source_code": "word = STDIN.read\nputs word.sub(/\\w/) {|c| c.capitalize}\n"}, {"source_code": "s = gets.chomp\ns[0] = s[0].upcase\nputs s"}, {"source_code": "a = gets.chomp\nputs a[0].upcase + a[1..a.length]\n"}, {"source_code": "a=gets;puts a[0].upcase+a[1..-1]"}, {"source_code": "s = gets.chop\nputs s[0].upcase + s[1..s.size-1]"}, {"source_code": "s = gets.chomp\nprint s[0].capitalize + s[1..-1]"}, {"source_code": "str = gets.chomp\nstr1 = str[0]\n\nprint str1.capitalize\nputs str[1..str.length]"}, {"source_code": "str = gets.chomp\nprint str[0].capitalize , str[1..str.length]"}, {"source_code": "s = gets\nputs s[0].upcase + s[1...s.size]"}, {"source_code": "puts gets.sub(/^./){|l| l.upcase}\n"}, {"source_code": "# http://codeforces.com/problemset/problem/281/A\n\nword = gets.chomp\nputs \"#{word[0].upcase}#{word[1..(word.length - 1)]}\""}, {"source_code": "input = gets.chomp\nl = input.length\nsov = Array.new\nsov[0] = input[0].upcase\nfor i in 1...l\n sov.push(input[i])\nend\nprint sov.join\n"}, {"source_code": "word = gets.chomp.to_s\nletters = word.split(\"\")\nprint letters[0].capitalize\nletters[0] = nil\nletters.each do |letter|\n\tprint letter\nend"}, {"source_code": "n = gets.split('')\n\nn[0].upcase!\n\nputs n.join('')"}, {"source_code": "puts gets[0].upcase+$_[1..$_.size-1]"}, {"source_code": "str = gets ; str[0] = str[0].to_s.upcase ; puts str"}, {"source_code": "s = gets.strip\ns = s[0].capitalize + s[1..s.length]\nputs s"}, {"source_code": "s = gets.to_s\ns[0] = s[0].upcase\nputs s"}, {"source_code": "word = gets.chomp\nword[0] = word[0].upcase\nputs word"}, {"source_code": "str = gets.chomp\nstr[0] = str[0].capitalize\nputs str"}, {"source_code": "word = String(gets.chomp)\nif word[0] == word[0].upcase\n puts word\nelse\n puts word[0].upcase + word[1...word.length]\nend\n"}, {"source_code": "s = gets.chomp\nputs s[0].upcase + s[1..-1]\n"}, {"source_code": "a=gets;puts a.upcase[0]+a[1..-1]"}, {"source_code": "gets[0]=$_[0].upcase;puts$_"}, {"source_code": "s = gets\nputs s[0].upcase + s[1..-1]"}, {"source_code": "s = gets.chomp\ns[0] = s[0].upcase\nputs s\n"}, {"source_code": "input_word = gets.chomp\ninput_word[0]=input_word[0].upcase\nprint input_word\n"}, {"source_code": "str = gets\na = str[0].upcase\nstr[0]=a\nputs str"}, {"source_code": "str = gets.chomp\nfirst = str[0,1]\nfirst.upcase!\nnewstr = first + str[1,(str.length-1)]\nputs newstr"}, {"source_code": "x=gets.strip.chars.to_a; x[0]=x[0].upcase; puts x.join"}, {"source_code": "a = gets.chomp.to_s\nb = a[1..-1].scan(/[A-Z]/).length\nc = a[0]\nd = []\nif c.capitalize == c && b >= 1\nputs a\nelse\na[0] = a[0].upcase\nputs a\nend"}, {"source_code": "s = gets.chomp.split(\"\")\nif s[0] == s[0].upcase\n\tputs s.join\nelse\n\ts0 = s[0].upcase\n\ts.delete_at(0)\n\tputs s0 << s.join\nend\n"}, {"source_code": "input =gets\ninput[0]=input[0].upcase\nprint input"}, {"source_code": "$><<(gets p)[0].upcase+$_[1..-1]"}, {"source_code": "puts gets[0].upcase+$_[1..-1]"}, {"source_code": "cad = gets.chomp\n\ncad[0] = cad[0].upcase\n\nputs cad\n"}, {"source_code": "a=gets.chomp\na=a[0].upcase+a[1..a.length-1]\nputs \"#{a}\"\n\n"}, {"source_code": "n = gets.chomp\nm = []\nm = n.split(\"\")\nprint m[0].capitalize\nfor i in m.drop(1) do\n print i\nend"}, {"source_code": "a = gets.chomp\nb = a[0]\nb = b.upcase\na[0] = b[0]\nputs a\n"}, {"source_code": "a=gets\nprint a[0].capitalize+a[1..a.length-1]"}, {"source_code": "line = gets.chomp\n\nline[0] = line[0].upcase\nputs line\n"}, {"source_code": "String word = gets.chomp\nword[0]=word[0].capitalize\nputs word\n"}, {"source_code": "gets[0]=$_[0].upcase;puts$_\n"}, {"source_code": "word = gets.chomp\nfirst = word.split(//).first.upcase\nword[0] = first\nputs word"}, {"source_code": "s = gets[0..-2]\ncode = s[0].ord\ncode -= 32 if code > \"Z\".ord\ns[0] = code.chr\nprint s\n"}, {"source_code": "#!/usr/bin/env ruby\n\ngets.split.collect{|i| puts \"#{i[0].upcase}#{i[1..-1]}\"}\n"}, {"source_code": "input = gets.strip\n\ninput[0] = input[0].upcase\nputs input\n"}, {"source_code": "string = gets\nstring[0] = string[0].capitalize\nputs string\n"}, {"source_code": "s = gets.chomp; s[0] = s[0].upcase; puts s\n"}, {"source_code": "s = gets.chomp\ns[0] = s[0].upcase\nputs s\n"}, {"source_code": "string = gets.chomp.split('')\nstring[0].upcase!\n\nstring.each do |item|\n\tprint item\nend"}, {"source_code": "arr = gets.chomp.split(\"\")\nfirst_letter = arr.first.upcase\nputs [first_letter, arr[1..-1]].flatten.join"}, {"source_code": "a = gets.chomp\nprint a[0].upcase\nprint a[1..-1]"}, {"source_code": "gets[0]=$_[0].upcase;puts$_\n"}, {"source_code": "gets[0]=$_[0].upcase;puts$_"}, {"source_code": "s = gets.chomp\ns[0] = s[0].capitalize\nputs s"}, {"source_code": "str = gets.to_s.strip\n\ndef newlife(word)\n\tfirst_char = word[0]\n\tfirst_char.upcase!\n\tword[0] = first_char\n\tword\nend\n\nputs newlife(str)"}, {"source_code": "input = gets.chomp\n\nprint input.slice!(0).capitalize, input"}, {"source_code": "s = gets\nputs s[0].capitalize + s[1..-1]"}, {"source_code": "s = gets.strip\nif s[0].ord >= 'a'.ord && s[0].ord <= 'z'.ord then\n s[0] = (s[0].ord - 32).chr\nend\nputs s"}, {"source_code": "word = gets.chomp\nputs word[0].upcase + word[1..-1]"}, {"source_code": "s = gets.chomp\ns[0] = s[0].upcase\nputs s"}, {"source_code": "def xenia()\n word = gets.chomp\n letter = word[0]\n letter.upcase!\n print \"#{letter}#{word[1..-1]}\"\nend\n\nxenia "}, {"source_code": "a = gets.chomp\na[0] = a[0].upcase \nputs a\n"}, {"source_code": "#!/usr/bin/ruby1.9\n\nword = STDIN.readline.strip\nputs word[0].upcase+word[1..-1]\n\n"}, {"source_code": "s = gets.chomp\ns[0] = s[0].capitalize\nputs s\n"}, {"source_code": "A = gets.chomp\nA[0] = A[0].upcase\nputs A"}, {"source_code": "s = gets.chomp\nf = s[0].capitalize\nputs f + s[1..-1]"}, {"source_code": "ar=gets\nar[0]=ar[0].capitalize\nputs ar"}, {"source_code": "a = gets.chomp\nb = a.capitalize\nputs b[0] + a[1..-1]"}, {"source_code": "str = gets.chomp\nputs str[0].upcase + str[1..10**3]"}, {"source_code": "def run(input = STDIN.read)\n line = input.strip\n line[0] = line[0].capitalize\n puts line\nend\nrun"}, {"source_code": "src = gets\nsrc[0] = src[0].upcase\nputs src\n"}, {"source_code": "a=gets;puts a.upcase[0]+a[1..-1]"}, {"source_code": "str = gets.chomp()\nstr[0] = str[0].upcase\nputs str\n"}, {"source_code": "s = gets.chomp\ns[0] = s[0].capitalize\nputs s"}, {"source_code": "s = gets.chomp\nf = s[0].capitalize\nputs f + s[1..-1]"}, {"source_code": "s = gets\ns[0] = s[0].upcase\nprint s\n"}, {"source_code": "t = $stdin.readline\ntt = t.scan(/./)\ntt[0] = t[0].capitalize\nputs tt.join('')"}, {"source_code": "s = gets.to_s\nputs s[0].upcase + s[1..-1]\n"}, {"source_code": "x = gets.chomp;\nx[0]= x[0].upcase;\nputs x;"}, {"source_code": "def run\n line = $stdin.readline.split(//)\n line[0].upcase!\n puts line.join(\"\")\nend\n\nrun if $0 == __FILE__\n"}, {"source_code": "a = gets \nputs a[0].upcase + a[1..-1]\n"}, {"source_code": "inp = gets.chomp\ninp = inp.sub(/^./) { |ch| ch.upcase }\nputs inp\n"}, {"source_code": "str = $stdin.gets\n\nstr[0] = str[0].upcase! if str[0].upcase!\nputs str"}, {"source_code": "w = gets.chomp\n\nputs w[0].upcase + w[1..-1]\n"}, {"source_code": "s = gets\n\ns[0] = s[0].capitalize;\n\nputs s"}, {"source_code": "test = gets\ntest[0] = test[0].capitalize\nputs test"}, {"source_code": "a = gets.chomp()\nputs a[0].upcase << a[1..-1]"}, {"source_code": "s = gets.chomp\nputs s[0].capitalize + s[1..-1]"}, {"source_code": "s = gets.strip\nt = \"\"\ns.length.times do |i|\n if i == 0\n t += s[i].upcase\n else\n t += s[i]\n end\nend\nputs t"}, {"source_code": "a=gets.chomp\na=a[0].upcase+a[1..a.length-1]\nputs \"#{a}\""}, {"source_code": "x = gets.chomp\nputs \"#{x[0].capitalize + x[1..-1]}\""}, {"source_code": "s=gets\ns[0]=s[0].upcase\nputs s"}, {"source_code": "#STDOUT.flush\n#str = gets.chomp\n#str_aux = \"AEIOUYaeiouy\"\n#str.each_char { |out|\n#\tif !str_aux.include? out.to_s\n#\t\tprint \".\"\n#\t\tprint out.downcase\n#\tend\n#}\n#puts \"\\n\"\n\nSTDOUT.flush\nstr = gets.chomp\nprint str[0].upcase\nputs str[1..str.size()]"}, {"source_code": "require 'set'\ninclude Math\n$stdin = File.open(\"./input.txt\", \"r\") if ENV[\"USER\"] == \"new\"\n# ====================================\n\nline = gets.strip\nline[0] = line[0].upcase\nputs line"}], "negative_code": [{"source_code": "s = gets.chomp.split(//)\ns[0] = s[0].capitalize\nputs s\n"}, {"source_code": "puts gets.chomp.capitalize"}, {"source_code": "puts gets.chomp.capitalize"}, {"source_code": "puts gets.capitalize"}, {"source_code": "s = gets\ns[0] = s[0] + 'a' + 'A' if 'a' <= s[0] && s[0] <= 'z'\nprint s\n"}, {"source_code": "puts gets.chomp.capitalize"}, {"source_code": "puts gets.capitalize"}, {"source_code": "s = gets\nputs s.capitalize"}, {"source_code": "#!/usr/bin/ruby1.9\n\nword = STDIN.readline.strip.capitalize\nputs word\n\n"}, {"source_code": "puts gets.capitalize"}, {"source_code": "def run(input = STDIN.read)\n line = input.strip\n puts line.capitalize\nend\nrun\n"}, {"source_code": "puts gets.capitalize\n"}, {"source_code": "inp = gets.chomp\ninp.sub(/^./) { |ch| ch.upcase }\nputs inp\n"}, {"source_code": "str = $stdin.gets\n\nputs str.capitalize"}, {"source_code": "test = gets.chomp\nfinal = test.capitalize\nputs final"}, {"source_code": "a = gets.chomp()\nputs a[0].upcase!.to_s << a[1..-1]"}, {"source_code": "a = gets.chomp()\nb = a[0].upcase!.to_s\nputs b << a[1..-1]"}, {"source_code": "puts gets.chomp.capitalize"}, {"source_code": "x=gets;p x[0].upcase+x[1..-2]"}, {"source_code": "x=gets;p x[0].upcase+x[1..-1]"}, {"source_code": "puts gets.capitalize"}, {"source_code": "puts gets.capitalize"}, {"source_code": "str = gets ; puts str.to_s.capitalize"}, {"source_code": "s = gets\nputs s.capitalize"}, {"source_code": "s = gets.strip\ns = s[0].capitalize + s[1..s.length]"}, {"source_code": "word = gets.chomp\nword[0].upcase!\nputs word"}, {"source_code": "puts gets.chomp.capitalize"}, {"source_code": "puts gets.capitalize"}, {"source_code": "puts gets.capitalize"}, {"source_code": "input_word = gets.chomp\nprint input_word[0].upcase\n"}, {"source_code": "a = gets.chomp.to_s\nb = a[1..-1].scan(/[A-Z]/).length\nc = a[0]\nif c.upcase == c && b >= 1\nputs a\nelse\nc.upcase!\nputs a\nend"}, {"source_code": "a = gets.chomp.to_s\nb = a[1..-1].scan(/[A-Z]/).length\nc = a[0]\nif c.upcase == c && b >= 1\nputs a\nelse\nputs a.capitalize\nend"}, {"source_code": "a = gets.chomp.to_s\nb = a[1..-1].scan(/[A-Z]/).length\nc = a[0]\nif c.capitalize == c && b >= 1\nputs a\nelse\nputs a.capitalize\nend"}, {"source_code": "a = gets.chomp.to_s\nb = a[1..-1].scan(/[A-Z]/).length\nc = a[0]\nif c.capitalize == c && b >= 1\nputs a\nelse\nputs a.capitalize!\nend"}, {"source_code": "input=gets\np input.to_s.capitalize"}, {"source_code": "String word = gets.chomp\nword[0].capitalize!\nputs word\n"}, {"source_code": "String word = gets.chomp\nword.capitalize!\nputs word\n"}, {"source_code": "puts gets.chomp.capitalize\n"}], "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4"} {"source_code": "#!/usr/bin/ruby\nhash = {'9' => '0', '8' => '1','7' => '2','6' => '3','5' => '4'}\ninput_line = gets\nres = ''\ninput_line.each_char do |ch|\n if hash[ch].nil?\n res+=ch;\n else\n if (ch == '9' && res == '')\n res+=ch\n else\n res+=hash[ch]\n end\n end\nend\n\nputs res\n\n", "positive_code": [{"source_code": "a=gets.chop.split(//).map(&:to_i).map{|i|i=[i,9-i].min}*''\na[0]='9' if a[0]=='0'\nputs a"}, {"source_code": "# coding: utf-8\n\n# if __FILE__ == $0\n# end\n\ndigits = gets.chomp.split(//).map { |i|\n i = i.to_i\n inverted = 9 - i\n if inverted < i\n inverted\n else\n i\n end\n}\n\n# remind leading zero!\nif digits[0] == 0\n digits[0] = 9\nend\n\nputs digits.join"}, {"source_code": "n = gets.chomp \n\nn = n.gsub(/[98765]/,'9'=>'0','8'=>'1','7'=>'2','6'=>'3','5'=>'4') \n\nif n[0] == '0' \n n[0] = '9' \n # puts n\nend \n\nputs n "}, {"source_code": "number = gets.chomp\ndigits = number.split(\"\")\n\nif digits[0].to_i >= 5 && digits[0].to_i != 9\n\tdigits[0] = 9 - digits[0].to_i\nend\nif digits[digits.size - 1].to_i >= 5 && digits.size > 1\n\tdigits[digits.size - 1] = 9 - digits[digits.size - 1].to_i\nend\nif digits.size == 2\n\tprint digits[0].to_i\n\tprint digits[1].to_i\nelsif digits.size == 1\n\tprint digits[0].to_i\nelse\n\tfor i in (1..digits.size-2)\n\t\tif digits[i].to_i >= 5 \n\t\t\tdigits[i] = 9 - digits[i].to_i\n\t\tend\n\tend\n\tfor i in (0..digits.size-1)\n\t\tprint digits[i].to_i\n\tend\nend"}, {"source_code": "digits = gets.chomp.chars.map(&:to_i)\nprint digits.shift if digits[0] == 9\nputs digits.map{|d| [d,9-d].min}.join"}, {"source_code": "a=gets.chomp.bytes.map{|e|[57-e,e-48].min}\na[0]=9 if a[0]==0\nputs a*''"}, {"source_code": "initial_num = ARGF.read\n\nresult = ''\n\ninitial_num.chars.each_with_index do |c, index|\n\ti = c.to_i\n\tif i >= 5\n\t\tif i == 9 and index == 0\n\t\t\tresult << c\n\t\telse\n\t\t\tresult << (9-i).to_s\n\t\tend\n\telse\n\t\tresult << c\n\tend\nend\n\nputs result"}, {"source_code": "# http://codeforces.com/contest/514/problem/A\n\ndigits = gets.chomp.chars.map(&:to_i)\ninverted = digits.map.with_index do |n, idx|\n case idx\n when 0\n (9 - n) < n && n != 9 ? 9 - n : n\n else\n (9 - n) < n ? 9 - n : n\n end\nend\n\nputs inverted.join.to_i\n"}, {"source_code": "s = gets.chomp.to_s\nk = s[0]\nfor i in 0..s.length - 1\n if s[i].to_i>=5\n s[i] = (9 - s[i].to_i).to_s\n end\nend\nif s[0] == \"0\"\n s[0] = k\nend\nputs s\n\n"}, {"source_code": "#!/usr/bin/ruby\n# coding: utf-8\n\ns = gets.chomp.to_s\n(s.length).times{|i|\n if s[i].to_i >= 5 \n if i == 0 and s[i].to_i == 9 \n next\n end\n s[i] = (9 - s[i].to_i).to_s\n end \n}\nputs s"}, {"source_code": "a = gets.strip.chars.each_with_index.map do |ci,i|\n d = ci.ord - '0'.ord\n if i == 0 && d == 9\n d\n elsif d >= 5\n 9-d\n else\n d\n end\nend\nputs a.join\n"}, {"source_code": "x = gets.strip.split('').map{|x| x.to_i}\nx[0] = 9 - x[0] if x[0] > 4 && x[0] != 9\n(1..x.size - 1).each{|i| x[i] = 9 - x[i] if x[i] > 4}\nputs(x.join)\n"}, {"source_code": "arr = gets.chomp.split(\"\")\narr.each_with_index do |item, index|\n print item.to_i <= 4 ? item : index.to_i == 0 && item.to_i == 9 ? item : 9 - item.to_i\nend\n"}, {"source_code": "x = gets.chomp.chars.map(&:to_i)\n\ntmp = x[0]\nx = x[1..-1]\n\ntmp = 9 - tmp if tmp > 4 and tmp < 9\n\nx = x.map { |i|\n if i > 4\n 9 - i\n else\n i\n end }\n\nputs ([tmp] + x).join(\"\")"}, {"source_code": "str=gets.to_s\nstr.chomp!\n\nfor i in 0..str.length-1\n x=str[i].to_i\n y=9-x\n if x>y\n str[i]=y.to_s\n else\n str[i]=x.to_s\n end\nend\n\nif str[0]==\"0\"\n str[0]=\"9\"\nend\n\nputs str"}, {"source_code": "\na = gets.split('').map(&:to_i)\n(a.length-1).times{|i|\n if ((i!=0 || a[i]!=9) && a[i]>4)\n print 9-a[i]\n else\n print a[i]\n end\n}"}, {"source_code": "res = gets.chomp.chars.map(&:to_i).\n map{|x| [x, 9 -x].min}.map(&:to_s).join('')\n\nres[0] = '9' if res[0] == '0'\nputs res\n"}, {"source_code": "\ns=gets.chomp\nx=s.chars\nt=x.shift\n\np1=\"8765\".index(t)\nif p1!=nil then\n\tt=[1,2,3,4][p1]\nelse\n\tt=t.to_i\nend\nans=t\nx.map{|e|\n\tans*=10\n\tp2=\"98765\".index(e)\n\tif p2==nil then\n\t\tans=ans+e.to_i\n\telse\n\t\tans=ans+[0,1,2,3,4][p2]\n\tend\n}\nputs ans\n\n"}, {"source_code": "s = gets.chomp\nif s[0] == '9'\n\tprint '9'\nelse\n\tprint [s[0].to_i,9-s[0].to_i].min\nend\n1.upto(s.length - 1) do |i|\n\tprint [s[i].to_i , 9-s[i].to_i].min\nend"}], "negative_code": [{"source_code": "\na = gets.split('').map(&:to_i)\n(a.length-1).times{|i|\n if (i!=0 && a[i]>4)\n print 9-a[i]\n else\n print a[i]\n end\n}"}, {"source_code": "def read_ints; STDIN.gets.split.map(&:to_i); end\n\nputs gets.chomp.chars.map(&:to_i).\n map{|x| [x, 9 -x].min}.map(&:to_s).join('')\n\n"}, {"source_code": "\ns=gets.chomp\nx=s.chars\nt=x.shift\n\np1=\"8765\".index(t)\nif p1!=nil then\n\tt=[1,2,3,4][p1]\n\tp t\nelse\n\tt=t.to_i\nend\nans=t\nx.map{|e|\n\tans*=10\n\tp2=\"98765\".index(e)\n\tif p2==nil then\n\t\tans=ans+e.to_i\n\telse\n\t\tans=ans+[0,1,2,3,4][p2]\n\tend\n}\nputs ans\n\n"}, {"source_code": "s = gets.chomp\nif s[0] == '9'\n\tprint '9'\nelse\n\tprint [s[0].to_i,9-s[0].to_i].min\nend\n1.upto(s.length - 1) do |i|\n\tprint [s[0].to_i , 9-s[0].to_i].min\nend"}, {"source_code": "# coding: utf-8\n\n# if __FILE__ == $0\n# end\n\ndigits = gets.chomp.split(//).map { |i|\n i = i.to_i\n inverted = 9 - i\n if inverted < i\n inverted\n else\n i\n end\n}\n\nputs digits.join"}, {"source_code": "number = gets.chomp\ndigits = number.split(\"\")\n\nif digits[0].to_i >= 5 && digits[0].to_i != 9\n\tdigits[0] = 9 - digits[0].to_i\nend\nif digits[digits.size - 1].to_i >= 5 \n\tdigits[digits.size - 1] = 9 - digits[digits.size - 1].to_i\nend\nif digits.size == 2\n\tprint digits[0].to_i\n\tprint digits[1].to_i\nelsif digits.size == 1\n\tprint digits[0].to_i\nelse\n\tfor i in (1..digits.size-2)\n\t\tif digits[i].to_i >= 5 \n\t\t\tdigits[i] = 9 - digits[i].to_i\n\t\tend\n\tend\n\tfor i in (0..digits.size-1)\n\t\tprint digits[i].to_i\n\tend\nend"}, {"source_code": "number = gets.chomp\ndigits = number.split(\"\")\n\nif digits[0].to_i >= 5 && digits[0].to_i != 9\n\tdigits[0] = 9 - digits[0].to_i\nend\nif digits[digits.size - 1].to_i >= 5 && digits[digits.size - 1].to_i != 9\n\tdigits[digits.size - 1] = 9 - digits[digits.size - 1].to_i\nend\nif digits.size == 2\n\tprint digits[0].to_i\n\tprint digits[1].to_i\nelsif digits.size == 1\n\tprint digits[0].to_i\nelse\n\tfor i in (1..digits.size-2)\n\t\tif digits[i].to_i >= 5 && digits[i].to_i != 9\n\t\t\tdigits[i] = 9 - digits[i].to_i\n\t\tend\n\tend\n\tfor i in (0..digits.size-1)\n\t\tprint digits[i].to_i\n\tend\nend"}, {"source_code": "number = gets.chomp\ndigits = number.split(\"\")\n\nif digits[0].to_i >= 5\n\tdigits[0] = 9 - digits[0].to_i\nend\nif digits[digits.size - 1].to_i >= 5\n\tdigits[digits.size - 1] = 9 - digits[digits.size - 1].to_i\nend\nif digits.size == 2\n\tprint digits[0].to_i\n\tprint digits[1].to_i\nelsif digits.size == 1\n\tprint digits[0].to_i\nelse\n\tfor i in (1..digits.size-2)\n\t\tif digits[i].to_i >= 5\n\t\t\tdigits[i] = 9 - digits[i].to_i\n\t\tend\n\tend\n\tfor i in (0..digits.size-1)\n\t\tprint digits[i].to_i\n\tend\nend"}, {"source_code": "number = gets.chomp\ndigits = number.split(\"\")\n\nif digits[0].to_i >= 5 && digits[0].to_i != 9\n\tputs \"asdf\"\n\tdigits[0] = 9 - digits[0].to_i\nend\nif digits[digits.size - 1].to_i >= 5 && digits.size > 1\n\tdigits[digits.size - 1] = 9 - digits[digits.size - 1].to_i\nend\nif digits.size == 2\n\tprint digits[0].to_i\n\tprint digits[1].to_i\nelsif digits.size == 1\n\tprint digits[0].to_i\nelse\n\tfor i in (1..digits.size-2)\n\t\tif digits[i].to_i >= 5 \n\t\t\tdigits[i] = 9 - digits[i].to_i\n\t\tend\n\tend\n\tfor i in (0..digits.size-1)\n\t\tprint digits[i].to_i\n\tend\nend"}, {"source_code": "ans = gets.chomp.chars.map(&:to_i).map{|d| [d,9-d].min}.join.to_i\nputs ans==0 ? 9 : ans"}, {"source_code": "puts gets.chomp.chars.map(&:to_i).map{|d| [d,9-d].min}.join.to_i"}, {"source_code": "initial_num = ARGF.read\n\nresult = ''\n\ninitial_num.chars.each_with_index do |c, index|\n i = c.to_i\n if i >= 5\n result << (9-i).to_s unless i == 9 and index == 0\n else\n result << c\n end\nend\n\nputs result"}, {"source_code": "initial_num = ARGF.read\n\nresult = ''\n\ninitial_num.chars.each_with_index do |c, index|\n\ti = c.to_i\n\tif i >= 5\n\t\tresult << (9-i).to_s unless i == 9 and index == 0\n\telse\n\t\tresult << c\n\tend\nend\n\nputs result"}, {"source_code": "c = gets.strip\nif c == '9'\n puts 0\nelse\n a = c.chars.each_with_index.map do |ci,i|\n d = ci.ord - '0'.ord\n if i == 0 && d == 9\n d\n elsif d >= 5\n 9-d\n else\n d\n end\n end\n puts a.join\nend\n"}, {"source_code": "x = gets.chomp.chars.map(&:to_i)\n\ntmp = x[0]\nx = x[1..-1]\n\ntmp = 9 - tmp if tmp > 4 and tmp < 9\n\nx = x.map { |i| 9 - i if i > 4 }\n\nputs ([tmp] + x).join(\"\")"}, {"source_code": "# cook your code here\nn = gets.chomp \n\nn = n.gsub(/[98765]/,'9'=>'0','8'=>'1','7'=>'2','6'=>'3','5'=>'4') \n\ni = 0 ;\n\nif n[0] == '0' \n n[0] == '9' \nend \n\nputs n "}, {"source_code": "# cook your code here\nn = gets.chomp \n\nn = n.gsub(/[98765]/,'9'=>'0','8'=>'1','7'=>'2','6'=>'3','5'=>'4') \n\ni = 0 ;\n\nwhile n[i]=='0' \n n[i] = '9' \n i = i+1 \nend \n\nputs n "}, {"source_code": "a=gets.chomp.bytes.map{|e|57-e}\na[0]=9 if a[0]==0\nputs a*''"}, {"source_code": "# http://codeforces.com/contest/514/problem/A\n\ndigits = gets.chomp.chars.map(&:to_i)\ndigits.map! { |n| (9 - n) < n ? 9 - n : n }\n\nputs digits.join.to_i\n"}, {"source_code": "arr = gets.chomp.split(\"\")\narr.each do |x| print x.to_i <= 4 ? x : arr[0] == '9' ? arr[0] : \n 9 - x.to_i\nend\n"}, {"source_code": "n = gets.to_i\nans = \"\"\nwhile n > 0 do\n dig = n % 10\n if 9 - dig < dig && 9 - dig != 0\n ans << (9 - dig).to_s\n else\n ans << dig.to_s\n end\n n /= 10\nend\nputs ans\n"}, {"source_code": "n = gets.to_i\nans = \"\"\nwhile n > 0 do\n dig = n % 10\n if 9 - dig < dig\n ans << (9 - dig).to_s\n else\n ans << dig.to_s\n end\n n /= 10\nend\nputs ans\n"}, {"source_code": "arr = gets.chomp.split(\"\")\narr.each do |x| print x.to_i <= 4 ? x : arr.size == 1 && arr[0] == '9' ? arr[0] : \n 9 - x.to_i\nend\n"}], "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61"} {"source_code": "a = Array.new(123, gets.split[1].to_i)\ngets.chars{|c| a[c.ord] -= 1}\nputs a.min < 0 ? :NO : :YES\n\n", "positive_code": [{"source_code": "n,k=gets.split.map &:to_i\nh=Hash.new 0\ngets.chomp.chars{|c|h[c]+=1}\nputs h.values.any?{|e|e>k} ? :NO : :YES"}, {"source_code": "n, k = gets.strip.split.map(&:to_i)\ns = gets.strip\nans = \"YES\"\ncount = Array.new(26, 0)\nn.times do |i|\n count[s[i].ord - 'a'.ord] += 1\nend\nmax_count = count.max\nans = \"NO\" if max_count > k\nputs ans\n"}, {"source_code": "n,f=gets.split.map{|e| e.to_i}\n\nhs=Hash.new(0)\ngets.chomp.chars.each{|e|\n\ths[e]+=1\n}\n\nv=hs.values.sort.pop\n\nif v<=f then\n\tputs \"YES\"\nelse\n\tputs \"NO\"\nend"}, {"source_code": "n,k=gets.split.map(&:to_i)\ns = gets.chomp\nh = Hash.new(0)\ns.chars do |c|\n h[c] += 1\nend\n\nf = true\n[*?a..?z].each do |c|\n if h[c] == 0\n next\n elsif (h[c] - 1) / k > 0\n f = false\n break\n end\nend\nputs f ? \"YES\" : \"NO\""}, {"source_code": "n, k=gets.split.map(&:to_i)\ns=gets.chomp.chars\n\nh=Hash.new(0)\ns.each{|c| h[c]+=1}\nok=true\nh.each_value do |v|\n ok&=v<=k\nend\n\nputs ok ? 'YES' : 'NO'\n"}], "negative_code": [{"source_code": "n,f=gets.split.map{|e| e.to_i}\n\nhs=Hash.new(0)\ngets.chomp.chars.each{|e|\n\ths[e]+=1\n}\n\nvs=hs.values\nsum=0\nwhile vs.size >1\n\td=vs.shift\n\tvs=vs.map{|e|\n\t\tif d>=e then\n\t\t\td-=e\n\t\t\tf-=e\n\t\t\t0\n\t\telse\n\t\t\tf-=d\n\t\t\tt=e-d\n\t\t\td=0\n\t\t\tt\n\t\tend\n\t}.select{|e| e>0}\n\tvs.push(d) if d>0\nend\nif f<=0 then\n\tputs \"YES\"\nelse\n\tputs \"NO\"\nend"}, {"source_code": "n,f=gets.split.map{|e| e.to_i}\n\nhs=Hash.new(0)\ngets.chomp.chars.each{|e|\n\ths[e]+=1\n}\n\nvs=hs.values\nsum=0\nwhile vs.size >1\n\td=vs.shift\n\tvs=vs.map{|e|\n\t\tif d>=e then\n\t\t\td-=e\n\t\t\tf-=e\n\t\t\t0\n\t\telse\n\t\t\tf-=d\n\t\t\tt=e-d\n\t\t\td=0\n\t\t\tt\n\t\tend\n\t}.select{|e| e>0}\n\tvs.push(d) if d>0\nend\nif vs.empty? && f>=0 then\n\tputs \"YES\"\nelse\n\tputs \"NO\"\nend"}, {"source_code": "n,f=gets.split.map{|e| e.to_i}\nhs=Hash.new(0)\ngets.chomp.chars.each{|e|\n\ths[e]+=1\n}\nhs.each{|k,v|\n\tf-=(v/2).to_i\n}\nif f<=0 then\n\tputs \"YES\"\nelse\n\tputs \"NO\"\nend"}, {"source_code": "n,k=gets.split.map(&:to_i)\ns = gets.chomp\nh = Hash.new(0)\ns.chars do |c|\n h[c] += 1\nend\n\nf = true\n[*?a..?z].each do |c|\n if h[c] % 2 == 1\n f = false\n break\n end\nend\nputs f ? \"YES\" : \"NO\""}, {"source_code": "a = Array.new(123, gets.split[1].to_i)\ngets.chars{|c| a[c.ord] -= 1}\np a.min < 0 ? 'NO' : 'YES'\n\n"}], "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be"} {"source_code": "# Input\nn = gets.to_i # 2 <= n <= 100\na = gets.split(\" \").map! { |b| b.to_i } # 1 <= b <= 100\n\n# Processing\na.sort!\npairs = Array.new(n / 2) { |i| [a[2 * i], a[2 * i + 1]] }\nsum = pairs.inject(0) { |mem, p| mem + (p[1] - p[0]) }\n\n# Output\nputs sum\n", "positive_code": [{"source_code": "class Main\n #def get_problem_link\n # problem_link = \"https://codeforces.com/problemset/problem/1092/B\"\n # return problem_link\n #end\n\n #def get_submission_link\n # submission_link = ''\n # return submisson_link\n #end\n\n #begin\n #of codeforces interface\n def run_interface\n n = gets.to_i\n k = gets.split(' ').map(&:to_i)\n puts solution(n, k)\n end\n #end\n #of codeforces interface\n\n def solution(n, students_array)\n res = 0\n students_array.sort!\n (0...students_array.length).step(2).each do |i|\n res = res + (students_array[i+1]-students_array[i]);\n end\n return res\n end\n\nend\n\n#then upload to codeforces uncomment this line:\nMain.new.run_interface\n"}, {"source_code": "gets\nr=0;gets.split.map(&:to_i).sort.each_slice(2){|x,y|r+=y-x};p r"}, {"source_code": "n = gets.to_i\na = gets.split.map(&:to_i)\na.sort!\nans = 0\n(n/2).times do |i|\n ans += a[2*i+1] - a[2*i]\nend\np ans\n"}, {"source_code": "\ndef solution\n count = read_int\n ss = read_ints.sort\n p ss.each_slice(2).map{ |a, b| b - a }.reduce(0, :+)\nend\n\ndef read_int\n gets.to_i\nend\n\ndef read_ints\n gets.split.map(&:to_i)\nend\n\ndef read_string\n gets.chomp\nend\n\nsolution unless ENV['TEST__MODE']\n\n"}, {"source_code": "n = gets.to_i\nas = gets.split.map(&:to_i).sort\nans = 0\n(0..(n/2-1)).each do |i|\n ans += (as[2*i] - as[2*i+1]).abs\nend\nputs ans\n"}, {"source_code": "n = gets.to_i\narr = gets.split.map(&:to_i).sort\nres = 0\narr.each_slice(2) do |slice|\n res += slice[1] - slice[0]\nend\nputs res"}, {"source_code": "n = gets.to_i\na = gets.split.map(&:to_i).sort\nans = 0\n(n/2).times do |i|\n ans += a[i*2+1]-a[i*2]\nend\nputs ans"}, {"source_code": "# coding: utf-8\n\n# if __FILE == $0\n# end\n\nn = gets.to_i\nskills = gets.split.map { |i| i.to_i }\ndeltas = 0\nskills.sort.each_slice(2) { |a| deltas += a[1] - a[0] }\nputs deltas"}, {"source_code": "# https://codeforces.com/problemset/problem/1092/B\n\ndef solution(n, a)\n skills = {}\n (0..(n - 1)).each do |i|\n skills[a[i]] = skills.fetch(a[i], 0) + 1\n end\n\n h = nil\n\n problems = 0\n 100.times do |x|\n i = 100 - x\n\n next if !skills.key?(i)\n next if skills[i] % 2 == 0\n next h = i if h.nil?\n\n problems += h - i\n\n h = nil\n end\n return problems\nend\n\nn = gets.chomp.to_i\na = gets.chomp.split(\" \").map(&:to_i)\n\nputs solution(n, a)\n"}, {"source_code": "n = gets.to_i\na = gets.split.map(&:to_i).sort\ni, s = 0, 0\nwhile i < a.size\n s += a[i + 1] - a[i]\n i += 2\nend\nputs s\n"}], "negative_code": [], "src_uid": "55485fe203a114374f0aae93006278d3"} {"source_code": "#!/usr/bin/ruby\nn=gets.chomp\np [n,*(1...n.size).map{|i|\n\t(n[0,i].to_i-1).to_s+'9'*(n.size-i)\n}].max_by{|e|[e.chars.map(&:to_i).reduce(:+),e.to_i]}.to_i", "positive_code": [{"source_code": "def sum(x)\n x.split('').map(&:to_i).inject(0) { |sum, x| sum + x }\nend\n\nx = gets.to_i\n\nsx = x.to_s\n\nans = x\nsans = sx\n\nsx.length.times do |i|\n sy = sx[0...i] + (sx[i].to_i - 1).to_s + '9' * (sx.length - i - 1)\n \n y = sy.to_i\n sy = y.to_s\n \n if (sum(sy) > sum(sans) || (sum(sy) == sum(sans) && y > ans))\n ans = y\n sans = sy\n end\nend\n\nputs sans"}], "negative_code": [{"source_code": "#!/usr/bin/ruby\nn=gets.chomp\nputs [n,*(1...n.size).map{|i|\n\t(n[0,i].to_i-1).to_s+'9'*(n.size-i)\n}].max_by{|e|[e.chars.map(&:to_i).reduce(:+),e.to_i]}"}, {"source_code": "#!/usr/bin/ruby\nn=gets.to_i\nr=0\nd=1\nwhile r<=n\n\tr=r*10+9\n\td*=10\nend\nd/=10\nr-=d while r>n\np [n,r].max_by{|e|[e.to_s.chars.map(&:to_i).reduce(:+),e]}\n"}, {"source_code": "#!/usr/bin/ruby\nn=gets.chomp\nputs [n,*(1...n.size).map{|i|\n\t(n[0,i].to_i-1).to_s+'9'*(n.size-i)\n}].max_by{|e|[e.chars.map(&:to_i).reduce(:+),e.to_i,e]}"}], "src_uid": "e55b0debbf33c266091e6634494356b8"} {"source_code": "n=gets.to_i;s=0;c=[0]*9;(1..n).each{|i|s-=n/i;c[i%9]+=1};9.times{|i|9.times{|j|s+=c[i]*c[j]*c[i*j%9]}};puts s", "positive_code": [{"source_code": "n=gets.to_i;s=0;c=[0]*9;(1..n).each{|i|s-=n/i;c[i%9]+=1};9.times{|i|9.times{|j|s+=c[i]*c[j]*c[i*j%9]}};puts s\n"}, {"source_code": "n=gets.to_i;s=0;c=[0]*9;(1..n).each{|i|s-=n/i;c[i%9]+=1};9.times{|i|9.times{|j|s+=c[i]*c[j]*c[i*j%9]}};puts s\n"}, {"source_code": "n=gets.to_i;s=0;c=[0]*9;(1..n).each{|i|s-=n/i;c[i%9]+=1};9.times{|i|9.times{|j|s+=c[i]*c[j]*c[i*j%9]}};puts s"}, {"source_code": "n=gets.to_i;s=0;c=[0]*9;(1..n).each{|i|s-=n/i;c[i%9]+=1};9.times{|i|9.times{|j|s+=c[i]*c[j]*c[i*j%9]}};puts s\n"}, {"source_code": "n=gets.to_i;s=0;c=[0]*9;(1..n).each{|i|s-=n/i;c[i%9]+=1};9.times{|i|9.times{|j|s+=c[i]*c[j]*c[i*j%9]}};puts s\n"}, {"source_code": "n=gets.to_i;s=0;c=[0]*9;(1..n).each{|i|s-=n/i;c[i%9]+=1};9.times{|i|9.times{|j|s+=c[i]*c[j]*c[i*j%9]}};puts s\n"}, {"source_code": "n=gets.to_i;s=0;c=[0]*9;(1..n).each{|i|s-=n/i;c[i%9]+=1};9.times{|i|9.times{|j|s+=c[i]*c[j]*c[i*j%9]}};puts s"}, {"source_code": "n=gets.to_i;s=0;c=[0]*9;(1..n).each{|i|s-=n/i;c[i%9]+=1};9.times{|i|9.times{|j|s+=c[i]*c[j]*c[i*j%9]}};puts s\n"}, {"source_code": "n=gets.to_i;s=0;c=[0]*9;(1..n).each{|i|s-=n/i;c[i%9]+=1};9.times{|i|9.times{|j|s+=c[i]*c[j]*c[i*j%9]}};puts s\n"}, {"source_code": "n=gets.to_i;s=0;c=[0]*9;(1..n).each{|i|s-=n/i;c[i%9]+=1};9.times{|i|9.times{|j|s+=c[i]*c[j]*c[i*j%9]}};puts s\n"}], "negative_code": [], "src_uid": "fc133fe6353089a0ebee08dec919f608"} {"source_code": "name = gets.strip\nregistered_char = []\ncounter = 0\n\nname.each_char do |char|\n next if registered_char.include?(char)\n\n registered_char.push(char)\n counter += 1\nend\n\nif counter.odd?\n puts 'IGNORE HIM!'\nelse\n puts 'CHAT WITH HER!'\nend\n", "positive_code": [{"source_code": "$><<[\"IGNORE HIM!\",\"CHAT WITH HER!\"][gets.chars.uniq.size%2]"}, {"source_code": "#rextester.com:2.3.1--codeforces.com:2.0.0p645\nputs gets.chomp.chars.uniq.length%2==0?'CHAT WITH HER!':'IGNORE HIM!'"}, {"source_code": "#rextester.com:2.3.1--codeforces.com:2.0.0p645\nputs gets.chomp.chars.uniq.size%2==0?'CHAT WITH HER!':'IGNORE HIM!'"}, {"source_code": "puts gets.split('').sort.uniq.size % 2==1 ? \"CHAT WITH HER!\" : \"IGNORE HIM!\""}, {"source_code": "puts gets.split(//).uniq.size.odd? ? 'CHAT WITH HER!' : 'IGNORE HIM!'\n"}, {"source_code": "$><<[\"IGNORE HIM!\",\"CHAT WITH HER!\"][gets.chars.uniq.size%2]"}, {"source_code": "puts ['IGNORE HIM!','CHAT WITH HER!'][gets.chars.to_a.uniq.size%2]\n\n"}, {"source_code": "puts (gets.strip.split('').uniq.size.odd?)?'IGNORE HIM!':'CHAT WITH HER!'\n\n"}, {"source_code": "puts ['IGNORE HIM!','CHAT WITH HER!'][gets.split('').uniq.size%2]\n\n"}, {"source_code": "if gets.chomp.split(\"\").uniq.size.odd?\n puts \"IGNORE HIM!\"\nelse\n puts \"CHAT WITH HER!\"\nend"}, {"source_code": "# http://codeforces.com/problemset/problem/236/A\n\nusername = gets.chomp\n\nif username.chars.to_a.uniq.length % 2 == 0\n puts \"CHAT WITH HER!\"\nelse\n puts \"IGNORE HIM!\"\nend"}, {"source_code": "puts [\"CHAT WITH HER!\", \"IGNORE HIM!\"][gets.chomp.chars.to_a.uniq{|x| x}.length.odd? ? 1 : 0]"}, {"source_code": "puts gets.chomp.split(//).uniq.count.even? ? 'CHAT WITH HER!' : 'IGNORE HIM!'"}, {"source_code": "string = gets.chomp.split(\"\")\n\narr = []\nfor i in (0..string.size-1)\n\tif arr.include?(string[i]) == false\n\t\tarr << string[i]\n\tend\nend\n\nif arr.count % 2 == 0\n\tprint \"CHAT WITH HER!\"\nelse\n\tprint \"IGNORE HIM!\"\nend"}, {"source_code": "if gets.chomp.split(//).uniq.count.odd?\n puts \"IGNORE HIM!\"\nelse\n puts \"CHAT WITH HER!\"\nend"}, {"source_code": "name = gets.strip()\nif name.size() <= 100\n array_of_characters = name.chars.uniq\n\tif array_of_characters.size % 2 == 0\n\t\tputs \"CHAT WITH HER!\"\n\telse\n\t\tputs \"IGNORE HIM!\"\n\tend\nend\n"}, {"source_code": "puts gets.chomp.chars.uniq.size%2!=0 ? \"IGNORE HIM!\" : \"CHAT WITH HER!\""}, {"source_code": "$><<[\"IGNORE HIM!\",\"CHAT WITH HER!\"][gets.chars.uniq.size%2]\n"}, {"source_code": "puts gets.chomp.chars.uniq.size.even? ? 'CHAT WITH HER!': 'IGNORE HIM!'"}, {"source_code": "x = gets\nh = {}\nx.split(\"\").each { |e|\n h[e]=1\n}\nif !h.keys.count.odd?\n puts \"IGNORE HIM!\"\n else \n puts \"CHAT WITH HER!\"\nend \n\n"}, {"source_code": "puts gets.chomp.split(\"\").uniq.count.even? ? 'CHAT WITH HER!' : 'IGNORE HIM!'"}, {"source_code": "puts gets.split(//).uniq.size.odd? ? 'CHAT WITH HER!' : 'IGNORE HIM!'\n"}, {"source_code": "def BoyOrGirl(str)\n puts str.chars.uniq.length % 2 == 0 ? \"CHAT WITH HER!\" : \"IGNORE HIM!\"\nend\n\nstr = gets.chomp\nBoyOrGirl(str)"}, {"source_code": "puts (gets.split(//).uniq.count.even?) ? \"IGNORE HIM!\" : \"CHAT WITH HER!\"\n"}, {"source_code": "puts [\"IGNORE HIM!\",\"CHAT WITH HER!\"][gets.chars.uniq.size[0]]"}, {"source_code": "input = gets\nputs input.split(//).uniq.count % 2 == 0 ? 'IGNORE HIM!' : 'CHAT WITH HER!'\n"}, {"source_code": "#!/usr/bin/ruby\nputs ['IGNORE HIM!','CHAT WITH HER!'][gets.chars.uniq.size%2]"}, {"source_code": "$><<[\"IGNORE HIM!\",\"CHAT WITH HER!\"][gets.chars.uniq.size%2]"}, {"source_code": "inp = gets.chomp\nif inp.split('').uniq.length.odd?\n puts 'IGNORE HIM!'\nelse\n puts 'CHAT WITH HER!'\nend"}, {"source_code": "puts gets.chomp.split(\"\").uniq.length.even? ? \"CHAT WITH HER!\" : \"IGNORE HIM!\""}, {"source_code": "user_name = gets.chomp\ni = 0\nchar_arr = []\n\nwhile i < user_name.length do\n if char_arr.index(user_name.split('')[i]) == nil then\n\tchar_arr.push(user_name.split('')[i])\n end\n i+=1 \nend\nif char_arr.length % 2 == 0 then \n print 'CHAT WITH HER!'\nelsif \n print 'IGNORE HIM!'\nend\n"}, {"source_code": "#!/usr/bin/ruby\n\nstr = gets.chomp\ncnt = str.each_char.to_a.uniq.size\nif cnt.even?\n puts \"CHAT WITH HER!\"\nelse\n puts \"IGNORE HIM!\"\nend\n"}, {"source_code": "$><<[\"IGNORE HIM!\",\"CHAT WITH HER!\"][gets.chars.uniq.size%2]\n"}, {"source_code": "puts ['CHAT WITH HER!','IGNORE HIM!'][gets.strip.split('').uniq.join('').length%2]"}, {"source_code": "#$stdin=File.open('input.txt')\n#$stdout=File.open('output.txt', 'w')\ns=gets.to_s\na=Array.new\nfor i in 1..s.size-1\n\ta<<<[\"IGNORE HIM!\",\"CHAT WITH HER!\"][gets.chars.uniq.size%2]\n"}, {"source_code": "printf (gets.chomp.each_char.to_a.uniq.size % 2 == 0) ? 'CHAT WITH HER!' : 'IGNORE HIM!'"}, {"source_code": "w = gets.chomp\nif w.scan(/./).uniq.size % 2 == 0\n puts \"CHAT WITH HER!\"\nelse\n puts \"IGNORE HIM!\"\nend"}, {"source_code": "def tram ()\n n = gets.chomp\n n = n.split(\"\")\n n = n.uniq\n if n.length % 2 == 0\n print \"CHAT WITH HER!\"\n else \n print \"IGNORE HIM!\"\n end\nend\n\ntram"}, {"source_code": "name = gets.chomp\namount = Array.new(26, 0)\nname.split(\"\").each { |char| amount[char.ord - 97] += 1 }\ncnt = 0\namount.each { |tmp| cnt += 1 if tmp > 0 }\nif cnt.even?\n\tputs \"CHAT WITH HER!\"\nelse\n\tputs \"IGNORE HIM!\"\nend"}, {"source_code": "$><<[\"IGNORE HIM!\",\"CHAT WITH HER!\"][gets.chars.uniq.size%2]"}, {"source_code": "if (gets.chomp.split(//).uniq.size % 2) == 1\nprint \"IGNORE HIM!\\n\"\nelse\nprint \"CHAT WITH HER!\\n\"\nend"}, {"source_code": "s = gets.split(//).uniq\nputs (s.length % 2 == 1) ? \"CHAT WITH HER!\" : \"IGNORE HIM!\""}, {"source_code": "if gets.strip.split('').to_a.uniq.size % 2 == 0\n puts \"CHAT WITH HER!\"\nelse\n puts \"IGNORE HIM!\"\nend"}, {"source_code": "if gets.chomp.split('').uniq.size%2 == 0\n puts \"CHAT WITH HER!\"\nelse\n puts \"IGNORE HIM!\"\nend"}, {"source_code": "puts (gets[0..-2].chars.to_a.uniq.count % 2 == 0 ? \"CHAT WITH HER!\" : \"IGNORE HIM!\")\n"}, {"source_code": "$><<[\"IGNORE HIM!\",\"CHAT WITH HER!\"][gets.chars.uniq.size%2]\n"}, {"source_code": "name = gets.chomp\n\nputs name.chars.sort.uniq.size.even? ? 'CHAT WITH HER!' : 'IGNORE HIM!'\n"}, {"source_code": "# Codeforces Round #146\n# Problem A -- Boy or Girl\nputs gets.split(//).uniq.size.odd? ? \"CHAT WITH HER!\" : \"IGNORE HIM!\"\n"}, {"source_code": "str = gets.chomp\nif str.chars.uniq.size.even? \n puts \"CHAT WITH HER!\"\nelse \n puts \"IGNORE HIM!\"\nend "}, {"source_code": "u = $stdin.readline.scan(/./).uniq\n\nif u.count % 2 == 1\n puts \"IGNORE HIM!\"\nelse\n puts \"CHAT WITH HER!\"\nend"}, {"source_code": "if gets.chomp.split(//).uniq.size % 2 == 0 then puts \"CHAT WITH HER!\" else puts \"IGNORE HIM!\" end\n"}, {"source_code": "$><<[\"IGNORE HIM!\",\"CHAT WITH HER!\"][gets.chars.uniq.size%2]\n"}, {"source_code": "hashed = Hash.new(0)\ninp = gets.chomp.split(\"\").each { |item| hashed[item] += 1 }\nif hashed.size % 2 == 0\n puts \"CHAT WITH HER!\"\nelse \n puts \"IGNORE HIM!\"\nend\n"}, {"source_code": "require 'set'\nname = gets.split(//)\ns = Set.new\nname.each do |char|\n s.add(char)\nend\nif s.size.even?\n puts \"IGNORE HIM!\"\nelse\n puts \"CHAT WITH HER!\"\nend\n"}, {"source_code": "puts gets.chomp.split(\"\").uniq.join.length.%(2).to_s.include?(\"1\")?\"IGNORE HIM!\":\"CHAT WITH HER!\""}, {"source_code": "puts (gets.chomp.split('').uniq.length.odd?) ? \"IGNORE HIM!\" : \"CHAT WITH HER!\"\n"}, {"source_code": "puts STDIN.read.strip.split(//).uniq.length % 2 == 0 ? \"CHAT WITH HER!\" : \"IGNORE HIM!\"\n"}, {"source_code": "s = gets.chomp.chars\nputs s.uniq.count.odd? ? \"IGNORE HIM!\" : \"CHAT WITH HER!\""}, {"source_code": "s = gets.strip.split(\"\").uniq\nans = s.length.odd?\nputs ans ? \"IGNORE HIM!\" : \"CHAT WITH HER!\"\n"}, {"source_code": "$><<[\"IGNORE HIM!\",\"CHAT WITH HER!\"][gets.chars.uniq.size%2]\n"}, {"source_code": " x = gets.chomp\n hash = Hash.new\n x.each_char do |c|\n hash[c] = 0 if hash[c] == nil\n hash[c] += 1\n end\n puts \"CHAT WITH HER!\" if hash.count % 2 == 0\n puts \"IGNORE HIM!\" if hash.count % 2 != 0"}, {"source_code": "username = gets.chomp\nputs (username.split(//).uniq.length % 2 == 1)? \"IGNORE HIM!\" : \"CHAT WITH HER!\"\n"}], "negative_code": [{"source_code": "#rextester.com:2.3.1--codeforces.com:2.0.0p645\nputs(gets.chars.uniq.size%2==0?'CHAT WITH HER':'IGNORE HIM')"}, {"source_code": "#rextester.com:2.3.1--codeforces.com:2.0.0p645\nputs gets.chars.uniq.size%2?'IGNORE HIM':'CHAT WITH HER'"}, {"source_code": "#rextester.com:2.3.1--codeforces.com:2.0.0p645\nputs(gets.chars.uniq.length%2==0?\"CHAT WITH HER\":\"IGNORE HIM\")"}, {"source_code": "#rextester.com:2.3.1--codeforces.com:2.0.0p645\nputs gets.chars.uniq.size%2==0?'CHAT WITH HER':'IGNORE HIM'"}, {"source_code": "#rextester.com:2.3.1--codeforces.com:2.0.0p645\nputs(gets.chomp.chars.uniq.length%2==0?'CHAT WITH HER':'IGNORE HIM')"}, {"source_code": "#rextester.com:2.3.1--codeforces.com:2.0.0p645\nputs gets.chomp.split(//).uniq.length%2==0?'CHAT WITH HER':'IGNORE HIM'"}, {"source_code": "#rextester.com:2.3.1--codeforces.com:2.0.0p645\nputs gets.split(//).uniq.length%2==0?'CHAT WITH HER':'IGNORE HIM'"}, {"source_code": "#rextester.com:2.3.1--codeforces.com:2.0.0p645\nputs(gets.chars.uniq.length%2==0?'CHAT WITH HER':'IGNORE HIM')"}, {"source_code": "require \"set\"\n\nset = Set.new(gets.chars)\nset.each {|x| puts x}\nif set.size() % 2 == 0\n puts \"CHAT WITH HER!\"\nelse\n puts \"IGNORE HIM!\"\nend"}, {"source_code": "require \"set\"\n\nset = Set.new(gets.chop.chars)\nset.each {|x| puts x}\nif set.size() % 2 == 0\n puts \"CHAT WITH HER!\"\nelse\n puts \"IGNORE HIM!\"\nend"}, {"source_code": "require \"set\"\n\ns = gets\nset = Set.new\ns.each_char {|c| set << c}\nif s.size() % 2 == 0\n puts \"CHAT WITH HER!\"\nelse\n puts \"IGNORE HIM!\"\nend"}, {"source_code": "uname = gets.chomp\nusername = uname.split(\"\")\n\ncount = uname.length.to_i\nusername.each do |n|\n\tcount = count - username.count(n) + 1\n\tif username.count(n) != 1\n\t\ti = username.index(n)\n\t\twhile i < uname.length.to_i\n\t\t\tif n == username[i+1]\n\t\t\t\tusername.delete_at(i+1)\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\tend\nend\n\nif username.size%2 == 0\n\tputs \"CHAT WITH HER!\"\nelse\n\tputs \"IGNORE HIM!\"\nend"}, {"source_code": "uname = gets.chomp\nusername = uname.split(\"\")\n\ncount = uname.length.to_i\nusername.each do |n|\n\tcount = count - username.count(n) + 1\n\tif username.count(n) > 1\n\t\ti = username.index(n)\n\t\twhile i < uname.length.to_i - 1\n\t\t\tif n == username[i+1]\n\t\t\t\tusername.delete_at(i+1)\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\tend\nend\nputs username.size\nif username.size%2 == 0\n\tputs \"CHAT WITH HER!\"\nelse\n\tputs \"IGNORE HIM!\"\nend"}, {"source_code": "uname = gets.chomp\nusername = uname.split(\"\")\n\ni = 0\ncount = uname.length.to_i\nusername.each do |n|\n\tcount = count - username.count(n) + 1\n\tif username.count(n) != 1\n\t\ti = username.index(n)\n\t\twhile i < uname.length.to_i\n\t\t\tif n == username[i]\n\t\t\t\tusername.delete_at(i)\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\tend\nend\n\nif count%2 == 0\n\tputs \"CHAT WITH HER!\"\nelse\n\tputs \"IGNORE HIM!\"\nend"}, {"source_code": "uname = gets.chomp\nusername = uname.split(\"\")\n\ncount = uname.length.to_i\nusername.each do |n|\n\tcount = count - username.count(n) + 1\n\tif username.count(n) > 1\n\t\ti = username.index(n)\n\t\twhile i < uname.length.to_i - 1\n\t\t\tif n == username[i+1]\n\t\t\t\tusername.delete_at(i+1)\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\tend\nend\nif username.size%2 == 0\n\tputs \"CHAT WITH HER!\"\nelse\n\tputs \"IGNORE HIM!\"\nend"}, {"source_code": "uname = gets.chomp\nusername = uname.split(\"\")\n\ni = 0\ncount = uname.length.to_i\nusername.each do |n|\n\tcount = count - username.count(n) + 1\n\tif username.count(n) != 1\n\t\ti = username.index(n)\n\t\twhile i+1 < uname.length.to_i\n\t\t\tif n == username[i+1]\n\t\t\t\tusername.delete_at(i+1)\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\tend\nend\n\nif count%2 == 0\n\tputs \"CHAT WITH HER!\"\nelse\n\tputs \"IGNORE HIM!\"\nend"}, {"source_code": "x = gets\nh = {}\nx.split(\"\").each { |e|\n h[e]=1\n}\nif h.keys.count.odd?\n puts \"IGNORE HIM!\"\n else \n puts \"CHAT WITH HER!\"\nend \n\n"}, {"source_code": "# http://codeforces.com/problemset/problem/236/A\n\nchars = gets.chomp\nalready = {}\ndups = 0\nchars.each_char do |c|\n if already[c] == true\n dups = dups + 1\n else\n already[c] = true\n end\nend\n\nuniq = chars.length - dups\n\nif uniq % 2 == 0\n p 'CHAT WITH HER!'\nelse\n p 'IGNORE HIM!'\nend\n"}, {"source_code": "inp = gets.chomp\nif inp.length.odd?\n puts 'CHAT WITH HER!'\nelse\n puts 'IGNORE HIM!'\nend"}, {"source_code": "inp = gets.chomp\nif inp.length.odd?\n p 'CHAT WITH HER!'\nelse\n p 'IGNORE HIM!'\nend"}, {"source_code": "inp = gets.chomp\nif inp.split('').uniq.length.odd?\n puts 'CHAT WITH HER!'\nelse\n puts 'IGNORE HIM!'\nend"}, {"source_code": "inp = gets.chomp\nif inp.length.odd?\n p 'IGNORE HIM!'\nelse\n p 'CHAT WITH HER!'\nend"}, {"source_code": "puts ['IGNORE HIM!','CHAT WITH HER!'][gets.strip.length%2]"}, {"source_code": "h = {}\ngets.split('').each { |c| h[c] = 1 }\nputs h.keys.count.even? ? 'CHAT WITH HER!' : 'IGNORE HIM!'"}, {"source_code": "puts gets.split('').uniq.size.even? ? 'CHAT WITH HER!' : 'IGNORE HIM!'"}, {"source_code": "a=gets.chomp\n0.upto(a.length-1) do |i|\n(i+1).upto(a.length-1) do|j|\nif a[i] ==a [j]\na=a[0..j-1]+a[j+1..a.length-1]\nend\nend\nend\nif a.length%2==0\nputs \"CHAT WITH HER!\"\nelse \nputs \"IGNORE HIM!\" \nend"}, {"source_code": "p(gets.chomp.each_char.to_a.uniq.size % 2 == 0 ? 'CHAT WITH HER!' : 'IGNORE HIM!')"}, {"source_code": "output = (gets.chomp.each_char.to_a.uniq.size % 2 == 0) ? 'CHAT WITH HER!' : 'IGNORE HIM!'\np output"}, {"source_code": "p(gets.chomp.each_char.to_a.uniq.size % 2 == 0 ? \"CHAT WITH HER!\" : \"IGNORE HIM!\")"}, {"source_code": "n = gets.to_s\nar = []\nar = n.split(\"\").map(&:to_s)\nj = ar.uniq.count \n\nif j%2 == 0\n puts \"CHAT WITH HER!\"\nelse\n puts \"IGNORE HIM!\"\nend\nputs j\n"}, {"source_code": "n = gets.to_s\nar = []\nar = n.split(\"\").map(&:to_s)\nj = ar.uniq.count-1\n\nif j%2 == 0\n puts \"CHAT WITH HER!\"\nelse\n puts \"IGNORE HIM!\"\nend\nputs j\n"}, {"source_code": "n = gets.to_s\nar = []\nar = n.split(\"\").map(&:to_s)\nj = ar.uniq.count - 1\n\nif j%2 == 0\n puts \"CHAT WITH HER!\"\nelse\n puts \"IGNORE HIM!\"\nend\nputs j\n"}, {"source_code": "n = gets.to_s\nar = []\nar = n.split(\"\").map(&:to_s)\nj = ar.uniq.count \n\nif j%2 == 0\n puts \"CHAT WITH HER!\"\nelse\n puts \"IGNORE HIM!\"\nend\n\n"}, {"source_code": "s = gets.split(//).uniq!\nputs (s.length % 2 == 1) ? \"CHAT WITH HER!\" : \"CHAT WITH HIM!\"\n"}, {"source_code": "# while (s=gets.chomp()) != \"42\" do puts s end\n\ns=gets.chomp()\nc= s.split(//).uniq\n# s.to_a\n# c=b.uniq\n\n# a=s.uniq\nif c.length%2==0\n puts \"IGNORE HIM!\"\nelse\n puts \"CHAT WITH HER!\"\nend"}, {"source_code": "# while (s=gets.chomp()) != \"42\" do puts s end\n\ns=gets.chomp()\nc= s.split(//).uniq\n# s.to_a\n# c=b.uniq\n\n# a=s.uniq\nputs c.length\nif c.length%2==0\n puts \"CHAT WITH HER!\"\nelse\n \n puts \"IGNORE HIM!\"\nend"}, {"source_code": "name = gets.strip()\nif name.size() <= 100\n\tif name.size() % 2 == 0\n\t\tputs \"CHAR WITH HER!\"\n\telse\n\t\tputs \"IGNORE HIM!\"\n\tend\nend"}, {"source_code": "name = gets.strip()\nif name.size() <= 100\n array_of_characters = name.chars.uniq\n\tif array_of_characters.size % 2 == 0\n\t\tputs \"CHAR WITH HER!\"\n\telse\n\t\tputs \"IGNORE HIM!\"\n\tend\nend\n"}, {"source_code": "puts [\"CHAT WITH HER!\",\"IGNORE HIM!\"][gets.chars.uniq.size[0]]"}, {"source_code": "puts [\"CHAT WITH HER!\",\"IGNORE HIM!\"][\"ab\".chars.uniq.size[0]]"}, {"source_code": "puts gets.chomp.length.even? ? \"CHAT WITH HER!\" : \"IGNORE HIM\""}, {"source_code": "#$stdin=File.open('input.txt')\n#$stdout=File.open('output.txt', 'w')\ns=gets.to_s\nif s.size%2==0 then\nputs \"CHAT WITH HER!\" \nelse\nputs \"IGNORE HIM!\" \nend\n\n\n\n\n\n\n\n\n\n\t\n\n\n\n\n\n\t\n\t\n\t\n"}, {"source_code": "#$stdin=File.open('input.txt')\n#$stdout=File.open('output.txt', 'w')\ns=gets.to_s\nif s.size%2!=0 then\nputs \"CHAT WITH HER!\" \nelse\nputs \"IGNORE HIM!\" \nend\n\n\n\n\n\n\n\n\n\n\t\n\n\n\n\n\n\t\n\t\n\t\n"}, {"source_code": "p(gets.chomp.split.uniq.size.odd? ? 'IGNORE HIM!' : 'CHAT WITH HER!')"}, {"source_code": "str = gets.chomp.each_char\np(str.take(str.count).size.odd? ? 'IGNORE HIM!' : 'CHAT WITH HER!')"}, {"source_code": "p(gets.chomp.each_char.to_a.uniq.size.odd? ? 'IGNORE HIM!' : 'CHAT WITH HER!')"}], "src_uid": "a8c14667b94b40da087501fd4bdd7818"} {"source_code": "n = gets.to_i\ns = gets.strip\nd = Array.new(n + 1) { [Float::INFINITY] * 2 }\nd[0][0] = 0\nn.times do |i|\n 2.times do |j|\n d[i + 1][j] = [d[i + 1][j], d[i][j] + 1].min\n end\n if i + i <= n && s[0, i] == s[i, i]\n d[i + i][1] = [d[i + i][1], d[i][0] + 1].min\n end\nend\np d[-1].min\n", "positive_code": [{"source_code": "n = gets.to_i\ns = gets.chomp\nmax = 0\nfor i in 0..n / 2\n\tmax = s[0..i] == s[i + 1..i * 2 + 1] ? i : max\nend\nputs n - max"}], "negative_code": [{"source_code": "n = gets.to_i - 1\ns = gets.chomp\nmax = 0\nfor i in 0..n / 2\n\tmax = s[i+1..n+1][s[0..i]] != nil ? i : max\nend\nputs n - max + 1"}, {"source_code": "n = gets.to_i - 1\ns = gets.chomp\nmax = 0\nfor i in 0..n / 2\n\tmax = s[s[0..i] * 2] != nil ? i : max\nend\nputs n - max + 1"}], "src_uid": "ed8725e4717c82fa7cfa56178057bca3"}