Polycarpus has got n candies and m friends (n ≥ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such ai, where ai is the number of candies in the i-th friend's present, that the maximum ai differs from the least ai as little as possible.For example, if n is divisible by m, then he is going to present the same number of candies to all his friends, that is, the maximum ai won't differ from the minimum one.

The single line of the input contains a pair of space-separated positive integers n, m (1 ≤ n, m ≤ 100;n ≥ m) — the number of candies and the number of Polycarpus's friends.

Print the required sequence a1, a2, ..., am, where ai is the number of candies in the i-th friend's present. All numbers ai must be positive integers, total up to n, the maximum one should differ from the minimum one by the smallest possible value.

NotePrint ai in any order, separate the numbers by spaces.

#!/usr/bin/ruby
n,m=gets.split.map(&:to_i)
puts m.times.map{|i|n/m+(i<n%m ? 1 : 0)}*' '

# https://codeforces.com/problemset/problem/306/A

input = gets.split(' ').map(&:to_i)

candies = input[0]
friends = input[1]

c = candies / friends
leftover = candies - c * friends

puts ("#{c} " * (friends - leftover) + "#{c + 1} " * leftover).rstrip

n, m = gets.split.map(&:to_i)

a = Array.new(m, 0)
for i in 0...n
  a[i%m] += 1
end

for i in a
  print i, " "
end

candies, friends = gets.strip.split(' ').map(&:to_i)

result = []
number = candies/friends
redundant = candies%friends
friends.times do |f|
  result << number
end
if redundant != 0
  for i in 0...redundant
    result[i] += 1
  end
  result = result.reverse
end

print result.join(' ')

n, m = gets.split.map(&:to_i)
r, n = n % m, n / m
r.times{print "#{n+1} "}
(m-r).times{print "#{n} "}


Vasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer $$$p$$$ (which may be positive, negative, or zero). To combine their tastes, they invented $$$p$$$-binary numbers of the form $$$2^x + p$$$, where $$$x$$$ is a non-negative integer.For example, some $$$-9$$$-binary ("minus nine" binary) numbers are: $$$-8$$$ (minus eight), $$$7$$$ and $$$1015$$$ ($$$-8=2^0-9$$$, $$$7=2^4-9$$$, $$$1015=2^{10}-9$$$).The boys now use $$$p$$$-binary numbers to represent everything. They now face a problem: given a positive integer $$$n$$$, what's the smallest number of $$$p$$$-binary numbers (not necessarily distinct) they need to represent $$$n$$$ as their sum? It may be possible that representation is impossible altogether. Help them solve this problem.For example, if $$$p=0$$$ we can represent $$$7$$$ as $$$2^0 + 2^1 + 2^2$$$.And if $$$p=-9$$$ we can represent $$$7$$$ as one number $$$(2^4-9)$$$.Note that negative $$$p$$$-binary numbers are allowed to be in the sum (see the Notes section for an example).

The only line contains two integers $$$n$$$ and $$$p$$$ ($$$1 \leq n \leq 10^9$$$, $$$-1000 \leq p \leq 1000$$$).

If it is impossible to represent $$$n$$$ as the sum of any number of $$$p$$$-binary numbers, print a single integer $$$-1$$$. Otherwise, print the smallest possible number of summands.

Note$$$0$$$-binary numbers are just regular binary powers, thus in the first sample case we can represent $$$24 = (2^4 + 0) + (2^3 + 0)$$$.In the second sample case, we can represent $$$24 = (2^4 + 1) + (2^2 + 1) + (2^0 + 1)$$$.In the third sample case, we can represent $$$24 = (2^4 - 1) + (2^2 - 1) + (2^2 - 1) + (2^2 - 1)$$$. Note that repeated summands are allowed.In the fourth sample case, we can represent $$$4 = (2^4 - 7) + (2^1 - 7)$$$. Note that the second summand is negative, which is allowed.In the fifth sample case, no representation is possible.

#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def r_sort(a) a.sort{|a,b|b<=>a} end

t = []
n , p = inp
min = 9999999
50.times do|i|
  cn = n-i*p
  break if(cn <= 0)
  c = cn.to_s(2).count("1")
  chib = i - c
  if(chib >= 0 and chib < cn)
    min = [min, i ].min
  end
end
if(min > 999)
  puts -1
else
  puts min
end

#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def r_sort(a) a.sort{|a,b|b<=>a} end

t = []
n , p = inp
min = 9999999
50.times do|i|
  cn = n-i*p
  break if(cn <= 0)
  c = cn.to_s(2).count("1")
  chib = i - c
  if(chib >= 0)
    min = [min, i ].min
  end
end
if(min > 999)
  puts -1
else
  puts min
end


Polycarp loves ciphers. He has invented his own cipher called repeating.Repeating cipher is used for strings. To encrypt the string $$$s=s_{1}s_{2} \dots s_{m}$$$ ($$$1 \le m \le 10$$$), Polycarp uses the following algorithm:  he writes down $$$s_1$$$ ones,  he writes down $$$s_2$$$ twice,  he writes down $$$s_3$$$ three times,  ...  he writes down $$$s_m$$$ $$$m$$$ times. For example, if $$$s$$$="bab" the process is: "b" $$$\to$$$ "baa" $$$\to$$$ "baabbb". So the encrypted $$$s$$$="bab" is "baabbb".Given string $$$t$$$ — the result of encryption of some string $$$s$$$. Your task is to decrypt it, i. e. find the string $$$s$$$.

The first line contains integer $$$n$$$ ($$$1 \le n \le 55$$$) — the length of the encrypted string. The second line of the input contains $$$t$$$ — the result of encryption of some string $$$s$$$. It contains only lowercase Latin letters. The length of $$$t$$$ is exactly $$$n$$$. It is guaranteed that the answer to the test exists.

Print such string $$$s$$$ that after encryption it equals $$$t$$$.

n=gets.to_i
i=x=0
s=gets.chomp
while i<n
print s[i]
i+=x+=1
end

# Input
n = gets.to_i
t = gets.chomp

# Processing
m = (((8*t.length + 1)**0.5 - 1) / 2).round
str = ""
m.times do |i|
  str << t[(i + 2) * (i + 1) / 2 - 1]
end

# Output
puts str

n = gets.to_i
s = gets.chomp
ans = ''
j = 0
(1..n).each do |i|
  j += i
  if s[j-1].nil?
    break
  end
  ans += s[j-1]
end
puts ans

# https://codeforces.com/problemset/problem/1095/A

def decrypt(n, t)
  s = ""
  c = 1
  i = 0
  while i < n do
    s += t[i]
    i += c
    c += 1
  end
  return s
end

n = gets.chomp.to_i
t = gets.chomp

puts decrypt(n, t)

n = gets.to_i
t = gets.strip
i = 0
d = 1
s = ''
while i < t.size
    s += t[i]
    i += d
    d += 1
end
puts s

n = gets.to_i
str = gets.chomp

newstr = ""

i = 0
(1..n).each do |x|
  newstr += str[i]
  i += x
  break if i>=str.length
end

puts newstr

gets
s = gets.chomp

result = ''
1.upto(10) do |i|
  break if s.empty?

  result += s[0]

  s.replace s[i..-1]
end

puts result

n=gets.to_i
s=gets.split('')
idx=0
ans=""
ctr=1
while idx<n do
  ans+=s[idx]
  idx+=ctr
  ctr+=1
end
puts ans


A big company decided to launch a new series of rectangular displays, and decided that the display must have exactly n pixels. Your task is to determine the size of the rectangular display — the number of lines (rows) of pixels a and the number of columns of pixels b, so that:  there are exactly n pixels on the display;  the number of rows does not exceed the number of columns, it means a ≤ b;  the difference b - a is as small as possible.

The first line contains the positive integer n (1 ≤ n ≤ 106) — the number of pixels display should have.

Print two integers — the number of rows and columns on the display.

NoteIn the first example the minimum possible difference equals 2, so on the display should be 2 rows of 4 pixels.In the second example the minimum possible difference equals 0, so on the display should be 8 rows of 8 pixels.In the third example the minimum possible difference equals 4, so on the display should be 1 row of 5 pixels.

n=gets.to_i
r=i=1
while i*i<=n
r=i if n%i==0
i+=1
end
puts '%d %d'%[r,n/r]

n = gets.to_i
a = (1..n).select { |x| x * x <= n && n % x == 0 }.last
puts [a, n / a].join(' ')

n = gets.to_i
a, b = 1, n
(1..Math.sqrt(n)).each do |i|
  a, b = i, n / i if n % i == 0
end
puts "#{a} #{b}"

require 'prime'
def find_minimum(row, col, factor, n)
  res = (0..n).collect {|i|
    [row * (factor**i), col * (factor**(n-i))]
  }.select{ |pair|
    pair[0] <= pair[1]
  }.min_by { |pair|
    pair[1] - pair[0]
  }
  res.nil? ? [1, row*col*(factor**n)] : res
end

def minimum_pair(row, col, primes)
  if primes.size == 1
    return find_minimum(row, col, primes[0][0], primes[0][1])
  else
    prime = primes[0][0]
    n = primes[0][1]
    rest = primes[1..-1]
    minimum = 10000000
    minimum_result = nil
    (0..n).collect { |i|
      minimum_pair(row*(prime**i), col*(prime**(n-i)), rest)
    }.select{ |pair|
      pair[0] <= pair[1]
    }.min_by { |pair|
      pair[1] - pair[0]
    }
  end
end

def solve(n)
  return [1,1] if n == 1
  return [0,0] if n == 0
  primes = n.prime_division
  minimum_pair(1, 1, primes)
end

puts solve(STDIN.read.to_i).join(" ")

n = gets.to_i
x = 0
y = 0
for i in 1..Math.sqrt(n).round
  if (n%i === 0)
    x = i
    y = n/i
  end
end
print x
print " "
print y

n=gets.to_i
x, y=1, n
a=1
d=n-1
while a<=n
    if n % a==0 and n/a>=a and n/a-a<d
        x=a
        y=n/a
        d=y-x
    end
    a+=1
end
puts [x, y]*' '

class RectangleLike
  class << self
    def from_area(area)
      width = Math.sqrt(area).to_i
      new(area, width)
    end
  end

  attr_reader(:area, :width)
  def initialize(area, width)
    @area = area
    @width = width
  end

  def next
    if(not valid?)
      return RectangleLike.new(area, width - 1).next
    else
      return self
    end
  end

  def length
    (area / width).to_i
  end

  def valid?
    area == width * length
  end

  def to_s
    "#{width} #{length}"
  end

end

puts RectangleLike.from_area(gets.strip.to_i).next

require 'prime'
def find_minimum(row, col, factor, n)
  (0..n).collect {|i|
    [row * (factor**i), col * (factor**(n-i))]
  }.select{ |pair|
    pair[0] <= pair[1]
  }.min_by { |pair|
    pair[1] - pair[0]
  }
end

def minimum_pair(row, col, primes)
  if primes.size == 1
    return find_minimum(row, col, primes[0][0], primes[0][1])
  else
    prime = primes[0][0]
    n = primes[0][1]
    rest = primes[1..-1]
    minimum = 10000000
    minimum_result = nil
    (0..n).collect { |i|
      minimum_pair(row*(prime**i), col*(prime**(n-i)), rest)
    }.select{ |pair|
      pair[0] <= pair[1]
    }.min_by { |pair|
      pair[1] - pair[0]
    }
  end
end

def solve(n)
  primes = n.prime_division
  puts primes
  minimum_pair(1, 1, primes)
end

puts solve(STDIN.read.to_i).join(" ")


Dawid has four bags of candies. The $$$i$$$-th of them contains $$$a_i$$$ candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amount of candies in total?Note, that you can't keep bags for yourself or throw them away, each bag should be given to one of the friends.

The only line contains four integers $$$a_1$$$, $$$a_2$$$, $$$a_3$$$ and $$$a_4$$$ ($$$1 \leq a_i \leq 100$$$) — the numbers of candies in each bag.

Output YES if it's possible to give the bags to Dawid's friends so that both friends receive the same amount of candies, or NO otherwise. Each character can be printed in any case (either uppercase or lowercase).

NoteIn the first sample test, Dawid can give the first and the third bag to the first friend, and the second and the fourth bag to the second friend. This way, each friend will receive $$$12$$$ candies.In the second sample test, it's impossible to distribute the bags.

as = gets.split.map(&:to_i)

(1..4**2).each do |x|
  sum = 0
  (0..3).each do |i|
    if x & (1<< i) == 0
      sum += as[i]
    end
  end
  if sum * 2 == as.inject(:+)
    puts 'YES'
    exit
  end
end
puts 'NO'

a = gets.split.map &:to_i
(0..15).each do |x|
  f, s = 0, 0
  (0..3).each { |i| x & 1 << i != 0 ? f += a[i] : s += a[i] }
  if f == s
    puts 'YES'
    exit
  end
end
puts 'NO'

a = gets.split.map &:to_i
a.permutation.each do |p|
  if p[0] + p[1] == p[2] + p[3]
    puts 'YES'
    exit
  end
end
puts 'NO'

a = gets.split.map(&:to_i).sort
puts a[0] + a[3] == a[1] + a[2] ? 'YES' : 'NO'


Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three integers x1, x2, x3 and three more integers y1, y2, y3, such that x1 < x2 < x3, y1 < y2 < y3 and the eight point set consists of all points (xi, yj) (1 ≤ i, j ≤ 3), except for point (x2, y2).You have a set of eight points. Find out if Gerald can use this set?

The input consists of eight lines, the i-th line contains two space-separated integers xi and yi (0 ≤ xi, yi ≤ 106). You do not have any other conditions for these points.

In a single line print word "respectable", if the given set of points corresponds to Gerald's decency rules, and "ugly" otherwise.

points = 8.times.map{|i| gets.split.map(&:to_i) }.uniq
puts [:first, :last].all?{|sym| points.group_by(&sym).to_a.sort_by(&:first).map{|x| x.last.length} == [3,2,3] } ? "respectable" : "ugly"

xs, ys = [], []
x_count, y_count = {}, {}
8.times do
	x, y = STDIN.readline.split.map {|s| s.to_i }
	xs.push(x)
	ys.push(y)
	x_count[x] = (x_count[x] || 0) + 1
	y_count[y] = (y_count[y] || 0) + 1
end
[x_count, y_count].each do |z_count|
	values = z_count.values.sort
	if values.length != 3
		puts 'ugly'
		exit
	end
end
input_points = xs.zip(ys).sort
x1, x2, x3 = x_count.keys.sort
y1, y2, y3 = y_count.keys.sort
constructed_points = [[x1, y1], [x1, y2], [x1, y3],
					  [x2, y1], [x2, y3],
					  [x3, y1], [x3, y2], [x3, y3]].sort
if constructed_points == input_points
	puts 'respectable'
else
	puts 'ugly'
end

xs, ys = [], []
x_count, y_count = {}, {}
8.times do
	x, y = STDIN.readline.split.map {|s| s.to_i }
	xs.push(x)
	ys.push(y)
	x_count[x] = (x_count[x] || 0) + 1
	y_count[y] = (y_count[y] || 0) + 1
end
if x_count.values.length != 3 || y_count.values.length != 3
	puts 'ugly'
	exit
end
input_points = xs.zip(ys).sort
x1, x2, x3 = x_count.keys.sort
y1, y2, y3 = y_count.keys.sort
constructed_points = [[x1, y1], [x1, y2], [x1, y3],
					  [x2, y1], [x2, y3],
					  [x3, y1], [x3, y2], [x3, y3]].sort
puts constructed_points == input_points ? 'respectable' : 'ugly'

#!/usr/bin/env ruby
point,x, y = [], [], []
8.times do
  point << gets.split(' ').map(&:to_i)
  x << point[-1][0] unless x.include? point[-1][0]
  y << point[-1][1] unless y.include? point[-1][1]
end
if x.sort!.size == 3 && y.sort!.size == 3
  if point.uniq.size == point.size && !point.include?([x[1], y[1]])
    puts "respectable"
  else
    puts "ugly"
  end
else
  puts "ugly"
end

#!/usr/bin/env ruby
point,x, y = [], [], []
8.times do
  point << gets.split(' ').map(&:to_i)
  x << point[-1][0] unless x.include? point[-1][0]
  y << point[-1][1] unless y.include? point[-1][1]
end
if x.sort!.size == 3 && y.sort!.size == 3
  ok = true
  for i in 0...3
    for j in 0...3
      next if i == 1 && j == 1
      ok = false unless point.include?([x[i], y[j]])
    end
  end
  puts ok ? "respectable" : "ugly"
else
  puts "ugly"
end

points =[]
for i in 1..8
 temp=gets.chomp.split.collect{|a| a.to_i}
 points.push temp
end
xs=points.collect{|a| a.first}.sort.uniq
ys=points.collect{|a| a.last }.sort.uniq
#puts xs,ys
#puts points.uniq.length
if xs.length!=3 ||ys.length!=3 || points.uniq.length !=8
   puts "ugly"
else
  avg=[xs[1],ys[1]]
 # puts avg
  if points.include? avg
     puts "ugly"
  else
      puts"respectable"
  end
end

xy = []
8.times do
  x,y = gets.split(' ').map(&:to_i)
  xy << [x,y]
end

xs,ys = xy.transpose
xxs = xs.sort.uniq
yys = ys.sort.uniq

ok = xy.uniq.size == 8
xxs.each.with_index do |x,i|
  if xs.count(x) != (i == 1 ? 2 : 3)
    ok = false
    break;
  end
end if ok

yys.each.with_index do |y,i|
  if ys.count(y) != (i == 1 ? 2 : 3)
    ok = false
    break;
  end
end if ok

if !ok || xxs.size != 3 || yys.size != 3 || xy.include?([xxs[1], yys[1]])
  puts "ugly"
else
  puts "respectable"
end

def runb(list)
  x = list.map{|x,y| x}.uniq.sort
  y = list.map{|x,y| y}.uniq.sort

  return false unless x.size == 3
  return false unless y.size == 3
  x.each_with_index do |x,i|
    y.each_with_index do |y,j|
      if (i == j) and (j == 1)
        return false if list.member?([x,y])
      else
        return false unless list.member?([x,y])
      end
    end
  end
  return true
end

def run(list)
  runb(list) ? "respectable" : "ugly"
end

def convert(n)
  n.split(' ').map(&:to_i)
end

n = gets
list = []
while n != nil
  list << convert(n)
  if list.size == 8
    puts run(list)
    list = []
  end
  n = gets
end

#0 0
#2 1
#1 0
#0 2
#2 2
#1 0
#2 1
#0 2

x=[]
y=[]
8.times do
  a,b=gets.split.map(&:to_i)
  x<<a
  y<<b
end
a=x.uniq.sort
b=y.uniq.sort
if a.size!=3 or b.size!=3
  puts 'ugly'
  exit
end
p=[]
3.times do |i|
  3.times do |j|
    next if i==1 and j==1
    p << [a[i],b[j]]
  end
end
8.times do |i|
  p.delete([x[i],y[i]])
end
if p.size == 0
  puts 'respectable'
else
  puts 'ugly'
end

# http://codeforces.com/problemset/problem/334/B
list = []
list_x = []
list_y = []
8.times do |i|
  list << gets.chomp.split.map(&:to_i)
  list_x << list[i][0]
  list_y << list[i][1]
end

def eight_point_set(list, list_x, list_y)
  for i in 0..7
    for j in (i + 1)..7
      if list[j] == list[i]
        return "ugly"
      end
    end
  end

  sorted_list_x = list_x.sort
  sorted_list_y = list_y.sort
  avg_x, avg_y = 0, 0

  for i in 0..7
    avg_x += 1 if sorted_list_x[i] == sorted_list_x[3]
    avg_y += 1 if sorted_list_y[i] == sorted_list_y[3]
  end

  return avg_x == 2 && avg_y == 2 ? "respectable" : "ugly"
end

puts eight_point_set(list, list_x, list_y)

# http://codeforces.com/problemset/problem/334/B
list = []
list_x = []
list_y = []
8.times do |i|
  list << gets.chomp.split.map(&:to_i)
  list_x << list[i][0]
  list_y << list[i][1]
end

def eight_point_set(list, list_x, list_y)
  hash = Hash.new { |hash, key| hash[key] = 0 }
  for i in 0..7
    hash[list[i]] += 1

    if hash[list[i]] > 1
      return "ugly"
    end
  end

  sorted_list_x = list_x.sort
  sorted_list_y = list_y.sort
  avg_x, avg_y = 0, 0

  for i in 0..7
    avg_x += 1 if sorted_list_x[i] == sorted_list_x[3]
    avg_y += 1 if sorted_list_y[i] == sorted_list_y[3]
  end

  return avg_x == 2 && avg_y == 2 ? "respectable" : "ugly"
end

puts eight_point_set(list, list_x, list_y)

#!/usr/bin/env ruby
point,x, y = [], [], []
8.times do
  point << gets.split(' ').map(&:to_i)
  x << point[-1][0] unless x.include? point[-1][0]
  y << point[-1][1] unless y.include? point[-1][1]
end
if x.size == 3 && y.size == 3
  ok = true
  for i in 0...3
    for j in 0...3
      next if i == 1 && j == 1
      ok = false unless point.include?([x[i], y[j]])
    end
  end
  puts ok ? "respectable" : "ugly"
else
  puts "ugly"
end

#!/usr/bin/env ruby
point,x, y = [], [], []
8.times do
  point << gets.split(' ').map(&:to_i)
  x << point[-1][0] unless x.include? point[-1][0]
  y << point[-1][1] unless y.include? point[-1][1]
end
if x.size == 3 && y.size == 3
  if x.size > 1 && y.size > 1 && point.include?([x.sort[1], y.sort[1]])
    puts "ugly"
  else
    puts "respectable"
  end
else
  puts "ugly"
end

#!/usr/bin/env ruby
point,x, y = [], [], []
8.times do
  point << gets.split(' ').map(&:to_i)
  x << point[-1][0] unless x.include? point[-1][0]
  y << point[-1][1] unless y.include? point[-1][1]
end
if x.sort!.size == 3 && y.sort!.size == 3
  if point.uniq.size == point.size && point.include?([x[1], y[1]])
    puts "respectable"
  else
    puts "ugly"
  end
else
  puts "ugly"
end

points =[]
for i in 1..8
 temp=gets.chomp.split.collect{|a| a.to_i}
 points.push temp
end
xs=points.collect{|a| a.first}.uniq
ys=points.collect{|a| a.last }.uniq
#puts xs,ys
if xs.length!=3 ||ys.length!=3
   puts "ugly"
else
  avg=[xs[1],ys[1]]
 # puts avg
  if points.include? avg
     puts "ugly"
  else
      puts"respectable"
  end
end

points =[]
for i in 1..8
 temp=gets.chomp.split.collect{|a| a.to_i}
 points.push temp
end
xs=points.collect{|a| a.first}.uniq.sort
ys=points.collect{|a| a.last }.uniq.sort
#puts xs,ys
if xs.length!=3 ||ys.length!=3 || temp.uniq !=8
   puts "ugly"
else
  avg=[xs[1],ys[1]]
 # puts avg
  if points.include? avg
     puts "ugly"
  else
      puts"respectable"
  end
end

points =[]
for i in 1..8
 temp=gets.chomp.split.collect{|a| a.to_i}
 points.push temp
end
xs=points.collect{|a| a.first}.sort.uniq
ys=points.collect{|a| a.last }.sort.uniq
#puts xs,ys
if xs.length!=3 ||ys.length!=3 || points.uniq !=8
   puts "ugly"
else
  avg=[xs[1],ys[1]]
 # puts avg
  if points.include? avg
     puts "ugly"
  else
      puts"respectable"
  end
end

points =[]
for i in 1..8
 temp=gets.chomp.split.collect{|a| a.to_i}
 points.push temp
end
xs=points.collect{|a| a.first}.uniq.sort
ys=points.collect{|a| a.last }.uniq.sort
#puts xs,ys
if xs.length!=3 ||ys.length!=3
   puts "ugly"
else
  avg=[xs[1],ys[1]]
 # puts avg
  if points.include? avg
     puts "ugly"
  else
      puts"respectable"
  end
end

xy = []
8.times do
  x,y = gets.split(' ').map(&:to_i)
  xy << [x,y]
end

xs,ys = xy.transpose
xxs = xs.sort.uniq
yys = ys.sort.uniq

ok = true
xxs.each do |x|
  if xs.count(x) != 3
    ok = false
    break;
  end
end

yys.each do |y|
  if ys.count(y) != 3
    ok = false
    break;
  end
end if ok

if !ok || xxs.size != 3 || yys.size != 3 || xy.include?([xxs[1], yys[1]])
  puts "ugly"
else
  puts "respectable"
end

xy = []
8.times do
  x,y = gets.split(' ').map(&:to_i)
  xy << [x,y]
end

xs,ys = xy.transpose
xxs = xs.sort.uniq
yys = ys.sort.uniq

ok = true
xxs.each.with_index do |x,i|
  if xs.count(x) != (i == 1 ? 2 : 3)
    ok = false
    break;
  end
end

yys.each.with_index do |y,i|
  if ys.count(y) != (i == 1 ? 2 : 3)
    ok = false
    break;
  end
end if ok

if !ok || xxs.size != 3 || yys.size != 3 || xy.include?([xxs[1], yys[1]])
  puts "ugly"
else
  puts "respectable"
end

xy = []
8.times do
  x,y = gets.split(' ').map(&:to_i)
  xy << [x,y]
end

xs,ys = xy.transpose
xxs = xs.sort.uniq
yys = ys.sort.uniq

if xxs.size != 3 || yys.size != 3 || xy.include?([xxs[1], yys[1]])
  puts "ugly"
else
  puts "respectable"
end

def runb(list)
  x = list.map{|x,y| x}.uniq.sort
  y = list.map{|x,y| y}.uniq.sort

  return false unless x.size == 3
  return false unless y.size == 3
  return false if list.member?([x[1],y[1]])
  return true
end

def run(list)
  runb(list) ? "respectable" : "ugly"
end

def convert(n)
  n.split(' ').map(&:to_i)
end

n = gets
list = []
while n != nil
  list << convert(n)
  if list.size == 8
    puts run(list)
    list = []
  end
  n = gets
end

# http://codeforces.com/problemset/problem/334/B
list = []
list_x = []
list_y = []
8.times do |i|
  list << gets.chomp.split.map(&:to_i)
  list_x << list[i][0]
  list_y << list[i][1]
end

def eight_point_set(list, list_x, list_y)
  hash = Hash.new { |hash, key| hash[key] = 0 }
  for i in 0..7
    hash[list[i]] += 0

    if hash[list[i]] > 1
      return "ugly"
    end
  end

  sorted_list_x = list_x.sort
  sorted_list_y = list_y.sort
  avg_x, avg_y = 0, 0

  for i in 0..7
    avg_x += 1 if sorted_list_x[i] == sorted_list_x[3]
    avg_y += 1 if sorted_list_y[i] == sorted_list_y[3]
  end

  return avg_x == 2 && avg_y == 2 ? "respectable" : "ugly"
end

puts eight_point_set(list, list_x, list_y)

# http://codeforces.com/problemset/problem/334/B

list_x = []
list_y = []
8.times do
  pair = gets.chomp.split
  list_x << pair[0].to_i
  list_y << pair[1].to_i
end

list_x = list_x.sort
list_y = list_y.sort

avg_x, avg_y = 0, 0

for i in 0..7
  avg_x += 1 if list_x[i] == list_x[3]
  avg_y += 1 if list_y[i] == list_y[3]
end

puts avg_x == 2 && avg_y == 2 ? "respectable" : "ugly"


Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.Note, that during capitalization all the letters except the first one remains unchanged.

A single line contains a non-empty word. This word consists of lowercase and uppercase English letters. The length of the word will not exceed 103.

Output the given word after capitalization.

s = gets.chomp
s[0] = s[0].capitalize
puts s

A = gets.chomp
A[0] = A[0].upcase
puts A

str = gets.chomp()
str[0] = str[0].upcase
puts str

s = gets.chomp
f = s[0].capitalize
puts f + s[1..-1]

arr = gets.chomp.split("")
first_letter = arr.first.upcase
puts [first_letter, arr[1..-1]].flatten.join

a = gets.chomp
print a[0].upcase
print a[1..-1]

str = gets.to_s.strip

def newlife(word)
	first_char = word[0]
	first_char.upcase!
	word[0] = first_char
	word
end

puts newlife(str)

input = gets.chomp

print input.slice!(0).capitalize, input

s = gets
puts s[0].capitalize + s[1..-1]

s = gets.strip
if s[0].ord >= 'a'.ord && s[0].ord <= 'z'.ord then
  s[0] = (s[0].ord - 32).chr
end
puts s

word = gets.chomp
puts word[0].upcase + word[1..-1]

s = gets.chomp
s[0] = s[0].upcase
puts s

def xenia()
  word = gets.chomp
  letter = word[0]
  letter.upcase!
  print "#{letter}#{word[1..-1]}"
end

xenia

a = gets.chomp
a[0] = a[0].upcase
puts a

#!/usr/bin/ruby1.9

word = STDIN.readline.strip
puts word[0].upcase+word[1..-1]

a = gets.chomp
b = a.capitalize
puts b[0] + a[1..-1]

str = gets.chomp
puts str[0].upcase + str[1..10**3]

def run(input = STDIN.read)
  line = input.strip
  line[0] = line[0].capitalize
  puts line
end
run

src = gets
src[0] = src[0].upcase
puts src

s = gets.chomp
s[0] = s[0].capitalize
puts s

t = $stdin.readline
tt = t.scan(/./)
tt[0] = t[0].capitalize
puts tt.join('')

s = gets.to_s
puts s[0].upcase + s[1..-1]

x = gets.chomp;
x[0]= x[0].upcase;
puts x;

def run
  line = $stdin.readline.split(//)
  line[0].upcase!
  puts line.join("")
end

run if $0 == __FILE__

inp = gets.chomp
inp = inp.sub(/^./) { |ch| ch.upcase }
puts inp

str = $stdin.gets

str[0] = str[0].upcase! if str[0].upcase!
puts str

w = gets.chomp

puts w[0].upcase + w[1..-1]

s = gets

s[0] = s[0].capitalize;

puts s

test = gets
test[0] = test[0].capitalize
puts test

a = gets.chomp()
puts a[0].upcase << a[1..-1]

s = gets.chomp
puts s[0].capitalize + s[1..-1]

s = gets.strip
t = ""
s.length.times do |i|
    if i == 0
        t += s[i].upcase
    else
        t += s[i]
    end
end
puts t

a=gets.chomp
a=a[0].upcase+a[1..a.length-1]
puts  "#{a}"

x = gets.chomp
puts "#{x[0].capitalize + x[1..-1]}"

#STDOUT.flush
#str = gets.chomp
#str_aux = "AEIOUYaeiouy"
#str.each_char { |out|
#	if !str_aux.include? out.to_s
#		print "."
#		print out.downcase
#	end
#}
#puts "\n"

STDOUT.flush
str = gets.chomp
print str[0].upcase
puts str[1..str.size()]

require 'set'
include Math
$stdin = File.open("./input.txt", "r") if ENV["USER"] == "new"
# ====================================

line = gets.strip
line[0] = line[0].upcase
puts line

s = gets
puts s[0].upcase + s[1, s.length]

word = STDIN.read
puts word.sub(/\w/) {|c| c.capitalize}

s = gets.chomp
s[0] = s[0].upcase
puts s

a = gets.chomp
puts a[0].upcase + a[1..a.length]

s = gets.chop
puts s[0].upcase + s[1..s.size-1]

s = gets.chomp
print s[0].capitalize + s[1..-1]

str = gets.chomp
str1 = str[0]

print str1.capitalize
puts str[1..str.length]

str = gets.chomp
print str[0].capitalize , str[1..str.length]

s = gets
puts s[0].upcase + s[1...s.size]

# http://codeforces.com/problemset/problem/281/A

word = gets.chomp
puts "#{word[0].upcase}#{word[1..(word.length - 1)]}"

input = gets.chomp
l = input.length
sov = Array.new
sov[0] = input[0].upcase
for i in 1...l
    sov.push(input[i])
end
print sov.join

word = gets.chomp.to_s
letters = word.split("")
print letters[0].capitalize
letters[0] = nil
letters.each do |letter|
	print letter
end

n = gets.split('')

n[0].upcase!

puts n.join('')

str = gets ; str[0] = str[0].to_s.upcase ; puts str

s = gets.strip
s = s[0].capitalize + s[1..s.length]
puts s

word = gets.chomp
word[0] = word[0].upcase
puts word

str = gets.chomp
str[0] = str[0].capitalize
puts str

word = String(gets.chomp)
if word[0] == word[0].upcase
  puts word
else
  puts word[0].upcase + word[1...word.length]
end

s = gets.chomp
puts s[0].upcase + s[1..-1]

s = gets.chomp
s[0] = s[0].upcase
puts s

input_word = gets.chomp
input_word[0]=input_word[0].upcase
print input_word

str = gets
a = str[0].upcase
str[0]=a
puts str

str = gets.chomp
first = str[0,1]
first.upcase!
newstr = first + str[1,(str.length-1)]
puts newstr

x=gets.strip.chars.to_a; x[0]=x[0].upcase; puts x.join

a = gets.chomp.to_s
b = a[1..-1].scan(/[A-Z]/).length
c = a[0]
d = []
if c.capitalize == c && b >= 1
puts a
else
a[0] = a[0].upcase
puts a
end

s = gets.chomp.split("")
if s[0] == s[0].upcase
	puts s.join
else
	s0 = s[0].upcase
	s.delete_at(0)
	puts s0 << s.join
end

input =gets
input[0]=input[0].upcase
print input

cad = gets.chomp

cad[0] = cad[0].upcase

puts cad

n = gets.chomp
m = []
m = n.split("")
print m[0].capitalize
for i in m.drop(1) do
        print i
end

a = gets.chomp
b = a[0]
b = b.upcase
a[0] = b[0]
puts a

line = gets.chomp

line[0] = line[0].upcase
puts line

String word = gets.chomp
word[0]=word[0].capitalize
puts word

word = gets.chomp
first = word.split(//).first.upcase
word[0] = first
puts word

s = gets[0..-2]
code = s[0].ord
code -= 32 if code > "Z".ord
s[0] = code.chr
print s

#!/usr/bin/env ruby

gets.split.collect{|i| puts "#{i[0].upcase}#{i[1..-1]}"}

input = gets.strip

input[0] = input[0].upcase
puts input

string = gets
string[0] = string[0].capitalize
puts string

s = gets.chomp; s[0] = s[0].upcase; puts s

s = gets.chomp
s[0] = s[0].upcase
puts s

string = gets.chomp.split('')
string[0].upcase!

string.each do |item|
	print item
end

s = gets.chomp.split(//)
s[0] = s[0].capitalize
puts s

#!/usr/bin/ruby1.9

word = STDIN.readline.strip.capitalize
puts word

def run(input = STDIN.read)
  line = input.strip
  puts line.capitalize
end
run

inp = gets.chomp
inp.sub(/^./) { |ch| ch.upcase }
puts inp

test = gets.chomp
final = test.capitalize
puts final

a = gets.chomp()
puts a[0].upcase!.to_s << a[1..-1]

a = gets.chomp()
b = a[0].upcase!.to_s
puts b << a[1..-1]

word = gets.chomp
word[0].upcase!
puts word

input_word = gets.chomp
print input_word[0].upcase

a = gets.chomp.to_s
b = a[1..-1].scan(/[A-Z]/).length
c = a[0]
if c.upcase == c && b >= 1
puts a
else
c.upcase!
puts a
end

a = gets.chomp.to_s
b = a[1..-1].scan(/[A-Z]/).length
c = a[0]
if c.upcase == c && b >= 1
puts a
else
puts a.capitalize
end

a = gets.chomp.to_s
b = a[1..-1].scan(/[A-Z]/).length
c = a[0]
if c.capitalize == c && b >= 1
puts a
else
puts a.capitalize
end

a = gets.chomp.to_s
b = a[1..-1].scan(/[A-Z]/).length
c = a[0]
if c.capitalize == c && b >= 1
puts a
else
puts a.capitalize!
end

String word = gets.chomp
word[0].capitalize!
puts word

String word = gets.chomp
word.capitalize!
puts word


Luke Skywalker gave Chewbacca an integer number x. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit t means replacing it with digit 9 - t. Help Chewbacca to transform the initial number x to the minimum possible positive number by inverting some (possibly, zero) digits. The decimal representation of the final number shouldn't start with a zero.

The first line contains a single integer x (1 ≤ x ≤ 1018) — the number that Luke Skywalker gave to Chewbacca.

Print the minimum possible positive number that Chewbacca can obtain after inverting some digits. The number shouldn't contain leading zeroes.

a = gets.split('').map(&:to_i)
(a.length-1).times{|i|
  if ((i!=0 || a[i]!=9) && a[i]>4)
    print 9-a[i]
  else
    print a[i]
    end
}

res = gets.chomp.chars.map(&:to_i).
         map{|x| [x, 9 -x].min}.map(&:to_s).join('')

res[0] = '9' if res[0] == '0'
puts res

s=gets.chomp
x=s.chars
t=x.shift

p1="8765".index(t)
if p1!=nil then
	t=[1,2,3,4][p1]
else
	t=t.to_i
end
ans=t
x.map{|e|
	ans*=10
	p2="98765".index(e)
	if p2==nil then
		ans=ans+e.to_i
	else
		ans=ans+[0,1,2,3,4][p2]
	end
}
puts ans

s = gets.chomp
if s[0] == '9'
	print '9'
else
	print [s[0].to_i,9-s[0].to_i].min
end
1.upto(s.length - 1) do |i|
	print [s[i].to_i , 9-s[i].to_i].min
end

#!/usr/bin/ruby
hash = {'9' => '0', '8' => '1','7' => '2','6' => '3','5' => '4'}
input_line = gets
res = ''
input_line.each_char do |ch|
    if hash[ch].nil?
        res+=ch;
    else
        if (ch == '9' && res == '')
            res+=ch
        else
            res+=hash[ch]
        end
    end
end

puts res

# coding: utf-8

# if __FILE__ == $0
# end

digits = gets.chomp.split(//).map { |i|
    i = i.to_i
    inverted = 9 - i
    if inverted < i
        inverted
    else
        i
    end
}

# remind leading zero!
if digits[0] == 0
    digits[0] = 9
end

puts digits.join

number = gets.chomp
digits = number.split("")

if digits[0].to_i >= 5 && digits[0].to_i != 9
	digits[0] = 9 - digits[0].to_i
end
if digits[digits.size - 1].to_i >= 5 && digits.size > 1
	digits[digits.size - 1] = 9 - digits[digits.size - 1].to_i
end
if digits.size == 2
	print digits[0].to_i
	print digits[1].to_i
elsif digits.size == 1
	print digits[0].to_i
else
	for i in (1..digits.size-2)
		if digits[i].to_i >= 5
			digits[i] = 9 - digits[i].to_i
		end
	end
	for i in (0..digits.size-1)
		print digits[i].to_i
	end
end

digits = gets.chomp.chars.map(&:to_i)
print digits.shift if digits[0] == 9
puts digits.map{|d| [d,9-d].min}.join

initial_num = ARGF.read

result = ''

initial_num.chars.each_with_index do |c, index|
	i = c.to_i
	if i >= 5
		if i == 9 and index == 0
			result << c
		else
			result << (9-i).to_s
		end
	else
		result << c
	end
end

puts result

a = gets.strip.chars.each_with_index.map do |ci,i|
  d = ci.ord - '0'.ord
  if i == 0 && d == 9
    d
  elsif d >= 5
    9-d
  else
    d
  end
end
puts a.join

x = gets.chomp.chars.map(&:to_i)

tmp = x[0]
x = x[1..-1]

tmp = 9 - tmp if tmp > 4 and tmp < 9

x = x.map { |i|
  if i > 4
    9 - i
  else
    i
  end }

puts ([tmp] + x).join("")

str=gets.to_s
str.chomp!

for i in 0..str.length-1
  x=str[i].to_i
  y=9-x
  if x>y
    str[i]=y.to_s
  else
    str[i]=x.to_s
  end
end

if str[0]=="0"
  str[0]="9"
end

puts str

a=gets.chomp.bytes.map{|e|[57-e,e-48].min}
a[0]=9 if a[0]==0
puts a*''

# http://codeforces.com/contest/514/problem/A

digits = gets.chomp.chars.map(&:to_i)
inverted = digits.map.with_index do |n, idx|
  case idx
  when 0
    (9 - n) < n && n != 9 ? 9 - n : n
  else
    (9 - n) < n ? 9 - n : n
  end
end

puts inverted.join.to_i

s = gets.chomp.to_s
k = s[0]
for i in 0..s.length - 1
  if s[i].to_i>=5
      s[i] = (9 - s[i].to_i).to_s
  end
end
if s[0] == "0"
    s[0] = k
end
puts s

#!/usr/bin/ruby
# coding: utf-8

s = gets.chomp.to_s
(s.length).times{|i|
  if s[i].to_i >= 5
    if i == 0 and s[i].to_i == 9
      next
    end
    s[i] = (9 - s[i].to_i).to_s
  end
}
puts s

arr = gets.chomp.split("")
arr.each_with_index do |item, index|
  print item.to_i <= 4 ? item : index.to_i == 0 && item.to_i == 9 ? item : 9 - item.to_i
end

a = gets.split('').map(&:to_i)
(a.length-1).times{|i|
  if (i!=0 && a[i]>4)
    print 9-a[i]
  else
    print a[i]
    end
}

def read_ints; STDIN.gets.split.map(&:to_i); end

puts gets.chomp.chars.map(&:to_i).
         map{|x| [x, 9 -x].min}.map(&:to_s).join('')

s=gets.chomp
x=s.chars
t=x.shift

p1="8765".index(t)
if p1!=nil then
	t=[1,2,3,4][p1]
	p t
else
	t=t.to_i
end
ans=t
x.map{|e|
	ans*=10
	p2="98765".index(e)
	if p2==nil then
		ans=ans+e.to_i
	else
		ans=ans+[0,1,2,3,4][p2]
	end
}
puts ans

s = gets.chomp
if s[0] == '9'
	print '9'
else
	print [s[0].to_i,9-s[0].to_i].min
end
1.upto(s.length - 1) do |i|
	print [s[0].to_i , 9-s[0].to_i].min
end

# coding: utf-8

# if __FILE__ == $0
# end

digits = gets.chomp.split(//).map { |i|
    i = i.to_i
    inverted = 9 - i
    if inverted < i
        inverted
    else
        i
    end
}

puts digits.join

number = gets.chomp
digits = number.split("")

if digits[0].to_i >= 5 && digits[0].to_i != 9
	digits[0] = 9 - digits[0].to_i
end
if digits[digits.size - 1].to_i >= 5
	digits[digits.size - 1] = 9 - digits[digits.size - 1].to_i
end
if digits.size == 2
	print digits[0].to_i
	print digits[1].to_i
elsif digits.size == 1
	print digits[0].to_i
else
	for i in (1..digits.size-2)
		if digits[i].to_i >= 5
			digits[i] = 9 - digits[i].to_i
		end
	end
	for i in (0..digits.size-1)
		print digits[i].to_i
	end
end

number = gets.chomp
digits = number.split("")

if digits[0].to_i >= 5 && digits[0].to_i != 9
	digits[0] = 9 - digits[0].to_i
end
if digits[digits.size - 1].to_i >= 5 && digits[digits.size - 1].to_i != 9
	digits[digits.size - 1] = 9 - digits[digits.size - 1].to_i
end
if digits.size == 2
	print digits[0].to_i
	print digits[1].to_i
elsif digits.size == 1
	print digits[0].to_i
else
	for i in (1..digits.size-2)
		if digits[i].to_i >= 5 && digits[i].to_i != 9
			digits[i] = 9 - digits[i].to_i
		end
	end
	for i in (0..digits.size-1)
		print digits[i].to_i
	end
end

number = gets.chomp
digits = number.split("")

if digits[0].to_i >= 5
	digits[0] = 9 - digits[0].to_i
end
if digits[digits.size - 1].to_i >= 5
	digits[digits.size - 1] = 9 - digits[digits.size - 1].to_i
end
if digits.size == 2
	print digits[0].to_i
	print digits[1].to_i
elsif digits.size == 1
	print digits[0].to_i
else
	for i in (1..digits.size-2)
		if digits[i].to_i >= 5
			digits[i] = 9 - digits[i].to_i
		end
	end
	for i in (0..digits.size-1)
		print digits[i].to_i
	end
end

number = gets.chomp
digits = number.split("")

if digits[0].to_i >= 5 && digits[0].to_i != 9
	puts "asdf"
	digits[0] = 9 - digits[0].to_i
end
if digits[digits.size - 1].to_i >= 5 && digits.size > 1
	digits[digits.size - 1] = 9 - digits[digits.size - 1].to_i
end
if digits.size == 2
	print digits[0].to_i
	print digits[1].to_i
elsif digits.size == 1
	print digits[0].to_i
else
	for i in (1..digits.size-2)
		if digits[i].to_i >= 5
			digits[i] = 9 - digits[i].to_i
		end
	end
	for i in (0..digits.size-1)
		print digits[i].to_i
	end
end

ans = gets.chomp.chars.map(&:to_i).map{|d| [d,9-d].min}.join.to_i
puts ans==0 ? 9 : ans

initial_num = ARGF.read

result = ''

initial_num.chars.each_with_index do |c, index|
    i = c.to_i
    if i >= 5
        result << (9-i).to_s unless i == 9 and index == 0
    else
        result << c
    end
end

puts result

c = gets.strip
if c == '9'
  puts 0
else
  a = c.chars.each_with_index.map do |ci,i|
    d = ci.ord - '0'.ord
    if i == 0 && d == 9
      d
    elsif d >= 5
      9-d
    else
      d
    end
  end
  puts a.join
end

x = gets.chomp.chars.map(&:to_i)

tmp = x[0]
x = x[1..-1]

tmp = 9 - tmp if tmp > 4 and tmp < 9

x = x.map { |i| 9 - i if i > 4 }

puts ([tmp] + x).join("")

a=gets.chomp.bytes.map{|e|57-e}
a[0]=9 if a[0]==0
puts a*''

# http://codeforces.com/contest/514/problem/A

digits = gets.chomp.chars.map(&:to_i)
digits.map! { |n| (9 - n) < n ? 9 - n : n }

puts digits.join.to_i

arr = gets.chomp.split("")
arr.each do |x| print x.to_i <= 4 ? x : arr[0] == '9' ? arr[0] :
  9 - x.to_i
end

n = gets.to_i
ans = ""
while n > 0 do
  dig = n % 10
  if 9 - dig < dig && 9 - dig != 0
    ans << (9 - dig).to_s
  else
    ans << dig.to_s
  end
  n /= 10
end
puts ans

n = gets.to_i
ans = ""
while n > 0 do
  dig = n % 10
  if 9 - dig < dig
    ans << (9 - dig).to_s
  else
    ans << dig.to_s
  end
  n /= 10
end
puts ans

arr = gets.chomp.split("")
arr.each do |x| print x.to_i <= 4 ? x : arr.size == 1 && arr[0] == '9' ? arr[0] :
  9 - x.to_i
end


One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si — lowercase letter of the Latin alphabet. Also Kefa has k friends. Friend will be upset, If he get two baloons of the same color. Kefa want to give out all baloons to his friends. Help Kefa to find out, can he give out all his baloons, such that no one of his friens will be upset — print «YES», if he can, and «NO», otherwise. Note, that Kefa's friend will not upset, if he doesn't get baloons at all.

The first line contains two integers n and k (1 ≤ n, k ≤ 100) — the number of baloons and friends. Next line contains string s — colors of baloons.

Answer to the task — «YES» or «NO» in a single line. You can choose the case (lower or upper) for each letter arbitrary.

NoteIn the first sample Kefa can give 1-st and 3-rd baloon to the first friend, and 2-nd and 4-th to the second.In the second sample Kefa needs to give to all his friends baloons of color a, but one baloon will stay, thats why answer is «NO».

n,k=gets.split.map &:to_i
h=Hash.new 0
gets.chomp.chars{|c|h[c]+=1}
puts h.values.any?{|e|e>k} ? :NO : :YES

n, k = gets.strip.split.map(&:to_i)
s = gets.strip
ans = "YES"
count = Array.new(26, 0)
n.times do |i|
    count[s[i].ord - 'a'.ord] += 1
end
max_count = count.max
ans = "NO" if max_count > k
puts ans

n,f=gets.split.map{|e| e.to_i}

hs=Hash.new(0)
gets.chomp.chars.each{|e|
	hs[e]+=1
}

v=hs.values.sort.pop

if v<=f then
	puts "YES"
else
	puts "NO"
end

n,k=gets.split.map(&:to_i)
s = gets.chomp
h = Hash.new(0)
s.chars do |c|
    h[c] += 1
end

f = true
[*?a..?z].each do |c|
    if h[c] == 0
        next
    elsif (h[c] - 1) / k > 0
        f = false
        break
    end
end
puts f ? "YES" : "NO"

a = Array.new(123, gets.split[1].to_i)
gets.chars{|c| a[c.ord] -= 1}
puts a.min < 0 ? :NO : :YES

n, k=gets.split.map(&:to_i)
s=gets.chomp.chars

h=Hash.new(0)
s.each{|c| h[c]+=1}
ok=true
h.each_value do |v|
  ok&=v<=k
end

puts ok ? 'YES' : 'NO'

n,f=gets.split.map{|e| e.to_i}

hs=Hash.new(0)
gets.chomp.chars.each{|e|
	hs[e]+=1
}

vs=hs.values
sum=0
while vs.size >1
	d=vs.shift
	vs=vs.map{|e|
		if d>=e then
			d-=e
			f-=e
			0
		else
			f-=d
			t=e-d
			d=0
			t
		end
	}.select{|e| e>0}
	vs.push(d) if d>0
end
if f<=0 then
	puts "YES"
else
	puts "NO"
end

n,f=gets.split.map{|e| e.to_i}

hs=Hash.new(0)
gets.chomp.chars.each{|e|
	hs[e]+=1
}

vs=hs.values
sum=0
while vs.size >1
	d=vs.shift
	vs=vs.map{|e|
		if d>=e then
			d-=e
			f-=e
			0
		else
			f-=d
			t=e-d
			d=0
			t
		end
	}.select{|e| e>0}
	vs.push(d) if d>0
end
if vs.empty? && f>=0 then
	puts "YES"
else
	puts "NO"
end

n,f=gets.split.map{|e| e.to_i}
hs=Hash.new(0)
gets.chomp.chars.each{|e|
	hs[e]+=1
}
hs.each{|k,v|
	f-=(v/2).to_i
}
if f<=0 then
	puts "YES"
else
	puts "NO"
end

n,k=gets.split.map(&:to_i)
s = gets.chomp
h = Hash.new(0)
s.chars do |c|
    h[c] += 1
end

f = true
[*?a..?z].each do |c|
    if h[c] % 2 == 1
        f = false
        break
    end
end
puts f ? "YES" : "NO"

a = Array.new(123, gets.split[1].to_i)
gets.chars{|c| a[c.ord] -= 1}
p a.min < 0 ? 'NO' : 'YES'


There are $$$n$$$ students in a university. The number of students is even. The $$$i$$$-th student has programming skill equal to $$$a_i$$$. The coach wants to form $$$\frac{n}{2}$$$ teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can form a team only if their skills are equal (otherwise they cannot understand each other and cannot form a team).Students can solve problems to increase their skill. One solved problem increases the skill by one.The coach wants to know the minimum total number of problems students should solve to form exactly $$$\frac{n}{2}$$$ teams (i.e. each pair of students should form a team). Your task is to find this number.

The first line of the input contains one integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of students. It is guaranteed that $$$n$$$ is even. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 100$$$), where $$$a_i$$$ is the skill of the $$$i$$$-th student.

Print one number — the minimum total number of problems students should solve to form exactly $$$\frac{n}{2}$$$ teams.

NoteIn the first example the optimal teams will be: $$$(3, 4)$$$, $$$(1, 6)$$$ and $$$(2, 5)$$$, where numbers in brackets are indices of students. Then, to form the first team the third student should solve $$$1$$$ problem, to form the second team nobody needs to solve problems and to form the third team the second student should solve $$$4$$$ problems so the answer is $$$1 + 4 = 5$$$.In the second example the first student should solve $$$99$$$ problems to form a team with the second one.

class Main
  #def get_problem_link
  #  problem_link = "https://codeforces.com/problemset/problem/1092/B"
  #  return problem_link
  #end

  #def get_submission_link
  #  submission_link = ''
  #  return submisson_link
  #end

  #begin
  #of codeforces interface
  def run_interface
    n = gets.to_i
    k = gets.split(' ').map(&:to_i)
    puts solution(n, k)
  end
  #end
  #of codeforces interface

  def solution(n, students_array)
      res = 0
      students_array.sort!
      (0...students_array.length).step(2).each do |i|
          res = res + (students_array[i+1]-students_array[i]);
      end
      return res
  end

end

#then upload to codeforces uncomment this line:
Main.new.run_interface

n = gets.to_i
a = gets.split.map(&:to_i)
a.sort!
ans = 0
(n/2).times do |i|
  ans += a[2*i+1] - a[2*i]
end
p ans

def solution
  count = read_int
  ss = read_ints.sort
  p ss.each_slice(2).map{ |a, b| b - a }.reduce(0, :+)
end

def read_int
  gets.to_i
end

def read_ints
  gets.split.map(&:to_i)
end

def read_string
  gets.chomp
end

solution unless ENV['TEST__MODE']

# Input
n = gets.to_i # 2 <= n <= 100
a = gets.split(" ").map! { |b| b.to_i } # 1 <= b <= 100

# Processing
a.sort!
pairs = Array.new(n / 2) { |i| [a[2 * i], a[2 * i + 1]] }
sum = pairs.inject(0) { |mem, p| mem + (p[1] - p[0]) }

# Output
puts sum

n = gets.to_i
as = gets.split.map(&:to_i).sort
ans = 0
(0..(n/2-1)).each do |i|
  ans += (as[2*i] - as[2*i+1]).abs
end
puts ans

n = gets.to_i
arr = gets.split.map(&:to_i).sort
res = 0
arr.each_slice(2) do |slice|
  res += slice[1] - slice[0]
end
puts res

n = gets.to_i
a = gets.split.map(&:to_i).sort
ans = 0
(n/2).times do |i|
    ans += a[i*2+1]-a[i*2]
end
puts ans

# coding: utf-8

# if __FILE == $0
# end

n = gets.to_i
skills = gets.split.map { |i| i.to_i }
deltas = 0
skills.sort.each_slice(2) { |a| deltas += a[1] - a[0] }
puts deltas

# https://codeforces.com/problemset/problem/1092/B

def solution(n, a)
  skills = {}
  (0..(n - 1)).each do |i|
    skills[a[i]] = skills.fetch(a[i], 0) + 1
  end

  h = nil

  problems = 0
  100.times do |x|
    i = 100 - x

    next       if !skills.key?(i)
    next       if skills[i] % 2 == 0
    next h = i if h.nil?

    problems += h - i

    h = nil
  end
  return problems
end

n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)

puts solution(n, a)

n = gets.to_i
a = gets.split.map(&:to_i).sort
i, s = 0, 0
while i < a.size
    s += a[i + 1] - a[i]
    i += 2
end
puts s


Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits.Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them.

The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has.

Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros.

#!/usr/bin/ruby
n=gets.chomp
p [n,*(1...n.size).map{|i|
	(n[0,i].to_i-1).to_s+'9'*(n.size-i)
}].max_by{|e|[e.chars.map(&:to_i).reduce(:+),e.to_i]}.to_i

def sum(x)
    x.split('').map(&:to_i).inject(0) { |sum, x| sum + x }
end

x = gets.to_i

sx = x.to_s

ans = x
sans = sx

sx.length.times do |i|
    sy = sx[0...i] + (sx[i].to_i - 1).to_s + '9' * (sx.length - i - 1)

    y = sy.to_i
    sy = y.to_s

    if (sum(sy) > sum(sans) || (sum(sy) == sum(sans) && y > ans))
        ans = y
        sans = sy
    end
end

puts sans

#!/usr/bin/ruby
n=gets.chomp
puts [n,*(1...n.size).map{|i|
	(n[0,i].to_i-1).to_s+'9'*(n.size-i)
}].max_by{|e|[e.chars.map(&:to_i).reduce(:+),e.to_i]}

#!/usr/bin/ruby
n=gets.to_i
r=0
d=1
while r<=n
	r=r*10+9
	d*=10
end
d/=10
r-=d while r>n
p [n,r].max_by{|e|[e.to_s.chars.map(&:to_i).reduce(:+),e]}

#!/usr/bin/ruby
n=gets.chomp
puts [n,*(1...n.size).map{|i|
	(n[0,i].to_i-1).to_s+'9'*(n.size-i)
}].max_by{|e|[e.chars.map(&:to_i).reduce(:+),e.to_i,e]}


Not long ago Billy came across such a problem, where there were given three natural numbers A, B and C from the range [1, N], and it was asked to check whether the equation AB = C is correct. Recently Billy studied the concept of a digital root of a number. We should remind you that a digital root d(x) of the number x is the sum s(x) of all the digits of this number, if s(x) ≤ 9, otherwise it is d(s(x)). For example, a digital root of the number 6543 is calculated as follows: d(6543) = d(6 + 5 + 4 + 3) = d(18) = 9. Billy has counted that the digital root of a product of numbers is equal to the digital root of the product of the factors' digital roots, i.e. d(xy) = d(d(x)d(y)). And the following solution to the problem came to his mind: to calculate the digital roots and check if this condition is met. However, Billy has doubts that this condition is sufficient. That's why he asks you to find out the amount of test examples for the given problem such that the algorithm proposed by Billy makes mistakes.

The first line contains the only number N (1 ≤ N ≤ 106).

Output one number — the amount of required A, B and C from the range [1, N].

NoteFor the first sample the required triples are (3, 4, 3) and (4, 3, 3).


Those days, many boys use beautiful girls' photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat with a beauty (he thought so). After that they talked very often and eventually they became a couple in the network. But yesterday, he came to see "her" in the real world and found out "she" is actually a very strong man! Our hero is very sad and he is too tired to love again now. So he came up with a way to recognize users' genders by their user names.This is his method: if the number of distinct characters in one's user name is odd, then he is a male, otherwise she is a female. You are given the string that denotes the user name, please help our hero to determine the gender of this user by his method.

The first line contains a non-empty string, that contains only lowercase English letters — the user name. This string contains at most 100 letters.

If it is a female by our hero's method, print "CHAT WITH HER!" (without the quotes), otherwise, print "IGNORE HIM!" (without the quotes).

CHAT WITH HER!
IGNORE HIM!
CHAT WITH HER!

NoteFor the first example. There are 6 distinct characters in "wjmzbmr". These characters are: "w", "j", "m", "z", "b", "r". So wjmzbmr is a female and you should print "CHAT WITH HER!".

  x = gets.chomp
  hash = Hash.new
  x.each_char do |c|
    hash[c] = 0 if hash[c] == nil
    hash[c] += 1
  end
  puts "CHAT WITH HER!" if hash.count % 2 == 0
  puts "IGNORE HIM!" if hash.count % 2 != 0

#$stdin=File.open('input.txt')
#$stdout=File.open('output.txt', 'w')
s=gets.to_s
a=Array.new
for i in 1..s.size-1
	a<<s[i-1]
end
if a.uniq.size%2==0 then
	puts "CHAT WITH HER!"
	else
	puts "IGNORE HIM!"
end

$><<["IGNORE HIM!","CHAT WITH HER!"][gets.chars.uniq.size%2]

#rextester.com:2.3.1--codeforces.com:2.0.0p645
puts gets.chomp.chars.uniq.size%2==0?'CHAT WITH HER!':'IGNORE HIM!'

inp = gets.chomp
if inp.split('').uniq.length.odd?
  puts 'IGNORE HIM!'
else
  puts 'CHAT WITH HER!'
end

puts gets.split(//).uniq.size.odd? ? 'CHAT WITH HER!' : 'IGNORE HIM!'

username = gets.chomp
puts (username.split(//).uniq.length % 2 == 1)? "IGNORE HIM!" : "CHAT WITH HER!"

s = gets.chomp.chars
puts s.uniq.count.odd? ? "IGNORE HIM!" : "CHAT WITH HER!"

puts gets.chomp.chars.uniq.size.even? ? 'CHAT WITH HER!': 'IGNORE HIM!'

# http://codeforces.com/problemset/problem/236/A

username = gets.chomp

if username.chars.to_a.uniq.length % 2 == 0
  puts "CHAT WITH HER!"
else
  puts "IGNORE HIM!"
end

name = gets.chomp

puts name.chars.sort.uniq.size.even? ? 'CHAT WITH HER!' : 'IGNORE HIM!'

str = gets.chomp
if str.chars.uniq.size.even?
    puts "CHAT WITH HER!"
else
    puts "IGNORE HIM!"
end

x = gets
h = {}
x.split("").each { |e|
    h[e]=1
}
if !h.keys.count.odd?
    puts "IGNORE HIM!"
  else
    puts "CHAT WITH HER!"
end

puts gets.chomp.split("").uniq.count.even? ?  'CHAT WITH HER!' : 'IGNORE HIM!'

username = gets.strip
L = username.length
check = Array.new(26, false)
for i in 0...L
  check[username[i].ord-97] = true
end
count = 0
for i in 0...26
  count += 1 if check[i]
end
if count%2 == 1
  print "IGNORE HIM!"
else
  print "CHAT WITH HER!"
end

require 'set'
name = gets.split(//)
s = Set.new
name.each do |char|
  s.add(char)
end
if s.size.even?
  puts "IGNORE HIM!"
else
  puts "CHAT WITH HER!"
end

def BoyOrGirl(str)
  puts str.chars.uniq.length % 2 == 0 ? "CHAT WITH HER!" : "IGNORE HIM!"
end

str = gets.chomp
BoyOrGirl(str)

if (gets.chomp.split(//).uniq.size % 2) == 1
print "IGNORE HIM!\n"
else
print "CHAT WITH HER!\n"
end

puts gets.split('').uniq.size.odd? ? 'CHAT WITH HER!' : 'IGNORE HIM!'

puts ["IGNORE HIM!","CHAT WITH HER!"][gets.chars.uniq.size[0]]

puts gets.chomp.split("").uniq.join.length.%(2).to_s.include?("1")?"IGNORE HIM!":"CHAT WITH HER!"

user_name = gets.chomp
i = 0
char_arr = []

while i < user_name.length do
    if char_arr.index(user_name.split('')[i]) == nil then
	char_arr.push(user_name.split('')[i])
    end
    i+=1
end
if char_arr.length % 2 == 0 then
    print 'CHAT WITH HER!'
elsif
    print 'IGNORE HIM!'
end

puts (gets.split(//).uniq.count.even?) ? "IGNORE HIM!" : "CHAT WITH HER!"

$><<["IGNORE HIM!","CHAT WITH HER!"][gets.chars.uniq.size%2]

puts gets.split('').sort.uniq.size % 2==1 ? "CHAT WITH HER!" : "IGNORE HIM!"

input = gets
puts input.split(//).uniq.count % 2 == 0 ? 'IGNORE HIM!' : 'CHAT WITH HER!'

puts (gets.strip.split('').uniq.size.odd?)?'IGNORE HIM!':'CHAT WITH HER!'

w = gets.chomp
if w.scan(/./).uniq.size % 2 == 0
  puts "CHAT WITH HER!"
else
  puts "IGNORE HIM!"
end

#!/usr/bin/ruby

str = gets.chomp
cnt = str.each_char.to_a.uniq.size
if cnt.even?
    puts "CHAT WITH HER!"
else
    puts "IGNORE HIM!"
end

s = gets.strip.split("").uniq
ans = s.length.odd?
puts ans ? "IGNORE HIM!" : "CHAT WITH HER!"

printf(gets.chomp.each_char.to_a.uniq.size.odd? ? 'IGNORE HIM!' : 'CHAT WITH HER!')

#rextester.com:2.3.1--codeforces.com:2.0.0p645
puts gets.chomp.chars.uniq.length%2==0?'CHAT WITH HER!':'IGNORE HIM!'

if gets.chars.to_a.uniq.size % 2 == 0 then puts 'IGNORE HIM!'
else puts 'CHAT WITH HER!'
end

puts gets.chomp.chars.uniq.size%2!=0 ? "IGNORE HIM!" : "CHAT WITH HER!"

name = gets.strip()
if name.size() <= 100
    array_of_characters = name.chars.uniq
	if array_of_characters.size % 2 == 0
		puts "CHAT WITH HER!"
	else
		puts "IGNORE HIM!"
	end
end

if gets.chomp.split(//).uniq.size % 2 == 0 then puts "CHAT WITH HER!" else puts "IGNORE HIM!" end

puts ['IGNORE HIM!','CHAT WITH HER!'][gets.chars.to_a.uniq.size%2]

puts gets.chomp.split("").uniq.count.even? ?  'CHAT WITH HER!' : 'IGNORE HIM!'

if gets.chomp.split("").uniq.size.odd?
 puts "IGNORE HIM!"
else
 puts "CHAT WITH HER!"
end

# Codeforces Round #146
# Problem A -- Boy or Girl
puts gets.split(//).uniq.size.odd? ? "CHAT WITH HER!" : "IGNORE HIM!"

if gets.strip.split('').to_a.uniq.size % 2 == 0
  puts "CHAT WITH HER!"
else
  puts "IGNORE HIM!"
end

#!/usr/bin/ruby
puts ['IGNORE HIM!','CHAT WITH HER!'][gets.chars.uniq.size%2]

def tram ()
  n = gets.chomp
  n = n.split("")
  n = n.uniq
  if n.length % 2 == 0
    print "CHAT WITH HER!"
  else
    print "IGNORE HIM!"
  end
end

tram

if gets.chomp.split(//).uniq.count.odd?
  puts "IGNORE HIM!"
else
  puts "CHAT WITH HER!"
end

name = gets.strip
registered_char = []
counter = 0

name.each_char do |char|
  next if registered_char.include?(char)

  registered_char.push(char)
  counter += 1
end

if counter.odd?
  puts 'IGNORE HIM!'
else
  puts 'CHAT WITH HER!'
end

puts STDIN.read.strip.split(//).uniq.length % 2 == 0 ?  "CHAT WITH HER!" : "IGNORE HIM!"

puts (gets.chomp.split('').uniq.length.odd?) ? "IGNORE HIM!" : "CHAT WITH HER!"

$><<["IGNORE HIM!","CHAT WITH HER!"][gets.chars.uniq.size%2]

puts gets.split('').sort.uniq.size % 2==1 ? "CHAT WITH HER!" : "IGNORE HIM!"

hashed = Hash.new(0)
inp = gets.chomp.split("").each { |item| hashed[item] += 1 }
if hashed.size % 2 == 0
 puts "CHAT WITH HER!"
else
  puts "IGNORE HIM!"
end

puts ['IGNORE HIM!','CHAT WITH HER!'][gets.split('').uniq.size%2]

puts gets.split(//).uniq.size.odd? ? 'CHAT WITH HER!' : 'IGNORE HIM!'

if gets.chomp.split(//).uniq.size % 2 == 0 then puts "CHAT WITH HER!" else puts "IGNORE HIM!" end

puts ["CHAT WITH HER!", "IGNORE HIM!"][gets.chomp.chars.to_a.uniq{|x| x}.length.odd? ? 1 : 0]

if gets.chomp.split('').uniq.size%2 == 0
  puts "CHAT WITH HER!"
else
  puts "IGNORE HIM!"
end

puts gets.chomp.chars.uniq.size % 2 == 0 ? "CHAT WITH HER!" : "IGNORE HIM!"

puts gets.split('').uniq.size.odd? ? 'CHAT WITH HER!' : 'IGNORE HIM!'

u = $stdin.readline.scan(/./).uniq

if u.count % 2 == 1
    puts "IGNORE HIM!"
else
    puts "CHAT WITH HER!"
end

s = gets.split(//).uniq
puts (s.length % 2 == 1) ? "CHAT WITH HER!"  : "IGNORE HIM!"

name = gets.chomp
amount = Array.new(26, 0)
name.split("").each { |char| amount[char.ord - 97] += 1 }
cnt = 0
amount.each { |tmp| cnt += 1 if tmp > 0 }
if cnt.even?
	puts "CHAT WITH HER!"
else
	puts "IGNORE HIM!"
end

puts gets.chomp.chars.uniq.size.even? ? 'CHAT WITH HER!': 'IGNORE HIM!'

puts ['CHAT WITH HER!','IGNORE HIM!'][gets.strip.split('').uniq.join('').length%2]

puts (gets.strip.split('').uniq.size.odd?)?'IGNORE HIM!':'CHAT WITH HER!'

string = gets.chomp.split("")

arr = []
for i in (0..string.size-1)
	if arr.include?(string[i]) == false
		arr << string[i]
	end
end

if arr.count % 2 == 0
	print "CHAT WITH HER!"
else
	print "IGNORE HIM!"
end

$><<["IGNORE HIM!","CHAT WITH HER!"][gets.chars.uniq.size%2]

puts gets.chomp.split(//).uniq.count.even? ? 'CHAT WITH HER!' : 'IGNORE HIM!'

printf (gets.chomp.each_char.to_a.uniq.size % 2 == 0) ? 'CHAT WITH HER!' : 'IGNORE HIM!'

puts (gets[0..-2].chars.to_a.uniq.count % 2 == 0 ? "CHAT WITH HER!" : "IGNORE HIM!")

puts gets.chomp.split("").uniq.length.even? ? "CHAT WITH HER!" : "IGNORE HIM!"

if gets.chomp.split(//).uniq.count.odd?
  puts "IGNORE HIM!"
else
  puts "CHAT WITH HER!"
end

#rextester.com:2.3.1--codeforces.com:2.0.0p645
puts(gets.chars.uniq.size%2==0?'CHAT WITH HER':'IGNORE HIM')

#rextester.com:2.3.1--codeforces.com:2.0.0p645
puts gets.chars.uniq.size%2?'IGNORE HIM':'CHAT WITH HER'

#rextester.com:2.3.1--codeforces.com:2.0.0p645
puts(gets.chars.uniq.length%2==0?"CHAT WITH HER":"IGNORE HIM")

#rextester.com:2.3.1--codeforces.com:2.0.0p645
puts gets.chars.uniq.size%2==0?'CHAT WITH HER':'IGNORE HIM'

#rextester.com:2.3.1--codeforces.com:2.0.0p645
puts(gets.chomp.chars.uniq.length%2==0?'CHAT WITH HER':'IGNORE HIM')

#rextester.com:2.3.1--codeforces.com:2.0.0p645
puts gets.chomp.split(//).uniq.length%2==0?'CHAT WITH HER':'IGNORE HIM'

#rextester.com:2.3.1--codeforces.com:2.0.0p645
puts gets.split(//).uniq.length%2==0?'CHAT WITH HER':'IGNORE HIM'

#rextester.com:2.3.1--codeforces.com:2.0.0p645
puts(gets.chars.uniq.length%2==0?'CHAT WITH HER':'IGNORE HIM')

require "set"

set = Set.new(gets.chars)
set.each {|x| puts x}
if set.size() % 2 == 0
  puts "CHAT WITH HER!"
else
  puts "IGNORE HIM!"
end

require "set"

set = Set.new(gets.chop.chars)
set.each {|x| puts x}
if set.size() % 2 == 0
  puts "CHAT WITH HER!"
else
  puts "IGNORE HIM!"
end

require "set"

s = gets
set = Set.new
s.each_char {|c| set << c}
if s.size() % 2 == 0
  puts "CHAT WITH HER!"
else
  puts "IGNORE HIM!"
end

uname = gets.chomp
username = uname.split("")

count = uname.length.to_i
username.each do |n|
	count = count - username.count(n) + 1
	if username.count(n) != 1
		i = username.index(n)
		while i < uname.length.to_i
			if n == username[i+1]
				username.delete_at(i+1)
			end
			i += 1
		end
	end
end

if username.size%2 == 0
	puts "CHAT WITH HER!"
else
	puts "IGNORE HIM!"
end

uname = gets.chomp
username = uname.split("")

count = uname.length.to_i
username.each do |n|
	count = count - username.count(n) + 1
	if username.count(n) > 1
		i = username.index(n)
		while i < uname.length.to_i - 1
			if n == username[i+1]
				username.delete_at(i+1)
			end
			i += 1
		end
	end
end
puts username.size
if username.size%2 == 0
	puts "CHAT WITH HER!"
else
	puts "IGNORE HIM!"
end

uname = gets.chomp
username = uname.split("")

i = 0
count = uname.length.to_i
username.each do |n|
	count = count - username.count(n) + 1
	if username.count(n) != 1
		i = username.index(n)
		while i < uname.length.to_i
			if n == username[i]
				username.delete_at(i)
			end
			i += 1
		end
	end
end

if count%2 == 0
	puts "CHAT WITH HER!"
else
	puts "IGNORE HIM!"
end

uname = gets.chomp
username = uname.split("")

count = uname.length.to_i
username.each do |n|
	count = count - username.count(n) + 1
	if username.count(n) > 1
		i = username.index(n)
		while i < uname.length.to_i - 1
			if n == username[i+1]
				username.delete_at(i+1)
			end
			i += 1
		end
	end
end
if username.size%2 == 0
	puts "CHAT WITH HER!"
else
	puts "IGNORE HIM!"
end

uname = gets.chomp
username = uname.split("")

i = 0
count = uname.length.to_i
username.each do |n|
	count = count - username.count(n) + 1
	if username.count(n) != 1
		i = username.index(n)
		while i+1 < uname.length.to_i
			if n == username[i+1]
				username.delete_at(i+1)
			end
			i += 1
		end
	end
end

if count%2 == 0
	puts "CHAT WITH HER!"
else
	puts "IGNORE HIM!"
end

x = gets
h = {}
x.split("").each { |e|
    h[e]=1
}
if h.keys.count.odd?
    puts "IGNORE HIM!"
  else
    puts "CHAT WITH HER!"
end

# http://codeforces.com/problemset/problem/236/A

chars = gets.chomp
already = {}
dups = 0
chars.each_char do |c|
  if already[c] == true
    dups = dups + 1
  else
    already[c] = true
  end
end

uniq = chars.length - dups

if uniq % 2 == 0
  p 'CHAT WITH HER!'
else
  p 'IGNORE HIM!'
end

inp = gets.chomp
if inp.length.odd?
  puts 'CHAT WITH HER!'
else
  puts 'IGNORE HIM!'
end

inp = gets.chomp
if inp.length.odd?
  p 'CHAT WITH HER!'
else
  p 'IGNORE HIM!'
end

inp = gets.chomp
if inp.split('').uniq.length.odd?
  puts 'CHAT WITH HER!'
else
  puts 'IGNORE HIM!'
end

inp = gets.chomp
if inp.length.odd?
  p 'IGNORE HIM!'
else
  p 'CHAT WITH HER!'
end

puts ['IGNORE HIM!','CHAT WITH HER!'][gets.strip.length%2]

h = {}
gets.split('').each { |c| h[c] = 1 }
puts h.keys.count.even? ? 'CHAT WITH HER!' : 'IGNORE HIM!'

puts gets.split('').uniq.size.even? ? 'CHAT WITH HER!' : 'IGNORE HIM!'

a=gets.chomp
0.upto(a.length-1) do |i|
(i+1).upto(a.length-1) do|j|
if a[i] ==a [j]
a=a[0..j-1]+a[j+1..a.length-1]
end
end
end
if a.length%2==0
puts "CHAT WITH HER!"
else
puts "IGNORE HIM!"
end

p(gets.chomp.each_char.to_a.uniq.size % 2 == 0 ? 'CHAT WITH HER!' : 'IGNORE HIM!')

output = (gets.chomp.each_char.to_a.uniq.size % 2 == 0) ? 'CHAT WITH HER!' : 'IGNORE HIM!'
p output

p(gets.chomp.each_char.to_a.uniq.size % 2 == 0 ? "CHAT WITH HER!" : "IGNORE HIM!")

n = gets.to_s
ar = []
ar = n.split("").map(&:to_s)
j = ar.uniq.count

if j%2 == 0
        puts "CHAT WITH HER!"
else
        puts "IGNORE HIM!"
end
puts j

n = gets.to_s
ar = []
ar = n.split("").map(&:to_s)
j = ar.uniq.count-1

if j%2 == 0
        puts "CHAT WITH HER!"
else
        puts "IGNORE HIM!"
end
puts j

n = gets.to_s
ar = []
ar = n.split("").map(&:to_s)
j = ar.uniq.count - 1

if j%2 == 0
        puts "CHAT WITH HER!"
else
        puts "IGNORE HIM!"
end
puts j

s = gets.split(//).uniq!
puts (s.length % 2 == 1) ? "CHAT WITH HER!"  : "CHAT WITH HIM!"

# while (s=gets.chomp()) != "42" do puts s end

s=gets.chomp()
c= s.split(//).uniq
# s.to_a
# c=b.uniq

# a=s.uniq
if c.length%2==0
    puts "IGNORE HIM!"
else
    puts "CHAT WITH HER!"
end

# while (s=gets.chomp()) != "42" do puts s end

s=gets.chomp()
c= s.split(//).uniq
# s.to_a
# c=b.uniq

# a=s.uniq
puts c.length
if c.length%2==0
     puts "CHAT WITH HER!"
else

    puts "IGNORE HIM!"
end

name = gets.strip()
if name.size() <= 100
	if name.size() % 2 == 0
		puts "CHAR WITH HER!"
	else
		puts "IGNORE HIM!"
	end
end

name = gets.strip()
if name.size() <= 100
    array_of_characters = name.chars.uniq
	if array_of_characters.size % 2 == 0
		puts "CHAR WITH HER!"
	else
		puts "IGNORE HIM!"
	end
end

puts ["CHAT WITH HER!","IGNORE HIM!"][gets.chars.uniq.size[0]]

puts ["CHAT WITH HER!","IGNORE HIM!"]["ab".chars.uniq.size[0]]

puts gets.chomp.length.even? ? "CHAT WITH HER!" : "IGNORE HIM"

#$stdin=File.open('input.txt')
#$stdout=File.open('output.txt', 'w')
s=gets.to_s
if s.size%2==0 then
puts "CHAT WITH HER!"
else
puts "IGNORE HIM!"
end

#$stdin=File.open('input.txt')
#$stdout=File.open('output.txt', 'w')
s=gets.to_s
if s.size%2!=0 then
puts "CHAT WITH HER!"
else
puts "IGNORE HIM!"
end

p(gets.chomp.split.uniq.size.odd? ? 'IGNORE HIM!' : 'CHAT WITH HER!')

str = gets.chomp.each_char
p(str.take(str.count).size.odd? ? 'IGNORE HIM!' : 'CHAT WITH HER!')

p(gets.chomp.each_char.to_a.uniq.size.odd? ? 'IGNORE HIM!' : 'CHAT WITH HER!')


You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.Initially, you have an empty string. Until you type the whole string, you may perform the following operation:  add a character to the end of the string. Besides, at most once you may perform one additional operation: copy the string and append it to itself.For example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.If you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.Print the minimum number of operations you need to type the given string.

The first line of the input containing only one integer number n (1 ≤ n ≤ 100) — the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.

Print one integer number — the minimum number of operations you need to type the given string.

NoteThe first test described in the problem statement.In the second test you can only type all the characters one by one.

n = gets.to_i
s = gets.strip
d = Array.new(n + 1) { [Float::INFINITY] * 2 }
d[0][0] = 0
n.times do |i|
  2.times do |j|
    d[i + 1][j] = [d[i + 1][j], d[i][j] + 1].min
  end
  if i + i <= n && s[0, i] == s[i, i]
    d[i + i][1] = [d[i + i][1], d[i][0] + 1].min
  end
end
p d[-1].min

n = gets.to_i
s = gets.chomp
max = 0
for i in 0..n / 2
	max = s[0..i] == s[i + 1..i * 2 + 1] ? i : max
end
puts n - max

n = gets.to_i - 1
s = gets.chomp
max = 0
for i in 0..n / 2
	max = s[i+1..n+1][s[0..i]] != nil ? i : max
end
puts n - max + 1

n = gets.to_i - 1
s = gets.chomp
max = 0
for i in 0..n / 2
	max = s[s[0..i] * 2] != nil ? i : max
end
puts n - max + 1