Time Limit: 8 sec / Memory Limit: 64 MB Example Input 5 3 2 aaaaa aaa aab Output 1 6
- User
Time Limit: 8 sec / Memory Limit: 64 MB
Example Input
5 3 2 aaaaa aaa aab
Output
1 6
Assistant
def count_non_overlapping(s, t): count = 0 i = 0 len_t = len(t) while i <= len(s) - len_t: if s[i:i+len_t] == t: count += 1 i += len_t else: i += 1 return count def sum_start_indices(s, u): len_u = len(u) total = 0 for i in range(len(s) - len_u + 1): if s[i:i+len_u] == u: total += i return total n, m, k = map(int, input().split()) s = input().strip() t = input().strip() u = input().strip() a = count_non_overlapping(s, t) b = sum_start_indices(s, u) print(a, b)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.