Localized modes in monoatomic and diatomic chains due to the anharmonicity