# #!/usr/bin/env python3

# import re
# import csv
# from datetime import datetime
# import argparse
# import os

# # Define the keywords for filtering
# KEYWORD1 = "TIMESTAMP1"
# KEYWORD2 = "TIMESTAMP2"

# def extract_timestamp(line):
#     timestamp_pattern = r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}\+\d{2}'
#     match = re.search(timestamp_pattern, line)
#     return match.group(0) if match else None

# def parse_log_line(line, verbose=False):
#     timestamp = extract_timestamp(line)
#     if not timestamp:
#         return None

#     data = {'timestamp': timestamp}

#     # Extract Id, Pt, and Et
#     id_match = re.search(r'Id<(\d+)>', line)
#     pt_match = re.search(r'Pt<(\d+)>', line)
#     et_match = re.search(r'Et<(\d+)>', line)

#     if not id_match:
#         return None  # Skip lines without Id

#     data['Id'] = id_match.group(1)
#     if pt_match:
#         data['Pt'] = pt_match.group(1)
#     if et_match:
#         data['Et'] = et_match.group(1)

#     # Categorize the line
#     if pt_match and et_match:
#         data['type'] = 'start'
#     elif 'send to measure' in line:
#         data['type'] = 'sent'
#     elif 'measurement complete' in line:
#         data['type'] = 'complete'
#     else:
#         return None  # Skip lines that don't match any of the three types

#     if verbose:
#         print("Parsed line:")
#         print(f"  Timestamp: {data['timestamp']}")
#         print(f"  Id: {data['Id']}")
#         print(f"  Type: {data['type']}")
#         if 'Pt' in data:
#             print(f"  Pt: {data['Pt']}")
#         if 'Et' in data:
#             print(f"  Et: {data['Et']}")

#     return data

# def process_log(log_file, verbose=False):
#     data_dict = {}
#     lines_processed = 0
#     valid_lines = 0

#     with open(log_file, 'r') as infile:
#         for line in infile:
#             lines_processed += 1
#             parsed_data = parse_log_line(line, verbose)
#             if parsed_data:
#                 valid_lines += 1
#                 id_num = parsed_data['Id']
#                 if id_num not in data_dict:
#                     data_dict[id_num] = {'Pt': None, 'Et': None, 'start': None, 'sent': None, 'complete': None}
                
#                 line_type = parsed_data['type']
#                 data_dict[id_num][line_type] = parsed_data['timestamp']
                
#                 if line_type == 'start':
#                     data_dict[id_num]['Pt'] = parsed_data.get('Pt')
#                     data_dict[id_num]['Et'] = parsed_data.get('Et')

#     if verbose:
#         print("\nProcessing Summary:")
#         print(f"Total lines processed: {lines_processed}")
#         print(f"Valid lines for data processing: {valid_lines}")
#         print(f"Unique Ids found: {len(data_dict)}")

#     return data_dict

# def create_intermediate_log(input_log_file, output_log_file, verbose=False):
#     """
#     Create an intermediate log file that only contains lines with specific keywords.
    
#     Purpose:
#     - Filter the input log file based on two predefined keywords.
#     - Create a new log file with only the filtered lines.
    
#     Expected Behavior:
#     - Read the input log file line by line.
#     - Check each line for the presence of either KEYWORD1 or KEYWORD2.
#     - If a line contains either keyword, write it to the output log file.
#     - Provide a summary of the filtering process if verbose mode is enabled.
    
#     Args:
#     input_log_file (str): Path to the input log file.
#     output_log_file (str): Path to the output intermediate log file.
#     verbose (bool): Whether to print detailed processing information.
    
#     Returns:
#     int: The number of lines written to the intermediate log file.
#     """
#     lines_processed = 0
#     lines_written = 0

#     with open(input_log_file, 'r') as infile, open(output_log_file, 'w') as outfile:
#         for line in infile:
#             lines_processed += 1
#             if KEYWORD1 in line or KEYWORD2 in line:
#                 outfile.write(line)
#                 lines_written += 1

#     if verbose:
#         print("\nIntermediate Log Creation Summary:")
#         print(f"Input file: {input_log_file}")
#         print(f"Output file: {output_log_file}")
#         print(f"Total lines processed: {lines_processed}")
#         print(f"Lines written to intermediate log: {lines_written}")
#         print(f"Filtering keywords: '{KEYWORD1}' and '{KEYWORD2}'")

#     return lines_written

# def calculate_durations(data_dict):
#     for id_num, data in data_dict.items():
#         if data['start'] and data['sent']:
#             start_time = datetime.strptime(data['start'], '%Y-%m-%d %H:%M:%S.%f+%H')
#             sent_time = datetime.strptime(data['sent'], '%Y-%m-%d %H:%M:%S.%f+%H')
#             data['sent_to_start'] = (sent_time - start_time).total_seconds()
        
#         if data['start'] and data['complete']:
#             start_time = datetime.strptime(data['start'], '%Y-%m-%d %H:%M:%S.%f+%H')
#             complete_time = datetime.strptime(data['complete'], '%Y-%m-%d %H:%M:%S.%f+%H')
#             data['total_duration'] = (complete_time - start_time).total_seconds()

# def write_csv(data_dict, output_file, verbose=False):
#     with open(output_file, 'w', newline='') as csvfile:
#         writer = csv.writer(csvfile)
#         writer.writerow(['Id', 'Pt', 'Et', 'Sent to Start (s)', 'Total Duration (s)'])

#         for id_num, data in data_dict.items():
#             row = [
#                 id_num,
#                 data.get('Pt', ''),
#                 data.get('Et', ''),
#                 round(data.get('sent_to_start', 0), 3),
#                 round(data.get('total_duration', 0), 3)
#             ]
#             writer.writerow(row)

#     if verbose:
#         print("\nCSV Output:")
#         print(f"File created: {output_file}")
#         print(f"Total rows written: {len(data_dict)}")

# def main(log_file, output_file, verbose=True):
#     if verbose:
#         print("Starting log processing")
#         print(f"Input file: {log_file}")
#         print(f"Output file: {output_file}")

#     # Create intermediate log file name
#     base_name = os.path.splitext(output_file)[0]
#     intermediate_log_file = f"{base_name}_intermediate.log"

#     # Create the intermediate log
#     lines_filtered = create_intermediate_log(log_file, intermediate_log_file, verbose)

#     # Process the original log for data extraction
#     data_dict = process_log(log_file, verbose)
#     calculate_durations(data_dict)
#     write_csv(data_dict, output_file, verbose)

#     print("\nProcessing complete.")
#     print(f"Total unique Ids processed: {len(data_dict)}")
#     print(f"Output written to: {output_file}")
#     print(f"Intermediate log written to: {intermediate_log_file}")
#     print(f"Lines in intermediate log: {lines_filtered}")

# if __name__ == "__main__":
#     parser = argparse.ArgumentParser(description="Parse log file, generate CSV report, and create filtered intermediate log.")
#     parser.add_argument("log_file", help="Path to the log file")
#     parser.add_argument("-o", "--output", default="output.csv", help="Output CSV file name")
#     parser.add_argument("-q", "--quiet", action="store_true", help="Disable verbose mode")
#     args = parser.parse_args()

#     main(args.log_file, args.output, not args.quiet)

print(34)