x=3
counter=0
iterations=0
if 1 <= x <= 3*9:
for s in range(max(1,x-2*9),1+min(9,x)):
for d in range(max(0,x-s-9),1+min(9,x-s)):
iterations+=1
counter+=1
print(counter,": ",s,d,x-s-d,sep='')
print("iterations=",iterations)
eD0zCmNvdW50ZXI9MAppdGVyYXRpb25zPTAKaWYgMSA8PSB4IDw9IDMqOToKCWZvciBzIGluIHJhbmdlKG1heCgxLHgtMio5KSwxK21pbig5LHgpKToKCQlmb3IgZCBpbiByYW5nZShtYXgoMCx4LXMtOSksMSttaW4oOSx4LXMpKToKCQkJaXRlcmF0aW9ucys9MQoJCQljb3VudGVyKz0xCgkJCXByaW50KGNvdW50ZXIsIjogIixzLGQseC1zLWQsc2VwPScnKQpwcmludCgiaXRlcmF0aW9ucz0iLGl0ZXJhdGlvbnMp