using System; using System.Text; using System.Linq; using System.Collections.Generic; public class Program { public void Proc() { Reader.IsDebug = false; string text = Reader.ReadLine(); long ans = 0; int wordCount = int.Parse(Reader.ReadLine()); Dictionary>> dic = new Dictionary>>(); for(int i=0; i>()); } if(!dic[wrd[0]].ContainsKey(wrd.Length)) { dic[wrd[0]].Add(wrd.Length, new Dictionary()); } dic[wrd[0]][wrd.Length].Add(wrd, true); } for(int i=0; ia)) { if(len > text.Length - i) { break; } string target = text.Substring(i, len); if(dic[text[i]][len].ContainsKey(target)) { ans++; } } } Console.WriteLine(ans); } public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" ABAACABCAACBABABACBBAC 7 A C AA ABB ABA BA CBBAC "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }