{"lang": "Ruby", "source_code": "n = Integer(gets())\nif n.odd? then\n puts \"NO\"\n exit 0\nend\n\na = b = n/2\n\nif a.even? && b.even? then\n puts \"YES\"\n exit 0\nend\na--\nb++\nif a <= 0:\n puts \"NO\"\n exit 0\nend\nif a.even? && b.even? then\n puts \"YES\"\n exit 0\nend\nputs \"NO\"\n", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "e57b72f0ba4cac22f6ec5d800487b7f1", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800} {"lang": "Ruby", "source_code": " w = gets.to_i\n (w%2 == 0 and w >= 2)? puts 'YES' : puts 'NO'", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "c471b9bc244b6b80f1949482b43c2e47", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800} {"lang": "Ruby", "source_code": "w = gets.to_i\n(w%2 == 0 and w >= 2) puts 'YES' : puts 'NO'", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "08b895035b4d9330fb21fbe813f5124f", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800} {"lang": "Ruby", "source_code": "puts gets.to_i.even? \"YES\" : \"NO\"", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "0e456ac7c11bd47b1e89c5229677dcb6", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2", "difficulty": 800} {"lang": "Ruby", "source_code": "puts gets[/^.[A-Z]*$] ? $_.swapcase : $_", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "dd240a14bcffe938176808349fd08b6b", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000} {"lang": "Ruby", "source_code": "inp = gets\nif inp.index('0000000') || inp.index('1111111'))\n puts \"YES\"\nelse\n puts \"NO\"\nend", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "1b7fb43a4bd8da4abd8d01b2416de72d", "src_uid": "ed9a763362abc6ed40356731f1036b38", "difficulty": 900} {"lang": "Ruby", "source_code": "a=gets.split.map{|i| i.to_i}\nk=a[0]\nn=a[1..3]\nt=a[4..-1]\nq=[0]*4\ntq=[0]*3\no=0\nwhile k>0||q.any?{|i| i>0}\n\to+=1\n\ttq.map{|i| i-1 if i>0}\n\t3.times{|i| \n\t\tif tq[2-i]==0\n\t\t\tq[i+1]+=q[i]\n\t\t\t}\n\tif q[0]==0\n\t\tq[0]=n[0]\n\t\tk-=n[0]\n\t\ttq[0]=t[0]\n\n", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "730a35ffebb7866d7bce003aea43ea18", "src_uid": "0b9ce20c36e53d4702869660cbb53317", "difficulty": 2100} {"lang": "Ruby", "source_code": "(1+gets.to_i).upto(10000)) { |i| if i.to_s.split(//).uniq.length == 4; puts i; break; end; }\n", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "5125dffece97f5e3a05fce296e99c4f5", "src_uid": "d62dabfbec52675b7ed7b582ad133acd", "difficulty": 800} {"lang": "Ruby", "source_code": "k=gets.chomp.to_i\nl=gets.chomp.to_i\nm=gets.chomp.to_i\nn=gets.chomp.to_i\nd=gets.chomp.to_i\nret=0\n1.upto(d){|i| if %k==0 || i%l==0 || i%m==0 || i%n==0 || i%d==0 then ret+=1 end}\nprint(ret,\"\\n\")\n", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "4d0d4efb59826477cd6c50e1e8e748e1", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800} {"lang": "Ruby", "source_code": "bottle = gets.to_i - 1\npeople = w%[Sheldon Leonard Penny Rajesh Howard]\np_num = people.length\n\nuntil bottle <= p_num do\n bottle = (bottle - p_num)/2\nend\n\nputs people[n] \n", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "e777119c15bbf76a260a5d95467561c8", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100} {"lang": "Ruby", "source_code": "gets.strip.scan(/[47]/).size.to_s =~ /^[47]*$/ ? puts \"YES\" : puts \"NO\"", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "052f18ceb872ede901d29a9e5395b2ea", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1", "difficulty": 800} {"lang": "Ruby", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define INIT(range, val) memset(range, val, sizeof(range))\n#define inject(x) { cerr << \"Fuction: \" << __FUNCTION__ << \", Line: \" << __LINE__ << \", \" << #x << \": \" << (x) << endl; }\n#define mp make_pair\n#define pb push_back\n\ninline void __CIN__() { ios::sync_with_stdio(false); cin.tie(0); }\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pii;\n\nchar buf;\ninline int xint() { while (buf = getchar(), buf < '0' || buf > '9'); int x = buf - '0'; for (; buf = getchar(), buf >= '0' && buf <= '9'; x = x * 10 + buf - '0'); return x; }\ninline ll xll() { while (buf = getchar(), buf < '0' || buf > '9'); ll x = buf - '0'; for (; buf = getchar(), buf >= '0' && buf <= '9'; x = x * 10 + buf - '0'); return x; }\ninline string xstring() { while (buf = getchar(), buf == ' ' || buf == '\\n'); string x = \"\"; for (x += buf; buf = getchar(), buf != ' ' && buf != '\\n'; x += buf); return x; }\n\nint main() {\n\treturn 0;\n}", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "524eab0c8416c7b734bb60b6a344ebde", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900} {"lang": "Ruby", "source_code": "arr = gets.split(' ')\nk = arr[0].to_i\nn = arr[1].to_i\nw = arr[2].to_i\ntotal_sum = w*(k+w*k)/2\nneeded = total_sum - n\nneeded>0 ? puts needed : puts 0", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "78f73274283ed3435ef0cf7a403c9c49", "src_uid": "e87d9798107734a885fd8263e1431347", "difficulty": 800} {"lang": "Ruby", "source_code": "p = ('H','Q','+','9').to_a\ns = gets.to_s.split(//)\ns = s & p\nif s.size>0 \n print 'YES'\nelse\n print 'NO'\nend", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "8ab7f8546dc0e8155f38c77ae837417e", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900} {"lang": "Ruby", "source_code": "#!/usr/bin/ruby\nhodnoty = \"6789TJQKA\"\ntrumf = gets.chop.to_s\n//puts trumf\ncards = gets.chop\n//puts cards\nc1h = cards[0].chr\nc1b = cards[1].chr\nc2h = cards[3].chr\nc2b = cards[4].chr\nif c1b == c2b\n\tthen\n\t\tif hodnoty.index(c1h) > hodnoty.index(c2h)\n\t\t\tthen\n\t\t\t\tputs \"YES\"\n\t\t\telse\n\t\t\t\tputs \"NO\"\n\t\t\tend\n\tend\nif c1b != c2b\n\tthen\n\t\tif c1b == trumf\n\t\t\tthen\n\t\t\t\tputs \"YES\"\n\t\t\telse\n\t\t\t\tputs \"NO\"\n\t\t\tend\n\tend\n", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "8d23549bca0c445e4640a1d4cf77fb54", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000} {"lang": "Ruby", "source_code": "q,x,*y=[*$<].map{$:scan(/./).permutation.map{|j|j.join.to_i}};p x.zip(*y).map{|l|l.max-l.min}.min", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "9b9dd839c6fee07e8b20a0ecd6b7ecce", "src_uid": "51a072916bff600922a77da0c4582180", "difficulty": 1000} {"lang": "Ruby", "source_code": "def solve(n,k)\n big=n;small=k\n a=0\n while big!=1||small!=1\n t=big/small\n if big%small==0 then t-=1 end\n if t==0 then return 99999999 end\n a+=t\n big-=t*small\n if big vasya_points\n puts 'Misha'\n elsif misha_points == vasya_points\n puts 'Tie'\n else\n puts 'Vasya'\n end\nend\n", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "322a3015d3080fb24ab3e1618486ee32", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900} {"lang": "Ruby", "source_code": "$><= now && d >= (r-now)%mod && q >= (r-now)%mod ) \n res = q-(r-now)%mod\n end\n mod *= 10\n now *= 10\n now += 9\n}\nif( res == 0 ) puts p-1\nelse print res,\"\\n\"\nend", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "19b66d4b1db4c3232c5592d29d3d3eea", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400} {"lang": "Ruby", "source_code": "sum = gets.chomp.to_i\nsum<0 ? \n {sum = -sum\n a = sum/10\n b = (sum/100)*10 + sum%10\n acc = case\n when a<=b && a= x && d < y && c - d >= x && c - d < y\n\t\tanswer = i + 1\n\t\tbreak\n\tend\nend\nputs answer", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "e9373977b825da81e7dcea26daf33713", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b", "difficulty": 1000} {"lang": "Ruby", "source_code": "a, b, s = gets.chomp.split.map &:to_i\nsum = a + b\nputs if s >= sum && (s - sum) % 2 == 0 then\n \"Yes\"\nelse\n \"No\"\nend", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "ddce2a99a1b85cccaa2e1088fc88859d", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000} {"lang": "Ruby", "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", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "5fd31c81e771db566dbdfb443e47c105", "src_uid": "c052d85e402691b05e494b5283d62679", "difficulty": 900} {"lang": "Ruby", "source_code": "#include \n\nconst int MAXN = 128;\n\nint main() {\n\tint r, c;\n\tchar s[MAXN][MAXN];\n\n\tscanf(\"%d%d\", &r, &c);\n\tfor (int i = 0; i < r; ++i) {\n\t\tscanf(\"%s\", s[i]);\n\t}\n\tfor (int i = 0; i < r; ++i) {\n\t\tfor (int j = 0; j < c; ++j) {\n\t\t\tbool flag = true;\n\t\t\tfor (int k = 0; flag && k < r; ++k) {\n\t\t\t\tflag &= k == i || s[k][j] != s[i][j];\n\t\t\t}\n\t\t\tfor (int k = 0; flag && k < c; ++k) {\n\t\t\t\tflag &= k == j || s[i][k] != s[i][j];\n\t\t\t}\n\t\t\tif (flag) {\n\t\t\t\tputchar(s[i][j]);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "Ruby", "compilation_error": true, "code_uid": "d701bcdaf58fc7a67f4d746209868d97", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000} {"lang": "Ruby", "source_code": "n,m = gets.strip.split.map(&:to_i)\ntarget = []\ntmp = \".\"*m\ngrid = []\nn.times do\n grid << gets.strip\n target << tmp.dup\nend\n\n1.upto(n-2).each do |i|\n 1.upto(m-2).each do |j|\n next if grid[i-1][j-1] == '.'\n next if grid[i-1][j-0] == '.'\n next if grid[i-1][j+1] == '.'\n next if grid[i-0][j-1] == '.'\n next if grid[i-0][j+1] == '.'\n next if grid[i+1][j-1] == '.'\n next if grid[i+1][j-0] == '.'\n next if grid[i+1][j+1] == '.'\n\n target[i-1][j-1] = '#'\n target[i-1][j-0] = '#'\n target[i-1][j+1] = '#'\n target[i-0][j-1] = '#'\n target[i-0][j+1] = '#'\n target[i+1][j-1] = '#'\n target[i+1][j-0] = '#'\n target[i+1][j+1] = '#'\n end\nend\n\npoossible = true\n0.upto(n-1).each do |i|\n if grid[i] != target[i]\n poossible = false\n break\n end\nend\n\nputs (poossible ? \"YES\" : \"NO\")\n", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "4a11f8e65a7a41147f3b7cd8c001c960", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300} {"lang": "Ruby", "source_code": "x1, y1, x2, y2 = gets.chomp.split.map &:to_i\nx, y = gets.chomp.split.map &:to_i\n\nm = (x1.abs - x2.abs) / x\nn = (y1.abs - y2.abs) / y\nif m == 0\n if n.even?\n puts \"YES\"\n else\n puts \"NO\"\n end\nelse\n if m == n\n puts \"YES\"\n else\n puts \"NO\"\n end\nend\n", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "4e6044618c9fa2a481f9375271c3d577", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200} {"lang": "Ruby", "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 == 0\n puts \"0 0\"\n exit\nend\n\nm = n - 1\n\nd = 0\n\n\nk = 9 + 4 * 3 * n\nd = (- 3 + (k ** 0.5)) / 6\nd = d.floor\n\nf = d * (d - 1) * 3\n\ncase\nwhen (n - f) <= d\n e = n - f\n x = d * 2 - e\n y = e * 2\nwhen (n - f) <= 2 * d\n e = (n - f) - d\n x = d - e * 2\n y = d * 2\nwhen (n - f) <= 3 * d\n e = (n - f) - d * 2\n x = -d - e\n y = d * 2 - e * 2\nwhen (n - f) <= 4 * d\n e = (n - f) - d * 3\n x = - d * 2 + e\n y = -e * 2\nwhen (n - f) <= 5 * d\n e = (n - f) - d * 4\n x = -d + 2 * e\n y = -d * 2\nelse\n e = (n - f) - d * 5\n x = d + e\n y = -d * 2 + e * 2\nend\n\nputs \"%d %d\" % [x, y]\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "b8d3ac7e7bfdc054aa93a728c00c560d", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100} {"lang": "Ruby", "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", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "5a2ba258108b3a7c6a6a5276600f5323", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300} {"lang": "Ruby", "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", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "db01bd18c4e97540cb22fa8bccccc64a", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000} {"lang": "Ruby 3", "source_code": "require 'set'\r\n\r\nt = gets\r\n(1..t.to_i).each do |ind|\r\n n = gets\r\n i = 1\r\n n = n.to_i\r\n while i*i <= n\r\n st = Set[]\r\n st << i*i\r\n end\r\n while i*i*i <= n\r\n st = Set[]\r\n st << i*i*i\r\n end\r\n puts st.size\r\nend\r\n ", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "4bce77a704fe7977ddf04c7f90bd88ec", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800} {"lang": "Ruby", "source_code": "n= gets.to_i\na = gets.split(\"\")\na.pop\na.each_index do |i|\n\tmove = a[i]\n\tif move == 'L'\n\t\tk = a.index 'R'\n\t\tif k\n\t\t\ta[i] = 0\n\t\t\ta[k] = 0\n\t\tend\n\tend\n\tif move == 'R'\n\t\tk = a.index 'L'\n\t\tif k\n\t\t\ta[i] = 0\n\t\t\ta[k] = 0\n\t\tend\n\tend\n\tif move == 'U'\n\t\tk = a.index 'D'\n\t\tif k\n\t\t\ta[i] = 0\n\t\t\ta[k] = 0\n\t\tend\n\tend\n\tif move == 'D'\n\t\tk = a.index 'U'\n\t\tif k\n\t\t\ta[i] = 0\n\t\t\ta[k] = 0\n\t\tend\n\tend\nend\ncount = 0\na.each do |move|\n\tcount +=1 if move ==0\nend\nprint(count)\n", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "368cc7b7fd665bac81e484ace7656f4f", "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a", "difficulty": 1000} {"lang": "Ruby", "source_code": "T='fedabc'\ns=gets.chomp\nx=T.index(s[-1])+1\ns=s.to_i-1\nd,r=s.divmod(4)\nif r%2==1\n\tx+=7\nend\np x+d*16", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "b1a21e9bdffe5e2f5f6f372ac4b9f32a", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200} {"lang": "Ruby", "source_code": "c = gets.chomp.split(\" \").map{|i| i.to_i}\n\na = c[0]\nb = c[1]\nk = c[2]\n\nL = []\n\n(1..b).each do |i|\n L[i] = 1\nend\nL[1] = 0\n\n(2..b).each do |i|\n kq = 2*i\n if L[i] == 1\n while kq <= b do\n L[kq] = 0\n kq += i\n end\n end\nend\n\ndem = 0\nP = []\nmax = 0\n\n(a..b).each do |i|\n if L[i] == 1\n dem += 1\n P[dem] = i\n end \nend\n\nif dem < k\n max = -1\nelse\n max = b - P[dem-k+1] + 1\n if max < (P[k] - a + 1)\n max = P[k] -a + 1\n end\n j = dem - k \n (1..j).each do |i|\n if (P[i+k] - P[i]+1) > max\n max = P[i+k] - P[i] \n end\n end\nend\n\nputs max", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "2faadd95fdb84eb866153cd1dd7d3578", "src_uid": "3e1751a2990134f2132d743afe02a10e", "difficulty": 1600} {"lang": "Ruby", "source_code": "hs=Hash.new(0)\ngets.chomp.chars.each{|e|\n\ths[e]+=1\n}\np hs.size", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "75a7ed04acd177d336cc1c260d64afe1", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900} {"lang": "Ruby", "source_code": "require 'set'\nclass Spelling\n attr_reader(:s)\n def initialize(s)\n @s = s\n end\n\n def sp\n @s.split(\"\")\n end\n\n def rotated\n (0..s.length).map{|i| sp.rotate(i)}\n end\n\n def result\n rotated.to_set\n end\nend\n\nprint Spelling.new(gets.strip).result.length\n", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "c79723ed4f8ed4616c509dbcbfed12ef", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900} {"lang": "Ruby", "source_code": "n = gets.to_i\nas = gets.split.map(&:to_i)\nlefted = []\n(n-1).downto(0) do |i|\n a = as[i]\n lefted << a unless lefted.include?(a)\nend\nputs lefted.size\nputs lefted.reverse.join(\" \")", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "54397cf4a26bfd49bcaa819758c12970", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a", "difficulty": 800} {"lang": "Ruby", "source_code": "s=gets.chomp\np ['a1','a8','h1','h8'].include?(s) ? 3 : s=~/[ah18]/ ? 5 : 8", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "bc1f3afec6e1a88e634546681ac8e427", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800} {"lang": "Ruby", "source_code": "gets\na=gets.split.map(&:to_i)\np a[-1]^a.max", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "ab9c7c1beeee8542d045d6ff3fc7b73c", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800} {"lang": "Ruby", "source_code": "MOD = 10**9+7\ndef modpow(x,n)\n ret = 1\n while n > 0\n ret = ret*x % MOD if n&1 == 1\n x = x*x % MOD\n n >>= 1\n end\n return ret\nend\n\nn,m = gets.split.map(&:to_i)\n\np modpow((modpow(2,m) - 1),n)", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "ed4f9b66fd36944ca5a291abd287a435", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500} {"lang": "Ruby", "source_code": "def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end\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 kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end\n\ndef scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end\n\ndef na(n=0,d=0) Array.new(n,d)end\n\ndef na2(n=0,m=0,d=0) Array.new(n){Array.new(m,d)}end\n\ndef na3(n=0,m=0,l=0,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end\n\ndef bit(n) n.to_s(2).split(\"\").map(&:to_i) end\n\ndef inp() a=gets.chomp.split(\" \").map(&:to_i)end\n\ndef k2(k,n,m)\n return 1 if k == 0\n return n if(k == 1)\n ans = 1\n if((k%2) == 0)\n ans *= k2(k/2,n,m)**2\n else\n ans *= k2(k-1,n,m)\n ans *= n\n end\n return ans % m\nend\nmod = 10**9+7\na,b = inp\np k2(a,k2(b,2,mod)-1,mod)", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "387e1de44da3c4a7cf683c92520958b3", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500} {"lang": "Ruby", "source_code": "a, b, c = gets.split.map(&:to_i)\nputs c * 2 + [a, b].min * 2 + (a != b ? 1 : 0)\n", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "ce4b35c00b9d824ecc78f435dc944e90", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800} {"lang": "Ruby", "source_code": "st = gets.split\nn=st[0].to_i\n\narray=[1,0,18,0,1800,0,180000,0,18000000,0,1800000000,0,180000000000,0,18000000000000,0]\n\nputs array[n-1]%1000000007", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "f4d8536251b2d0cb07438ca03a391047", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900} {"lang": "Ruby", "source_code": "a, b = gets.strip.split.map{|s|s.to_i}\nif a == b\n puts 'Equal'\n exit\nend\nd = a * b / a.gcd(b)\nfa = d / a\nfb = d / b\na < b ? fa -= 1 : fb -= 1\nif fa > fb\n puts 'Dasha'\nelsif fa < fb\n puts 'Masha'\nelse\n puts 'Equal'\nend\n", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "6bacb44cfac0b7d68ed09e31d3e3febd", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500} {"lang": "Ruby", "source_code": "f = gets.strip.split ''\ns = gets.split.join.split ''\nputs(s.any?{|x| f.any?{|y| x == y}} ? \"YES\" : \"NO\")\n", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "7102b6106569cc01b5f8b51bd4a1333b", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800} {"lang": "Ruby", "source_code": "\ndef fact(x)\n fact = 1\n x.times do |el|\n fact *= (el + 1)\n #fact %= (10**9 + 7)\n end\n fact\nend\n\n\ndef fact_mod(x)\n fact = 1\n x.times do |el|\n fact *= (el + 1)\n fact %= (10**9 + 7)\n end\n fact\nend\n\ndef fc(n, k)\n return 0 if k > n\n fact(n)/(fact(n - k)) # % (10**9 + 7)\nend\n\nn, x, pos = gets.chomp.split(' ').map(&:to_i)\nless = -1 \ngreater = 0\nleft = 0\nright = n\narr = (1..n).to_a\nwhile left < right\n middle = (left + right) / 2\n if arr[middle] <= pos + 1\n less += 1\n left = middle + 1\n else\n greater += 1\n right = middle\n end\nend\ngr_count = n - x\nls_count = n - gr_count - 1\nfixed = n - less - greater - 1\nputs (fact(fixed) * fc(gr_count, greater) * fc(ls_count, less)) % (10**9 + 7)\n", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "0d46c96a1545d0231af562e7cefb78bd", "src_uid": "24e2f10463f440affccc2755f4462d8a", "difficulty": 1500} {"lang": "Ruby", "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", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "b1491e503f6ccbf5b63a30fc8cc58d2c", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300} {"lang": "Ruby", "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", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "07cfb521e666aeb08fd0191334a3f545", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900} {"lang": "Ruby", "source_code": "# coding: utf-8\n\nx, y, z = gets.split.map(&:to_i)\n# x -> andrew: only green\n# y -> dmitry: green and purple\n# z -> michal: any type is good\na, b, c = gets.split.map(&:to_i)\n# a -> green\n# b -> purple\n# c -> black\n# happy YES unhappy NO\n\na -= x\nif a < 0\n puts \"NO\"\nelse\n ab = a + b - y\n if ab < 0\n puts \"NO\"\n else\n if ab + c >= z\n puts \"YES\"\n else\n puts \"NO\"\n end\n end\nend\n", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "da2ec35f1ae7243ed51fa31a1bdb9e64", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800} {"lang": "Ruby", "source_code": "n=gets.chomp.to_i\ns=gets.chomp\n\nif s=='0'\n puts 0\nelse\n puts '1'+'0'*s.count('0')\nend", "lang_cluster": "Ruby", "compilation_error": false, "code_uid": "604514026a694fed5c10a6c3be56e9c1", "src_uid": "ac244791f8b648d672ed3de32ce0074d", "difficulty": 800}