What causes dirty power? Outlet? Old apartment?
'Dirty' power defines numerous and completely different anomalies. A useful discussion about 'dirty' power says specifically which anomaly. For example, one type of dirty power is low voltage. Incandescent bulbs dim. But then Mac specifications say it will work even when incandescent bulbs dim to 40% intensity.
How often do your bulbs dim that much? Never?
'Dirtiest' power is created by a 120 volt UPS. In battery backup mode, its voltage is 200 volt square waves with a spike of up to 270 volts. That 'dirty' power is also ideal power for any Mac. Because Macs are so robust.
One problem with that UPS is battery degradation. A UPS battery typically lasts three years. Your symptoms are classic of a UPS switching to seriously degraded batteries. However, many other anomalies can also explain that behavior.
Noise created by a Mac on power up can confuse monitoring circuits in a UPS. So the UPS temporarily switches to batteries - that may have degraded too much.
Connect an incandescent bulb to the other wall duplex receptacle. Does it change intensity when the Mac powers? If not, wiring is perfectly fine.
Finally, that APC is not a surge protector. Claims near zero protection. The APC only does something useful when voltages drop - approaches zero. Surges are high voltages - ie thousands of volts. APC's specs make no claims for protecting from thousands of volts. It is a UPS. It creates temporary and 'dirty' power during a blackout. Nothing more.