#!/usr/bin/perl
# your code goes here
{
my @data;
for (1, 21, 31, 41, 51, 61, 71, 81, 91) {
$data[$_] = 1;
}
for (2..4, 22..24, 32..34, 42..44,
52..54, 62..64, 72..74, 82..84, 92..94) {
$data[$_] = 2;
}
for (0, 5..9, 10..20, 25..30,
35..40, 45..50, 55..60, 65..70,
75..80, 85..90, 95, 96, 97, 98, 99) {
$data[$_] = 3;
}
sub plural($$$$) {
return $_[$data[$_[0] % 100]]; }
}
for (1..5, 34, 35, 180, 181, 182, 255) {
printf "%d %s\n", $_, plural
($_, 'день','дня','дней'); }
IyEvdXNyL2Jpbi9wZXJsCiMgeW91ciBjb2RlIGdvZXMgaGVyZQp7CglteSBAZGF0YTsKCQoJZm9yICgxLCAyMSwgMzEsIDQxLCA1MSwgNjEsIDcxLCA4MSwgOTEpIHsKCQkkZGF0YVskX10gPSAxOwoJfQoJCglmb3IgKDIuLjQsIDIyLi4yNCwgMzIuLjM0LCA0Mi4uNDQsCgkJIDUyLi41NCwgNjIuLjY0LCA3Mi4uNzQsIDgyLi44NCwgOTIuLjk0KSB7CgkJJGRhdGFbJF9dID0gMjsKCX0KCQoJZm9yICgwLCA1Li45LCAxMC4uMjAsIDI1Li4zMCwKICAgIAkgMzUuLjQwLCA0NS4uNTAsIDU1Li42MCwgNjUuLjcwLAogICAgICAgICA3NS4uODAsIDg1Li45MCwgOTUsIDk2LCA5NywgOTgsIDk5KSB7CiAgICAgICAgJGRhdGFbJF9dID0gMzsKICAgIH0KICAgIAogICAgc3ViIHBsdXJhbCgkJCQkKSB7CiAgICAJcmV0dXJuICRfWyRkYXRhWyRfWzBdICUgMTAwXV07CiAgICB9Cn0KCmZvciAoMS4uNSwgMzQsIDM1LCAxODAsIDE4MSwgMTgyLCAyNTUpIHsKCXByaW50ZiAiJWQgJXNcbiIsICRfLCBwbHVyYWwoJF8sICfQtNC10L3RjCcsJ9C00L3RjycsJ9C00L3QtdC5Jyk7Cn0=