def removeNestedParentheses(input):
ret = ''
skip = 0
for i in input:
if i == '(':
skip += 1
elif i == ')'and skip > 0:
skip -= 1
elif skip == 0:
ret += i
return ret
x = removeNestedParentheses('stuff (inside (nested) brackets) (and (some(are)) here) here')
print x
ZGVmIHJlbW92ZU5lc3RlZFBhcmVudGhlc2VzKGlucHV0KToKICAgIHJldCA9ICcnCiAgICBza2lwID0gMAogICAgZm9yIGkgaW4gaW5wdXQ6CiAgICAgICAgaWYgaSA9PSAnKCc6CiAgICAgICAgICAgIHNraXAgKz0gMQogICAgICAgIGVsaWYgaSA9PSAnKSdhbmQgc2tpcCA+IDA6CiAgICAgICAgICAgIHNraXAgLT0gMQogICAgICAgIGVsaWYgc2tpcCA9PSAwOgogICAgICAgICAgICByZXQgKz0gaQogICAgcmV0dXJuIHJldAoKeCA9IHJlbW92ZU5lc3RlZFBhcmVudGhlc2VzKCdzdHVmZiAoaW5zaWRlIChuZXN0ZWQpIGJyYWNrZXRzKSAoYW5kIChzb21lKGFyZSkpIGhlcmUpIGhlcmUnKQpwcmludCB4