A heating and cooling system, comprising at least one heat pump, for providing heating and cooling, characterized in that the system comprises a district heating network comprising a return stream and a feed stream, at least one heat pump unit comprising at least one heat pump, the heat pump comprising an evaporator for cooling a desired heat transfer stream and a condenser for heating a desired heat transfer stream, at least one liquid storage unit and cold storage unit, optionally at least one heat exchanger (32,33), a pipework comprising pipes connected each other for conveying heat transfer streams, valves (26,27,28,29) arranged in connection with the pipework for selecting paths of the heat transfer streams in the pipework and for implementing desired heat transfer arrangements comprising heating and cooling arrangements in a building, at least one control device for controlling the valves and the paths of the heat transfer streams in the pipework and for controlling the desired heat transfer arrangements in the system, and the control device and valves being configured to control the convey of the heat transfer stream in the pipework from the return stream of the district heating network to the heat pump, from the heat pump to the return stream of the district heating network, from the heat pump to the liquid storage unit, from the liquid storage unit to the heat pump, from the heat pump to the cold storage unit, from the cold storage unit to the heat pump, from the heat pump to the feed stream of the district heating network, from the liquid storage unit to the feed stream of the district heating network, from the feed stream of the district heating network to the heat pump, from the feed stream of the district heating network to the liquid storage unit, from the heat pump to the heat exchanger (32,33), from the heat exchanger (32,33) to the heat pump, from the liquid or cold storage unit (7,25) to the heat exchanger (32,33), and/or from the heat exchanger (32,33) to the liquid or cold storage unit (7,25), and/or past the heat pump by a bypass pipe, and the evaporator is arranged to cool the return stream of the district heating network or a cooling liquid of the cold storage unit and the condenser is arranged to heat a liquid of the liquid storage unit or the return stream of the district heating network by means of the control device with the valve arrangements. a district heating network comprising a return stream and a feed stream, at least one heat pump unit comprising at least one heat pump, the heat pump comprising an evaporator for cooling a desired heat transfer stream and a condenser for heating a desired heat transfer stream, at least one liquid storage unit and cold storage unit, optionally at least one heat exchanger (32,33), a pipework comprising pipes connected each other for conveying heat transfer streams, valves (26,27,28,29) arranged in connection with the pipework for selecting paths of the heat transfer streams in the pipework and for implementing desired heat transfer arrangements comprising heating and cooling arrangements in a building, at least one control device for controlling the valves and the paths of the heat transfer streams in the pipework and for controlling the desired heat transfer arrangements in the system, and the control device and valves being configured to control the convey of the heat transfer stream in the pipework from the return stream of the district heating network to the heat pump, from the heat pump to the return stream of the district heating network, from the heat pump to the liquid storage unit, from the liquid storage unit to the heat pump, from the heat pump to the cold storage unit, from the cold storage unit to the heat pump, from the heat pump to the feed stream of the district heating network, from the liquid storage unit to the feed stream of the district heating network, from the feed stream of the district heating network to the heat pump, from the feed stream of the district heating network to the liquid storage unit, from the heat pump to the heat exchanger (32,33), from the heat exchanger (32,33) to the heat pump, from the liquid or cold storage unit (7,25) to the heat exchanger (32,33), and/or from the heat exchanger (32,33) to the liquid or cold storage unit (7,25), and/or past the heat pump by a bypass pipe, and the evaporator is arranged to cool the return stream of the district heating network or a cooling liquid of the cold storage unit and the condenser is arranged to heat a liquid of the liquid storage unit or the return stream of the district heating network by means of the control device with the valve arrangements.