Day 6 is up! Difficult decreased drastically, its all over the place this year. 19 LOC, but it feels like it could be much less.
The constraint is that X(X-T) > D, where X is the time spent charging, T is the total available time and D is the record distance. Therefore, the distance travelled and time charged correspond via a quadratic equation: X^2 - XT + D = 0. The solutions to the equation mark the bounds of the minimum and maximum possible charge time to be within record distance.
:- use_module(library(dcg/basics)).
line([]) --> ("";"\n").
line([X|Xs]) --> blanks,number(X),line(Xs).
file(Time,Dist) --> "Time:",line(Time),"Distance:",line(Dist).
sols(T-D,N) :-
Q is sqrt(T^2-4*D),
Min is (T-Q)/2, Max is (T+Q)/2,
(floor(Min)=:=Min->Xmn is Min+1; Xmn is ceiling(Min)),
(floor(Max)=:=Max->Xmx is Max-1; Xmx is floor(Max)),
N is floor(Xmx-Xmn+1).
concat(Ns,R) :-
maplist(number_chars,Ns,Cs),
flatten(Cs,S),number_chars(R,S).
solve(File,Part1,Part2) :-
phrase_from_file(file(Time,Dist),File),
pairs_keys_values(Pairs,Time,Dist),
foldl([A,B,C]>>(sols(A,N),C is N*B),Pairs,1,Part1),
concat(Time,T), concat(Dist,D),
sols(T-D,Part2).