scanf("%ld %d",&a,&b); Using uninitialized variables lead to UB. You should use &a and &b to scan variables...
That specific error can result from white-space / tab indentation on the same line after the closing HEREDOC: Most people catch the opening white-space issue, this one is obviously harder to see. When in doubt with HEREDOC blocks try and eliminate all possible white-space and indentations. Possible Dupe: Why do...