<?php
0 => 'ноль', 10 => 'десять', 100 => 'сто',
1 => 'один', 11 => 'одиннадцать', 20 => 'двадцать', 200 => 'двести',
2 => 'два', 12 => 'двенадцать', 30 => 'тридцать', 300 => 'триста',
3 => 'три', 13 => 'тринадцать', 40 => 'сорок', 400 => 'четыреста',
4 => 'четыре', 14 => 'четырнадцать', 50 => 'пятьдесят', 500 => 'пятьсот',
5 => 'пять', 15 => 'пятнадцать', 60 => 'шестьдесят', 600 => 'шестьсот',
6 => 'шесть', 16 => 'шестнадцать', 70 => 'семьдесят', 700 => 'семьсот',
7 => 'семь', 17 => 'семнадцать', 80 => 'восемьдесят', 800 => 'восемьсот',
8 => 'восемь', 18 => 'восемнадцать', 90 => 'девяносто', 900 => 'девятьсот',
9 => 'девять', 19 => 'девятнадцать'
);
1 => 'одна', 2 => 'две'
);
1 => 'один', 2 => 'два'
);
'рубля' => array(2, 3, 4), 'рублей' => array(0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900) );
'тысячи' => array(2, 3, 4), 'тысяч' => array(0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900) );
'миллиона' => array(2, 3, 4), 'миллионов' => array(0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900) );
function findMatch($num, $spelling) {
$result = 0;
foreach ($spelling as $numbers => $numbersInWords) {
if ($num == $numbers) {
$result = $numbersInWords;
return $result;
}
}
}
function getRoubles($num, $roubles) {
foreach ($roubles as $forms => $numerals) {
foreach ($numerals as $array => $numeral) {
if ($num == $numeral) {
return $forms;
}
}
}
}
function threeNumeralsToText($num, $number, $spelling, $roubles, $i, $x, $femaleSpelling) {
foreach ($spelling as $numbers => $numbersInWords) {
if ($num == $numbers) { // Если число соответствует иммеющимс в массиве $spelling - выводим их и форму рублей.
$result = $numbersInWords;
$rouble = getRoubles($num, $roubles);
$i++;
}
}
if ($i > 0) {
$numeralsInWords = $result.' '.$rouble;
} else {
$firstNumeral = floor($num / 100); //находим первое число в сотне $hundred = $firstNumeral * 100;
$num = $hundred;
$hundredInWords = findMatch($num, $spelling);
$ten = $number - $hundred; // Получаем десятки
$num = $ten;
if ($num == 0) {
} else {
foreach ($spelling as $numbers => $numbersInWords) {
if ($num == $numbers) {
$result = $numbersInWords;
if ($num == 1) {
$result = findMatch($num, $femaleSpelling);
}
if ($num == 2) {
$result = findMatch($num, $femaleSpelling);
}
$rouble = getRoubles($num, $roubles);
$x++;
}
}
}
if ($x > 0) {
$numeralsInWords = $hundredInWords.' '.$result.' '.$rouble;
} else {
$tenWithoutOne = floor(($number - $hundred) / 10) * 10; $num = $tenWithoutOne;
$tenWithoutOneInWords = findMatch($num, $spelling);
$one = $number - ($hundred + $tenWithoutOne);
$num = $one;
$oneInWords = findMatch($num, $spelling);
if ($num == 1) {
$oneInWords = findMatch($num, $femaleSpelling);
}
if ($num == 2) {
$oneInWords = findMatch($num, $femaleSpelling);
}
$rouble = getRoubles($num, $roubles);
$numeralsInWords = $hundredInWords.' '.$tenWithoutOneInWords.' '.$oneInWords.' '.$rouble;
}
}
return $numeralsInWords;
}
function twoNumeralsToText($num, $number, $spelling, $roubles, $i, $x, $femaleSpelling) {
foreach ($spelling as $numbers => $numbersInWords) {
if ($num == $numbers) { // Если число соответствует иммеющимс в массиве $spelling - выводим их и форму рублей.
$result = $numbersInWords;
if ($num == 1) {
$result = findMatch($num, $femaleSpelling);
}
if ($num == 2) {
$result = findMatch($num, $femaleSpelling);
}
$rouble = getRoubles($num, $roubles);
$i++;
}
}
if ($i > 0) {
$numeralsInWords = $result.' '.$rouble;
} else {
$firstNumeral = floor($num / 10); //находим первое число в десятке $ten = $firstNumeral * 10;
$num = $ten;
$tenInWords = findMatch($num, $spelling);
$one = $number - $ten;
$num = $one;
$oneInWords = findMatch($num, $spelling);
$result = $oneInWords;
if ($num == 1) {
$oneInWords = findMatch($num, $femaleSpelling);
}
if ($num == 2) {
$oneInWords = findMatch($num, $femaleSpelling);
}
$rouble = getRoubles($num, $roubles);
$numeralsInWords = $tenInWords.' '.$oneInWords.' '.$rouble;
}
return $numeralsInWords;
}
function oneNumeralToText($num, $number, $spelling, $roubles, $femaleSpelling) {
foreach ($spelling as $numbers => $numbersInWords) {
if ($num == $numbers) { // Если число соответствует иммеющимс в массиве $spelling - выводим их и форму рублей.
$result = $numbersInWords;
$rouble = getRoubles($num, $roubles);
if ($num == 1) {
$result = findMatch($num, $femaleSpelling);
}
if ($num == 2) {
$result = findMatch($num, $femaleSpelling);
}
}
}
$numeralsInWords = $result.' '.$rouble;
return $numeralsInWords;
}
$num = $number;
$i = 0;
$x = 0;
if ($count == 7) {
$firstNumeral = floor($num / 1000000); $num = $firstNumeral;
$firstNumeralInWords = findMatch($num, $spelling);
$million = getRoubles($num, $millions);
/*Ищет ноль в начале следующей тройки чисел*/
$nextNumeral = floor(($number - ($firstNumeral * 1000000)) / 1000); if ($nextNumeral == 0) {
$million = getRoubles($firstNumeral, $millions);
$numeralsInWords = $firstNumeralInWords.' '.$million.' '.$rouble;
} else {
$temporary = $number;
$num = $nextNumeral;
$number = $nextNumeral;
if ($threeNumerals == 3) {
$threeNumeralsInWords = threeNumeralsToText($num, $number, $spelling, $thousands, $i, $x, $femaleSpelling);
$number = $temporary;
$general = $threeNumeralsInWords;
$numeralsInWords = $firstNumeralInWords.' '.$million.' '.$threeNumeralsInWords;
}
if ($threeNumerals == 2) {
$twoNumeralsInWords = twoNumeralsToText($num, $number, $spelling, $thousands, $i, $x, $menSpelling);
$number = $temporary;
$general = $twoNumeralsInWords;
$numeralsInWords = $firstNumeralInWords.' '.$million.' '.$twoNumeralsInWords;
}
if ($threeNumerals == 1) {
$oneNumeralInWords = oneNumeralToText($num, $number, $spelling, $thousands, $i, $x, $menSpelling);
$number = $temporary;
$general = $oneNumeralInWords;
$numeralsInWords = $firstNumeralInWords.' '.$million.' '.$oneNumeralInWords;
}
}
$threeLastNumerals = $number - (($firstNumeral * 1000000) + ($nextNumeral * 1000));
if ($threeLastNumerals == 0) {
$rouble = getRoubles($nextNumeral, $roubles);
$number = $temporary;
if ($threeLastNumerals != $nextNumeral) {
$numeralsInWords = $firstNumeralInWords.' '.$million.' '.$general.' '.$rouble;
}
if ($threeLastNumerals == $nextNumeral) {
$numeralsInWords = $firstNumeralInWords.' '.$million.' '.$rouble;
}
} else {
$text = strval($threeLastNumerals); $num = $threeLastNumerals;
$temporary = $number;
$number = $threeLastNumerals;
if ($threeNumerals == 3) {
$threeNumeralsInWords = threeNumeralsToText($num, $number, $spelling, $roubles, $i, $x, $menSpelling);
$number = $temporary;
if ($nextNumeral != 0) {
$numeralsInWords = $firstNumeralInWords.' '.$million.' '.$general.' '.$threeNumeralsInWords;
}
if ($nextNumeral == 0) {
$numeralsInWords = $firstNumeralInWords.' '.$million.' '.$threeNumeralsInWords;
}
}
if ($threeNumerals == 2) {
$twoNumeralsInWords = twoNumeralsToText($num, $number, $spelling, $roubles, $i, $x, $menSpelling);
$number = $temporary;
if ($nextNumeral != 0) {
$numeralsInWords = $firstNumeralInWords.' '.$million.' '.$general.' '.$twoNumeralsInWords;
}
if ($nextNumeral == 0) {
$numeralsInWords = $firstNumeralInWords.' '.$million.' '.$twoNumeralsInWords;
}
}
if ($threeNumerals == 1) {
$oneNumeralInWords = oneNumeralToText($num, $number, $spelling, $roubles, $menSpelling);
if ($nextNumeral != 0) {
$number = $temporary;
$numeralsInWords = $firstNumeralInWords.' '.$million.' '.$general.' '.$oneNumeralInWords;
}
if ($nextNumeral == 0) {
$number = $temporary;
$numeralsInWords = $firstNumeralInWords.' '.$million.' '.$oneNumeralInWords;
}
}
}
}
if ($count == 6) {
$threeNumerals = floor($num / 1000); $num = $threeNumerals;
$temporary = $number;
$number = $threeNumerals;
$threeNumeralsToText = threeNumeralsToText($num, $number, $spelling, $thousands, $i, $x, $femaleSpelling);
/*Ищет ноль в начале следующей тройки чисел*/
$nextNumeral = $temporary - ($threeNumerals * 1000);
if ($nextNumeral == 0) {
$rouble = getRoubles($nextNumeral, $roubles);
$number = $temporary;
$numeralsInWords = $threeNumeralsToText.' '.$rouble;
} else {
$num = $nextNumeral;
$number = $nextNumeral;
if ($threeNumerals == 3) {
$threeNumeralsInWords = threeNumeralsToText($num, $number, $spelling, $roubles, $i, $x, $menSpelling);
$number = $temporary;
$numeralsInWords = $threeNumeralsToText.' '.$threeNumeralsInWords;
}
if ($threeNumerals == 2) {
$twoNumeralsInWords = twoNumeralsToText($num, $number, $spelling, $roubles, $i, $x, $menSpelling);
$number = $temporary;
$numeralsInWords = $threeNumeralsToText.' '.$twoNumeralsInWords;
}
if ($threeNumerals == 1) {
$oneNumeralInWords = oneNumeralToText($num, $number, $spelling, $roubles, $menSpelling);
$number = $temporary;
$numeralsInWords = $threeNumeralsToText.' '.$oneNumeralInWords;
}
}
}
if ($count == 5) {
$twoNumerals = floor($num / 1000); $num = $twoNumerals;
$temporary = $number;
$number = $twoNumerals;
$thousandsInWords = twoNumeralsToText($num, $number, $spelling, $thousands, $i, $x, $femaleSpelling);
/*Ищет ноль в начале следующей тройки чисел*/
$nextNumeral = $temporary - ($twoNumerals * 1000);
if ($nextNumeral == 0) {
$rouble = getRoubles($nextNumeral, $roubles);
$number = $temporary;
$numeralsInWords = $thousandsInWords.' '.$rouble;
} else {
$num = $nextNumeral;
$number = $nextNumeral;
if ($threeNumerals == 3) {
$threeNumeralsInWords = threeNumeralsToText($num, $number, $spelling, $roubles, $i, $x);
$number = $temporary;
$numeralsInWords = $thousandsInWords.' '.$threeNumeralsInWords;
}
if ($threeNumerals == 2) {
$twoNumeralsInWords = twoNumeralsToText($num, $number, $spelling, $roubles, $i, $x, $menSpelling);
$number = $temporary;
$numeralsInWords = $thousandsInWords.' '.$twoNumeralsInWords;
}
if ($threeNumerals == 1) {
$oneNumeralInWords = oneNumeralToText($num, $number, $spelling, $roubles, $menSpelling);
$number = $temporary;
$numeralsInWords = $thousandsInWords.' '.$oneNumeralInWords;
}
}
}
if ($count == 4) {
$firstNumeral = floor($num / 1000); $num = $firstNumeral;
$firstNumeralInWords = findMatch($num, $spelling);
if ($num == 1) {
$firstNumeralInWords = findMatch($num, $femaleSpelling);
}
if ($num == 2) {
$firstNumeralInWords = findMatch($num, $femaleSpelling);
}
$thousand = getRoubles($num, $thousands);
/*Ищет ноль в начале следующей тройки чисел*/
$nextNumeral = $number - ($firstNumeral * 1000);
if ($nextNumeral == 0) {
$rouble = getRoubles($nextNumeral, $roubles);
$numeralsInWords = $firstNumeralInWords.' '.$thousand.' '.$rouble;
} else {
$temporary = $number;
$num = $nextNumeral;
$number = $nextNumeral;
if ($threeNumerals == 3) {
$threeNumeralsInWords = threeNumeralsToText($num, $number, $spelling, $roubles, $i, $x, $menSpelling);
$number = $temporary;
$numeralsInWords = $firstNumeralInWords.' '.$thousand.' '.$threeNumeralsInWords;
}
if ($threeNumerals == 2) {
$twoNumeralsInWords = twoNumeralsToText($num, $number, $spelling, $roubles, $i, $x, $menSpelling);
$number = $temporary;
$numeralsInWords = $firstNumeralInWords.' '.$thousand.' '.$twoNumeralsInWords;
}
if ($threeNumerals == 1) {
$oneNumeralInWords = oneNumeralToText($num, $number, $spelling, $roubles, $i, $x, $menSpelling);
$number = $temporary;
$numeralsInWords = $firstNumeralInWords.' '.$thousand.' '.$oneNumeralInWords;
}
}
}
if ($count == 3) {
$numeralsInWords = threeNumeralsToText($num, $number, $spelling, $roubles, $i, $x, $menSpelling);
}
if ($count == 2) {
$numeralsInWords = twoNumeralsToText($num, $number, $spelling, $roubles, $i, $x, $menSpelling);
}
if ($count == 1) {
$numeralsInWords = oneNumeralToText($num, $number, $spelling, $roubles, $menSpelling);
}
echo "На счету \"$number руб.\" или \"$numeralsInWords\".";
PD9waHAKCmVycm9yX3JlcG9ydGluZygtMSk7Cm1iX2ludGVybmFsX2VuY29kaW5nKCdVVEYtOCcpOwoKJG51bWJlciA9IG10X3JhbmQoMCw5OTk5OTk5KTsKICAgICRzcGVsbGluZyA9IGFycmF5KAogICAgICAgIDAgICA9PiAgJ9C90L7Qu9GMJywgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMTAgID0+ICAn0LTQtdGB0Y/RgtGMJywgICAgICAgMTAwID0+ICAn0YHRgtC+JywKICAgICAgICAxICAgPT4gICfQvtC00LjQvScsICAgICAgICAgMTEgID0+ICAn0L7QtNC40L3QvdCw0LTRhtCw0YLRjCcsICAgICAgMjAgID0+ICAn0LTQstCw0LTRhtCw0YLRjCcsICAgICAyMDAgPT4gICfQtNCy0LXRgdGC0LgnLAogICAgICAgIDIgICA9PiAgJ9C00LLQsCcsICAgICAgICAgIDEyICA9PiAgJ9C00LLQtdC90LDQtNGG0LDRgtGMJywgICAgICAgMzAgID0+ICAn0YLRgNC40LTRhtCw0YLRjCcsICAgICAzMDAgPT4gICfRgtGA0LjRgdGC0LAnLAogICAgICAgIDMgICA9PiAgJ9GC0YDQuCcsICAgICAgICAgIDEzICA9PiAgJ9GC0YDQuNC90LDQtNGG0LDRgtGMJywgICAgICAgNDAgID0+ICAn0YHQvtGA0L7QuicsICAgICAgICA0MDAgPT4gICfRh9C10YLRi9GA0LXRgdGC0LAnLAogICAgICAgIDQgICA9PiAgJ9GH0LXRgtGL0YDQtScsICAgICAgIDE0ICA9PiAgJ9GH0LXRgtGL0YDQvdCw0LTRhtCw0YLRjCcsICAgICA1MCAgPT4gICfQv9GP0YLRjNC00LXRgdGP0YInLCAgICA1MDAgPT4gICfQv9GP0YLRjNGB0L7RgicsCiAgICAgICAgNSAgID0+ICAn0L/Rj9GC0YwnLCAgICAgICAgIDE1ICA9PiAgJ9C/0Y/RgtC90LDQtNGG0LDRgtGMJywgICAgICAgNjAgID0+ICAn0YjQtdGB0YLRjNC00LXRgdGP0YInLCAgIDYwMCA9PiAgJ9GI0LXRgdGC0YzRgdC+0YInLAogICAgICAgIDYgICA9PiAgJ9GI0LXRgdGC0YwnLCAgICAgICAgMTYgID0+ICAn0YjQtdGB0YLQvdCw0LTRhtCw0YLRjCcsICAgICAgNzAgID0+ICAn0YHQtdC80YzQtNC10YHRj9GCJywgICAgNzAwID0+ICAn0YHQtdC80YzRgdC+0YInLCAgICAKICAgICAgICA3ICAgPT4gICfRgdC10LzRjCcsICAgICAgICAgMTcgID0+ICAn0YHQtdC80L3QsNC00YbQsNGC0YwnLCAgICAgICA4MCAgPT4gICfQstC+0YHQtdC80YzQtNC10YHRj9GCJywgICA4MDAgPT4gICfQstC+0YHQtdC80YzRgdC+0YInLAogICAgICAgIDggICA9PiAgJ9Cy0L7RgdC10LzRjCcsICAgICAgIDE4ICA9PiAgJ9Cy0L7RgdC10LzQvdCw0LTRhtCw0YLRjCcsICAgICA5MCAgPT4gICfQtNC10LLRj9C90L7RgdGC0L4nLCAgICAgOTAwID0+ICAn0LTQtdCy0Y/RgtGM0YHQvtGCJywKICAgICAgICA5ICAgPT4gICfQtNC10LLRj9GC0YwnLCAgICAgICAxOSAgPT4gICfQtNC10LLRj9GC0L3QsNC00YbQsNGC0YwnICAgIAogICAgKTsKICAgICRmZW1hbGVTcGVsbGluZyA9IGFycmF5KAogICAgICAgIDEgICA9PiAgJ9C+0LTQvdCwJywgICAgICAgIDIgICA9PiAgJ9C00LLQtScKICAgICk7CiAgICAkbWVuU3BlbGxpbmcgPSBhcnJheSgKICAgICAgICAxICAgPT4gICfQvtC00LjQvScsICAgICAgICAyICAgPT4gICfQtNCy0LAnCiAgICApOwogICAgJHJvdWJsZXMgPSBhcnJheSgKICAgIAkn0YDRg9Cx0LvRjCcgPT4gYXJyYXkoMSksCiAgICAJJ9GA0YPQsdC70Y8nID0+IGFycmF5KDIsIDMsIDQpLAogICAgCSfRgNGD0LHQu9C10LknID0+IGFycmF5KDAsIDUsIDYsIDcsIDgsI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IDEwMCk7IC8v0L3QsNGF0L7QtNC40Lwg0L/QtdGA0LLQvtC1INGH0LjRgdC70L4g0LIg0YHQvtGC0L3QtQogICAgCSRodW5kcmVkID0gJGZpcnN0TnVtZXJhbCAqIDEwMDsKICAgIAkkbnVtID0gJGh1bmRyZWQ7CiAgICAgICAgJGh1bmRyZWRJbldvcmRzID0gZmluZE1hdGNoKCRudW0sICRzcGVsbGluZyk7CiAgICAgICAgJHRlbiA9ICRudW1iZXIgLSAkaHVuZHJlZDsgLy8g0J/QvtC70YPRh9Cw0LXQvCDQtNC10YHRj9GC0LrQuAogICAgICAgICRudW0gPSAkdGVuOwogICAgICAgIGlmICgkbnVtID09IDApIHsKCSAgICB9IGVsc2UgewoJICAgICAgICAgZm9yZWFjaCAoJHNwZWxsaW5nIGFzICRudW1iZXJzID0+ICRudW1iZXJzSW5Xb3JkcykgewogICAgICAgICAgICAgICAgIGlmICgkbnVtID09ICRudW1iZXJzKSB7CiAgICAJICAgICAgICAgJHJlc3VsdCA9ICRudW1iZXJzSW5Xb3JkczsKICAgIAkgICAgICAgICBpZiAoJG51bSA9PSAxKSB7CiAgICAgICAgCSAgICAgICAgICAgJHJlc3VsdCA9IGZpbmRNYXRjaCgkbnVtLCAkZmVtYWxlU3BlbGxpbmcpOwogICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgaWYgKCRudW0gPT0gMikgewogICAgICAgIAkgICAgICAgICAgICRyZXN1bHQgPSBmaW5kTWF0Y2goJG51bSwgJGZlbWFsZVNwZWxsaW5nKTsKICAgICAgICAgICAgICAgICAgIH0KICAgIAkgICAgICAgICAkcm91YmxlID0gZ2V0Um91YmxlcygkbnVtLCAkcm91Ymxlcyk7CiAgICAJICAgICAgICAgJHgrKzsKICAgIAkgICAgICAgIH0gCiAgICAgICAgICAgICB9IAoJICAgIH0KICAgICAgICAgICAgIGlmICgkeCA+IDApIHsKICAgICAgICAgICAgIAkkbnVtZXJhbHNJbldvcmRzID0gJGh1bmRyZWRJbldvcmRzLicgJy4kcmVzdWx0LicgJy4kcm91YmxlOwogICAgICAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgIAkgICAkdGVuV2l0aG91dE9uZSA9IGZsb29yKCgkbnVtYmVyIC0gJGh1bmRyZWQpIC8gMTApICogMTA7CiAgICAgICAgICAgICAJICAgJG51bSA9ICR0ZW5XaXRob3V0T25lOwogICAgICAgICAgICAgCSAgICR0ZW5XaXRob3V0T25lSW5Xb3JkcyA9IGZpbmRNYXRjaCgkbnVtLCAkc3BlbGxpbmcpOwogICAgICAgICAgICAgIAkgICAkb25lID0gJG51bWJlciAtICgkaHVuZHJlZCArICR0ZW5XaXRob3V0T25lKTsKICAgICAgICAgICAgIAkgICAkbnVtID0gJG9uZTsKICAgICAgICAgICAgIAkgICAkb25lSW5Xb3JkcyA9IGZpbmRNYXRjaCgkbnVtLCAkc3BlbGxpbmcpOwogICAgICAgICAgICAgCSAgIGlmICgkbnVtID09IDEpIHsKICAgICAgICAJICAgICAgICAgICAkb25lSW5Xb3JkcyA9IGZpbmRNYXRjaCgkbnVtLCAkZmVtYWxlU3BlbGxpbmcpOwogICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgaWYgKCRudW0gPT0gMikgewogICAgICAgIAkgICAgICAgICAgICRvbmVJbldvcmRzID0gZmluZE1hdGNoKCRudW0sICRmZW1hbGVTcGVsbGluZyk7CiAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAJICAgJHJvdWJsZSA9IGdldFJvdWJsZXMoJG51bSwgJHJvdWJsZXMpOwogICAgICAgICAgICAgCSAgICRudW1lcmFsc0luV29yZHMgPSAkaHVuZHJlZEluV29yZHMuJyAnLiR0ZW5XaXRob3V0T25lSW5Xb3Jkcy4nICcuJG9uZUluV29yZHMuJyAnLiRyb3VibGU7CiAgICAgICAgICAgICB9CiAgICAgICB9CiAgICByZXR1cm4gJG51bWVyYWxzSW5Xb3JkczsgCn0KZnVuY3Rpb24gdHdvTn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