Language: C++

#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
"\\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\"

=end
class Main
  def initialize()

    #fh = open("/home/muz/Downloads/ALDS1_3_D_in9.txt")
    fh = STDIN
    s = fh.gets.chomp
    t = s.gsub(/\\/,"D").gsub(/\//,"U").gsub(/_/,"F")
    u=t.split(//)
    xsize = t.length
    matsize = [t.gsub(/[^D]/,"").length, t.gsub(/[^U]/,"").length].max*2+1

    #matsize=6000
    #puts "u size=#{u.length}"
    #puts "xsize=#{xsize}"
    #puts "matsize=#{matsize}"
#    exit
    start=matsize/2
    mt = Array.new(xsize).map{Array.new(matsize, " ")}

    v= u.dup
    x=0
    y=start
    while c = v.shift do
      if c=="D" then
        mt[x][y]="D"
        y = y + 1
      elsif c=="F" then
        mt[x][y]="F"
        y = y
      elsif c=="U" then
        y = y - 1
        mt[x][y]="U"
      else
        abort("Unknown:#{c}")
      end
      x = x + 1
    end

    p = []
    0.upto(mt[0].length-1){|y|
      st = false
      x0=-9999
      0.upto(xsize-1){|x|
        if (not st) and mt[x][y] == "D" then
          st=true
          x0=x
        elsif st and mt[x][y] == "U" then
          p.push([x0, (x-x0)])
          st = false
        end
      }
    }

    if p.length ==0 then
      puts 0 
      puts 0
    else
      rst=[]
      q = p.sort{|a,b| a[0]<=>b[0]}
      st=false
      x1=q[0][0] + q[0][1]
      v=q[0][1]
      1.upto(q.length-1){|i|
        if q[i][0]<=x1 then
          st=true
          v += q[i][1]
        else
          st=false
          rst.push(v)
          x1=q[i][0]+ q[i][1]
          v=q[i][1]
        end
      }
      rst.push(v)
      puts rst.inject(0){|acc,x| acc+x}
      print rst.length
      print " "
      puts rst.map{|x| x.to_s}.join(" ")
    end
  end
end

if $0==__FILE__ then
  Main.new()
end

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #!/usr/bin/ruby
      |  ^
a.cc:2:3: error: invalid preprocessing directive #-
    2 | # -*- coding: utf-8 -*-
      |   ^
a.cc:4:1: warning: missing terminating " character
    4 | "\\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\"
      | ^
a.cc:4:1: error: missing terminating " character
    4 | "\\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\"
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:10:6: error: invalid preprocessing directive #fh
   10 |     #fh = open("/home/muz/Downloads/ALDS1_3_D_in9.txt")
      |      ^~
a.cc:13:17: error: stray '\' in program
   13 |     t = s.gsub(/\\/,"D").gsub(/\//,"U").gsub(/_/,"F")
      |                 ^
a.cc:13:18: error: stray '\' in program
   13 |     t = s.gsub(/\\/,"D").gsub(/\//,"U").gsub(/_/,"F")
      |                  ^
a.cc:13:32: error: stray '\' in program
   13 |     t = s.gsub(/\\/,"D").gsub(/\//,"U").gsub(/_/,"F")
      |                                ^
a.cc:18:6: error: invalid preprocessing directive #matsize
   18 |     #matsize=6000
      |      ^~~~~~~
a.cc:19:6: error: invalid preprocessing directive #puts
   19 |     #puts "u size=#{u.length}"
      |      ^~~~
a.cc:20:6: error: invalid preprocessing directive #puts
   20 |     #puts "xsize=#{xsize}"
      |      ^~~~
a.cc:21:6: error: invalid preprocessing directive #puts
   21 |     #puts "matsize=#{matsize}"
      |      ^~~~
a.cc:22:6: error: invalid preprocessing directive #exit
   22 | #    exit
      |      ^~~~
a.cc:3:1: error: expected unqualified-id before '=' token
    3 | =begin
      | ^
a.cc:26:5: error: 'v' does not name a type
   26 |     v= u.dup
      |     ^
a.cc:60:5: error: expected unqualified-id before 'if'
   60 |     if p.length ==0 then
      |     ^~
a.cc:66:7: error: 'st' does not name a type
   66 |       st=false
      |       ^~
a.cc:80:7: error: 'rst' does not name a type
   80 |       rst.push(v)
      |       ^~~
a.cc:82:7: error: 'print' does not name a type; did you mean 'int'?
   82 |       print rst.length
      |       ^~~~~
      |       int
a.cc:84:31: error: expected unqualified-id before '.' token
   84 |       puts rst.map{|x| x.to_s}.join(" ")
      |                               ^