import requests import json import os def run_cf_sync(): # 1. Fetch data from Codeforces c_resp = requests.get("https://codeforces.com/api/contest.list?gym=false") contests = [c for c in c_resp.json()['result'] if c.get('phase') == "FINISHED"] # 2. Logic to group/process (Simplified for example) output_filename = "cf_contests.json" with open(output_filename, "w") as f: json.dump(contests[:50], f) # Limit for speed # 3. Return the absolute path so Gradio can find the file return os.path.abspath(output_filename)