using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
public static class Test
{
private static IEnumerable<string> GraphemeClusters(this string s) {
var enumerator = StringInfo.GetTextElementEnumerator(s);
while(enumerator.MoveNext()) {
yield return (string)enumerator.Current;
}
}
private static string ReverseGraphemeClusters(this string s) {
return string.Join("", s.GraphemeClusters().Reverse().ToArray());
}
public static void Main()
{
var s = "Les Mise\u0301rables";
var r = s.ReverseGraphemeClusters();
Console.WriteLine(r);
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLkdsb2JhbGl6YXRpb247CnVzaW5nIFN5c3RlbS5MaW5xOwoKcHVibGljIHN0YXRpYyBjbGFzcyBUZXN0CnsKICAgIHByaXZhdGUgc3RhdGljIElFbnVtZXJhYmxlPHN0cmluZz4gR3JhcGhlbWVDbHVzdGVycyh0aGlzIHN0cmluZyBzKSB7CiAgICAgICAgdmFyIGVudW1lcmF0b3IgPSBTdHJpbmdJbmZvLkdldFRleHRFbGVtZW50RW51bWVyYXRvcihzKTsKICAgICAgICB3aGlsZShlbnVtZXJhdG9yLk1vdmVOZXh0KCkpIHsKICAgICAgICAgICAgeWllbGQgcmV0dXJuIChzdHJpbmcpZW51bWVyYXRvci5DdXJyZW50OwogICAgICAgIH0KICAgIH0KICAgIHByaXZhdGUgc3RhdGljIHN0cmluZyBSZXZlcnNlR3JhcGhlbWVDbHVzdGVycyh0aGlzIHN0cmluZyBzKSB7CiAgICAgICAgcmV0dXJuIHN0cmluZy5Kb2luKCIiLCBzLkdyYXBoZW1lQ2x1c3RlcnMoKS5SZXZlcnNlKCkuVG9BcnJheSgpKTsKICAgIH0KICAgIAoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewoJCXZhciBzID0gIkxlcyBNaXNlXHUwMzAxcmFibGVzIjsKICAgICAgICB2YXIgciA9IHMuUmV2ZXJzZUdyYXBoZW1lQ2x1c3RlcnMoKTsKICAgICAgICBDb25zb2xlLldyaXRlTGluZShyKTsKCX0KfQ==