I have been active in competitive programming for around a year, have been solving problems like every day. But I still can't get over this problem. I almost never accurate codes on first try. If I have taken half an hour to write a code, I have to spend another half debugging it. This happens in almost all medium to large sized codes. How do I improve accuracy of code?