maxim2511:
schematic is in attachment.
Well let's see it then!

maxim2511:
Before You ask me why I use pin mode for all pins, answer is to eliminate all floating pins with noise what can affect my measurement for battery. Is one of that solutions what I found on internet.
Sounds as if you found the wrong one.
To stabilise unused input pins, you do not set them to OUTPUT. You set them to INPUT_PULLUP. This makes it safe should they accidentally be connected to something.
And whether or not it actually does anything, you should not attempt to change the mode of or write to pins 0 or 1.
maxim2511:
for (short i = 0; i < 18; i++) {
pinMode(i, OUTPUT);
digitalWrite(i, 1);
}
short pin[4] = {A0, A1, A2, A3};
for (short i = 0; i < 4; i++) {
pinMode(pin[i], OUTPUT);
digitalWrite(pin[i], 1);
}
Somewhat odd approach - you set all pins HIGH except A4 and A5, then do it again for the analog pins using different names! A0 to A3 are of course, pins 14 to 17 on the 328.

maxim2511:
pinMode(A0, INPUT);
delay(1);
for (short i = 0; i < 1; i++) {
input = analogRead(A0);
}
That is indeed, a short loop! Only runs once. 
maxim2511:
{
pinMode(A0, OUTPUT);
digitalWrite(A0, 1);
delay(1);
delay(2000);
}
So A0 is connected to a battery, and you are going to write it HIGH as an output? Is that a good idea?
May be a few bugs in the code. 
