We need to count the number of triples (A,B,C) of positive integers such that A * B + C = N, where N is given up to 10^6.
We need to count number of triples (A,B,C) with A,B,C >=1 integers, AB + C = N. Since C = N - AB, and C >=1 implies AB <= N-1. Also AB >=1 obviously. So for each ordered pair (A,B) positive integers such that AB <= N-1, we have exactly one C = N - AB, which is positive. So number of triples = number of positive integer pairs (A,B) such that AB < N. Since C = N - AB must be >=1 => AB <= N-1, i.e., AB < N.
Thus answer = sum_{a=1}^{∞} sum_{b=1}^{∞} [a*b < N] where N up to 1e6.
We need to count number of ordered pairs (a,b) with a,b >=1 and a*b < N.
This is a classic problem: number of pairs (a,b) with product < N. Since N up to 1e6, we can compute via iteration over a from 1 to N-1. For each a, number of b such that b <= floor((N-1)/a). But careful: b must be positive integer. So for each a, b_max = floor((N-1)/a). Since b_max >= 1 if a <= N-1. So total pairs = sum_{a=1}^{N-1} floor((N-1)/a). But that's O(N) which is fine for N=1e6 (10^6) operations. That's acceptable. However, we need to output for N=1e6? O(N) ~ 1e6 which is trivial. But wait: In examples, N=100 gives answer 473. Let's check: sum_{a=1}^{99} floor(99/a) = ? 473? We can compute quickly: known sum_{i=1}^{n} floor(n/i) = 2 * sum_{i=1}^{√n} floor(n/i) - (floor(√n))^2 etc. But O(N) is fine for 1e6. But careful: N could be up to 1e6, but Python loops of 1e6 are fast. So we can just compute sum_{a=1}^{N-1} floor((N-1)/a). However, double-check: Are we counting all pairs? For a=1 to N-1? But what about a > N-1? Then b_max = floor((N-1)/a) = 0, so no b. So it's fine.
But note that A and B are positive integers; they can be large? But product < N ensures they are bounded. Actually a could be up to N-1, with b=1. So sum_{a=1}^{N-1} floor((N-1)/a) gives the total count. For N=3: (N-1)=2, sum_{a=1}^{2} floor(2/a) = floor(2/1)=2 + floor(2/2)=1 =3. matches example. For N=100: sum_{a=1}^{99} floor(99/a). Let's quickly check if that equals 473? I'll approximate but seems plausible.
But careful: The condition is AB + C = N, with C>=1. So AB <= N-1 indeed. So answer = number of positive integer pairs (A,B) with A*B < N.
But is there any double counting? Since (A,B) ordered, that's correct. So answer is sum_{a=1}^{N-1} floor((N-1)/a). Equivalent to number of ordered pairs.
But we must ensure we are not missing any? For each product, we have unique C, so it's one-to-one.
Thus we can compute answer in O(N). But we can also compute faster using divisor counting approach but not needed.
Thus solution: read N, compute M = N-1, then ans = sum_{a=1}^{M} (M // a). Print ans.
But wait: for N up to 10^6, M=999999, sum up to 10^6 terms is fine. But we must be careful: in Python, loops are okay. But consider worst-case: N=10^6, M=999999, sum_{a=1}^{M} floor(M/a) ~ M log M + (2γ-1)M? Actually sum floor(M/a) is about M ln M + (2γ-1)M ~ 1e6ln(1e6) ~ 1e613.8 = 13.8e6, that's sum of many terms but that's just the answer value, not computational cost. The loop runs 1e6 iterations, each performing integer division and addition. That's fine; 1e6 is small.
Thus straightforward approach works.
But let's test with N=100. Compute sum_{a=1}^{99} floor(99/a). Let's compute quickly to confirm 473:
We can break: for a=1..99. But I can trust example.
Now test N=1000000. The example output is 13969985. Let's see if our sum yields that. We can compute approximate: sum_{a=1}^{999999} floor(999999/a). This is typical. I can test mentally? Not needed. But should match.
Thus answer is simple.
But careful: Are there any corner cases? N=2: M=1, sum_{a=1}^{1} floor(1/1)=1. So answer should be 1. Check: AB+C=2, with positive ints. Possible: (1,1,1) because 11+1=2. That's only one. Yes.
Thus algorithm:
def solve():
N = int(input().strip())
M = N-1
ans = 0
for a in range(1, M+1):
ans += M // a
print(ans)
But we could also use a faster method: note that floor division repeats values. We can compute sum_{a=1}^{M} floor(M/a) by grouping intervals where quotient is constant. That would be O(sqrt(M)). Since N up to 1e6, it's not necessary but we can implement for speed if needed. But simpler is fine.
But caution: The constraints say "All values in input are integers." It's just N.
Given that the problem likely expects an optimized solution, but for N=1e6, O(N) works within time limit in typical online judges (like AtCoder) where Python is allowed? AtCoder often expects O(N) loops of 1e6 to be okay (like 0.2 sec?). But Python may be borderline; 1e6 integer divisions can be ~0.1-0.2 sec maybe? Actually 1e6 operations is fine. Usually AtCoder Python can handle 1e7 operations maybe slower, but 1e6 is fine. However, there may be hidden larger N? Constraint says N ≤ 10^6, so okay.
But to be safe, we can implement a more efficient method: sum_{i=1}^{M} floor(M/i) can be computed using the trick: for i in range(1, int(sqrt(M))+1) and then double count etc. Let's recall: The number of pairs (a,b) with a*b <= M (or < N) is actually sum_{a=1}^{M} floor(M/a). But we can compute by iterating i from 1 to sqrt(M). For each i, quotient q = M // i. The number of i with floor(M / i) = k is ... Actually the method: ans = 0; i = 1; while i <= M: q = M // i; next_i = M // q + 1; ans += q * (next_i - i); i = next_i. This is O(sqrt(M)). That is more efficient. But not needed.
Given the simplicity, I'll just do O(N) loop; but maybe N=10^6, the loop is fine.
Let's compute approximate runtime: 1e6 divisions in Python can be about 0.05 sec? Actually divisions are slower. It may be around 0.2-0.3 sec. Usually acceptable. AtCoder's time limit is typically 2 sec, so it's okay.
But let's also verify the output for N=1000000. Our formula sum_{a=1}^{999999} floor(999999/a) gives some number. Is it 13969985? Let's test quickly with known results: For N=1000000, number of ordered pairs (a,b) with a*b < 1000000 equals? There's known value for 10^6. I can quickly compute approximate to cross-check: Sum_{i=1}^{n} floor(n/i) ≈ n log n + (2γ-1)n + O(sqrt(n)). For n=999999, log(1e6) ≈ 13.8155, so n log n ≈ 13.8155e6 ≈ 13815500. Plus (2γ-1)n, γ≈0.57721 => 2γ-1 ≈ 0.15442, times 1e6 ≈ 154420, total ≈ 13969920. That's close to 13969985. So seems consistent. So O(N) works.
Thus final answer: read N, compute N-1 = M, ans = sum_{i=1}^{M} M//i, print.
But careful: The problem might be from AtCoder ABC (like ABC179 C maybe?). Actually AtCoder ABC 179 C: A x B + C = N. Yes, exactly. The typical solution is to fix A and B, or count pairs (A,B) with A*B < N. Many solutions use O(N) or O(sqrt(N)) method. O(N) is fine for N up to 10^6. So I'll go with O(N).
But to be thorough, I'll implement efficient O(sqrt N) method: Let M = N-1. ans = 0; i = 1; while i <= M: t = M // i; j = M // t; ans += t * (j - i + 1); i = j + 1; This yields sum_{i=1}^{M} floor(M/i). Indeed.
Let's test: For M=2: i=1, t=2, j=2//2=1? Wait: j = M // t = 2 // 2 = 1. So (j - i + 1) = (1-1+1)=1, ans+=2; i=j+1=2. Next i=2<=2, t=2//2=1, j=2//1=2, (2-2+1)=1, ans+=1; i=3 => ans=3. Works.
So both ways.
Simplify: In Python:
def solve():
N = int(input())
M = N-1
ans = 0
for i in range(1, M+1):
ans += M // i
print(ans)
But consider memory? No.
Alternatively, could also note that answer is sum_{a=1}^{N-1} floor((N-1)/a) = sum_{a=1}^{N-1} floor(N/a) - 1? Actually not exactly. But okay.
Thus final code is straightforward.
But wait: In some interpretations, does (A,B,C) with A,B,C positive integers and A*B+C=N? Yes.
Thus final answer.
Edge Cases: N=2 → 1, N=3 → 3, as examples.
Thus provide solution.
But given the problem statement, "Input N" and output number of triples.
Thus code.
But I want to double-check with N=100: compute sum_{i=1}^{99} floor(99/i). Let's quickly calculate to ensure 473.
We'll break down: For i=1..99, floor(99/i) values:
Now from i=50..99: each floor=1. Number of terms = 50 (from 50 to 99 inclusive: 99-50+1=50). So add 50 => total 473. Perfect.
So answer matches.
Thus solution is correct.
Implementation: We'll write solve() function and call it.
Edge Cases: Input may have trailing spaces; we handle with int(input().strip()).
We'll output ans.
Now the problem might require using 64-bit integer? Ans for N=10^6 is about 14 million, fits in 32-bit, but safe to use Python int.
Thus final code:
import sys
def main():
N = int(sys.stdin.readline())
M = N - 1
ans = 0
for i in range(1, M+1):
ans += M // i
print(ans)
if name == "main":
main()
But we could also use the grouping method for speed but not necessary.
I'll produce final answer with explanation.
But as ChatGPT, need to provide answer and reasoning.
Thus final response: explanation and code. The problem reduces to counting ordered pairs of positive integers ((A, B)) such that (A \times B < N), because (C = N - A \times B) will automatically be a positive integer.
Thus the answer is the number of pairs ((A, B)) with (A, B \ge 1) and (A \times B \le N-1).
For each (A) from (1) to (N-1), the number of valid (B) is (\left\lfloor\frac{N-1}{A}\right\rfloor). Summing this over all (A) gives the result.
Since (N \le 10^6), a simple loop over (A) runs in time and is acceptable.
python
import sys
def main():
N = int(sys.stdin.readline())
M = N - 1
ans = 0
for a in range(1, M + 1):
ans += M // a
print(ans)
if __name__ == "__main__":
main()