So here are the results of my experiments:
1) The issue can be resolved if individual language selection for different applications is disabled ("Let me use a different input method for each app window" unchecked in "Advanced keyboard settings"). However, it makes working with several applications in parallel significantly uncomfortable.
2) The second methods is to hack the registry.
Simply removing registry key "HKLM\SYSTEM\CurrentControlSet\Control\Keyboard Layout" doesn't work. Windows restores it after reboot and the issue is back. However, there is another way (attention! for skilled users only!). You need to remove all values in that key and then edit security settings by removing all access rights (especially the rights for SYSTEM) except maybe the right for your user account. I don't provide a detailed description of the method to make a natural barrier for people who have no experience and have a high risk of irrevocably corrupting the registry.