fork download
  1. *s,=input().replace('[?]','*');print(*[('a','A')[i==0 or s[i-2]in'.?!']+'n'*(s[i+2]in 'aeiouAEIOU')if c=='*'else c for i,c in enumerate(s)],sep='')
  2.  
Success #stdin #stdout 0s 9992KB
stdin
[?] apple [?] day keeps the doctor away. [?] lie.
stdout
An apple a day keeps the doctor away. A lie.