26 USC 1237 - Real property subdivided for sale

(a) General 
Any lot or parcel which is part of a tract of real property in the hands of a taxpayer other than a C corporation shall not be deemed to be held primarily for sale to customers in the ordinary course of trade or business at the time of sale solely because of the taxpayer having subdivided such tract for purposes of sale or because of any activity incident to such subdivision or sale, if
(1) such tract, or any lot or parcel thereof, had not previously been held by such taxpayer primarily for sale to customers in the ordinary course of trade or business (unless such tract at such previous time would have been covered by this section) and, in the same taxable year in which the sale occurs, such taxpayer does not so hold any other real property; and
(2) no substantial improvement that substantially enhances the value of the lot or parcel sold is made by the taxpayer on such tract while held by the taxpayer or is made pursuant to a contract of sale entered into between the taxpayer and the buyer. For purposes of this paragraph, an improvement shall be deemed to be made by the taxpayer if such improvement was made by
(A) the taxpayer or members of his family (as defined in section 267 (c)(4)), by a corporation controlled by the taxpayer, an S corporation which included the taxpayer as a shareholder, or by a partnership which included the taxpayer as a partner; or
(B) a lessee, but only if the improvement constitutes income to the taxpayer; or
(C) Federal, State, or local government, or political subdivision thereof, but only if the improvement constitutes an addition to basis for the taxpayer; and
(3) such lot or parcel, except in the case of real property acquired by inheritance or devise, is held by the taxpayer for a period of 5 years.
(b) Special rules for application of section 

(1) Gains 
If more than 5 lots or parcels contained in the same tract of real property are sold or exchanged, gain from any sale or exchange (which occurs in or after the taxable year in which the sixth lot or parcel is sold or exchanged) of any lot or parcel which comes within the provisions of paragraphs (1), (2) and (3) of subsection (a) of this section shall be deemed to be gain from the sale of property held primarily for sale to customers in the ordinary course of the trade or business to the extent of 5 percent of the selling price.
(2) Expenditures of sale 
For the purpose of computing gain under paragraph (1) of this subsection, expenditures incurred in connection with the sale or exchange of any lot or parcel shall neither be allowed as a deduction in computing taxable income, nor treated as reducing the amount realized on such sale or exchange; but so much of such expenditures as does not exceed the portion of gain deemed under paragraph (1) of this subsection to be gain from the sale of property held primarily for sale to customers in the ordinary course of trade or business shall be so allowed as a deduction, and the remainder, if any, shall be treated as reducing the amount realized on such sale or exchange.
(3) Necessary improvements 
No improvement shall be deemed a substantial improvement for purposes of subsection (a) if the lot or parcel is held by the taxpayer for a period of 10 years and if
(A) such improvement is the building or installation of water, sewer, or drainage facilities or roads (if such improvement would except for this paragraph constitute a substantial improvement);
(B) it is shown to the satisfaction of the Secretary that the lot or parcel, the value of which was substantially enhanced by such improvement, would not have been marketable at the prevailing local price for similar building sites without such improvement; and
(C) the taxpayer elects, in accordance with regulations prescribed by the Secretary, to make no adjustment to basis of the lot or parcel, or of any other property owned by the taxpayer, on account of the expenditures for such improvements. Such election shall not make any item deductible which would not otherwise be deductible.
(c) Tract defined 
For purposes of this section, the term tract of real property means a single piece of real property, except that 2 or more pieces of real property shall be considered a tract if at any time they were contiguous in the hands of the taxpayer or if they would be contiguous except for the interposition of a road, street, railroad, stream, or similar property. If, following the sale or exchange of any lot or parcel from a tract of real property, no further sales or exchanges of any other lots or parcels from the remainder of such tract are made for a period of 5 years, such remainder shall be deemed a tract.