The number of trees is three times more than the number of rocks, meaning there are 3*40 = <<3*40=120>>120 more trees than rocks in the courtyard.
The total number of trees in the yard is 120+40 = <<120+40=160>>160
Combined, there are 160+40 = <<160+40=200>>200 trees and stones in the courtyard.
Since the number of birds is twice the combined number of trees and stones in the courtyard, there are 2*200 =<<2*200=400>>400 birds on the trees.
#### 400